mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
Simplify hasChanged handling for chunk init
we always want chunks to be saved if they have tiles or entities
This commit is contained in:
parent
c8eefddfc0
commit
722da5e88d
@ -579,8 +579,8 @@ class Chunk{
|
|||||||
*/
|
*/
|
||||||
public function initChunk(World $world) : void{
|
public function initChunk(World $world) : void{
|
||||||
if(!$this->isInit){
|
if(!$this->isInit){
|
||||||
$changed = false;
|
|
||||||
if($this->NBTentities !== null){
|
if($this->NBTentities !== null){
|
||||||
|
$this->hasChanged = true;
|
||||||
$world->timings->syncChunkLoadEntitiesTimer->startTiming();
|
$world->timings->syncChunkLoadEntitiesTimer->startTiming();
|
||||||
foreach($this->NBTentities as $nbt){
|
foreach($this->NBTentities as $nbt){
|
||||||
if($nbt instanceof CompoundTag){
|
if($nbt instanceof CompoundTag){
|
||||||
@ -588,12 +588,10 @@ class Chunk{
|
|||||||
$entity = EntityFactory::createFromData($world, $nbt);
|
$entity = EntityFactory::createFromData($world, $nbt);
|
||||||
if(!($entity instanceof Entity)){
|
if(!($entity instanceof Entity)){
|
||||||
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown entity type " . $nbt->getString("id", $nbt->getString("identifier", "<unknown>", true), true));
|
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown entity type " . $nbt->getString("id", $nbt->getString("identifier", "<unknown>", true), true));
|
||||||
$changed = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}catch(\Exception $t){ //TODO: this shouldn't be here
|
}catch(\Exception $t){ //TODO: this shouldn't be here
|
||||||
$world->getLogger()->logException($t);
|
$world->getLogger()->logException($t);
|
||||||
$changed = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -603,6 +601,7 @@ class Chunk{
|
|||||||
$world->timings->syncChunkLoadEntitiesTimer->stopTiming();
|
$world->timings->syncChunkLoadEntitiesTimer->stopTiming();
|
||||||
}
|
}
|
||||||
if($this->NBTtiles !== null){
|
if($this->NBTtiles !== null){
|
||||||
|
$this->hasChanged = true;
|
||||||
$world->timings->syncChunkLoadTileEntitiesTimer->startTiming();
|
$world->timings->syncChunkLoadTileEntitiesTimer->startTiming();
|
||||||
foreach($this->NBTtiles as $nbt){
|
foreach($this->NBTtiles as $nbt){
|
||||||
if($nbt instanceof CompoundTag){
|
if($nbt instanceof CompoundTag){
|
||||||
@ -610,7 +609,6 @@ class Chunk{
|
|||||||
$world->addTile($tile);
|
$world->addTile($tile);
|
||||||
}else{
|
}else{
|
||||||
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>", true));
|
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>", true));
|
||||||
$changed = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -620,8 +618,6 @@ class Chunk{
|
|||||||
$world->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
$world->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->hasChanged = $changed;
|
|
||||||
|
|
||||||
$this->isInit = true;
|
$this->isInit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user