mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-16 00:15:35 +00:00
Level: Add API method getViewersForPosition()
This returns all players who have the given position within their view radius.
This commit is contained in:
parent
3028832cd3
commit
43426a4c5c
@ -595,6 +595,16 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
return $this->chunkLoaders[Level::chunkHash($chunkX, $chunkZ)] ?? [];
|
return $this->chunkLoaders[Level::chunkHash($chunkX, $chunkZ)] ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of players who have the target position within their view distance.
|
||||||
|
* @param Vector3 $pos
|
||||||
|
*
|
||||||
|
* @return Player[]
|
||||||
|
*/
|
||||||
|
public function getViewersForPosition(Vector3 $pos) : array{
|
||||||
|
return $this->getChunkPlayers($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queues a DataPacket to be sent to all players using the chunk at the specified X/Z coordinates at the end of the
|
* Queues a DataPacket to be sent to all players using the chunk at the specified X/Z coordinates at the end of the
|
||||||
* current tick.
|
* current tick.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user