Skip to content

InteractivelyPickupItemEvent

Package: com.hypixel.hytale.server.core.event.events.ecs Extends: CancellableEcsEvent Implements: ICancellableEcsEvent Cancellable: Yes

ECS event dispatched when an entity picks up an item from the world. Cancelling this event prevents the pickup. The itemStack field is mutable, allowing listeners to modify the item being picked up (e.g., change quantity or metadata).

FieldTypeAccessorMutableNullable
itemStackItemStackgetItemStack()YesNo
  • itemStack — The item being picked up. Mutable — changing this alters what the entity receives in their inventory.
  • ItemUtils.pickupItem() (line 35) via componentAccessor.invoke(ref, event) — ECS dispatch when an entity picks up an item from the world.

ECS events are handled by EntityEventSystem subclasses, not by getEventRegistry().register().

public class MyPickupHandler extends EntityEventSystem<EntityStore, InteractivelyPickupItemEvent> {
@Override
public Query<EntityStore> getQuery() {
return MY_COMPONENT_TYPE;
}
@Override
public void handle(int index, ArchetypeChunk<EntityStore> chunk,
Store<EntityStore> store, CommandBuffer<EntityStore> commandBuffer,
InteractivelyPickupItemEvent event) {
ItemStack item = event.getItemStack();
// Example: prevent picking up banned items
if (isBannedItem(item)) {
event.setCancelled(true);
}
// Example: double the stack size on pickup
event.setItemStack(item.withCount(item.getCount() * 2));
}
}
// Register in plugin setup():
getEntityStoreRegistry().registerSystem(new MyPickupHandler());
  • DropItemEvent — The inverse operation: fired when a player drops an item into the world.