Class AttributeInstance
java.lang.Object
net.minestom.server.entity.attribute.AttributeInstance
Represents an instance of an attribute and its modifiers.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAttributeInstance(@NotNull Attribute attribute, double baseValue, @NotNull Collection<AttributeModifier> modifiers, @Nullable Consumer<AttributeInstance> listener) AttributeInstance(@NotNull Attribute attribute, @Nullable Consumer<AttributeInstance> listener) -
Method Summary
Modifier and TypeMethodDescriptionaddModifier(@NotNull AttributeModifier modifier) Add a modifier to this instance.doubleapplyModifiers(double baseValue) Gets the value of this instance, calculated assuming the givenbaseValue.@NotNull AttributeGets the attribute associated to this instance.@NotNull AttributeDeprecated.doubleThe base value of this instance without modifiers@NotNull Collection<AttributeModifier> Deprecated.doublegetValue()Gets the value of this instance calculated with modifiers applied.@NotNull Collection<AttributeModifier> Get the modifiers applied to this instance.removeModifier(@NotNull AttributeModifier modifier) Remove a modifier from this instance.removeModifier(@NotNull NamespaceID id) Remove a modifier from this instance.voidsetBaseValue(double baseValue) Sets the base value of this instance.
-
Field Details
-
NETWORK_TYPE
-
-
Constructor Details
-
AttributeInstance
public AttributeInstance(@NotNull @NotNull Attribute attribute, @Nullable @Nullable Consumer<AttributeInstance> listener) -
AttributeInstance
public AttributeInstance(@NotNull @NotNull Attribute attribute, double baseValue, @NotNull @NotNull Collection<AttributeModifier> modifiers, @Nullable @Nullable Consumer<AttributeInstance> listener)
-
-
Method Details
-
attribute
Gets the attribute associated to this instance.- Returns:
- the associated attribute
-
getBaseValue
public double getBaseValue()The base value of this instance without modifiers- Returns:
- the instance base value
- See Also:
-
setBaseValue
public void setBaseValue(double baseValue) Sets the base value of this instance.- Parameters:
baseValue- the new base value- See Also:
-
modifiers
Get the modifiers applied to this instance.- Returns:
- an immutable collection of the modifiers applied to this attribute.
-
addModifier
Add a modifier to this instance.- Parameters:
modifier- the modifier to add- Returns:
- the old modifier, or null if none
-
removeModifier
Remove a modifier from this instance.- Parameters:
modifier- the modifier to remove- Returns:
- the modifier that was removed, or null if none
-
removeModifier
Remove a modifier from this instance.- Parameters:
id- The namespace id of the modifier to remove- Returns:
- the modifier that was removed, or null if none
-
getValue
public double getValue()Gets the value of this instance calculated with modifiers applied.- Returns:
- the attribute value
-
applyModifiers
public double applyModifiers(double baseValue) Gets the value of this instance, calculated assuming the givenbaseValue.- Parameters:
baseValue- the value to be used as the base for this operation, rather than this instance's normal base value- Returns:
- the attribute value
-
getModifiers
Deprecated. -
getAttribute
Deprecated.
-