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.
import crafttweaker . forge.api.event.item . 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. ItemAttributeModifierEvent extends Event
.
This event can be listened to like so:
events . register < crafttweaker . forge.api.event.item . ItemAttributeModifierEvent > ( event = > {
println ( "ItemAttributeModifierEvent ran!" ) ;
Adds a new AttributeModifier to the ItemStack. Returns : True if the modifier was added. False otherwise.
// ItemAttributeModifierEvent.addModifier(attribute as Attribute, name as string, value as double, operation as Operation) as bool;
event . addModifier( < attribute : minecraft:generic.attack_damage > , "Extra Power" , 10 , AttributeOperation . ADDITION);
Parameters:
name: string
Type: string
- The name of the modifier to add
value: double
Type: double
- The value of the modifier.
Return Type:
bool
Adds a new AttributeModifier to the ItemStack. Returns : True if the modifier was added. False otherwise.
// ItemAttributeModifierEvent.addModifier(attribute as Attribute, uuid as string, name as string, value as double, operation as Operation) as bool;
event . addModifier( < attribute : minecraft:generic.attack_damage > , "8c1b5535-9f79-448b-87ae-52d81480aaa3" , "Extra Power" , 10 , AttributeOperation . ADDITION);
Parameters:
uuid: string
Type: string
- The UUID of the modifier.
name: string
Type: string
- The name of the modifier.
value: double
Type: double
- The value of the modifier.
Return Type:
bool
Cancels the event. Same as setCanceled(true)
// ItemAttributeModifierEvent.cancel();
// ItemAttributeModifierEvent.cancelable as bool
Return Type:
bool
// ItemAttributeModifierEvent.cancelable() as bool;
Return Type:
bool
// ItemAttributeModifierEvent.canceled as bool
Return Type:
bool
// ItemAttributeModifierEvent.canceled = (cancel as bool);
// ItemAttributeModifierEvent.canceled() as bool;
Return Type:
bool
// ItemAttributeModifierEvent.canceled(cancel as bool);
Clears all AttributeModifiers from the ItemStack. // ItemAttributeModifierEvent.clearModifiers();
// ItemAttributeModifierEvent.hasResult as bool
Return Type:
bool
// ItemAttributeModifierEvent.hasResult() as bool;
Return Type:
bool
Gets the ItemStack that this event is being ran for. // ItemAttributeModifierEvent.itemStack as IItemStack
Return Type:
IItemStack
Gets the modifiers on the ItemStack // ItemAttributeModifierEvent.modifiers as List<AttributeModifier>[Attribute]
Return Type:
List <AttributeModifier > [Attribute ]
Gets the original modifiers on the ItemStack before being changed by any other event listener. // ItemAttributeModifierEvent.originalModifiers as List<AttributeModifier>[Attribute]
Return Type:
List <AttributeModifier > [Attribute ]
Removes an Attribute from the ItemStack. Returns : A List of the AttributeModifiers for the removed Attribute.
// ItemAttributeModifierEvent.removeAttribute(attribute as Attribute) as List<AttributeModifier>;
event . removeAttribute( < attribute : minecraft:generic.attack_damage > );
Return Type:
List <AttributeModifier >
Removes an AttributeModifier from the ItemStack based on the modifier's UUID. Returns : True if the modifier was remove. False otherwise.
// ItemAttributeModifierEvent.removeModifier(attribute as Attribute, uuid as string) as bool;
event . removeModifier( < attribute : minecraft:generic.attack_damage > , "8c1b5535-9f79-448b-87ae-52d81480aaa3" );
Parameters:
uuid: string
Type: string
- The UUID of the modifier.
Return Type:
bool
Removes an AttributeModifier from the ItemStack. Returns : True if the modifier was remove. False otherwise.
// ItemAttributeModifierEvent.removeModifier(attribute as Attribute, modifier as AttributeModifier) as bool;
event . removeModifier( < attribute : minecraft:generic.attack_damage > , modifier);
Return Type:
bool
// ItemAttributeModifierEvent.result as Result
Return Type:
EventResult
// ItemAttributeModifierEvent.result = (result as Result);
// ItemAttributeModifierEvent.result() as Result;
Return Type:
EventResult
// ItemAttributeModifierEvent.result(result as Result);
sets the event's result to allow
// ItemAttributeModifierEvent.setAllow();
sets the event's result to default
// ItemAttributeModifierEvent.setDefault();
sets the event's result to deny
// ItemAttributeModifierEvent.setDeny();
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. // ItemAttributeModifierEvent.slotType as EquipmentSlot
Return Type:
EquipmentSlot