Skip to content

ItemDamage ​

com.jsmacrosce.jsmacros.client.api.event.impl.inventory.EventItemDamage

Since1.2.7Not cancellable

Fires when polling detects a main-hand, off-hand, or armor stack change attributable to its damage value. Increased and decreased values both trigger it. When the stack also differs in a way other than damage, only the corresponding EventHeldItemChange or EventArmorChange fires; a damage-only change triggers this event first and then the corresponding stack-change event.
damage is the resulting value, not the amount changed;
item wraps the live stack and can be used to modify it.

js
JsMacros.on("ItemDamage", JavaWrapper.methodToJava(function (event) {
 const item = event.item;  
 if (!item.isDamageable()) {
   return;  
 }
 const left = item.getMaxDurability() - event.damage;  
 if (left === 1) {
   Chat.log(`${item.getName().getString()} is one hit from breaking`);  
 }
}))

Constructors ​

new EventItemDamage ​

new EventItemDamage(ItemStack stack, int damage)#
Wraps the supplied stack and stores the supplied resulting damage value; it does not apply that value to the stack or validate it against the stack's damage or durability. A null raw stack is retained by the helper and causes a NullPointerException when its accessors are used.

Parameters:

  • stack: raw stack to retain; may be null
  • damage: resulting damage value to store, not required to match the stack

Fields ​

damage ​

damage: intread-only#
The stack's current damage value, not the change since the previous tick or remaining durability.

item ​

item: ItemStackHelperread-only#
The changed stack in its current state. This wraps the live stack; modifications affect the player's item.

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name and the current helper string for the stored item. The format is %s:{"item": %s}; the damage field is omitted, though the helper's string may itself include the raw stack's current damage.
Returns: diagnostic event-name and item string