Package com.minecolonies.core.util
Class AttributeModifierUtils
java.lang.Object
com.minecolonies.core.util.AttributeModifierUtils
Utility class for handling add/removal of attribute modifiers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddHealthModifier(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 voidaddModifier(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 voidremoveAllHealthModifiers(net.minecraft.world.entity.LivingEntity entity) Remove all healthmodifiers from a citizenstatic voidremoveHealthModifier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.resources.ResourceLocation modifierName) Removes healthmodifier by name.static voidremoveModifier(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.
-
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 frommodifierName- 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 tomodifier- 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.
-