From 17037f5e9ca9ca1169ee5291d32ac2d4fe93f44e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 1 Dec 2019 21:14:23 +0000 Subject: [PATCH] Chunk: clean up nonsensical code in initChunk() I have no idea why the extra check was there, or why the null assignment was used, because it doesn't make any sense. --- src/pocketmine/level/format/Chunk.php | 72 +++++++++++++-------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index 8bbdefe19..5847dd0ab 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -694,50 +694,48 @@ class Chunk{ public function initChunk(Level $level){ if(!$this->isInit){ $changed = false; - if($this->NBTentities !== null){ - $level->timings->syncChunkLoadEntitiesTimer->startTiming(); - foreach($this->NBTentities as $nbt){ - if($nbt instanceof CompoundTag){ - if(!$nbt->hasTag("id")){ //allow mixed types (because of leveldb) - $changed = true; - continue; - } - try{ - $entity = Entity::createEntity($nbt->getTag("id")->getValue(), $level, $nbt); - if(!($entity instanceof Entity)){ - $changed = true; - continue; - } - }catch(\Throwable $t){ - $level->getServer()->getLogger()->logException($t); + $level->timings->syncChunkLoadEntitiesTimer->startTiming(); + foreach($this->NBTentities as $nbt){ + if($nbt instanceof CompoundTag){ + if(!$nbt->hasTag("id")){ //allow mixed types (because of leveldb) + $changed = true; + continue; + } + + try{ + $entity = Entity::createEntity($nbt->getTag("id")->getValue(), $level, $nbt); + if(!($entity instanceof Entity)){ $changed = true; continue; } + }catch(\Throwable $t){ + $level->getServer()->getLogger()->logException($t); + $changed = true; + continue; } } - $level->timings->syncChunkLoadEntitiesTimer->stopTiming(); - - $level->timings->syncChunkLoadTileEntitiesTimer->startTiming(); - foreach($this->NBTtiles as $nbt){ - if($nbt instanceof CompoundTag){ - if(!$nbt->hasTag(Tile::TAG_ID, StringTag::class)){ - $changed = true; - continue; - } - - if(Tile::createTile($nbt->getString(Tile::TAG_ID), $level, $nbt) === null){ - $changed = true; - continue; - } - } - } - - $level->timings->syncChunkLoadTileEntitiesTimer->stopTiming(); - - $this->NBTentities = null; - $this->NBTtiles = null; } + $this->NBTentities = []; + $level->timings->syncChunkLoadEntitiesTimer->stopTiming(); + + $level->timings->syncChunkLoadTileEntitiesTimer->startTiming(); + foreach($this->NBTtiles as $nbt){ + if($nbt instanceof CompoundTag){ + if(!$nbt->hasTag(Tile::TAG_ID, StringTag::class)){ + $changed = true; + continue; + } + + if(Tile::createTile($nbt->getString(Tile::TAG_ID), $level, $nbt) === null){ + $changed = true; + continue; + } + } + } + + $this->NBTtiles = []; + $level->timings->syncChunkLoadTileEntitiesTimer->stopTiming(); $this->hasChanged = $changed;