mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
Improved saving of modified properties
This commit is contained in:
parent
66f28f6dc4
commit
92a2be024a
@ -2299,8 +2299,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
return false;
|
||||
}
|
||||
|
||||
$chunk->setChanged(false);
|
||||
|
||||
if($this->isChunkInUse($x, $z)){
|
||||
foreach($this->getChunkLoaders($x, $z) as $loader){
|
||||
$loader->onChunkLoaded($chunk);
|
||||
|
@ -108,55 +108,60 @@ abstract class BaseFullChunk implements FullChunk{
|
||||
}
|
||||
|
||||
public function initChunk(){
|
||||
if($this->getProvider() instanceof LevelProvider and !$this->isInit and $this->NBTentities !== null){
|
||||
$this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->startTiming();
|
||||
foreach($this->NBTentities as $nbt){
|
||||
if($nbt instanceof Compound){
|
||||
if(!isset($nbt->id)){
|
||||
$this->setChanged();
|
||||
continue;
|
||||
}
|
||||
if($this->getProvider() instanceof LevelProvider and !$this->isInit){
|
||||
$changed = false;
|
||||
if($this->NBTentities !== null){
|
||||
$this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->startTiming();
|
||||
foreach($this->NBTentities as $nbt){
|
||||
if($nbt instanceof Compound){
|
||||
if(!isset($nbt->id)){
|
||||
$this->setChanged();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(($nbt["Pos"][0] >> 4) !== $this->x or ($nbt["Pos"][2] >> 4) !== $this->z){
|
||||
$this->setChanged();
|
||||
continue; //Fixes entities allocated in wrong chunks.
|
||||
}
|
||||
if(($nbt["Pos"][0] >> 4) !== $this->x or ($nbt["Pos"][2] >> 4) !== $this->z){
|
||||
$changed = true;
|
||||
continue; //Fixes entities allocated in wrong chunks.
|
||||
}
|
||||
|
||||
if(($entity = Entity::createEntity($nbt["id"], $this, $nbt)) instanceof Entity){
|
||||
$entity->spawnToAll();
|
||||
}else{
|
||||
$this->setChanged();
|
||||
continue;
|
||||
if(($entity = Entity::createEntity($nbt["id"], $this, $nbt)) instanceof Entity){
|
||||
$entity->spawnToAll();
|
||||
}else{
|
||||
$changed = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->stopTiming();
|
||||
$this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->stopTiming();
|
||||
|
||||
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->startTiming();
|
||||
foreach($this->NBTtiles as $nbt){
|
||||
if($nbt instanceof Compound){
|
||||
if(!isset($nbt->id)){
|
||||
$this->setChanged();
|
||||
continue;
|
||||
}
|
||||
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->startTiming();
|
||||
foreach($this->NBTtiles as $nbt){
|
||||
if($nbt instanceof Compound){
|
||||
if(!isset($nbt->id)){
|
||||
$changed = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(($nbt["x"] >> 4) !== $this->x or ($nbt["z"] >> 4) !== $this->z){
|
||||
$this->setChanged();
|
||||
continue; //Fixes tiles allocated in wrong chunks.
|
||||
}
|
||||
if(($nbt["x"] >> 4) !== $this->x or ($nbt["z"] >> 4) !== $this->z){
|
||||
$changed = true;
|
||||
continue; //Fixes tiles allocated in wrong chunks.
|
||||
}
|
||||
|
||||
if(Tile::createTile($nbt["id"], $this, $nbt) === null){
|
||||
$this->setChanged();
|
||||
continue;
|
||||
if(Tile::createTile($nbt["id"], $this, $nbt) === null){
|
||||
$changed = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
||||
|
||||
$this->NBTentities = null;
|
||||
$this->NBTtiles = null;
|
||||
|
||||
$this->setChanged($changed);
|
||||
}
|
||||
|
||||
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
||||
|
||||
$this->NBTentities = null;
|
||||
$this->NBTtiles = null;
|
||||
|
||||
$this->isInit = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user