public class EntityAttributeInstance extends Object
Modifier and Type | Field and 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 and Description |
---|
EntityAttributeInstance(EntityAttribute type,
Consumer<EntityAttributeInstance> updateCallback) |
private final EntityAttribute type
private final Map<EntityAttributeModifier.Operation,Set<EntityAttributeModifier>> operationToModifiers
private final Map<UUID,EntityAttributeModifier> idToModifiers
private final Set<EntityAttributeModifier> persistentModifiers
private double baseValue
private boolean dirty
private double value
private final Consumer<EntityAttributeInstance> updateCallback
public EntityAttributeInstance(EntityAttribute type, Consumer<EntityAttributeInstance> updateCallback)
public EntityAttribute getAttribute()
public double getBaseValue()
public void setBaseValue(double baseValue)
public Set<EntityAttributeModifier> getModifiers(EntityAttributeModifier.Operation operation)
public Set<EntityAttributeModifier> getModifiers()
@Nullable public EntityAttributeModifier getModifier(UUID uuid)
public boolean hasModifier(EntityAttributeModifier modifier)
private void addModifier(EntityAttributeModifier modifier)
public void addTemporaryModifier(EntityAttributeModifier modifier)
public void addPersistentModifier(EntityAttributeModifier modifier)
protected void onUpdate()
public void removeModifier(EntityAttributeModifier modifier)
public void removeModifier(UUID uuid)
public boolean tryRemoveModifier(UUID uuid)
@Environment(value=CLIENT) public void clearModifiers()
public double getValue()
private double computeValue()
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.private Collection<EntityAttributeModifier> getModifiersByOperation(EntityAttributeModifier.Operation operation)
public void setFrom(EntityAttributeInstance other)
Temporary modifiers are copied when using the operation.
public CompoundTag toTag()
public void fromTag(CompoundTag tag)