Class AttributeModifierUtils

java.lang.Object
com.minecolonies.core.util.AttributeModifierUtils

public abstract class AttributeModifierUtils extends Object
Utility class for handling add/removal of attribute modifiers.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addHealthModifier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.ai.attributes.AttributeModifier modifier)
    Adds a health modifier, overwriting old modifier with the same name.
    static void
    addModifier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.ai.attributes.AttributeModifier modifier, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute)
    Add a specific new modifier.
    static void
    removeAllHealthModifiers(net.minecraft.world.entity.LivingEntity entity)
    Remove all healthmodifiers from a citizen
    static void
    removeHealthModifier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.resources.ResourceLocation modifierName)
    Removes healthmodifier by name.
    static void
    removeModifier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.resources.ResourceLocation modifierName, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute)
    Remove a specific modifier from an entity.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AttributeModifierUtils

      public AttributeModifierUtils()
  • Method Details

    • removeAllHealthModifiers

      public static void removeAllHealthModifiers(net.minecraft.world.entity.LivingEntity entity)
      Remove all healthmodifiers from a citizen
      Parameters:
      entity - the entity to remove the modifiers from
    • removeHealthModifier

      public static void removeHealthModifier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.resources.ResourceLocation modifierName)
      Removes healthmodifier by name. Reduces HP if needed
      Parameters:
      entity - the entity to remove the modifier from
      modifierName - Name of the modifier to remove, see e.g. GUARD_HEALTH_MOD_LEVEL_NAME
    • addHealthModifier

      public static void addHealthModifier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.ai.attributes.AttributeModifier modifier)
      Adds a health modifier, overwriting old modifier with the same name. Keeps health percentage.
      Parameters:
      entity - entity to add a healthmodifier to
      modifier - the modifier to add.
    • removeModifier

      public static void removeModifier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.resources.ResourceLocation modifierName, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute)
      Remove a specific modifier from an entity.
      Parameters:
      entity - the entity.
      modifierName - the name of the modifier.
      attribute - the type of attribute.
    • addModifier

      public static void addModifier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.ai.attributes.AttributeModifier modifier, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute)
      Add a specific new modifier.
      Parameters:
      entity - the entity to add it to.
      modifier - the modifier to add.
      attribute - the type of the attribute.