Record Class SpellStat

java.lang.Object
java.lang.Record
at.minecraftschurli.mods.arsmagicalegacy.api.spell.SpellStat
Record Components:
id - The id of the stat.
genericModifierFunction - A function to be used by generic SpellModifiers (e.g. Solar or Lunar), to create a SpellStatModifier from a given multiplier. If empty, generic SpellModifiers will ignore this stat.

public record SpellStat(net.minecraft.resources.Identifier id, Optional<DoubleFunction<SpellStatModifier>> genericModifierFunction) extends Record
Represents a stat that can be modified, e.g. by SpellModifiers. No registration is necessary, equality is checked via equals(Object).
  • Field Details

    • COLOR

      public static final SpellStat COLOR
  • Constructor Details

    • SpellStat

      public SpellStat(net.minecraft.resources.Identifier id, Optional<DoubleFunction<SpellStatModifier>> genericModifierFunction)
      Creates an instance of a SpellStat record class.
      Parameters:
      id - the value for the id record component
      genericModifierFunction - the value for the genericModifierFunction record component
    • SpellStat

      public SpellStat(net.minecraft.resources.Identifier id)
      Represents a stat that can be modified, e.g. by SpellModifiers.
      Parameters:
      id - The id of the stat.
    • SpellStat

      public SpellStat(net.minecraft.resources.Identifier id, DoubleFunction<SpellStatModifier> genericModifierFunction)
      Represents a stat that can be modified, e.g. by SpellModifiers.
      Parameters:
      id - The id of the stat.
      genericModifierFunction - A function to be used by generic SpellModifiers (e.g. Solar or Lunar), to create a SpellStatModifier from a given multiplier.
  • Method Details

    • getAll

      public static List<SpellStat> getAll()
      Returns:
      All registered SpellStats.
    • 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
    • genericModifiers

      public static Map<SpellStat, SpellStatModifier> genericModifiers(ToDoubleFunction<SpellCastContext> multiplierFunction)
      Creation helper for a generic SpellModifier. Returns a map of SpellStatModifiers based on a multiplier function. On invocation of the SpellModifier, the multiplier is calculated using the SpellStatModifier's SpellCastContext. The SpellStatModifier is then wrapped and passed along, containing the generic SpellModifier's modifications.
      Parameters:
      multiplierFunction - The multiplier function to use.
      Returns:
      A map to be passed into SpellModifier(Map).
    • 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
    • id

      public net.minecraft.resources.Identifier id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • genericModifierFunction

      public Optional<DoubleFunction<SpellStatModifier>> genericModifierFunction()
      Returns the value of the genericModifierFunction record component.
      Returns:
      the value of the genericModifierFunction record component