Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6291

Ghost item in inventory after cancelling an item swap in inventory

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • None
    • 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)

    • This server is running CraftBukkit version git-Spigot-628435a-6917945 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT)
    • Yes

      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)).

            Unassigned Unassigned
            stefvanschie Stef van Schie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: