-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
PlayerInteractEvent: added APIs to independently control reaction of item and block #4683
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
Conversation
…item and block this allows, for example, banning the usage of spawn eggs, without preventing opening of doors, without the need for item ID whitelists. It also allows customizing the behaviour of item and block interactions when sneaking - it's now possible to force spawn eggs to work when sneaking, or force containers to open. Finally, this also allows preventing any interaction at all without preventing block placement (by setting both to false). Since cancelling the event will typically prevent placement too (which might not be desired). The naming of the functions is up for discussion, but the feature itself is stolen from Spigot and is much needed.
|
This causes some buggy behaviour when using |
|
Would it help if I also test with this so the PR can get merged, or are you currently busy with the work on |
|
I like the idea, I'd dig it up from the depths, soon |
|
I think the main issue with this is that I think fixing this will probably require BC breaks, unless deprecated wrappers are used. |
|
Turns out we can just always sync blocks during a block interaction. Since the client doesn't tell us what it expects, this is probably the best course of action anyway. Might even fix some issues in other areas. |
this ensures that the blocks stay in sync, regardless of whether plugins altered the outcome.
Introduction
this allows, for example, banning the usage of spawn eggs, without preventing opening of doors, without the need for item ID whitelists.
It also allows customizing the behaviour of item and block interactions when sneaking - it's now possible to force spawn eggs to work when sneaking, or force containers to open.
Finally, this also allows preventing any interaction at all without preventing block placement (by setting both to false). Since cancelling the event will typically prevent placement too (which might not be desired).
The naming of the functions is up for discussion, but the feature itself is stolen from Spigot and is much needed.
Relevant issues
Changes
API changes
PlayerInteractEvent->useBlock()- returns whether the clicked block'sonInteract()will be calledPlayerInteractEvent->useItem()- returns whether the held item'sonInteractBlock()will be calledPlayerInteractEvent->setUseBlock()PlayerInteractEvent->setUseItem()Note that setting these both to false does NOT cancel the event; rather, it makes the action behave as if the player was sneaking.
Behavioural changes
Backwards compatibility
Backwards compatible, but could cause unexpected results for plugins not aware of these features - e.g. a plugin may assume that chests are never opened if the player was sneaking, which this change would violate.
Tests
This has not yet been tested.