Solved How to switch hotbar slots via script?
-
Is there a list of things like mc.gameSettings.keyBindUseItem.pressed where i can
look up some things because i cant find anything on google and i dont always want to ask in the Forum.And i really want to become better at scripting but as already mentioned i cant find
these things i want to look up . Any tips ? -
@bygraf said in How to switch hotbar slots via script?:
Is there a list of things like mc.gameSettings.keyBindUseItem.pressed
https://scriptapi.liquidbounce.net/net/minecraft/client/settings/GameSettings.html
How to switch hotbar slots via scriptapi?
mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(slot));
-
@ali00035 thank u
-
@bygraf no problem
-
ByGraf
-
ByGraf
-
@ali00035 I tested it and it didnt switch the slot
-
This:
mc.thePlayer.inventory.currentItem = slot - 36
switches slots client-side.
This:
mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(slot - 36))
switches slots server-side.
-
@mems ty so much ur really helping me
-
@mems Thanks, I didn't know that
-
And this is how you should actually switch the slots on both sides.
mc.thePlayer.inventory.currentItem = x; mc.playerController.updateController();
because updateController does this:
public void updateController() { this.syncCurrentPlayItem(); if (this.netClientHandler.getNetworkManager().isChannelOpen()) { this.netClientHandler.getNetworkManager().processReceivedPackets(); } else { this.netClientHandler.getNetworkManager().checkDisconnected(); } } private void syncCurrentPlayItem() { int i = this.mc.thePlayer.inventory.currentItem; if (i != this.currentPlayerItem) { this.currentPlayerItem = i; this.netClientHandler.addToSendQueue(new C09PacketHeldItemChange(this.currentPlayerItem)); } }
-
Yeah, it has to be updated server-side too, because this:
mc.thePlayer.inventory.currentItem
only does it client-side. -
ByGraf
-
@czechhek said in How to switch hotbar slots via script?:
mc.playerController.updateController();
Thank u guys so much