Improved level switching for players

This commit is contained in:
Shoghi Cervantes 2014-11-01 17:39:09 +01:00
parent f8f1e0e9df
commit 4d97827d44

View File

@ -745,14 +745,11 @@ abstract class Entity extends Location implements Metadatable{
$X = null; $X = null;
$Z = null; $Z = null;
Level::getXZ($index, $X, $Z); Level::getXZ($index, $X, $Z);
foreach($this->level->getChunkEntities($X, $Z) as $entity){ $this->unloadChunk($X, $Z);
$entity->despawnFrom($this);
}
$this->level->freeChunk($X, $Z, $this);
} }
} }
} }
$this->setLevel($targetLevel, $this instanceof Player ? true : false); //Hard reference $this->setLevel($targetLevel);
$this->level->addEntity($this); $this->level->addEntity($this);
if($this instanceof Player){ if($this instanceof Player){
$this->usedChunks = []; $this->usedChunks = [];