diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index f08f704ae..9883b52d6 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -563,7 +563,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } public function spawnTo(Player $player) : void{ - if($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->getLevelNonNull() === $this->level and $player->canSee($this) and !$this->isSpectator()){ + if($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->canSee($this) and !$this->isSpectator()){ parent::spawnTo($player); } } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 419a4ee14..c4c017874 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -1950,6 +1950,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ } public function spawnTo(Player $player) : void{ + if($player->getLevelNonNull() !== $this->level){ + throw new \InvalidArgumentException("Player is not in the same world"); + } if( !isset($this->hasSpawned[$player->getLoaderId()]) and $this->chunk !== null and