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- TheSkills the player knows. Immutable by contract.skillPoints- TheSkillPoints the player has. Immutable by contract.affinityShifts- TheAffinityshifts 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<MagicAttachment> static final MagicAttachmentstatic final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, MagicAttachment> -
Constructor Summary
ConstructorsConstructorDescriptionMagicAttachment(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 aMagicAttachmentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theaffinityLockedrecord component.Returns the value of theaffinityShiftsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intlevel()Returns the value of thelevelrecord component.setAffinityLocked(boolean affinityLocked) setLevel(int level) setXp(double xp) Map<net.minecraft.core.Holder<SkillPoint>, Integer> Returns the value of theskillPointsrecord component.skills()Returns the value of theskillsrecord component.final StringtoString()Returns a string representation of this record class.updateAffinityShifts(Consumer<Map<net.minecraft.core.Holder<Affinity>, Double>> consumer) updateSkillPoints(Consumer<Map<net.minecraft.core.Holder<SkillPoint>, Integer>> consumer) updateSkills(Consumer<Set<net.minecraft.core.Holder<Skill>>> consumer) doublexp()Returns the value of thexprecord component.
-
Field Details
-
CODEC
-
STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, MagicAttachment> STREAM_CODEC -
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 aMagicAttachmentrecord class.- Parameters:
level- the value for thelevelrecord componentxp- the value for thexprecord componentskills- the value for theskillsrecord componentskillPoints- the value for theskillPointsrecord componentaffinityShifts- the value for theaffinityShiftsrecord componentaffinityLocked- the value for theaffinityLockedrecord component
-
-
Method Details
-
setLevel
- Parameters:
level- The new level to set.- Returns:
- A new instance with the new level set.
-
setXp
- Parameters:
xp- The new xp to set.- Returns:
- A new instance with the new xp set.
-
updateSkills
- 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
- Parameters:
affinityLocked- The new affinity lock status to set.- Returns:
- A new instance with the new affinity lock status set.
-
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. -
level
-
xp
-
skills
-
skillPoints
Returns the value of theskillPointsrecord component.- Returns:
- the value of the
skillPointsrecord component
-
affinityShifts
Returns the value of theaffinityShiftsrecord component.- Returns:
- the value of the
affinityShiftsrecord component
-
affinityLocked
public boolean affinityLocked()Returns the value of theaffinityLockedrecord component.- Returns:
- the value of the
affinityLockedrecord component
-