From 7a0118820c2f7d4cc512916924a9027e7483b57a Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 4 Jan 2015 23:07:08 +0100 Subject: [PATCH] Improved chunk saving times by not marking it as changed when Players are added/removed --- src/pocketmine/entity/Entity.php | 2 -- src/pocketmine/level/format/generic/BaseFullChunk.php | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index f4fd85481..f3c75fd72 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -766,8 +766,6 @@ abstract class Entity extends Location implements Metadatable{ $this->despawnFromAll(); if($this instanceof Player){ foreach($this->usedChunks as $index => $d){ - $X = null; - $Z = null; Level::getXZ($index, $X, $Z); $this->unloadChunk($X, $Z); } diff --git a/src/pocketmine/level/format/generic/BaseFullChunk.php b/src/pocketmine/level/format/generic/BaseFullChunk.php index 18a2fd1a6..3fa300649 100644 --- a/src/pocketmine/level/format/generic/BaseFullChunk.php +++ b/src/pocketmine/level/format/generic/BaseFullChunk.php @@ -244,12 +244,16 @@ abstract class BaseFullChunk implements FullChunk{ public function addEntity(Entity $entity){ $this->entities[$entity->getId()] = $entity; - $this->hasChanged = true; + if(!($entity instanceof Player)){ + $this->hasChanged = true; + } } public function removeEntity(Entity $entity){ unset($this->entities[$entity->getId()]); - $this->hasChanged = true; + if(!($entity instanceof Player)){ + $this->hasChanged = true; + } } public function addTile(Tile $tile){