public void expelItems() { if (inventory == null || inventory.getSizeInventory() == 0) return; for (ItemStack stack : inventory.getValues()) { if (stack != null) { Random random = new Random(); EntityItem entityitem = new EntityItem( worldObj, pos.getX() + random.nextFloat() * 0.8F + 0.1F, pos.getY() + random.nextFloat() * 0.8F + 0.1F, pos.getZ() + random.nextFloat() * 0.8F + 0.1F, stack); if (stack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); } float f3 = 0.05F; entityitem.motionX = (double) ((float) random.nextGaussian() * f3); entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double) ((float) random.nextGaussian() * f3); worldObj.spawnEntityInWorld(entityitem); } } }
@Override public void setInventorySlotContents(int index, ItemStack stack) { inventory.setStackInSlot(stack, index); }
@Override public ItemStack getStackInSlot(int index) { return inventory.getStackInSlot(index); }
@Override public int getSizeInventory() { return inventory.getSizeInventory(); }
@Override public void clear() { for (int i = 0; i < inventory.getSizeInventory(); i++) { inventory.setStackInSlot(null, i); } }