From 71d602a4cf932d0587b1001ab06232022dc3e0a8 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 12 Dec 2014 15:51:31 +0100 Subject: [PATCH] Faster chunk setting on provider --- src/pocketmine/level/Level.php | 3 +-- src/pocketmine/level/format/mcregion/McRegion.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 3a12a7a4d..33734c7af 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1756,8 +1756,7 @@ public function generateChunkCallback($x, $z, FullChunk $chunk){ $oldChunk = $this->getChunk($x, $z, false); unset($this->chunkGenerationQueue[Level::chunkHash($x, $z)]); $this->setChunk($x, $z, $chunk); - $chunk = $this->getChunk($x, $z, false); - if($chunk !== null and (!($oldChunk !== null) or $oldChunk->isPopulated() === false) and $chunk->isPopulated()){ + if($chunk !== null and ($oldChunk === null or $oldChunk->isPopulated() === false) and $chunk->isPopulated()){ $this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($chunk)); } } diff --git a/src/pocketmine/level/format/mcregion/McRegion.php b/src/pocketmine/level/format/mcregion/McRegion.php index 91f4d3d1c..a70e200bf 100644 --- a/src/pocketmine/level/format/mcregion/McRegion.php +++ b/src/pocketmine/level/format/mcregion/McRegion.php @@ -251,11 +251,11 @@ public function setChunk($chunkX, $chunkZ, FullChunk $chunk){ $chunk->setZ($chunkZ); - if($this->getChunk($chunkX, $chunkZ, false) !== $chunk){ + if(isset($this->chunks[$index = Level::chunkHash($chunkX, $chunkZ)]) and $this->chunks[$index] !== $chunk){ $this->unloadChunk($chunkX, $chunkZ, false); } - $this->chunks[Level::chunkHash($chunkX, $chunkZ)] = $chunk; + $this->chunks[$index] = $chunk; } public static function createChunkSection($Y){