mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 00:39:45 +00:00
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.
This commit is contained in:
parent
fee3c17148
commit
17037f5e9c
@ -694,50 +694,48 @@ class Chunk{
|
|||||||
public function initChunk(Level $level){
|
public function initChunk(Level $level){
|
||||||
if(!$this->isInit){
|
if(!$this->isInit){
|
||||||
$changed = false;
|
$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{
|
$level->timings->syncChunkLoadEntitiesTimer->startTiming();
|
||||||
$entity = Entity::createEntity($nbt->getTag("id")->getValue(), $level, $nbt);
|
foreach($this->NBTentities as $nbt){
|
||||||
if(!($entity instanceof Entity)){
|
if($nbt instanceof CompoundTag){
|
||||||
$changed = true;
|
if(!$nbt->hasTag("id")){ //allow mixed types (because of leveldb)
|
||||||
continue;
|
$changed = true;
|
||||||
}
|
continue;
|
||||||
}catch(\Throwable $t){
|
}
|
||||||
$level->getServer()->getLogger()->logException($t);
|
|
||||||
|
try{
|
||||||
|
$entity = Entity::createEntity($nbt->getTag("id")->getValue(), $level, $nbt);
|
||||||
|
if(!($entity instanceof Entity)){
|
||||||
$changed = true;
|
$changed = true;
|
||||||
continue;
|
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;
|
$this->hasChanged = $changed;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user