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 - The SpellShapeGroups of the spell. Immutable by contract.
activeShapeGroup - The index of the currently active SpellShapeGroup. Immutable by contract.
grammar - The SpellGrammar of the spell. Immutable by contract.
dataComponents - The data components of the spell. To modify, call updateDataComponents(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 Details

    • MAX_SHAPE_GROUPS

      public static final int MAX_SHAPE_GROUPS
      See Also:
    • EMPTY

      public static final Spell EMPTY
    • CODEC

      public static final com.mojang.serialization.Codec<Spell> CODEC
    • PREFAB_CODEC

      public static final com.mojang.serialization.Codec<net.minecraft.core.Holder<Spell>> 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 a Spell record class.
      Parameters:
      name - the value for the name record component
      icon - the value for the icon record component
      shapeGroups - the value for the shapeGroups record component
      activeShapeGroup - the value for the activeShapeGroup record component
      grammar - the value for the grammar record component
      dataComponents - the value for the dataComponents record component
  • Method Details

    • setName

      public Spell setName(net.minecraft.network.chat.Component name)
      Parameters:
      name - The new name to set.
      Returns:
      A new spell with the new name set.
    • clearName

      public Spell clearName()
      Returns:
      A new spell with no name set.
    • setIcon

      public Spell setIcon(net.minecraft.resources.Identifier icon)
      Parameters:
      icon - The new icon to set.
      Returns:
      A new spell with the new icon set.
    • clearIcon

      public Spell clearIcon()
      Returns:
      A new spell with no icon set.
    • nextShapeGroup

      public Spell nextShapeGroup()
      Returns:
      The spell, with the next shape group set as active.
    • prevShapeGroup

      public Spell prevShapeGroup()
      Returns:
      The spell, with the previous shape group set as active.
    • setActiveShapeGroup

      public Spell setActiveShapeGroup(int activeShapeGroup)
      Parameters:
      activeShapeGroup - The active shape group index to set.
      Returns:
      The spell, with the given shape group index set as active.
    • updateDataComponents

      public Spell updateDataComponents(UnaryOperator<SpellDataComponentMap> operator)
      Parameters:
      operator - The modifications to apply to the data components.
      Returns:
      A new spell with the modifications to the data components applied.
    • currentShapeGroup

      public SpellShapeGroup 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 - The RegistryAccess to use.
      Returns:
      The combined mana cost of the spell.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public Optional<net.minecraft.network.chat.Component> name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • icon

      public Optional<net.minecraft.resources.Identifier> icon()
      Returns the value of the icon record component.
      Returns:
      the value of the icon record component
    • shapeGroups

      public List<SpellShapeGroup> shapeGroups()
      Returns the value of the shapeGroups record component.
      Returns:
      the value of the shapeGroups record component
    • activeShapeGroup

      public int activeShapeGroup()
      Returns the value of the activeShapeGroup record component.
      Returns:
      the value of the activeShapeGroup record component
    • grammar

      public SpellGrammar grammar()
      Returns the value of the grammar record component.
      Returns:
      the value of the grammar record component
    • dataComponents

      public SpellDataComponentMap dataComponents()
      Returns the value of the dataComponents record component.
      Returns:
      the value of the dataComponents record component