Record Class MagicAttachment

java.lang.Object
java.lang.Record
at.minecraftschurli.mods.arsmagicalegacy.api.magic.MagicAttachment
Record Components:
level - The magic level of the player.
xp - The magic xp of the player.
skills - The Skills the player knows. Immutable by contract.
skillPoints - The SkillPoints the player has. Immutable by contract.
affinityShifts - The Affinity shifts the player has. Immutable by contract.

public record MagicAttachment(int level, double xp, Set<net.minecraft.core.Holder<Skill>> skills, Map<net.minecraft.core.Holder<SkillPoint>, Integer> skillPoints, Map<net.minecraft.core.Holder<Affinity>, Double> affinityShifts, boolean affinityLocked) extends Record

Represents an attachment on a player, holding various data related to the mod.

Keep in mind that due to the immutability contract, any modification must use a new instance.

  • Field Details

    • CODEC

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

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, MagicAttachment> STREAM_CODEC
    • DEFAULT

      public static final MagicAttachment DEFAULT
  • Constructor Details

    • MagicAttachment

      public MagicAttachment(int level, double xp, Set<net.minecraft.core.Holder<Skill>> skills, Map<net.minecraft.core.Holder<SkillPoint>, Integer> skillPoints, Map<net.minecraft.core.Holder<Affinity>, Double> affinityShifts, boolean affinityLocked)
      Creates an instance of a MagicAttachment record class.
      Parameters:
      level - the value for the level record component
      xp - the value for the xp record component
      skills - the value for the skills record component
      skillPoints - the value for the skillPoints record component
      affinityShifts - the value for the affinityShifts record component
      affinityLocked - the value for the affinityLocked record component
  • Method Details

    • setLevel

      public MagicAttachment setLevel(int level)
      Parameters:
      level - The new level to set.
      Returns:
      A new instance with the new level set.
    • setXp

      public MagicAttachment setXp(double xp)
      Parameters:
      xp - The new xp to set.
      Returns:
      A new instance with the new xp set.
    • updateSkills

      public MagicAttachment updateSkills(Consumer<Set<net.minecraft.core.Holder<Skill>>> consumer)
      Parameters:
      consumer - The operation to perform on the skills.
      Returns:
      A new instance with the updated skills set.
    • updateSkillPoints

      public MagicAttachment updateSkillPoints(Consumer<Map<net.minecraft.core.Holder<SkillPoint>, Integer>> consumer)
      Parameters:
      consumer - The operation to perform on the skill points.
      Returns:
      A new instance with the updated skill points set.
    • updateAffinityShifts

      public MagicAttachment updateAffinityShifts(Consumer<Map<net.minecraft.core.Holder<Affinity>, Double>> consumer)
      Parameters:
      consumer - The operation to perform on the affinity shifts.
      Returns:
      A new instance with the updated affinity shifts set.
    • setAffinityLocked

      public MagicAttachment setAffinityLocked(boolean affinityLocked)
      Parameters:
      affinityLocked - The new affinity lock status to set.
      Returns:
      A new instance with the new affinity lock status set.
    • 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.
    • level

      public int level()
      Returns the value of the level record component.
      Returns:
      the value of the level record component
    • xp

      public double xp()
      Returns the value of the xp record component.
      Returns:
      the value of the xp record component
    • skills

      public Set<net.minecraft.core.Holder<Skill>> skills()
      Returns the value of the skills record component.
      Returns:
      the value of the skills record component
    • skillPoints

      public Map<net.minecraft.core.Holder<SkillPoint>, Integer> skillPoints()
      Returns the value of the skillPoints record component.
      Returns:
      the value of the skillPoints record component
    • affinityShifts

      public Map<net.minecraft.core.Holder<Affinity>, Double> affinityShifts()
      Returns the value of the affinityShifts record component.
      Returns:
      the value of the affinityShifts record component
    • affinityLocked

      public boolean affinityLocked()
      Returns the value of the affinityLocked record component.
      Returns:
      the value of the affinityLocked record component