Package net.minecraft.entity.attribute
Class EntityAttributeInstance
java.lang.Object
net.minecraft.entity.attribute.EntityAttributeInstance
public class EntityAttributeInstance extends Object
A double-valued attribute.
-
Field Summary
Fields Modifier and Type Field Description private double
baseValue
private boolean
dirty
private Map<UUID,EntityAttributeModifier>
idToModifiers
private Map<EntityAttributeModifier.Operation,Set<EntityAttributeModifier>>
operationToModifiers
private Set<EntityAttributeModifier>
persistentModifiers
private EntityAttribute
type
private Consumer<EntityAttributeInstance>
updateCallback
private double
value
-
Constructor Summary
Constructors Constructor Description EntityAttributeInstance(EntityAttribute type, Consumer<EntityAttributeInstance> updateCallback)
-
Method Summary
-
Field Details
-
type
-
operationToModifiers
private final Map<EntityAttributeModifier.Operation,Set<EntityAttributeModifier>> operationToModifiers -
idToModifiers
-
persistentModifiers
-
baseValue
private double baseValue -
dirty
private boolean dirty -
value
private double value -
updateCallback
-
-
Constructor Details
-
EntityAttributeInstance
public EntityAttributeInstance(EntityAttribute type, Consumer<EntityAttributeInstance> updateCallback)
-
-
Method Details
-
getAttribute
-
getBaseValue
public double getBaseValue()Gets the base value of this attribute instance. This is the value before any attribute modifiers are applied. -
setBaseValue
public void setBaseValue(double baseValue) -
getModifiers
-
getModifiers
-
getModifier
-
hasModifier
-
addModifier
-
addTemporaryModifier
Adds a temporary attribute modifier. The modifier will not be serialized. -
addPersistentModifier
-
onUpdate
protected void onUpdate() -
removeModifier
-
removeModifier
-
tryRemoveModifier
-
clearModifiers
@Environment(CLIENT) public void clearModifiers() -
getValue
public double getValue() -
computeValue
private double computeValue()Computes this attribute's value, taking modifiers into account.Attribute modifiers are applied in order by operation:
ADDITION
// Adds the value of the modifier to the attribute's base value.MULTIPLY_BASE
// Multiplies the value of the modifier to the attributes base value, and then adds it to the total value.MULTIPLY_TOTAL
// Adds 1 to the value of the attribute modifier. Then multiplies the attribute's value by the total value of the attribute after addition and multiplication of the base value occur.
-
getModifiersByOperation
private Collection<EntityAttributeModifier> getModifiersByOperation(EntityAttributeModifier.Operation operation) -
setFrom
Copies the values of an attribute to this attribute.Temporary modifiers are copied when using the operation.
-
toTag
-
fromTag
-