Skip to content

Commit

Permalink
Merge pull request #1224 from SamB440/fix/inventory-slot-set
Browse files Browse the repository at this point in the history
Fix setting slots in player inventory
  • Loading branch information
AoElite authored Nov 23, 2023
2 parents 2f49a90 + e31aee5 commit f5565df
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,13 @@ public void onPacketSend(final PacketSendEvent event) {
if (inventory.getInventoryStorage().getSize() > slot.getSlot() && slot.getSlot() >= 0) {
inventory.getInventoryStorage().setItem(slot.getSlot(), slot.getItem());
}
} else if (slot.getWindowId() == 0) { // Player hotbar (ONLY!)
if (slot.getSlot() >= 36 && slot.getSlot() <= 45) {
} else if (slot.getWindowId() == 0) { // Player inventory
// This packet can only be used to edit the hotbar and offhand of the player's inventory if
// window ID is set to 0 (slots 36 through 45) if the player is in creative, with their inventory open,
// and not in their survival inventory tab. Otherwise, when window ID is 0, it can edit any slot in the player's inventory.
// if (slot.getSlot() >= 36 && slot.getSlot() <= 45) {
inventory.getSlot(slot.getSlot()).set(slot.getItem());
}
// }
} else if (slot.getWindowId() == openWindowID) { // Opened inventory (if not valid, client crashes)
menu.getSlot(slot.getSlot()).set(slot.getItem());
}
Expand Down

0 comments on commit f5565df

Please sign in to comment.