-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add PlayerBrushBlockEvent #9774
Description
Is your feature request related to a problem?
As it currently exists, the BlockDropItemEvent is fired after the player has completed brushing a BrushableBlock. This event only controls the dropped items but occurs after the block has already changed from a 'suspicious ' to a normal block. A new event which controlled this change and controlled whether the BlockDropItemEvent would provide more customization to the brushing feature introduced in 1.20.
Describe the solution you'd like.
Introduce a new event - PlayerBrushBlockEvent.
This new event can extend the BlockEvent class and have a variable for the Player.
In the BrushableBlockEntity class, move the this.dropContent(player) and this.level.setBlock(this.worldPosition, block1defaultBlockState(), 3); into an if-statement to check if the brushable block event is cancelled.
See the attached picture for the possible solution. I attempted to contribute to Paper directly but got a little lost following the Contributing ReadMe documentation for Git and GitHub and gave up.

Describe alternatives you've considered.
As of right now, the only solution is to listen to the BlockItemDropEvent and check if the block was a suspicious type, using a BukkitRunnable set to a few ticks to "reset" the block if we want the mechanic to be cancelled. A new event to represent this situation is a more clean solution and provides more flexibility for developers.
Other
No response