WorldProvider: allow loadChunk() to return additional information about the loaded chunk data

this will be needed for dealing with #5733. I don't plan to fix that before 5.0, but we need to make the appropriate BC breaks now, before release.
This commit is contained in:
Dylan K. Taylor
2023-05-29 17:03:39 +01:00
parent f5a1a0c9cb
commit c10be0f346
8 changed files with 91 additions and 30 deletions

View File

@ -2702,25 +2702,25 @@ class World implements ChunkManager{
$this->timings->syncChunkLoadData->startTiming();
$chunk = null;
$loadedChunkData = null;
try{
$chunk = $this->provider->loadChunk($x, $z);
$loadedChunkData = $this->provider->loadChunk($x, $z);
}catch(CorruptedChunkException $e){
$this->logger->critical("Failed to load chunk x=$x z=$z: " . $e->getMessage());
}
$this->timings->syncChunkLoadData->stopTiming();
if($chunk === null){
if($loadedChunkData === null){
$this->timings->syncChunkLoad->stopTiming();
return null;
}
$this->chunks[$chunkHash] = $chunk->getChunk();
$this->chunks[$chunkHash] = $loadedChunkData->getData()->getChunk();
unset($this->blockCache[$chunkHash]);
$this->initChunk($x, $z, $chunk);
$this->initChunk($x, $z, $loadedChunkData->getData());
(new ChunkLoadEvent($this, $x, $z, $this->chunks[$chunkHash], false))->call();