Class AttributeInstance
java.lang.Object
com.github.darksoulq.abyssallib.world.data.attribute.AttributeInstance
Represents an active instance of an attribute on a specific entity.
Manages the base value and all applied modifiers to compute the final value.
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeInstance(Attribute attribute, double baseValue) Constructs a new attribute instance for an entity. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddModifier(AttributeModifier modifier) Adds a modifier to this attribute instance.Retrieves the attribute definition associated with this instance.doubleRetrieves the raw base value without applying any modifiers.getModifier(net.kyori.adventure.key.Key key) Retrieves a specific modifier applied to this instance.Retrieves all active modifiers on this instance.doublegetValue()Calculates and returns the final value of this attribute after applying all modifiers.voidremoveModifier(net.kyori.adventure.key.Key key) Removes a specific modifier from this attribute instance using its key.voidsetBaseValue(double baseValue) Sets the un-modified base value of this attribute instance.
-
Constructor Details
-
AttributeInstance
Constructs a new attribute instance for an entity.- Parameters:
attribute- The attribute definition.baseValue- The initial base value.
-
-
Method Details
-
getAttribute
-
getBaseValue
public double getBaseValue()Retrieves the raw base value without applying any modifiers.- Returns:
- The base value.
-
setBaseValue
public void setBaseValue(double baseValue) Sets the un-modified base value of this attribute instance.- Parameters:
baseValue- The new base value.
-
addModifier
Adds a modifier to this attribute instance.- Parameters:
modifier- TheAttributeModifierto add.
-
removeModifier
public void removeModifier(net.kyori.adventure.key.Key key) Removes a specific modifier from this attribute instance using its key.- Parameters:
key- The uniqueKeyof the modifier to remove.
-
getModifier
Retrieves a specific modifier applied to this instance.- Parameters:
key- The uniqueKeyof the modifier.- Returns:
- The
AttributeModifier, or null if not found.
-
getModifiers
Retrieves all active modifiers on this instance.- Returns:
- A collection of
AttributeModifiers.
-
getValue
public double getValue()Calculates and returns the final value of this attribute after applying all modifiers.- Returns:
- The final computed value.
-