add PlayerBrushBlockEvent
This is a small pull request adding an event that gets called whenever a player brushes a block. Closes #9774
Welcome to paper :wave: thank you for your first PR!
I am a tad unsure if your current implementation does actually fix the related issue. Right now, this mostly looks like an event that is pretty much just a duplicate of the PlayerInteractEvent.
If I interpret the issue correctly, the event should be called when the player is basically done brushing the block instead of the start of the brushing process.
Welcome to paper 👋 thank you for your first PR!
Thanks, but this isn't my first PR, have some old ones I have to clean up some day
If I interpret the issue correctly, the event should be called when the player is basically done brushing the block instead of the start of the brushing process.
Yeah, my bad, sorry, the event will no longer be cancel-able though, however, then, I can expose the dropped itemstack
Ah sorry, just saw "first time contributor" :sweat: I mean, plugins can infer a not cancelled "PlayerBrushBlockEvent" that is called exactly how the issue describes it (cancellable, does not expose item drops) and the following BlockDropItem event stuff.
As a follow up, warrior suggested internally that maybe an event called each time the block is "partially" brushed in the BrushItem useOnTick method would be useful.
Would work both as a "player starts brushing" and a progress event to do stuff with.
As a follow up, warrior suggested internally that maybe an event called each time the block is "partially" brushed in the BrushItem useOnTick method would be useful.
What would be the use of that? The server cannot stop the client from showing the animation to my knowledge
I'm sorry for this force push mess, had quite some trouble reverting my changes to the decompile-fixes patch... I'll squash the PR a final time soon
No worries, we squash on merge xD Go wild with the commits. I mean, I guess the "per brush tick" event is not really needed if brush would properly call events when it converts the block types to the "more brushed" state
I do not think this event is needed at all. You can accomplish the same things by listening to the BlockDropItemEvent which, contrary to the linked issue, is fired before the block is changed allowing you to change the dropped items.
You can then just add a call to the EntityChangeBlockEvent before the blockstate is changed when the brushing is completed which you can cancel to prevent the brushable block from changing.
In my opinion, having control over this in a singular event is better than having to listen to these two, as then, finding out if they were triggered due to that same block, same player, same time would be slightly harder. Also, couldn't a lot of events just be done plugin side using the PlayerInteractionEvent?
Anyways, feel free to close this PR as "won't add" if you disagree with me :)