Sponge
Sponge copied to clipboard
Closing InventoryMenu on slot click prevents the player from interacting with their inventory
Affected Product(s)
SpongeVanilla
Version
1.16.5-8.0.0-RC1118
Operating System
Linux/5.15.32-xanmod1-tt-1 (amd64)
Java Version
18.0.1/64-bit
Plugins/Mods
A test plugin with the code mentioned below
Describe the bug
Calling ServerPlayer#closeInventory()
in the slot click listener of the inventory menu will prevent the player from interacting with their inventory until they relog. This only happens if the player is not in creative mode and the clicked slot contains a non-empty itemstack.
https://imgur.com/fCFzl2s
To reproduce:
- Run a server with a plugin that contains this code.
- While in survival mode, run the
/test
command and click the stone item in the menu. - Try moving items around in your inventory.
This issue can be worked around by delaying the closeInventory call by 1 tick using the scheduler.
Link to logs
No response
Delaying is the way to go. Closing/Opening inventories during the callbacks cannot work.
see also https://github.com/SpongePowered/Sponge/issues/3420