Class AttributeInstance

java.lang.Object
com.github.darksoulq.abyssallib.world.data.attribute.AttributeInstance

public class AttributeInstance extends Object
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 Details

    • AttributeInstance

      public AttributeInstance(Attribute attribute, double baseValue)
      Constructs a new attribute instance for an entity.
      Parameters:
      attribute - The attribute definition.
      baseValue - The initial base value.
  • Method Details

    • getAttribute

      public Attribute getAttribute()
      Retrieves the attribute definition associated with this instance.
      Returns:
      The Attribute.
    • 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

      public void addModifier(AttributeModifier modifier)
      Adds a modifier to this attribute instance.
      Parameters:
      modifier - The AttributeModifier to 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 unique Key of the modifier to remove.
    • getModifier

      public AttributeModifier getModifier(net.kyori.adventure.key.Key key)
      Retrieves a specific modifier applied to this instance.
      Parameters:
      key - The unique Key of the modifier.
      Returns:
      The AttributeModifier, or null if not found.
    • getModifiers

      public Collection<AttributeModifier> 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.