Skip to content

A way to handle fertilizers correctly #6887

@ShockedPlot7560

Description

@ShockedPlot7560

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

  1. 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.
  2. The first solution combined with a seperate dedicated spawn table utility
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Category: APIRelated to the plugin APIType: EnhancementContributes features or other improvements to PocketMine-MP

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions