int window = Minecraft.getMinecraft().thePlayer.openContainer.windowId;
ItemStack replacement = inventory.mainInventory[slot].copy();
Minecraft.getMinecraft().playerController.windowClick(window, slot < 9 ? slot + 36 : slot, 0, 0, Minecraft.getMinecraft().thePlayer);
Minecraft.getMinecraft().playerController.windowClick(window, inventory.currentItem + 36, 0, 0, Minecraft.getMinecraft().thePlayer);
((EntityClientPlayerMP)Minecraft.getMinecraft().thePlayer).sendQueue.addToSendQueue(new Packet101CloseWindow(window));
((EntityClientPlayerMP)Minecraft.getMinecraft().thePlayer).sendQueue.queued = true;
((EntityClientPlayerMP)Minecraft.getMinecraft().thePlayer).sendQueue.packetQueueTime = System.currentTimeMillis() + 30L;
ItemStack current = inventory.mainInventory[inventory.currentItem];
if (replacement != null && current != null) {