Skip to content

Conversation

@konradpomocny
Copy link

The problem:
When placing an item with a "drag" (the InventoryDragEvent) onto GuiStorageElement, it will always get canceled. Placing a single item with drag event is undistinguishable to a player from a regular inventory click. This creates a weird bug where sometimes item just won't get placed into storage.

This is a fix.

@Phoenix616
Copy link
Owner

Phoenix616 commented Sep 8, 2025

Thank you for your PR and while it seems to make sense (as the single slot drag is forwarded as a click but then cancelled here by the event instance chec) I cannot reproduce any issue with the current implementation which is a bit confusing to me and I want to figure out why it's not actually causing an issue for me first before merging.

@konradpomocny
Copy link
Author

konradpomocny commented Sep 9, 2025

Thanks for a quick response!
You're right! The GUI that has this problem is a multi-page storage "chest" that's using GuiElementGroup class. I simplified it as much as I could to replicate the issue:

            InventoryGui gui = new InventoryGui(this, null, "", new String[]{
                "ggggggggg",
                "ggggggggg",
                "ggggggggg",
                "ggggggggg",
                "ggggggggg",
                "ggggggggg",
            });
            GuiElementGroup group = new GuiElementGroup('g');
            Inventory inventory = Bukkit.createInventory(null, 54);
            for (int i = 0; i < 54; i++) {
                group.addElement(new GuiStorageElement('e', inventory, i));
            }
            gui.addElement(group);
            gui.show(player);

When having an itemstack on the cursor and right clicking on each slot, this happens:
Base Profile 2025.09.09 - 15.22.08.02.webm

(I clicked once on each slot, eventually the item will go through)
@Phoenix616

@Phoenix616
Copy link
Owner

Phoenix616 commented Sep 10, 2025

Thanks for providing the additional info. My guess right now is that this is caused by using a group instead of the GuiStorageElement directly so the click would get passed through the group first which could potentially change behaviour and cause what you describe. I only tested with a direct storage element before. (your example should be able to not use a group at all as the GuiStorageElement would automatically map the slots to the slots in the inventory but of course storage inside groups should be properly fixed too)

@Phoenix616
Copy link
Owner

Can you please re-test if the latest changes to the library (1.6.5 release) fixes your issues already without this additional PR?

@konradpomocny
Copy link
Author

Can you please re-test if the latest changes to the library (1.6.5 release) fixes your issues already without this additional PR?

Unfortunately it appears that the issue is still there. I tested it on version 1.20.4 though (added a startup flag), could that be the problem?

@Phoenix616
Copy link
Owner

I tested it on version 1.20.4 though (added a startup flag), could that be the problem?

You need to test on 1.21.9+ as server versions previous to this have a bug which makes handling inventories correctly not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants