ItemAttributeModifierEvent
Link to itemattributemodifierevent
This event is fired when the attributes for an ItemStack are being calculated. Attributes are calculated on the server when equipping and un-equipping an item to add and remove attributes respectively, both must be consistent. Attributes are calculated on the client when rendering an item's tooltip to show relevant attributes.
The event is not cancelable.
The event does not have a result.
Importing the class
Link to importing-the-class
Importing the class is recommended for events, simply add this line to the top of your script file.
ZenScript Copyimport crafttweaker.forge.api.event.item.ItemAttributeModifierEvent;
Listening to the event
Link to listening-to-the-event
ZenScript Copyevents.register<crafttweaker.forge.api.event.item.ItemAttributeModifierEvent>(event => {
println("ItemAttributeModifierEvent ran!");
});
Supertype
Link to supertype
ItemAttributeModifierEvent extends Event. That means all methods available in Event are also available in ItemAttributeModifierEvent
Methods
Link to methods
Name: addModifier
Adds a new AttributeModifier to the ItemStack.
Returns: True if the modifier was added. False otherwise.
Return Type: boolean
ZenScript Copy// ItemAttributeModifierEvent.addModifier(attribute as Attribute, name as string, value as double, operation as AttributeOperation) as boolean
myItemAttributeModifierEvent.addModifier(<attribute:minecraft:generic.attack_damage>, "Extra Power", 10, AttributeOperation.ADDITION);
Parameter | Type | Description |
---|---|---|
Parameter attribute | Type Attribute | Description The Attribute to add. |
Parameter name | Type string | Description The name of the modifier to add |
Parameter value | Type double | Description The value of the modifier. |
Parameter operation | Type AttributeOperation | Description The operation of the modifier. |
Name: addModifier
Adds a new AttributeModifier to the ItemStack.
Returns: True if the modifier was added. False otherwise.
Return Type: boolean
ZenScript Copy// ItemAttributeModifierEvent.addModifier(attribute as Attribute, uuid as string, name as string, value as double, operation as AttributeOperation) as boolean
myItemAttributeModifierEvent.addModifier(<attribute:minecraft:generic.attack_damage>, "8c1b5535-9f79-448b-87ae-52d81480aaa3", "Extra Power", 10, AttributeOperation.ADDITION);
Parameter | Type | Description |
---|---|---|
Parameter attribute | Type Attribute | Description The Attribute to add. |
Parameter uuid | Type string | Description The UUID of the modifier. |
Parameter name | Type string | Description The name of the modifier. |
Parameter value | Type double | Description The value of the modifier. |
Parameter operation | Type AttributeOperation | Description The operation of the modifier. |
Name: clearModifiers
Clears all AttributeModifiers from the ItemStack.
ZenScript Copy// ItemAttributeModifierEvent.clearModifiers()
myItemAttributeModifierEvent.clearModifiers();
Name: removeAttribute
Removes an Attribute from the ItemStack.
Returns: A List of the AttributeModifiers for the removed Attribute.
Return Type: stdlib.List<AttributeModifier>
ZenScript Copy// ItemAttributeModifierEvent.removeAttribute(attribute as Attribute) as stdlib.List<AttributeModifier>
myItemAttributeModifierEvent.removeAttribute(<attribute:minecraft:generic.attack_damage>);
Parameter | Type | Description |
---|---|---|
Parameter attribute | Type Attribute | Description The Attribute to remove. |
Name: removeModifier
Removes an AttributeModifier from the ItemStack.
Returns: True if the modifier was remove. False otherwise.
Return Type: boolean
ZenScript Copy// ItemAttributeModifierEvent.removeModifier(attribute as Attribute, modifier as AttributeModifier) as boolean
myItemAttributeModifierEvent.removeModifier(<attribute:minecraft:generic.attack_damage>, modifier);
Parameter | Type | Description |
---|---|---|
Parameter attribute | Type Attribute | Description The Attribute to remove. |
Parameter modifier | Type AttributeModifier | Description The modifier to remove. |
Name: removeModifier
Removes an AttributeModifier from the ItemStack based on the modifier's UUID.
Returns: True if the modifier was remove. False otherwise.
Return Type: boolean
ZenScript Copy// ItemAttributeModifierEvent.removeModifier(attribute as Attribute, uuid as string) as boolean
myItemAttributeModifierEvent.removeModifier(<attribute:minecraft:generic.attack_damage>, "8c1b5535-9f79-448b-87ae-52d81480aaa3");
Parameter | Type | Description |
---|---|---|
Parameter attribute | Type Attribute | Description The Attribute to remove. |
Parameter uuid | Type string | Description The UUID of the modifier. |
Properties
Link to properties
Name | Type | Has Getter | Has Setter | Description |
---|---|---|---|---|
Name itemStack | Type IItemStack | Has Getter true | Has Setter false | Description Gets the ItemStack that this event is being ran for. |
Name modifiers | Type stdlib.List<AttributeModifier>[Attribute] | Has Getter true | Has Setter false | Description Gets the modifiers on the ItemStack |
Name originalModifiers | Type stdlib.List<AttributeModifier>[Attribute] | Has Getter true | Has Setter false | Description Gets the original modifiers on the ItemStack before being changed by any other event listener. |
Name slotType | Type EquipmentSlot | Has Getter true | Has Setter false | Description Gets the EquipmentSlotType that this event is being ran for. If you only want to add / remove a modifier from a specific slot, you can use this to filter based on the slot. |