World: Specialize generateChunkCallback() for PopulationTask

this allows us to also set the adjacent chunks before calling ChunkPopulateEvent, to give a more accurate picture of what changed.
This commit is contained in:
Dylan K. Taylor
2021-10-26 15:28:00 +01:00
parent b9d9b69bbe
commit 8f88393184
2 changed files with 14 additions and 15 deletions

View File

@ -153,6 +153,7 @@ class PopulationTask extends AsyncTask{
FastChunkSerializer::deserializeTerrain($this->chunk) :
throw new AssumptionFailedError("Center chunk should never be null");
$adjacentChunks = [];
for($i = 0; $i < 9; ++$i){
if($i === 4){
continue;
@ -162,12 +163,11 @@ class PopulationTask extends AsyncTask{
$xx = -1 + $i % 3;
$zz = -1 + intdiv($i, 3);
$c = FastChunkSerializer::deserializeTerrain($c);
$world->generateChunkCallback($this->chunkX + $xx, $this->chunkZ + $zz, $c);
$adjacentChunks[World::chunkHash($this->chunkX + $xx, $this->chunkZ + $zz)] = FastChunkSerializer::deserializeTerrain($c);
}
}
$world->generateChunkCallback($this->chunkX, $this->chunkZ, $chunk);
$world->generateChunkCallback($this->chunkX, $this->chunkZ, $chunk, $adjacentChunks);
}
}
}