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

    Constructors
    Constructor
    Description
    WizardryAttributeModifier(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 Type
    Method
    Description
    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).
    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).
    @Nullable SpellCondition
     
    static void
     
    static void
    safeAddModifiers(SpellModifiers modifiers, String key, float value)
     
    @NotNull net.minecraft.nbt.CompoundTag
     

    Methods inherited from class net.minecraft.world.entity.ai.attributes.AttributeModifier

    equals, getAmount, getId, getName, getOperation, hashCode, load, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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

      @Nullable public @Nullable SpellCondition getCondition()
    • save

      @NotNull public @NotNull net.minecraft.nbt.CompoundTag save()
      Overrides:
      save in class net.minecraft.world.entity.ai.attributes.AttributeModifier
    • onPreCast

      public static void onPreCast(SpellCastEvent.Pre event)
    • safeAddModifiers

      public static void safeAddModifiers(SpellModifiers modifiers, String key, float value)
    • 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 attribute
      spell - result of the casting/logic made by the entity
      attribute - 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 attribute
      condition - filter that goes to test the modifiers result
      attribute - 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