Record Class Spell
java.lang.Object
java.lang.Record
at.minecraftschurli.mods.arsmagicalegacy.api.spell.Spell
- Record Components:
name- The name of the spell.icon- The icon of the spell.shapeGroups- TheSpellShapeGroups of the spell. Immutable by contract.activeShapeGroup- The index of the currently activeSpellShapeGroup. Immutable by contract.grammar- TheSpellGrammarof the spell. Immutable by contract.dataComponents- The data components of the spell. To modify, callupdateDataComponents(UnaryOperator).
public record Spell(Optional<net.minecraft.network.chat.Component> name, Optional<net.minecraft.resources.Identifier> icon, List<SpellShapeGroup> shapeGroups, int activeShapeGroup, SpellGrammar grammar, SpellDataComponentMap dataComponents)
extends Record
Represents a spell.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<Spell> static final Spellstatic final intstatic final com.mojang.serialization.Codec<net.minecraft.core.Holder<Spell>> static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, Spell> -
Constructor Summary
ConstructorsConstructorDescriptionSpell(Optional<net.minecraft.network.chat.Component> name, Optional<net.minecraft.resources.Identifier> icon, List<SpellShapeGroup> shapeGroups, int activeShapeGroup, SpellGrammar grammar, SpellDataComponentMap dataComponents) Creates an instance of aSpellrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of theactiveShapeGrouprecord component.Returns the value of thedataComponentsrecord component.final booleanIndicates whether some other object is "equal to" this one.doublegetManaCost(net.minecraft.core.RegistryAccess registryAccess) grammar()Returns the value of thegrammarrecord component.final inthashCode()Returns a hash code value for this object.Optional<net.minecraft.resources.Identifier> icon()Returns the value of theiconrecord component.booleanbooleanisEmpty()booleanOptional<net.minecraft.network.chat.Component> name()Returns the value of thenamerecord component.setActiveShapeGroup(int activeShapeGroup) setIcon(net.minecraft.resources.Identifier icon) setName(net.minecraft.network.chat.Component name) Returns the value of theshapeGroupsrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
MAX_SHAPE_GROUPS
public static final int MAX_SHAPE_GROUPS- See Also:
-
EMPTY
-
CODEC
-
PREFAB_CODEC
-
STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, Spell> STREAM_CODEC
-
-
Constructor Details
-
Spell
public Spell(Optional<net.minecraft.network.chat.Component> name, Optional<net.minecraft.resources.Identifier> icon, List<SpellShapeGroup> shapeGroups, int activeShapeGroup, SpellGrammar grammar, SpellDataComponentMap dataComponents) Creates an instance of aSpellrecord class.- Parameters:
name- the value for thenamerecord componenticon- the value for theiconrecord componentshapeGroups- the value for theshapeGroupsrecord componentactiveShapeGroup- the value for theactiveShapeGrouprecord componentgrammar- the value for thegrammarrecord componentdataComponents- the value for thedataComponentsrecord component
-
-
Method Details
-
setName
- Parameters:
name- The new name to set.- Returns:
- A new spell with the new name set.
-
clearName
- Returns:
- A new spell with no name set.
-
setIcon
- Parameters:
icon- The new icon to set.- Returns:
- A new spell with the new icon set.
-
clearIcon
- Returns:
- A new spell with no icon set.
-
nextShapeGroup
- Returns:
- The spell, with the next shape group set as active.
-
prevShapeGroup
- Returns:
- The spell, with the previous shape group set as active.
-
setActiveShapeGroup
- Parameters:
activeShapeGroup- The active shape group index to set.- Returns:
- The spell, with the given shape group index set as active.
-
updateDataComponents
- Parameters:
operator- The modifications to apply to the data components.- Returns:
- A new spell with the modifications to the data components applied.
-
currentShapeGroup
- Returns:
- The currently active
SpellShapeGroup.
-
isEmpty
public boolean isEmpty()- Returns:
- Whether the spell is considered empty.
-
isContinuous
public boolean isContinuous()- Returns:
- Whether the spell is continuous, i.e., can be cast by holding down the spell.
-
isMalformed
public boolean isMalformed()- Returns:
- Whether the spell is malformed, i.e., does not fulfill basic requirements to the spell's structure.
-
getManaCost
public double getManaCost(net.minecraft.core.RegistryAccess registryAccess) - Parameters:
registryAccess- TheRegistryAccessto use.- Returns:
- The combined mana cost of the spell.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
name
-
icon
-
shapeGroups
Returns the value of theshapeGroupsrecord component.- Returns:
- the value of the
shapeGroupsrecord component
-
activeShapeGroup
public int activeShapeGroup()Returns the value of theactiveShapeGrouprecord component.- Returns:
- the value of the
activeShapeGrouprecord component
-
grammar
-
dataComponents
Returns the value of thedataComponentsrecord component.- Returns:
- the value of the
dataComponentsrecord component
-