# ItemPickup

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

**Since:** 1.2.7

**Cancellable:** No. Calling `event.cancel()` throws `UnsupportedOperationException`.

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](EventSlotUpdate.md).  
```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 {#com.jsmacrosce.jsmacros.client.api.event.impl.inventory.EventItemPickup_constructor-ItemStack-}

```js
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 {#com.jsmacrosce.jsmacros.client.api.event.impl.inventory.EventItemPickup_item}

```js
item: ItemStackHelper
```

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 {#com.jsmacrosce.jsmacros.client.api.event.impl.inventory.EventItemPickup_toString-}

```js
toString(): String
```

Returns a diagnostic string containing the event name and the stored item's string form.  
Calling this method throws [NullPointerException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) if the wrapped raw stack is
`null`.

**Returns:** the string in the form `%s:{"item": %s}`, with the event name and item string
