A way to handle fertilizers correctly
Problem description
Currently, if a block needs to perform an action depending on whether it was clicked by a fertilizer (or not), we have to use instanceof. In most cases, this seems fine, but when it's repeated many times, I wonder if there might be a cleaner solution.
In addition, as described in #6102, plugins actually do not have much control over the action performed by the fertilizer:
- the block spawn table: ability to add/remove/modify the percentage of blocks?
- cancel fertilization without having to cancel the entire block interaction
- precisely manage the growth of the block in question.
Proposed solution
- A BlockFertilizeEvent. Give some control but add code shit in all growing blocks and don't give much control on the spawn table : need to recalculate alls blocks if you want just a different percentage.
- The first solution combined with a seperate dedicated spawn table utility
- Maybe more ? Idk
Alternative solutions or workarounds
- Cancelling block interaction -> preventing other logics to be processed
- Cancelling block placing ? Looks difficult to detect
- Overriding the block in question -> whereas some blocks already delegate to utilities (like Grass)
I'm thinking an event that gives a list of blocks to be changed (or a BlockTransaction) would be a good enough start. I haven't given much thought to probabilities, but I think the biggest issue for plugins is just not being able to cancel the generation of randomly positioned blocks.
Cancelling the generation is the biggest but other issue is still important like adding / removing blocks (BlockTransaction could be a good start yes). Moving closer to something like probability tables in Java and chests could be a good way to adapt the systems. We'll see. Other solutions may exist.
That seems like overkill to me. I don't know how that would even be implemented.