Interface Attribute
public interface Attribute
Represents an instance of an
AttributeType that contains a value.
Attributes are held in an AttributeHolder
Attributes can have AttributeModifiers applied to an entity
through an equipped ItemStack
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddModifier(AttributeModifier modifier) Adds a modifier to this attribute.doubleGets the base value of this attribute.booleanhasModifier(AttributeModifier modifier) Checks if this attribute has the provided modifier.modifier(ResourceKey key) Gets an attribute modifier by its keyGets a collection of all applied modifiers.default Collection<AttributeModifier> modifiers(Supplier<? extends AttributeOperation> operation) Gets a collection of applied modifiers with the provided operation.modifiers(AttributeOperation operation) Gets a collection of applied modifiers with the provided operation.voidremoveModifier(AttributeModifier modifier) Removes a modifier from this attribute.voidRemoves a modifier from this attribute using it's keyvoidsetBaseValue(double baseValue) Sets the base value of this attribute.type()Gets the type of this attribute.doublevalue()Gets the value of this attribute.
-
Method Details
-
type
AttributeType type()Gets the type of this attribute.- Returns:
- The attribute type.
-
baseValue
double baseValue()Gets the base value of this attribute.This is the value of this attribute before any
AttributeModifiers are applied.- Returns:
- The base value.
-
setBaseValue
void setBaseValue(double baseValue) Sets the base value of this attribute.This is the value before modifiers are applied.
- Parameters:
baseValue- The base value
-
value
double value()Gets the value of this attribute.This is the value with modifiers applied.
- Returns:
- The value
-
modifiers
Collection<AttributeModifier> modifiers()Gets a collection of all applied modifiers.- Returns:
- A collection of applied modifiers
-
modifiers
Gets a collection of applied modifiers with the provided operation.- Parameters:
operation- The operation- Returns:
- A collection of modifiers
-
modifiers
Gets a collection of applied modifiers with the provided operation.- Parameters:
operation- The operation- Returns:
- A collection of modifiers
-
hasModifier
Checks if this attribute has the provided modifier.- Parameters:
modifier- The modifier- Returns:
trueif this attribute has the modifier,falseotherwise
-
modifier
Gets an attribute modifier by its key- Parameters:
key- The key- Returns:
- The attribute modifier, if present,
Optional.empty()otherwise
-
addModifier
Adds a modifier to this attribute.- Parameters:
modifier- The modifier
-
removeModifier
Removes a modifier from this attribute.- Parameters:
modifier- The modifier
-
removeModifier
Removes a modifier from this attribute using it's key- Parameters:
key- The key of the modifier.
-