Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InteractEvent is fired for main and offhand, when right-clicking on block with main hand #969

Closed
ghost opened this issue Jan 11, 2018 · 6 comments

Comments

@ghost
Copy link

ghost commented Jan 11, 2018

Incompatibility (Bug)

I tried the PlayerInteractEvent and noticed a wiered issue:
When the ground is clicked with the main hand, the event is fired twice.

  • One time for the main hand (that's ok)
  • One time for the off hand (bug)

Here are my testresults:

https://imgur.com/qPh5J49
I split up the different actions with the yellow line.

As you can see some events are fired not correctly (marked red)

Steps to reproduce:

This is my Code: https://pastebin.com/D6AHsqcK
Just reproduce the issue by testing different actions (see the image)

Paper build number:

git-Paper-1298 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT)

@electronicboy
Copy link
Member

Not a bug, this is sadly intentional (and is the behavior of CraftBukkit). It's up to plugin authors to filter the events properly, e.g. check if the action is a right click and only fire if the hand is the correct hand.

@ghost
Copy link
Author

ghost commented Jan 11, 2018

But why is the event fired for the offhand, when i right click on a block with the main hand

@electronicboy
Copy link
Member

Because that is shamefully what vanilla does to process such interactions, there is no way we can modify this behavior without breaking plugins that are expecting this to happen.

@ghost
Copy link
Author

ghost commented Jan 11, 2018

then...
how do you suggest me to fix this?
I mean: how do i clearly split the off hand from the main hand

@electronicboy
Copy link
Member

The event has a method to get the Action and the hand associated with the event, it will fire with OFF_HAND and another time with HAND, you just need to basically ignore if they right click air and their main hand fires with the event or something similar to that

@ghost
Copy link
Author

ghost commented Jan 11, 2018

now i disabled the OFF_HAND events with a early-out pattern

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

No branches or pull requests

1 participant