Sponge icon indicating copy to clipboard operation
Sponge copied to clipboard

Closing InventoryMenu on slot click prevents the player from interacting with their inventory

Open avaruus1 opened this issue 2 years ago • 1 comments

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:

  1. Run a server with a plugin that contains this code.
  2. While in survival mode, run the /test command and click the stone item in the menu.
  3. 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

avaruus1 avatar May 05 '22 12:05 avaruus1

Delaying is the way to go. Closing/Opening inventories during the callbacks cannot work.

see also https://github.com/SpongePowered/Sponge/issues/3420

Faithcaio avatar May 08 '22 14:05 Faithcaio