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

PlayerInteractEvent is never fired with Action.RIGHT_CLICK_AIR #595

Closed
kaenganxt opened this issue Dec 8, 2017 · 2 comments
Closed

PlayerInteractEvent is never fired with Action.RIGHT_CLICK_AIR #595

kaenganxt opened this issue Dec 8, 2017 · 2 comments

Comments

@kaenganxt
Copy link
Member

@kaenganxt kaenganxt commented Dec 8, 2017

I tested some plugins with glowstone and realized that the PlayerInteractEvent is never fired with Action.RIGHT_CLICK_AIR.

The only place in the code where RIGHT_CLICK_AIR is used, is when the right clicked blocked does not exist, and even then the event is not fired most of the time because of the return.
There are two more problems here:

  1. The clicked.getLocation() in line 118 might cause a null pointer because it is inside the clicked == null block
  2. When placing a block against a non-existent block, the client places the new block successfully, but Glowstone only reverts the clicked block (line 118 again) and not the newly placed block.

I'm not completely sure where a RIGHT_CLICK_AIR should be fired, there are two cases I would consider:

  1. Here's some code in a comment, which would fire a right click when the direction is -1, but I can't find documentation about this case on wiki.vg.
  2. The UseItem packet, because currently there's no event fired.
@kaenganxt kaenganxt changed the title InventoryClickEvent is never fired with Action.RIGHT_CLICK_AIR PlayerInteractEvent is never fired with Action.RIGHT_CLICK_AIR Dec 8, 2017
aramperes added a commit that referenced this issue Dec 17, 2017
* Removed impossible null check
* Revert newly placed block on client-side when perception is incorrect
* Call and handle right-click-air interact event in UseItemHandler
@aramperes
Copy link
Member

@aramperes aramperes commented Dec 17, 2017

I fixed some of these issues in 9254c74

  • The null check was impossible, because getBlockAt never returns null
  • Added newly placed block reversion
  • Added the right-click-air event in UseItem.

Please check with your use-cases if this solves your issues. I'm not sure about the -1 direction in the block placement packet either.

@kaenganxt
Copy link
Member Author

@kaenganxt kaenganxt commented Dec 23, 2017

RIGHT_CLICK_AIR now works as expected. I'm going to open a PR later to fix some other issues with the player interact event I found.

@kaenganxt kaenganxt closed this Dec 23, 2017
@ghost ghost removed the Status: review label Dec 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants