Package de.eldoria.eldoutilities.utils
Class AttributeUtil
java.lang.Object
de.eldoria.eldoutilities.utils.AttributeUtil
Class which holds utility methods to handle and manage attributes.
- Since:
- 1.1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
getAttributeValue
(LivingEntity entity, Attribute attribute) static void
setAttributeValue
(@NotNull LivingEntity entity, @NotNull Attribute attribute, @org.jetbrains.annotations.NotNull double target) Sets theAttributeInstance.getBaseValue()
to the value which is required to get the target value onAttributeInstance.getValue()
for the requestedAttribute
static void
setAttributeValue
(AttributeInstance attribute, double target) Deprecated.static void
syncAttributeValue
(LivingEntity source, LivingEntity target, Attribute attribute) Syncs to attributes to the same value.
-
Method Details
-
setAttributeValue
@Deprecated public static void setAttributeValue(AttributeInstance attribute, double target) throws NullPointerException Deprecated.UsesetAttributeValue(LivingEntity, Attribute, double)
for better and safer assignment.Sets theAttributeInstance.getBaseValue()
to the value which is required to get the target value onAttributeInstance.getValue()
- Parameters:
attribute
- attribute to settarget
- target value which should be retrieved viaAttributeInstance.getValue()
- Throws:
NullPointerException
- when the attribute is null
-
setAttributeValue
public static void setAttributeValue(@NotNull @NotNull LivingEntity entity, @NotNull @NotNull Attribute attribute, @NotNull @org.jetbrains.annotations.NotNull double target) Sets theAttributeInstance.getBaseValue()
to the value which is required to get the target value onAttributeInstance.getValue()
for the requestedAttribute
- Parameters:
entity
- to set the attribute forattribute
- attribute type to set if presenttarget
- target value which should be retrieved viaAttributeInstance.getValue()
-
syncAttributeValue
public static void syncAttributeValue(LivingEntity source, LivingEntity target, Attribute attribute) Syncs to attributes to the same value.If the
Attribute
isAttribute.GENERIC_MAX_HEALTH
the health of the entity health will be set to the new max health value.- Parameters:
source
- source of the attributetarget
- target of the source attribute valueattribute
- attribute to change
-
getAttributeValue
-
setAttributeValue(LivingEntity, Attribute, double)
for better and safer assignment.