AttributeInstance

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.api.entity.attribute.AttributeInstance;

Members

addPermanentModifier(modifier as AttributeModifier)
Adds a permanent AttributeModifier to the attribute.
script.zs
// AttributeInstance.addPermanentModifier(modifier as AttributeModifier);
myAttributeInstance.addPermanentModifier(myAttributeModifier);

Parameters:

modifier Type: AttributeModifier - The modifier to add.
addTransientModifier(modifier as AttributeModifier)
Adds a transient AttributeModifier to the attribute.
script.zs
// AttributeInstance.addTransientModifier(modifier as AttributeModifier);
myAttributeInstance.addTransientModifier(myAttributeModifier);

Parameters:

modifier Type: AttributeModifier - The modifier to add.
Getter
Gets the base value of the attribute.
script.zs
// AttributeInstance.baseValue as double
myAttributeInstance.baseValue

Return Type: double

Setter
Sets the base value of the attribute.
script.zs
// AttributeInstance.baseValue = (value as double);
myAttributeInstance.baseValue = myDouble;

Parameters:

value Type: double - The new base value of the attribute.
baseValue() as double
Gets the base value of the attribute.

Returns: The base value of the attribute.

script.zs
// AttributeInstance.baseValue() as double;
myAttributeInstance.baseValue();

Return Type: double

baseValue(value as double)
Sets the base value of the attribute.
script.zs
// AttributeInstance.baseValue(value as double);
myAttributeInstance.baseValue(myDouble);

Parameters:

value Type: double - The new base value of the attribute.
getModifier(id as ResourceLocation) as AttributeModifier
Gets the AttributeModifier with the given ID.

Returns: The AttributeModifier with the given ID, or null if it does not exist.

script.zs
// AttributeInstance.getModifier(id as ResourceLocation) as AttributeModifier;
myAttributeInstance.getModifier(myResourceLocation);

Parameters:

id Type: ResourceLocation - The ID of the modifier to get.

Return Type: AttributeModifier

hasModifier(id as ResourceLocation) as bool
Checks if the attribute has a modifier with the given ID.

Returns: True if the attribute has a modifier with the given ID, false otherwise.

script.zs
// AttributeInstance.hasModifier(id as ResourceLocation) as bool;
myAttributeInstance.hasModifier(myResourceLocation);

Parameters:

id Type: ResourceLocation - The ID of the modifier to check for.

Return Type: bool

Getter
Gets the AttributeModifier of the attribute.
script.zs
// AttributeInstance.modifiers as List<AttributeModifier>
myAttributeInstance.modifiers

Return Type: List<AttributeModifier>

modifiers() as List<AttributeModifier>
Gets the AttributeModifier of the attribute.

Returns: The modifiers of the attribute.

script.zs
// AttributeInstance.modifiers() as List<AttributeModifier>;
myAttributeInstance.modifiers();

Return Type: List<AttributeModifier>

removeModifier(id as ResourceLocation)
Removes the AttributeModifier with the given ID.
script.zs
// AttributeInstance.removeModifier(id as ResourceLocation);
myAttributeInstance.removeModifier(myResourceLocation);

Parameters:

id Type: ResourceLocation - The ID of the modifier to remove.
Getter
Gets the current value of the attribute.
script.zs
// AttributeInstance.value as double
myAttributeInstance.value

Return Type: double

value() as double
Gets the current value of the attribute.

Returns: The current value of the attribute.

script.zs
// AttributeInstance.value() as double;
myAttributeInstance.value();

Return Type: double