From ca9f3020b43146479b21ef189ca331a8ab02733d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 11 Oct 2020 15:21:15 +0100 Subject: [PATCH] World: added private broadcastPacketToPlayersUsingChunk() this is equivalent to the old addChunkPacket, but private and with a less stupid name. --- src/world/World.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/world/World.php b/src/world/World.php index 9b02eb183..837498e9b 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -525,7 +525,11 @@ class World implements ChunkManager{ * Broadcasts a packet to every player who has the target position within their view distance. */ 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]; }else{ $this->packetBuffersByChunk[$index][] = $packet;