Commit Graph

396 Commits

Author SHA1 Message Date
Dylan K. Taylor
83ddcce987 World: Considerably simplify ticked chunk selection
WARNING: This WILL have a performance impact on larger servers, but that's the price to pay for having crops actually grow.

The old overengineered method for doing this was causing glacially slow crop growth, vanilla parity issues and really just didn't make much sense. This method is probably incorrect too, but it will at least produce visible results.
2022-11-12 16:57:35 +00:00
Dylan K. Taylor
2d0602d19f World: fixed spawning in the void when the spawn terrain is higher than y=70 on default worlds
fixes #5390
2022-11-07 14:24:17 +00:00
Dylan K. Taylor
1a5cc8212c World: fixed spawning in the void when the spawn terrain is higher than y=70 on default worlds
fixes #5390
2022-11-07 14:23:29 +00:00
Dylan K. Taylor
01bad344a0 Merge branch 'next-minor' into next-major 2022-11-04 20:47:26 +00:00
Dylan K. Taylor
2fdc46c165 PHPStan 1.9 features 2022-11-04 20:23:34 +00:00
Dylan K. Taylor
9f6c6b2b71 Merge branch 'next-minor' into next-major 2022-10-16 16:58:50 +01:00
Dylan K. Taylor
2a910c1cc2 World: more minor documentation improvements 2022-10-16 16:50:42 +01:00
Dylan K. Taylor
cd04a3db2e World: ensure that addParticle/addSound don't send stuff to players who are not in range, even when an array of targets is given
closes #5347
2022-10-16 16:45:52 +01:00
Dylan K. Taylor
572def9245 World: Improve quality of type information 2022-10-16 16:21:59 +01:00
Dylan K. Taylor
b39eaaf91f Merge branch 'next-minor' into next-major 2022-09-21 15:07:11 +01:00
Dylan K. Taylor
f80ffd8de0 Merge branch 'next-minor' into next-major 2022-09-15 13:59:21 +01:00
Eren A. Akyol
82ba7903c8 Fixed wrong key being used for entity type ID in save data (#5288)
closes #5260
2022-09-15 13:40:48 +01:00
Dylan K. Taylor
ca4b8a5827 World: remove local static recursion guard variable, closes #3125 2022-09-02 19:24:09 +01:00
Dylan K. Taylor
eccfb3bbe2 World: fix borked check 2022-07-19 17:59:53 +01:00
Dylan K. Taylor
87b840ff97 Added a hack to allow tiles to trigger client-side render updates on blocks without actually changing the block
Bedrock block entity updates don't directly trigger block rendering
updates. This is a problem when the block entity data affects the
block's appearance directly (e.g. cauldron water colour, flower pot
contents), because it means changing them won't directly result in a
client-side render update.

This hack allows tiles to spoof block updates without actually changing
the server-side block, keeping the internals and API clean of random
shitbox workarounds.

fixes #5174
fixes #4944
2022-07-19 17:47:46 +01:00
Dylan K. Taylor
4f2f9b4352 Block::readStateFromWorld() now returns the block object that should be used for the target position
this enables changing the block type completely if the situation calls for it.
2022-07-16 20:04:08 +01:00
Dylan K. Taylor
d0ff6d2e36 Enable various types of interaction to return items to the player, without needing to have a bunch of boilerplate creative mode and held item checks
it became glaringly obvious that this was needed because of #4827 and #4868.

this is further needed with the addition of cauldrons.
2022-07-16 19:50:33 +01:00
Dylan K. Taylor
0a23e91329 Rename BlockFactory::fromFullBlock() -> BlockFactory::fromStateId() 2022-07-05 13:46:19 +01:00
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
aa9f8781ff Merge branch 'next-minor' into next-major 2022-06-07 19:56:26 +01:00
Dylan K. Taylor
d2613039ed Replace BlockLegacyIds usages with BlockTypeIds where possible 2022-06-05 21:17:10 +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
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
68491be847 Merge branch 'next-major' into modern-world-support 2022-05-20 11:21:35 +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
b88a47929f Modernize property declarations in src/world/* 2022-04-28 15:06:17 +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
Dylan K. Taylor
eafbc3a468 Expand height range to include -64 to 320 2022-04-15 19:10:24 +01:00
Dylan K. Taylor
a7bdef69e2 Merge remote-tracking branch 'origin/stable' into next-minor 2022-01-27 00:40:34 +00:00
Dylan K. Taylor
6cbc14f2b2 World: fixed block update bug introduced by 3faeb5a556 2022-01-25 21:53:15 +00:00
Dylan K. Taylor
32b07e0940 World: avoid repeated getInstance() calls in hot paths 2022-01-24 21:08:12 +00:00
Dylan K. Taylor
aae5962f6a Replace disallowed operators in src/world/ 2022-01-20 19:05:23 +00:00
Dylan K. Taylor
86bcc49972 Merge branch 'stable' into next-minor 2022-01-20 16:30:49 +00:00
Dylan K. Taylor
061d851fbd World: do not update entities which have been flagged for despawn
fixes #4718
2022-01-20 16:27:21 +00:00
Dylan K. Taylor
a0bb7059c1 Merge remote-tracking branch 'origin/stable' into next-minor 2022-01-19 19:48:51 +00:00
Dylan K. Taylor
858024afb7 Remove useless docs noticed by php-cs-fixer 3.5 2022-01-18 00:24:12 +00:00
Dylan K. Taylor
51f2a78dcf World: break random tick blocks initializing out of constructor
and fix a variable clobber by foreach as a side effect
2022-01-07 21:36:49 +00:00
Dylan K. Taylor
3faeb5a556 disable-block-ticking directive now supports names a la /give 2022-01-07 21:06:06 +00:00
Dylan K. Taylor
fb29653ed7 Merge remote-tracking branch 'origin/stable' into next-minor 2022-01-06 22:43:57 +00:00