I'm new to developing mods in Minecraft and I'm currently trying to figure out how to move an item in the player's inventory from one slot to another.
I get that for this action to work, it has to be sent as a packet to the server, and I've read in the PlayerControllerMP class, that windowClick() "Handles slot clicks, sends a packet to the server."
This code should open the inventory and move the item from the first slot to the second slot in the hotbar. However, when I run it, it only ever opens the inventory and nothing happens to the item.
Minecraft.getMinecraft().displayGuiScreen(new GuiInventory(Minecraft.getMinecraft().player));
Minecraft.getMinecraft().playerController.windowClick(Minecraft.getMinecraft().player.inventoryContainer.windowId, 0, 0, ClickType.PICKUP, Minecraft.getMinecraft().player);
Minecraft.getMinecraft().playerController.windowClick(Minecraft.getMinecraft().player.inventoryContainer.windowId, 1, 0, ClickType.PICKUP, Minecraft.getMinecraft().player);
What am I doing wrong?
Thanks for your help :)
Okay, I figured it out. The indecies in the player inventory go like this:
0 crafting output
1–4 crafting input
5–8 armor
9–35 main inventory
36–44 hotbar
45 Offhand slot