public void remove(World world, int i, int j, int k) { TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k); if (tileentitydispenser != null) { for (int l = 0; l < tileentitydispenser.getSize(); ++l) { ItemStack itemstack = tileentitydispenser.getItem(l); if (itemstack != null) { float f = this.a.nextFloat() * 0.8F + 0.1F; float f1 = this.a.nextFloat() * 0.8F + 0.1F; float f2 = this.a.nextFloat() * 0.8F + 0.1F; while (itemstack.count > 0) { int i1 = this.a.nextInt(21) + 10; if (i1 > itemstack.count) { i1 = itemstack.count; } itemstack.count -= i1; EntityItem entityitem = new EntityItem( world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.getData())); if (itemstack.hasTag()) { entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone()); } float f3 = 0.05F; entityitem.motX = (double) ((float) this.a.nextGaussian() * f3); entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F); entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3); world.addEntity(entityitem); } } } } super.remove(world, i, j, k); }
public void openDispenser(TileEntityDispenser tileentitydispenser) { // CraftBukkit start - inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent( this, new ContainerDispenser(this.inventory, tileentitydispenser)); if (container == null) return; // CraftBukkit end this.nextContainerCounter(); this.playerConnection.sendPacket( new Packet100OpenWindow( this.containerCounter, 3, tileentitydispenser.getName(), tileentitydispenser.getSize())); this.activeContainer = container; // CraftBukkit - Use container passed to event this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); }