diff --git a/src/Entity.php b/src/Entity.php index 42cdd91f0..f44bd99a1 100644 --- a/src/Entity.php +++ b/src/Entity.php @@ -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){ diff --git a/src/entity/PlayerEntity.php b/src/entity/PlayerEntity.php index 9e8c9bba8..6a554cd91 100644 --- a/src/entity/PlayerEntity.php +++ b/src/entity/PlayerEntity.php @@ -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); + } + } } \ No newline at end of file