[SPIGOT-6291] Ghost item in inventory after cancelling an item swap in inventory Created: 24/Dec/20  Updated: 24/Dec/20  Resolved: 24/Dec/20

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Stef van Schie Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: 1.16.4, inventory, inventoryclickevent
Environment:

Windows 7 Professional
For 1.16.4 testing: OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15+36, mixed mode, sharing)
For 1.15.2 testing: OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14+36, mixed mode, sharing)


Attachments: File IF-Test-0.0.0.jar    
Issue Links:
Duplicate
duplicates SPIGOT-6145 InventoryClickEvent does not get corr... Resolved
Version: This server is running CraftBukkit version git-Spigot-628435a-6917945 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

When opening an inventory, a player can swap an item within that inventory with the item in their off-hand by pressing the corresponding keybind (by default 'F'). Doing this fires an InventoryClickEvent. When cancelling this corresponding InventoryClickEvent, however, the item that was attempted to be swapped is correctly returned to the original spot in the inventory, but a 'ghost item' stays in the player's off-hand. This item doesn't have any functionality and the moment the player tries to interact with it, it disappears, yet is visible until such an interaction is made.
It seems to me like this ghost item is undesired behavior and should not be present, hence why I think this is a bug.
Attached below is a reproduction plugin that shows this behavior. The code that was used for this reproduction plugin can be viewed here: https://pastie.io/vydxbs.java.

Reproduction steps:

  1. Stop the server if it's currently enabled by executing the stop command (either from the console or as a player with operator level 4 or higher).
  2. Put the reproduction plugin that is attached below on the server by placing the file in the dedicated plugins folder.
  3. Start the server.
  4. Open the example inventory by executing the /gui command as a player.
  5. Hover with your cursor over the stone in the top left corner of the opened inventory.
  6. Press 'F' (or the corresponding key for swapping items).
  7. The actual stone now stays in the top left corner of the inventory, but a ghost item is now also visible in the off-hand.

This bug affects Spigot 1.16.4 (git-Spigot-628435a-6917945 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT)); and CraftBukkit 1.16.4 (git-Bukkit-6917945 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT)). This bug does not affect Spigot 1.15.2 (git-Spigot-a99063f-be6aaf0 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)); and CraftBukkit 1.15.2 (git-Bukkit-be6aaf0 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)).



 Comments   
Comment by md_5 [ 24/Dec/20 ]

Duplicate, cannot be fixed by Spigot

Generated at Fri Mar 14 09:44:47 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.