Posted November 30, 201410 yr Hello, random results of this code: @SubscribeEvent public void onPlayerTick(PlayerTickEvent event) { // Swap HotBar if (Keyboard.isKeyDown(Keyboard.KEY_B)) { if (!event.player.worldObj.isRemote) { int s = 0; ItemStack InvetoryPlayer[] = event.player.inventory.mainInventory.clone(); System.out.println("Length = " + InvetoryPlayer.length); for (s = 0; s < 9; ++s) { if(InvetoryPlayer[s] != null){ System.out.println("Slot = " + s + " -> " + InvetoryPlayer[s].getDisplayName()); } event.player.inventory.setInventorySlotContents(s, InvetoryPlayer[s+9]); } for (s = 9; s < 18; ++s) { if(InvetoryPlayer[s] != null){ System.out.println("Slot = " + s + " -> " + InvetoryPlayer[s].getDisplayName()); } event.player.inventory.setInventorySlotContents(s, InvetoryPlayer[s-9]); } InvetoryPlayer = null; } } } I need to swap the first inventory line with the hotbar every time i press "B" but it working only sometime. I think a misalignment client/server side ... Also the output is duplicated but this procedure is only server side ... i guess ... Please help.
December 1, 201410 yr Author a) Don't use Keyboard.keyDown, use a keybinding. b) You will need packets. Keys are client-only. thank you for reply, but i've never understood the packet handler, have you a VERY sample tutorial? I mean i know how to setup one but i dont know how to apply it in my case ...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.