pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.28k stars 1.56k forks source link

Implementing new blocks is a pain in the ass #6311

Open dktapps opened 7 months ago

dktapps commented 7 months ago

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:

Forward steps

The following is a non-exhaustive list of stuff that could be done to improve upon this mess:

Alternative methods

Bqleine commented 7 months ago

After programming the Structure Void and Structure block as an inexperienced contributor, I agree with what you said but I'd like to add that going forwards, making a documentation file on how to add a block would be much friendlier towards contributors and make it easier to understand.