Package net.minestom.server.attribute
Class AttributeInstance
java.lang.Object
net.minestom.server.attribute.AttributeInstance
Represents an instance of an attribute and its modifiers.
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeInstance(@NotNull Attribute attribute, @Nullable Consumer<AttributeInstance> listener) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddModifier(@NotNull AttributeModifier modifier) Add a modifier to this instance.@NotNull AttributeGets the attribute associated to this instance.floatThe base value of this instance without modifiers@NotNull Collection<AttributeModifier> Get the modifiers applied to this instance.floatgetValue()Gets the value of this instance calculated with modifiers applied.voidremoveModifier(@NotNull UUID uuid) Remove a modifier from this instance.voidremoveModifier(@NotNull AttributeModifier modifier) Remove a modifier from this instance.voidsetBaseValue(float baseValue) Sets the base value of this instance.
-
Constructor Details
-
AttributeInstance
public AttributeInstance(@NotNull @NotNull Attribute attribute, @Nullable @Nullable Consumer<AttributeInstance> listener)
-
-
Method Details
-
getAttribute
Gets the attribute associated to this instance.- Returns:
- the associated attribute
-
getBaseValue
public float getBaseValue()The base value of this instance without modifiers- Returns:
- the instance base value
- See Also:
-
setBaseValue
public void setBaseValue(float baseValue) Sets the base value of this instance.- Parameters:
baseValue- the new base value- See Also:
-
addModifier
Add a modifier to this instance.- Parameters:
modifier- the modifier to add
-
removeModifier
Remove a modifier from this instance.- Parameters:
modifier- the modifier to remove
-
removeModifier
Remove a modifier from this instance.- Parameters:
uuid- The UUID of the modifier to remove
-
getModifiers
Get the modifiers applied to this instance.- Returns:
- the modifiers.
-
getValue
public float getValue()Gets the value of this instance calculated with modifiers applied.- Returns:
- the attribute value
-