Skip to content

fix: PlayerItemUseEvent firing twice on right-click - #32

Merged
xRookieFight merged 3 commits into
altayofficial:masterfrom
bobyD3V:fix-double-item-use-event
Aug 13, 2026
Merged

fix: PlayerItemUseEvent firing twice on right-click#32
xRookieFight merged 3 commits into
altayofficial:masterfrom
bobyD3V:fix-double-item-use-event

Conversation

@bobyD3V

@bobyD3V bobyD3V commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #28

Changes

Found the bug - handleRightClickItemUse() gets called twice for one
right-click. This happens because START_USING_ITEM flag triggers it once,
and then itemInteractionData (ACTION_CLICK_AIR) triggers it again, both
from the same PlayerAuthInputPacket. Added a check so it only fires once
now.

Tests

Tested with a test plugin that spawns something on PlayerItemUseEvent.
Before the fix it spawned twice per click, now it only spawns once.

@xRookieFight

Copy link
Copy Markdown
Contributor

I couldn't reproduce the bug before, can you send some footage for it?

@bobyD3V

bobyD3V commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Here video showing what happening. Made a quick test plugin that
logs PlayerItemUseEvent with a timestamp. One right-click, two events,
~39ms apart - way too fast to be an actual second click:

[REPRO] PlayerItemUseEvent fired at 1,786,615,214.972
[REPRO] PlayerItemUseEvent fired at 1,786,615,215.011

[video attached]

Screenrecorder-2026-08-13-15-30-12-121.mp4
Screenshot_2026-08-13-15-30-26-867_com mojang minecraftpe

@xRookieFight

Copy link
Copy Markdown
Contributor

I assume it's only happening on fishing rod, right? It's not reproducable on other items.

@bobyD3V

bobyD3V commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

I try more with some items like

  • Fishing rod: happens X (double fires)
  • Bow: happens X (double fires)
  • Food, potion, sword, stick: doesn't happen (fires once, normal)

So it looks like it's specific to items that have a "charge up" / hold-to-use
action (fishing rod, bow) rather than instant-use items like food or potions.

@xRookieFight

Copy link
Copy Markdown
Contributor

Hmm, okay. I'll review the code. I assume this is new on 1.26.40 so it also may be a protocol issue too

@xRookieFight xRookieFight changed the title Fix PlayerItemUseEvent firing twice on right-click fix: PlayerItemUseEvent firing twice on right-click Aug 13, 2026
@xRookieFight
xRookieFight merged commit eefe929 into altayofficial:master Aug 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PlayerItemUseEvent is call two times

2 participants