Interface Attribute
-
public interface Attribute
Represents an instance of anAttributeType
that contains a value.Attributes are held in an
AttributeHolder
Attributes can have
AttributeModifier
s applied to an entity through an equippedItemStack
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addModifier(AttributeModifier modifier)
Adds a modifier to this attribute.double
baseValue()
Gets the base value of this attribute.boolean
hasModifier(AttributeModifier modifier)
Checks if this attribute has the provided modifier.java.util.Optional<AttributeModifier>
modifier(java.util.UUID uniqueId)
Gets an attribute modifier by its unique id.java.util.Collection<AttributeModifier>
modifiers()
Gets a collection of all applied modifiers.default java.util.Collection<AttributeModifier>
modifiers(java.util.function.Supplier<? extends AttributeOperation> operation)
Gets a collection of applied modifiers with the provided operation.java.util.Collection<AttributeModifier>
modifiers(AttributeOperation operation)
Gets a collection of applied modifiers with the provided operation.void
removeModifier(java.util.UUID uniqueId)
Removes a modifier from this attribute using it's unique id.void
removeModifier(AttributeModifier modifier)
Removes a modifier from this attribute.void
setBaseValue(double baseValue)
Sets the base value of this attribute.AttributeType
type()
Gets the type of this attribute.double
value()
Gets the value of this attribute.
-
-
-
Method Detail
-
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
AttributeModifier
s 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
java.util.Collection<AttributeModifier> modifiers()
Gets a collection of all applied modifiers.- Returns:
- A collection of applied modifiers
-
modifiers
default java.util.Collection<AttributeModifier> modifiers(java.util.function.Supplier<? extends AttributeOperation> operation)
Gets a collection of applied modifiers with the provided operation.- Parameters:
operation
- The operation- Returns:
- A collection of modifiers
-
modifiers
java.util.Collection<AttributeModifier> modifiers(AttributeOperation operation)
Gets a collection of applied modifiers with the provided operation.- Parameters:
operation
- The operation- Returns:
- A collection of modifiers
-
hasModifier
boolean hasModifier(AttributeModifier modifier)
Checks if this attribute has the provided modifier.- Parameters:
modifier
- The modifier- Returns:
true
if this attribute has the modifier,false
otherwise
-
modifier
java.util.Optional<AttributeModifier> modifier(java.util.UUID uniqueId)
Gets an attribute modifier by its unique id.- Parameters:
uniqueId
- The unique id- Returns:
- The attribute modifier, if present,
Optional.empty()
otherwise
-
addModifier
void addModifier(AttributeModifier modifier)
Adds a modifier to this attribute.- Parameters:
modifier
- The modifier
-
removeModifier
void removeModifier(AttributeModifier modifier)
Removes a modifier from this attribute.- Parameters:
modifier
- The modifier
-
removeModifier
void removeModifier(java.util.UUID uniqueId)
Removes a modifier from this attribute using it's unique id.- Parameters:
uniqueId
- The unique id of the modifier.
-
-