-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
-
git-Spigot-b5a13e6-1d74403 (MC: 1.16.2) (Implementing API version 1.16.2-R0.1-SNAPSHOT)
-
Yes
This bug was originally reported to paper, but also exist in the spigot upstream. See corresponding spigot version at the very bottom.
What behaviour is expected:
PlayerInteractEvent should be fired once for each hand.
What behaviour is observed:
PlayerInteractEvent is fired once for main hand and once for off hand if RIGHT_CLICK_AIR -> O.K
PlayerInteractEvent is fired once for main hand and once for off hand if RIGHT_CLICK_BLOCK and no item in hand -> OK
PlayerInteractEvent is fired twice for main hand and once for off hand if RIGHT_CLICK_BLOCK and item in hand -> As far as I know that is not an expected behavior.
Steps/models to reproduce:
Just run this code:
public class Tester extends JavaPlugin implements Listener { @Override public void onEnable() { super.onEnable(); getServer().getPluginManager().registerEvents(this, this); } @EventHandler public void test(PlayerInteractEvent e) { System.out.println("triggered " + e.getAction() + " hand " + e.getHand() + " item " + e.getMaterial() + " clicked " + e.getClickedBlock()); } }
Output with Spruce_Log in hand for example:
`[16:19:22 INFO]: triggered RIGHT_CLICK_BLOCK hand HAND item SPRUCE_LOG clicked CraftBlock{pos=BlockPosition {x=-1498, y=49, z=1},type=BEDROCK,data=Block{minecraft:bedrock},fluid=net.minecraft.server.v1_16_R2.FluidTypeEmpty@267bbe1a} [16:19:22 INFO]: triggered RIGHT_CLICK_BLOCK hand HAND item SPRUCE_LOG clicked CraftBlock{pos=BlockPosition{x=-1498, y=49, z=1} ,type=BEDROCK,data=Block{minecraft:bedrock},fluid=net.minecraft.server.v1_16_R2.FluidTypeEmpty@267bbe1a} [16:19:22 INFO]: triggered RIGHT_CLICK_BLOCK hand OFF_HAND item AIR clicked CraftBlock{pos=BlockPosition {x=-1498, y=49, z=1} ,type=BEDROCK,data=Block{minecraft:bedrock},fluid=net.minecraft.server.v1_16_R2.FluidTypeEmpty@267bbe1a} `
Plugin list:
Only the test plugin mentioned above
Paper version:
[16:20:35 INFO]: This server is running Paper version git-Paper-168 (MC: 1.16.2) (Implementing API version 1.16.2-R0.1-SNAPSHOT)
[16:20:35 INFO]: Checking version, please wait...
[16:20:35 INFO]: You are 14 version(s) behind
-> There are no code changes from 168 to latest which indicates introducing / resolving this bug.
Spigot version
Bug occurs on latest spigot: This server is running CraftBukkit version git-Spigot-b5a13e6-1d74403 (MC: 1.16.2) (Implementing API version 1.16.2-R0.1-SNAPSHOT)
Bug does not occur on: This server is running CraftBukkit version git-Spigot-379750e-43c7ff9 (MC: 1.16.2) (Implementing API version 1.16.2-R0.1-SNAPSHOT)
Bug maybe introduced here?: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/00bff02703914a4656c43afa5991db84626d0cb8#nms-patches/PlayerInteractManager.patch