Class endstone::AttributeInstance¶
ClassList > endstone > AttributeInstance
Represents a mutable instance of an attribute and its associated modifiers and values.
#include <endstone/attribute/attribute_instance.h>
Public Functions¶
| Type | Name |
|---|---|
| virtual void | addModifier (const AttributeModifier & modifier) = 0 Add a modifier to this instance. |
| virtual void | addTransientModifier (const AttributeModifier & modifier) = 0 Add a transient modifier to this instance. |
| virtual float | getBaseValue () const = 0 Base value of this instance before modifiers are applied. |
| virtual float | getMaxValue () const = 0 The maximum value this instance is allowed to take. |
| virtual float | getMinValue () const = 0 The minimum value this instance is allowed to take. |
| virtual std::optional< AttributeModifier > | getModifier (AttributeModifierId id) const = 0 Gets the modifier with the corresponding id. |
| virtual std::vector< AttributeModifier > | getModifiers () const = 0 Get all modifiers present on this instance. |
| virtual AttributeId | getType () const = 0 The attribute type pertaining to this instance. |
| virtual float | getValue () const = 0 Get the value of this instance after all associated modifiers have been applied. |
| virtual void | removeModifier (const AttributeModifier & modifier) = 0 Remove a modifier from this instance. |
| virtual void | removeModifier (AttributeModifierId id) = 0 Remove a modifier with the corresponding id from this instance. |
| virtual void | setBaseValue (float value) = 0 Set the base value of this instance. |
| virtual void | setMaxValue (float value) = 0 Set the maximum value this instance is allowed to take. |
| virtual void | setMinValue (float value) = 0 Set the minimum value this instance is allowed to take. |
| virtual | ~AttributeInstance () = default |
Public Functions Documentation¶
function addModifier¶
Add a modifier to this instance.
Parameters:
modifierto add
function addTransientModifier¶
Add a transient modifier to this instance.
virtual void endstone::AttributeInstance::addTransientModifier (
const AttributeModifier & modifier
) = 0
Transient modifiers are not persisted (saved with the NBT data).
Parameters:
modifierto add
function getBaseValue¶
Base value of this instance before modifiers are applied.
Returns:
base value
function getMaxValue¶
The maximum value this instance is allowed to take.
Note:
Bedrock-specific. The value of this instance is clamped to the range [min, max].
Returns:
maximum value
function getMinValue¶
The minimum value this instance is allowed to take.
Note:
Bedrock-specific. The value of this instance is clamped to the range [min, max].
Returns:
minimum value
function getModifier¶
Gets the modifier with the corresponding id.
virtual std::optional< AttributeModifier > endstone::AttributeInstance::getModifier (
AttributeModifierId id
) const = 0
Parameters:
idthe id of the modifier
Returns:
the modifier, or std::nullopt if no modifier with the given id is present
function getModifiers¶
Get all modifiers present on this instance.
Returns:
a copied collection of all modifiers
function getType¶
The attribute type pertaining to this instance.
Returns:
the attribute type
function getValue¶
Get the value of this instance after all associated modifiers have been applied.
Returns:
the total attribute value
function removeModifier [½]¶
Remove a modifier from this instance.
Parameters:
modifierto remove
function removeModifier [2/2]¶
Remove a modifier with the corresponding id from this instance.
Parameters:
idthe id of the modifier to remove
function setBaseValue¶
Set the base value of this instance.
Parameters:
valuenew base value
function setMaxValue¶
Set the maximum value this instance is allowed to take.
For example, raising the maximum of an entity's minecraft:health attribute increases its maximum health.
Note:
Bedrock-specific. The value is re-clamped to the new range on the next recalculation.
Parameters:
valuenew maximum value
function setMinValue¶
Set the minimum value this instance is allowed to take.
Note:
Bedrock-specific. The value is re-clamped to the new range on the next recalculation.
Parameters:
valuenew minimum value
function ~AttributeInstance¶
The documentation for this class was generated from the following file include/endstone/attribute/attribute_instance.h