Commit Graph

951 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
5ed75731f2 First (untested) look at hooking all the itemstack serializer/deserializer stuff together
this should address #5063 and related issues, if it works correctly.
2022-06-23 19:02:16 +01:00
Dylan K. Taylor
1533fcf8f6 Separate block legacy data upgrading from block deserialization
this commit provides a central place where all block data can go to be upgraded to the latest version (currently 1.19), irrespective of how old it is.

Previously I had issues during debugging, because it wasn't possible to just upgrade a block without deserializing it into a Block object, which isn't currently supported for many blocks.
This commit solves that problem by separating the upgrading from the deserialization.
2022-06-23 16:45:02 +01:00
Dylan K. Taylor
4aa1a3da8b Moving more stuff around 2022-06-08 15:57:02 +01:00
Dylan K. Taylor
680615eed8 Namespace rename 2022-06-08 15:54:45 +01:00
Dylan K. Taylor
e956cfed1c Branch-specific 1.19.0 stuff 2022-06-07 20:14:00 +01:00
Dylan K. Taylor
cf7d42b3ea Fix CS according to new rules 2022-06-07 20:02:24 +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
aa9f8781ff Merge branch 'next-minor' into next-major 2022-06-07 19:56:26 +01:00
Dylan K. Taylor
f08f82edfd Merge branch 'next-major' into modern-world-support 2022-06-06 17:33:19 +01:00
Dylan K. Taylor
b57f0a2b7e Fixed uninitialized typed properties 2022-06-06 17:23:43 +01:00
Dylan K. Taylor
5c85aa6e58 Eliminate remaining usages of legacy block ID+meta on disk
flower pots loaded from vanilla worlds should now correctly display the plant inside
2022-06-05 21:49:51 +01:00
Dylan K. Taylor
d2613039ed Replace BlockLegacyIds usages with BlockTypeIds where possible 2022-06-05 21:17:10 +01:00
Dylan K. Taylor
5a43db1c6d LevelDB: remove stale TODO comment
this has been addressed by folding to state 0 in the legacy blockstate mapper.
2022-06-04 18:47:29 +01:00
Dylan K. Taylor
dab7686656 Merge branch 'next-major' into modern-world-support 2022-06-04 18:43:11 +01:00
Dylan K. Taylor
083a35f970 Modernize property type declarations 2022-06-04 18:16:32 +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
01af70f671 Merge branch 'next-major' into modern-world-support 2022-06-02 20:24:25 +01:00
Dylan K. Taylor
23695fb900 RegionLoader: remove dead static property
[bc break]
2022-06-02 16:55:22 +01:00
Dylan K. Taylor
2bb99fa677 Modernize Position and Location
[bc break]
2022-06-01 21:21:31 +01:00
Dylan K. Taylor
6ee551c5e1 Remove premature optimisation from World::getCollidingEntities()
this is already covered in more fine-grained detail by canCollideWith().

[bc break]
2022-06-01 21:00:54 +01:00
Dylan K. Taylor
03c505aaa7 Merge branch 'next-major' into modern-world-support 2022-05-22 16:21:48 +01:00
Dylan K. Taylor
179cac45f5 Merge branch 'stable' into next-minor 2022-05-22 16:21:05 +01:00
Dylan K. Taylor
7eaf1246a0 Explosion: cap yield at 100%
this could overflow if the explosion size is less than 1.
While this currently doesn't have any negative effects, if we decided to support >100% yield, this would cause some issues.
2022-05-21 22:43:26 +01:00
Dylan K. Taylor
645c44ae9c Explosion: remove unused variables 2022-05-21 22:41:28 +01:00
Dylan K. Taylor
33e6b63fe5 Explosion: remove unused local variable in explodeB() 2022-05-21 17:39:11 +01:00
Dylan K. Taylor
01b0742bd4 LightUpdate: account for virtual nodes in prepareNodes()
fixes #3959
2022-05-21 17:07:49 +01:00
Dylan K. Taylor
68491be847 Merge branch 'next-major' into modern-world-support 2022-05-20 11:21:35 +01:00
Dylan K. Taylor
df3a69dcb7 Modernize private property declarations in Threaded classes
I previously avoided this due to being unsure of the effects; however, it's clear that we already use typed properties on Threaded things in other places anyway, and the only known issues are with uninit properties, and arrays.
2022-05-17 22:42:18 +01:00
Dylan K. Taylor
d4b7f66e15 Promote some constructors 2022-05-17 22:34:58 +01:00
Dylan K. Taylor
8b1bd5b7ff World: do not hardcode length of day in computeSunAnglePercentage() 2022-05-16 18:17:32 +01:00
Dylan K. Taylor
60d3bddfbc Merge branch 'next-major' into modern-world-support 2022-05-11 13:14:42 +01:00
Dylan K. Taylor
9ff1bf6deb Merge remote-tracking branch 'origin/stable' into next-minor 2022-05-11 13:12:45 +01:00
Dylan K. Taylor
593a4b65ea World: fixed crash when using unloadChunk() during ChunkPopulateEvent, ChunkLoadEvent or when using ChunkListeners
I sure hope there isn't any other cases where this edge case can appear ...

closes #5022
2022-05-10 13:09:26 +01:00
Dylan K. Taylor
0326c4964b Merge branch 'next-major' into modern-world-support 2022-04-28 21:06:44 +01:00
Dylan K. Taylor
937bb4c6ce Merge branch 'stable' into next-minor 2022-04-28 21:00:23 +01:00
Dylan K. Taylor
cf15a0913d World: fixed a corner case assertion failure in generation system
This required the following:
- A generation task (taskA) to already be running for any chunk (chunkA)
- A chunk (chunkB) is requested for generation, and the task (taskB) to do the generation
  is commenced immediately
- chunkB generation promise is aborted (e.g. due to chunk unload) and
  taskB is orphaned
- chunkB is subsequently re-requested, but ends up in the generation
  queue because taskB is still running
- taskA completes and drains the generation queue
- chunkB attempts to be populated a second time, but taskB has not yet
  been collected, resulting in an assertion failure.

This bug has been appearing intermittently ever since PM 4.0 release.
For most users there is no obvious effect since production servers don't
have assertions enabled; however, it's unclear what kind of weird side
effects this bug may have had.
2022-04-28 20:23:23 +01:00
Dylan K. Taylor
3752225ed5 World: fix CS 2022-04-28 16:00:34 +01:00
Dylan K. Taylor
5cf572892f WorldManager: fixed missing initializer for $defaultWorld 2022-04-28 15:38:20 +01:00
Dylan K. Taylor
b88a47929f Modernize property declarations in src/world/* 2022-04-28 15:06:17 +01:00
Dylan K. Taylor
159392e738 wtf is this shitbox code 2022-04-28 14:57:57 +01:00
Dylan K. Taylor
2f03af51dd Modernize property declarations in src/world/sound 2022-04-28 14:57:01 +01:00
Dylan K. Taylor
cb76c149e1 Modernize property declarations in src/world/particle 2022-04-28 14:55:53 +01:00
Dylan K. Taylor
ed2a239334 Modernize property declarations in src/world/generator 2022-04-28 13:16:21 +01:00
Dylan K. Taylor
de12b701ac Modernize type declarations in src/world/format 2022-04-28 13:07:58 +01:00
Dylan K. Taylor
43e61336cf Support 1.18.30 worlds 2022-04-20 14:58:32 +01:00
Dylan K. Taylor
e383f6d8f8 Merge branch 'next-major' into modern-world-support 2022-04-20 14:29:22 +01:00
Dylan K. Taylor
6dbfdd970f Merge branch 'stable' into next-minor 2022-04-20 14:23:51 +01:00
Dylan K. Taylor
c085bf0db4 Changes for 1.18.30 2022-04-20 13:59:50 +01:00
Dylan K. Taylor
42474c14aa World: reduce blockhash padding for Y axis to accommodate new height range 2022-04-15 19:47:25 +01:00