mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Level: fix chunk locks not getting released on generation errors
This commit is contained in:
@ -2296,28 +2296,33 @@ class Level implements ChunkManager, Metadatable{
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function generateChunkCallback(int $x, int $z, Chunk $chunk){
|
||||
public function generateChunkCallback(int $x, int $z, ?Chunk $chunk){
|
||||
Timings::$generationCallbackTimer->startTiming();
|
||||
if(isset($this->chunkPopulationQueue[$index = Level::chunkHash($x, $z)])){
|
||||
$oldChunk = $this->getChunk($x, $z, false);
|
||||
for($xx = -1; $xx <= 1; ++$xx){
|
||||
for($zz = -1; $zz <= 1; ++$zz){
|
||||
unset($this->chunkPopulationLock[Level::chunkHash($x + $xx, $z + $zz)]);
|
||||
}
|
||||
}
|
||||
unset($this->chunkPopulationQueue[$index]);
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
if(($oldChunk === null or !$oldChunk->isPopulated()) and $chunk->isPopulated()){
|
||||
$this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($this, $chunk));
|
||||
|
||||
foreach($this->getChunkLoaders($x, $z) as $loader){
|
||||
$loader->onChunkPopulated($chunk);
|
||||
if($chunk !== null){
|
||||
$oldChunk = $this->getChunk($x, $z, false);
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
if(($oldChunk === null or !$oldChunk->isPopulated()) and $chunk->isPopulated()){
|
||||
$this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($this, $chunk));
|
||||
|
||||
foreach($this->getChunkLoaders($x, $z) as $loader){
|
||||
$loader->onChunkPopulated($chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif(isset($this->chunkPopulationLock[$index])){
|
||||
unset($this->chunkPopulationLock[$index]);
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
}else{
|
||||
if($chunk !== null){
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
}
|
||||
}elseif($chunk !== null){
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
}
|
||||
Timings::$generationCallbackTimer->stopTiming();
|
||||
|
Reference in New Issue
Block a user