World: added private broadcastPacketToPlayersUsingChunk()

this is equivalent to the old addChunkPacket, but private and with a less stupid name.
This commit is contained in:
Dylan K. Taylor 2020-10-11 15:21:15 +01:00
parent a05b1fec7e
commit ca9f3020b4

View File

@ -525,7 +525,11 @@ class World implements ChunkManager{
* Broadcasts a packet to every player who has the target position within their view distance. * Broadcasts a packet to every player who has the target position within their view distance.
*/ */
public function broadcastPacketToViewers(Vector3 $pos, ClientboundPacket $packet) : void{ public function broadcastPacketToViewers(Vector3 $pos, ClientboundPacket $packet) : void{
if(!isset($this->packetBuffersByChunk[$index = World::chunkHash($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4)])){ $this->broadcastPacketToPlayersUsingChunk($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4, $packet);
}
private function broadcastPacketToPlayersUsingChunk(int $chunkX, int $chunkZ, ClientboundPacket $packet) : void{
if(!isset($this->packetBuffersByChunk[$index = World::chunkHash($chunkX, $chunkZ)])){
$this->packetBuffersByChunk[$index] = [$packet]; $this->packetBuffersByChunk[$index] = [$packet];
}else{ }else{
$this->packetBuffersByChunk[$index][] = $packet; $this->packetBuffersByChunk[$index][] = $packet;