sgui
sgui copied to clipboard
HotbarGui Syncing Issues
De-syncing when using number keys
Here's a minimal setup to reproduce this bug:
dispatcher.register(literal("de-sync-1").executes(context -> {
var player = context.getSource().getPlayerOrThrow();
var hotbar = new HotbarGui(player);
hotbar.setSlot(0, new ItemStack(Items.GOLDEN_PICKAXE));
hotbar.open();
return 1;
}));
- Join the server and run the
/de-sync-1
command - Hover over the first slot (Golden Pickaxe) and press the 2, 3, 4, etc. number keys, observe the Golden Pickaxe be "duplicated" into those slots
- You can also hover over any slot in the inventory and press 1 and observe the Golden Pickaxe being "Deleted"
https://github.com/user-attachments/assets/cd689917-a856-419b-999f-72d14b799a5f
De-syncing when using offhand key
Here's a minimal setup to reproduce this bug:
dispatcher.register(literal("de-sync-2").executes(context -> {
var player = context.getSource().getPlayerOrThrow();
var hotbar = new HotbarGui(player);
var elements = new GuiElement[1];
elements[0] = new GuiElement(new ItemStack(Items.GOLDEN_PICKAXE), (a, type, c, gui) -> {
if (type != ClickType.OFFHAND_SWAP) {
return;
}
var offhand = gui.getSlot(9);
if (offhand == null || offhand.getItemStack().isEmpty()) {
gui.setSlot(9, elements[0].getItemStack());
elements[0].setItemStack(ItemStack.EMPTY);
} else if (elements[0].getItemStack().isEmpty()) {
elements[0].setItemStack(offhand.getItemStack());
gui.setSlot(9, ItemStack.EMPTY);
}
});
hotbar.setSlot(0, elements[0]);
hotbar.open();
return 1;
}));
- Join the server and run the
/de-sync-2
command - Hit the offhand key in your first slot and observe the Golden Pickaxe "Duplicate" into the offhand
- This doesn't happen while inside the inventory
https://github.com/user-attachments/assets/1413c4a2-ed81-4ad4-aedd-03859b9da643