Fixed Entity & Player loaded chunk indexes

This commit is contained in:
Shoghi Cervantes 2014-06-23 11:57:47 +02:00
parent 496c004efc
commit fd4fc4ff94
2 changed files with 14 additions and 16 deletions

View File

@ -139,7 +139,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
protected $startAction = false;
protected $sleeping = false;
protected $usedChunks = [];
public $usedChunks = [];
protected $loadQueue = [];
protected $chunkACK = [];
/** @var \pocketmine\scheduler\TaskHandler */

View File

@ -225,7 +225,7 @@ abstract class Entity extends Position implements Metadatable{
* @param Player $player
*/
public function spawnTo(Player $player){
if(!isset($this->hasSpawned[$player->getID()]) and $player->chunksLoaded[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())] !== 0xff){
if(!isset($this->hasSpawned[$player->getID()]) and isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])){
$this->hasSpawned[$player->getID()] = $player;
}
}
@ -585,8 +585,7 @@ abstract class Entity extends Position implements Metadatable{
$this->chunk->removeEntity($this);
$this->despawnFromAll();
if($this instanceof Player){
foreach($this->chunksLoaded as $index => $Yndex){
if($Yndex !== 0xff){
foreach($this->usedChunks as $index => $d){
$X = null;
$Z = null;
Level::getXZ($index, $X, $Z);
@ -599,14 +598,13 @@ abstract class Entity extends Position implements Metadatable{
$pk->chunkZ = $Z;
$this->dataPacket($pk);
}
}
$this->getLevel()->freeAllChunks($this);
}
}
$this->setLevel($targetLevel, true); //Hard reference
$this->getLevel()->addEntity($this);
if($this instanceof Player){
$this->chunksLoaded = [];
$this->usedChunks = [];
$pk = new SetTimePacket();
$pk->time = $this->getLevel()->getTime();
$pk->started = $this->getLevel()->stopTime == false;