From 71f2a34616961d6328f06fd911b6d4450a61643e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 30 Oct 2021 15:38:27 +0100 Subject: [PATCH] Entity: spawnTo() must silently swallow errors Player->showPlayer() assumes that spawnTo() will take care of all the checks necessary to ensure we don't actually spawn a player to someone it shouldn't be able to see. In PM3, there's nothing we can do about that. This could be a problem if anything decides to override spawnTo() to do additional stuff and assumes that the function will always succeed; however, there's not much reason to do that (plugins sending packets should override sendSpawnPacket() instead). --- src/pocketmine/entity/Entity.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index c4c017874..39e1a28fc 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -1950,12 +1950,10 @@ 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 + $player->getLevelNonNull() === $this->level and isset($player->usedChunks[$chunkHash = Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())]) and $player->usedChunks[$chunkHash] === true ){