From 722da5e88d626321efffc0d96926a285f700d7fe Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 14 Jun 2019 18:00:37 +0100 Subject: [PATCH] Simplify hasChanged handling for chunk init we always want chunks to be saved if they have tiles or entities --- src/pocketmine/world/format/Chunk.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pocketmine/world/format/Chunk.php b/src/pocketmine/world/format/Chunk.php index 3adc91b74..5f78233d1 100644 --- a/src/pocketmine/world/format/Chunk.php +++ b/src/pocketmine/world/format/Chunk.php @@ -579,8 +579,8 @@ class Chunk{ */ public function initChunk(World $world) : void{ if(!$this->isInit){ - $changed = false; if($this->NBTentities !== null){ + $this->hasChanged = true; $world->timings->syncChunkLoadEntitiesTimer->startTiming(); foreach($this->NBTentities as $nbt){ if($nbt instanceof CompoundTag){ @@ -588,12 +588,10 @@ class Chunk{ $entity = EntityFactory::createFromData($world, $nbt); if(!($entity instanceof Entity)){ $world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown entity type " . $nbt->getString("id", $nbt->getString("identifier", "", true), true)); - $changed = true; continue; } }catch(\Exception $t){ //TODO: this shouldn't be here $world->getLogger()->logException($t); - $changed = true; continue; } } @@ -603,6 +601,7 @@ class Chunk{ $world->timings->syncChunkLoadEntitiesTimer->stopTiming(); } if($this->NBTtiles !== null){ + $this->hasChanged = true; $world->timings->syncChunkLoadTileEntitiesTimer->startTiming(); foreach($this->NBTtiles as $nbt){ if($nbt instanceof CompoundTag){ @@ -610,7 +609,6 @@ class Chunk{ $world->addTile($tile); }else{ $world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown tile entity type " . $nbt->getString("id", "", true)); - $changed = true; continue; } } @@ -620,8 +618,6 @@ class Chunk{ $world->timings->syncChunkLoadTileEntitiesTimer->stopTiming(); } - $this->hasChanged = $changed; - $this->isInit = true; } }