Skip to content

Always ensure player spawn chunk is generated #6657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dktapps opened this issue Mar 22, 2025 · 0 comments
Open

Always ensure player spawn chunk is generated #6657

dktapps opened this issue Mar 22, 2025 · 0 comments

Comments

@dktapps
Copy link
Member

dktapps commented Mar 22, 2025

Problem description

Currently we only require the player's spawn chunk to be generated if they're a new player trying to find a safe spawn.

We do not do this for general player joins since we don't need a safe spawn for those cases; however, we do currently sync-load the chunk here for reasons I'm not completely clear on:

$xSpawnChunk = $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE;
$zSpawnChunk = $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE;
$world->registerChunkLoader($this->chunkLoader, $xSpawnChunk, $zSpawnChunk, true);
$world->registerChunkListener($this, $xSpawnChunk, $zSpawnChunk);
$this->usedChunks[World::chunkHash($xSpawnChunk, $zSpawnChunk)] = UsedChunkStatus::NEEDED;

I believe this was needed in years past because the chunk needed to exist in order to add the player to it. However, this is no longer the case. In particular the chunk may not exist if the terrain isn't generated, but this currently seems to be fine.
(It's probably also needed to avoid redundant chunk reloading, since the spawn chunk would be unloaded after promise fulfillment if this wasn't present.)

This is problematic for a few reasons:

Proposed solution

  • Register as a chunk loader after calling the parent constructor, so that data loading throwing exceptions doesn't leave dead chunk loaders stuck on the World
  • Consider using orderChunkPopulation() async mechanism for existing players to guarantee that the spawn terrain will be loaded & generated. However I'm not clear if this is actually even necessary anyway.

Alternative solutions or workarounds

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant