Rolling chunk load

This commit is contained in:
Shoghi Cervantes 2014-03-01 19:13:08 +01:00
parent fdbefa0571
commit f8d91b5888
2 changed files with 15 additions and 3 deletions

View File

@ -327,11 +327,11 @@ abstract class Entity extends Position{
$this->level->loadChunk($this->x >> 4, $this->z >> 4);
$newChunk = $this->level->getUsingChunk($this->x >> 4, $this->z >> 4);
foreach($this->hasSpawned as $CID => $player){
if(!isset($newChunk[$CID])){
foreach($this->hasSpawned as $player){
if(!isset($newChunk[$player->CID])){
$this->despawnFrom($player);
}else{
unset($newChunk[$CID]);
unset($newChunk[$player->CID]);
}
}
foreach($newChunk as $player){

View File

@ -30,4 +30,16 @@ class PlayerEntity extends HumanEntity{
unset($this->level->players[$this->CID]);
parent::close();
}
public function spawnTo(Player $player){
if($this->spawned === true){
parent::spawnTo($player);
}
}
public function despawnFrom(Player $player){
if($this->spawned === true){
parent::despawnFrom($player);
}
}
}