14 Commits

Author SHA1 Message Date
Dylan K. Taylor
f24f2d9ca9
Hit block legacy metadata with the biggest nuke you've ever seen
This commit completely revamps the way that blocks are represented in memory at runtime.

Instead of being represented by legacy Mojang block IDs and metadata, which are dated, limited and unchangeable, we now use custom PM block IDs, which are generated from VanillaBlocks.
This means we have full control of how they are assigned, which opens the doors to finally addressing inconsistencies like glazed terracotta, stripped logs handling, etc.

To represent state, BlockDataReader and BlockDataWriter have been introduced, and are used by blocks with state information to pack said information into a binary form that can be stored on a chunk at runtime.
Conceptually it's pretty similar to legacy metadata, but the actual format shares no resemblance whatsoever to legacy metadata, and is fully controlled by PM.
This means that the 'state data' may change in serialization format at any time, so it should **NOT** be stored on disk or in a config.

In the future, this will be improved using more auto-generated code and attributes, instead of hand-baked decodeState() and encodeState(). For now, this opens the gateway to a significant expansion of features.
It's not ideal, but it's a big step forwards.
2022-06-24 23:19:37 +01:00
Dylan K. Taylor
1ff69136a3
Merge branch 'next-major' into modern-world-support 2022-06-07 20:01:40 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
d922f003f6
Fixed consistency check 2022-05-12 20:39:03 +01:00
Dylan K. Taylor
8b73549355
Use JSON_THROW_ON_ERROR for json_encode() and json_decode() 2021-12-08 19:14:07 +00:00
Dylan K. Taylor
e43bca95bf
Fixed build 2021-06-26 17:40:43 +01:00
Dylan K. Taylor
2a6009f8bf
Check consistency of block remaps 2021-06-21 20:45:30 +01:00
Dylan K. Taylor
61c59be299
Replace hardcoded block metadata shifts and masks with constants
we might want to make these bigger than 4 bits in the future.
2021-06-16 12:48:09 +01:00
Dylan K. Taylor
e8cb49f7ae
php-cs-fixer fixing php-cs-fixer's own mess 2021-05-05 11:25:11 +01:00
Dylan K. Taylor
ae75d73f48
Extract MainLoggerThread unit from MainLogger
MainLogger is no longer a Thread, as per the recent changes to pocketmine/log-pthreads.
2021-02-04 16:28:49 +00:00
Dylan K. Taylor
13d784cd0c Convert BlockFactory to singleton 2020-04-23 23:45:13 +01:00
Dylan K. Taylor
2ae09f635b Add more output to consistency check script
this helps catching state mapping bugs.
2019-03-09 17:19:17 +00:00
Dylan K. Taylor
d7e73705c2 consistency check regen script now emits which states were added/removed 2019-02-26 16:35:14 +00:00
Dylan K. Taylor
023fecabac Added an annoying consistency check for BlockFactory
This test is intended to enforce that the BlockFactory always has the same blocks in it from one commit to the next. Since there are a lot of changes going on right now around this, it's important that this is checked because bugs can go under the radar when large changes are happening.

The consistency check will need to be regenerated whenever a new block is registered, new states are found or when things are removed.
2019-02-24 13:56:55 +00:00