[SPIGOT-8002] PlayerInteractEntityEvent fires twice in spectator mode for right click actions. Created: 31/Jan/25  Updated: 03/Feb/25  Resolved: 02/Feb/25

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

Type: Bug Priority: Minor
Reporter: Chris Assignee: Unassigned
Resolution: Invalid Votes: 0
Labels: bug, entity, event, spigot

Version: CraftBukkit version 4430-Spigot-d421948-d20d4c1 (MC: 1.21.4) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

When a player right clicks ONCE in spectator mode, PlayerInteractEntityEvent fires twice.
 
For example,
 
@EventHandler
public void onEntityRightClick(PlayerInteractEntityEvent event) {
if (event.getRightClicked() instanceof Cat cat)

{ event.getPlayer().sendMessage("Click!"); }

}

returns in the chat in game
Click!
Click!

when a cat is right clicked ONCE when the player is in spectator mode.

This does not occur for other gamemodes, whereas it fires properly (i.e. one "Click!").



 Comments   
Comment by Chris [ 03/Feb/25 ]

event.getHand() resolved the issue, thank you

Comment by md_5 [ 02/Feb/25 ]

Check event.getHand(), they are different

Generated at Thu Apr 03 16:58:00 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.