Implementing new blocks is a pain in the ass #6311
Labels
BC break
Breaks API compatibility
Category: API
Related to the plugin API
Category: Core
Related to internal functionality
Type: Enhancement
Contributes features or other improvements to PocketMine-MP
Description
The current design of the blocks system is currently disastrously complex and painful to maintain, and needs to be redesigned.
Many people have criticized the system (for the wrong reasons), but those people weren't entirely wrong. The current system is an awful mess, and it's not one of my finer works.
Justification
The current system is awful to work with.
It ended up this way because it was being designed all the way back in 2019, and took 3 years to come to fruition. I attempted to solve several other problems at the same time (such as the inability to provide dynamic APIs for stuff like glazed terracotta due to the 1:1 linking of block type <-> minecraft block id, the heavy dependence on minecraft internal meta). While this redesign was partially successful (e.g. runtime state data is now far easier to work with than in prior versions), it's undeniable that the current system is not nice for maintenance or extension.
For what it's worth, I knew that the system I started to build out in 2019 was going to be a hunk of shit, but I pushed through with it anyway once LB got behind me, because it needed to be done, and I knew I wouldn't be able to see how better to do it until making the first version.
What we gained from the new system:
Design constraints which turned out to be unnecessary:
What we lost:
instanceof
plus various block-specific APIs, e.g.getColor()
)Forward steps
The following is a non-exhaustive list of stuff that could be done to improve upon this mess:
Alternative methods
The text was updated successfully, but these errors were encountered: