Interface AttributeInstance


public interface AttributeInstance
Represents a mutable instance of an attribute and its associated modifiers and values.
  • Method Details

    • getAttribute

      @NotNull @NotNull Attribute getAttribute()
      The attribute pertaining to this instance.
      Returns:
      the attribute
    • getBaseValue

      double getBaseValue()
      Base value of this instance before modifiers are applied.
      Returns:
      base value
    • setBaseValue

      void setBaseValue(double value)
      Set the base value of this instance.
      Parameters:
      value - new base value
    • getModifiers

      Get all modifiers present on this instance.
      Returns:
      a copied collection of all modifiers
    • getModifier

      Gets the modifier with the corresponding key.
      Parameters:
      key - the jey of the modifier
      Returns:
      the modifier, if it exists
    • removeModifier

      void removeModifier(@NotNull Key key)
      Remove a modifier with the corresponding key from this instance.
      Parameters:
      key - the key of the modifier
    • getModifier

      Deprecated, for removal: This API element is subject to removal in a future version.
      use getModifier(net.kyori.adventure.key.Key), modifiers are no longer stored by UUID
      Gets the modifier with the corresponding UUID.
      Parameters:
      uuid - the UUID of the modifier
      Returns:
      the modifier, if it exists
    • removeModifier

      @Deprecated(forRemoval=true, since="1.21") void removeModifier(@NotNull UUID uuid)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use removeModifier(net.kyori.adventure.key.Key), modifiers are no longer stored by UUID
      Remove a modifier with the corresponding UUID from this instance.
      Parameters:
      uuid - the UUID of the modifier
    • addModifier

      void addModifier(@NotNull @NotNull AttributeModifier modifier)
      Add a modifier to this instance.
      Parameters:
      modifier - to add
    • addTransientModifier

      void addTransientModifier(@NotNull @NotNull AttributeModifier modifier)
      Add a transient modifier to this instance. Transient modifiers are not persisted (saved with the NBT data)
      Parameters:
      modifier - to add
    • removeModifier

      void removeModifier(@NotNull @NotNull AttributeModifier modifier)
      Remove a modifier from this instance.
      Parameters:
      modifier - to remove
    • getValue

      double getValue()
      Get the value of this instance after all associated modifiers have been applied.
      Returns:
      the total attribute value
    • getDefaultValue

      double getDefaultValue()
      Gets the default value of the Attribute attached to this instance.
      Returns:
      server default value