@Override public void processData(EntityPlayer entityPlayer, ByteBufInputStream bbis) throws IOException { super.processData(entityPlayer, bbis); ItemStack itemStack = entityPlayer.getHeldItem(); side = bbis.readInt(); boolean result = entityPlayer .worldObj .getBlock(x, y, z) .onBlockActivated(entityPlayer.worldObj, x, y, z, entityPlayer, side, 1.0F, 1.0F, 1.0F); if (!result) { if (itemStack != null && itemStack.getItem() instanceof ItemBlock) { itemStack.tryPlaceItemIntoWorld( entityPlayer, entityPlayer.worldObj, x, y, z, side, 1.0F, 1.0F, 1.0F); if (!entityPlayer.capabilities.isCreativeMode && --itemStack.stackSize <= 0) { entityPlayer.inventory.setInventorySlotContents( entityPlayer.inventory.currentItem, (ItemStack) null); } } } }
@Override public void appendData(ByteBuf buffer) throws IOException { super.appendData(buffer); buffer.writeInt(side); }