public void onTick(float dt) {
for (Entity entity : getNearbyEntities()) {
Item item = entity.get(Item.class);
if (item != null && item.canBeCollected()) {
getOwner().getNetwork().callProtocolEvent(new EntityCollectItemEvent(getOwner(), entity));
PlayerInventory inv = getOwner().get(PlayerInventory.class);
if (inv != null) {
inv.add(item.getItemStack());
}
entity.remove();
}
}
}