package shootergame.entity; import shootergame.inventory.Inventory; import shootergame.items.ItemStack; import shootergame.util.math.vec.Vec2d; import shootergame.world.chunk.Chunk; import shootergame.world.layer.Layer; public class EntityItem extends EntityVertical { private ItemStack stack; public EntityItem(Vec2d pos, ItemStack stack) { super(stack.item.texture, 1); this.opaqueTile = true; this.pos = pos; this.stack = stack; } @Override public void tick(Chunk chunk, Layer layer) { super.tick(chunk, layer); for(Entity e : layer.getNearbyEntities(pos, 1)) { if(e instanceof EntityInventory) { // Pick the stack up if its an inventory stack.item.onPickedUp(stack, layer, chunk, e); // Kill this entity if the stack is empty if(stack.isEmpty()) { kill(); return; } } } } }