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
ConstructorDescriptionAttributeInstance
(@NotNull Attribute attribute, @Nullable Consumer<AttributeInstance> listener) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addModifier
(@NotNull AttributeModifier modifier) Add a modifier to this instance.@NotNull Attribute
Gets the attribute associated to this instance.float
The base value of this instance without modifiers@NotNull Collection
<AttributeModifier> Get the modifiers applied to this instance.float
getValue()
Gets the value of this instance calculated with modifiers applied.void
removeModifier
(@NotNull UUID uuid) Remove a modifier from this instance.void
removeModifier
(@NotNull AttributeModifier modifier) Remove a modifier from this instance.void
setBaseValue
(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
-