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

Missing player interact event


    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    •  This server is running CraftBukkit version git-Spigot-8faa8b4-13ed05d (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
    • Yes

      When holding an interactable item (I tested with a trident), and then right-clicking an entity (eg. a Pig), plugins receive:

      • 2 events for interacting with the entity (main and off hand)
      • 1 event for interacting with the item (either RIGHT_CLICK_AIR, or RIGHT_CLICK_BLOCK, depending on whether a block is reachable for the interaction)

      However, when first right clicking an interactable block (eg. a chest) while holding the trident in hand, and then right-clicking an entity, plugins only receive the 2 entity interaction events. The PlayerInteractEvent for the item interaction is omitted.

      I assume the cause of this is that CraftBukkit caches the interaction result for the chest interaction inside PlayerInteractManager (fields 'firedInteract' and 'interactResult'). The cached result of that is then used during the later entity interaction (inside PlayerConnectionManager).

      The problem with that is that the chest interaction and the later entity interaction in this test scenario have nothing to do with each other (the entity interaction can happen quite some time later). If a plugin wants to prevent the item interaction when a player right-clicks an entity (my usecase), the plugin may miss some events depending on the player's previous actions and the state of that interaction result cache.


      Example plugin (simply logs interact events): https://pastebin.com/LYARYWDZ

            Unassigned Unassigned
            blablubbabc blablubbabc
            0 Vote for this issue
            2 Start watching this issue