Record Class SpellGrammar

java.lang.Object
java.lang.Record
at.minecraftschurli.mods.arsmagicalegacy.api.spell.SpellGrammar
Record Components:
parts - A List of all parts. Used mainly for serialization, use components for gameplay.
components - A view of parts that lists the parts as SpellComponents with their associated SpellModifiers.

public record SpellGrammar(List<SpellPart> parts, List<com.mojang.datafixers.util.Pair<SpellComponent, List<SpellModifier>>> components) extends Record
Represents a spell's grammar. All fields are immutable by contract.
  • Field Details

    • MAX_PARTS

      public static final int MAX_PARTS
      See Also:
    • EMPTY

      public static final SpellGrammar EMPTY
    • CODEC

      public static final com.mojang.serialization.Codec<SpellGrammar> CODEC
    • STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, SpellGrammar> STREAM_CODEC
  • Constructor Details

  • Method Details

    • of

      public static SpellGrammar of(List<SpellPart> parts)
      Validates the given List of SpellParts and constructs a SpellGrammar from it.
      Parameters:
      parts - The List of SpellParts.
      Returns:
      A new SpellGrammar, or EMPTY if validation failed.
    • equals

      public 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • hashCode

      public 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
    • isEmpty

      public boolean isEmpty()
      Returns:
      Whether the spell grammar is considered empty.
    • getManaCost

      public double getManaCost(net.minecraft.core.RegistryAccess registryAccess)
      Parameters:
      registryAccess - The RegistryAccess to use.
      Returns:
      The combined mana cost of the spell grammar.
    • getBurnoutCost

      public double getBurnoutCost(net.minecraft.core.RegistryAccess registryAccess)
      Parameters:
      registryAccess - The RegistryAccess to use.
      Returns:
      The combined burnout cost of the spell grammar.
    • affinityShifts

      public Map<net.minecraft.core.Holder<Affinity>, Double> affinityShifts(net.minecraft.core.RegistryAccess registryAccess)
      Parameters:
      registryAccess - The RegistryAccess to use.
      Returns:
      A Map of combined Affinity shifts of the spell grammar.
    • primaryAffinity

      public net.minecraft.resources.ResourceKey<Affinity> primaryAffinity(net.minecraft.core.RegistryAccess registryAccess)
      Parameters:
      registryAccess - The RegistryAccess to use.
      Returns:
      The key of the primary Affinity of the spell grammar.
    • 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
    • parts

      public List<SpellPart> parts()
      Returns the value of the parts record component.
      Returns:
      the value of the parts record component
    • components

      public List<com.mojang.datafixers.util.Pair<SpellComponent, List<SpellModifier>>> components()
      Returns the value of the components record component.
      Returns:
      the value of the components record component