diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index b3066aa14..0f99e2f83 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -616,7 +616,10 @@ class Level implements ChunkManager, Metadatable{ } /** - * Gets the players being used in a specific chunk + * @deprecated WARNING: This function has a misleading name. Contrary to what the name might imply, this function + * DOES NOT return players who are IN a chunk, rather, it returns players who can SEE the chunk. + * + * Returns a list of players who have the target chunk within their view distance. * * @param int $chunkX * @param int $chunkZ @@ -2490,8 +2493,10 @@ class Level implements ChunkManager, Metadatable{ $oldChunk = $this->getChunk($chunkX, $chunkZ, false); if($oldChunk !== null and $oldChunk !== $chunk){ if($deleteEntitiesAndTiles){ - $players = $this->getChunkPlayers($chunkX, $chunkZ); - foreach($players as $player){ + foreach($oldChunk->getEntities() as $player){ + if(!($player instanceof Player)){ + continue; + } $chunk->addEntity($player); $oldChunk->removeEntity($player); $player->chunk = $chunk;