PocketMine-MP
PocketMine-MP copied to clipboard
BlockFormEvent: Add possibility the get the causing block for the event
Description
Unlike for example the BlockBurnEvent
or the BlockSpreadEvent
, the BlockFormEvent
currently only contains the information about the block which will be changed and its new state.
This issue proposes that the BlockFormEvent
gets a causingBlock
property and a matching getCausingBlock()
getter.
(Even the method liquidCollide()
requires the causing block as a parameter, which is not even used, neither in the method in the Liquid
class nor in any subclass.)
Justification
This proposal is most likely useless for most people, especially since the BlockFormEvent
is not an event which might be commonly used in plugins.
But when working on a kind of land protection plugin, I ran into a problem where liquids outside of a certain area were able to interact with liquids in that area, which is not desired.
Alternative methods
To get the causing block, you could check the block above and all horizontal blocks of the given block and check if those blocks are liquids. But this would also require checking the type of liquid of each block, since e.g. if your block is lava, you need to search for a water block, etc.
So, it would be possible, but with a lot more code than with a getCausingBlock()
method.
For posterity, I'm quite sure my intent was to implement this when I added that parameter to liquidCollide()
, but I evidently never got around to it.
Can be closed since #5226 was merged