Skip to content

ItemPickup ​

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

Since1.2.7Not cancellable

Fires while handling an item-pickup packet for the local player, before the corresponding client inventory update. To watch individual slot changes, listen for EventSlotUpdate.

js
JsMacros.on("ItemPickup", JavaWrapper.methodToJava(function (event) {
  const item = event.item;  
  if (item.getItemID() === "minecraft:diamond") {
    if (item.getCount() >= 5) {
      Chat.log(`picked up ${item.getCount()} diamonds`);  
    }
  }
}))

Constructors ​

new EventItemPickup ​

new EventItemPickup(ItemStack item)#
Wraps the supplied raw stack as the event's item; the wrapper retains the same reference without copying it. A null stack is retained as the wrapper's raw value.

Parameters:

  • item: raw stack to wrap; may be null

Fields ​

item ​

item: ItemStackHelperread-only#
A snapshot of the picked-up item stack, with its count set to the packet's pickup amount. Mutating it does not modify the dropped item or inventory.

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name and the stored item's string form. Calling this method throws NullPointerException if the wrapped raw stack is null.
Returns: the string in the form %s:{"item": %s}, with the event name and item string