Package com.binaris.wizardry.content
Class WizardryAttributeModifier
java.lang.Object
net.minecraft.world.entity.ai.attributes.AttributeModifier
com.binaris.wizardry.content.WizardryAttributeModifier
public class WizardryAttributeModifier
extends net.minecraft.world.entity.ai.attributes.AttributeModifier
Extension of the base Attribute Modifiers to add
SpellCondition for being used with the /magic_attribute
command. We use the Mixin AttributeModifierMixin to add the nbt loading.
This doesn't cancel or interrupt the base Attribute Modifier system, we can still use it normally. This just adds new load values when need it.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.world.entity.ai.attributes.AttributeModifier
net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation -
Constructor Summary
ConstructorsConstructorDescriptionWizardryAttributeModifier(String name, double amount, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation) WizardryAttributeModifier(UUID uuid, String name, double amount, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, @Nullable SpellCondition condition) -
Method Summary
Modifier and TypeMethodDescriptionstatic floatcalculateModifiers(net.minecraft.world.entity.LivingEntity entity, SpellCondition condition, net.minecraft.world.entity.ai.attributes.Attribute attribute) Search and load the attribute modifiers saved in the living entity, first, organize the attributes based on the operation order and then values the vanilla attribute modifiers and wizard attribute modifiers (modifiers with conditions).static floatcalculateModifiers(net.minecraft.world.entity.LivingEntity entity, Spell spell, net.minecraft.world.entity.ai.attributes.Attribute attribute) Search and load the attribute modifiers saved in the living entity, first, organize the attributes based on the operation order and then values the vanilla attribute modifiers and wizard attribute modifiers (modifiers with conditions).@Nullable SpellConditionstatic voidonPreCast(SpellCastEvent.Pre event) static voidsafeAddModifiers(SpellModifiers modifiers, String key, float value) @NotNull net.minecraft.nbt.CompoundTagsave()Methods inherited from class net.minecraft.world.entity.ai.attributes.AttributeModifier
equals, getAmount, getId, getName, getOperation, hashCode, load, toString
-
Constructor Details
-
WizardryAttributeModifier
public WizardryAttributeModifier(String name, double amount, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation) -
WizardryAttributeModifier
public WizardryAttributeModifier(UUID uuid, String name, double amount, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, @Nullable @Nullable SpellCondition condition)
-
-
Method Details
-
getCondition
-
save
@NotNull public @NotNull net.minecraft.nbt.CompoundTag save()- Overrides:
savein classnet.minecraft.world.entity.ai.attributes.AttributeModifier
-
onPreCast
-
safeAddModifiers
-
calculateModifiers
public static float calculateModifiers(net.minecraft.world.entity.LivingEntity entity, Spell spell, net.minecraft.world.entity.ai.attributes.Attribute attribute) Search and load the attribute modifiers saved in the living entity, first, organize the attributes based on the operation order and then values the vanilla attribute modifiers and wizard attribute modifiers (modifiers with conditions). In case the entity doesn't have the attribute instance it will return 0.- Parameters:
entity- living entity that could have the given attributespell- result of the casting/logic made by the entityattribute- attribute that needs to be check in order to find its modifiers- Returns:
- the calculation result of all the modifiers, 0 if there wasn't any modifiers or the entity doesn't have the attribute instance
-
calculateModifiers
public static float calculateModifiers(net.minecraft.world.entity.LivingEntity entity, SpellCondition condition, net.minecraft.world.entity.ai.attributes.Attribute attribute) Search and load the attribute modifiers saved in the living entity, first, organize the attributes based on the operation order and then values the vanilla attribute modifiers and wizard attribute modifiers (modifiers with conditions). In case the entity doesn't have the attribute instance it will return 0.- Parameters:
entity- living entity that could have the given attributecondition- filter that goes to test the modifiers resultattribute- attribute that needs to be check in order to find its modifiers- Returns:
- the calculation result of all the modifiers, 0 if there wasn't any modifiers or the entity doesn't have the attribute instance
-