diff --git a/src/Server.php b/src/Server.php index ee509696e..a81b1d74b 100644 --- a/src/Server.php +++ b/src/Server.php @@ -1351,6 +1351,7 @@ class Server{ /** * @param Player[] $players * @param ClientboundPacket[] $packets + * @deprecated */ public function broadcastPackets(array $players, array $packets) : bool{ return NetworkBroadcastUtils::broadcastPackets($players, $packets); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index c206b81d3..c60f2c1c4 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -787,7 +787,7 @@ abstract class Entity{ $this->spawnTo($player); } }else{ - $this->server->broadcastPackets($this->hasSpawned, [MoveActorAbsolutePacket::create( + NetworkBroadcastUtils::broadcastPackets($this->hasSpawned, [MoveActorAbsolutePacket::create( $this->id, $this->getOffsetPosition($this->location), $this->location->pitch, @@ -802,7 +802,7 @@ abstract class Entity{ } protected function broadcastMotion() : void{ - $this->server->broadcastPackets($this->hasSpawned, [SetActorMotionPacket::create($this->id, $this->getMotion())]); + NetworkBroadcastUtils::broadcastPackets($this->hasSpawned, [SetActorMotionPacket::create($this->id, $this->getMotion())]); } public function getGravity() : float{ @@ -1682,7 +1682,7 @@ abstract class Entity{ * @param Player[]|null $targets */ public function broadcastAnimation(Animation $animation, ?array $targets = null) : void{ - $this->server->broadcastPackets($targets ?? $this->getViewers(), $animation->encode()); + NetworkBroadcastUtils::broadcastPackets($targets ?? $this->getViewers(), $animation->encode()); } /** @@ -1691,7 +1691,7 @@ abstract class Entity{ */ public function broadcastSound(Sound $sound, ?array $targets = null) : void{ if(!$this->silent){ - $this->server->broadcastPackets($targets ?? $this->getViewers(), $sound->encode($this->location)); + NetworkBroadcastUtils::broadcastPackets($targets ?? $this->getViewers(), $sound->encode($this->location)); } } diff --git a/src/entity/Human.php b/src/entity/Human.php index 695777613..cdbd70bd7 100644 --- a/src/entity/Human.php +++ b/src/entity/Human.php @@ -176,7 +176,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{ * @param Player[]|null $targets */ public function sendSkin(?array $targets = null) : void{ - $this->server->broadcastPackets($targets ?? $this->hasSpawned, [ + NetworkBroadcastUtils::broadcastPackets($targets ?? $this->hasSpawned, [ PlayerSkinPacket::create($this->getUniqueId(), "", "", SkinAdapterSingleton::get()->toSkinData($this->skin)) ]); } diff --git a/src/world/World.php b/src/world/World.php index cd134f577..34cc33bd7 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -65,6 +65,7 @@ use pocketmine\math\Vector3; use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\StringTag; use pocketmine\network\mcpe\convert\RuntimeBlockMapping; +use pocketmine\network\mcpe\NetworkBroadcastUtils; use pocketmine\network\mcpe\protocol\BlockActorDataPacket; use pocketmine\network\mcpe\protocol\ClientboundPacket; use pocketmine\network\mcpe\protocol\types\BlockPosition; @@ -685,7 +686,7 @@ class World implements ChunkManager{ $this->broadcastPacketToViewers($pos, $e); } }else{ - $this->server->broadcastPackets($this->filterViewersForPosition($pos, $players), $pk); + NetworkBroadcastUtils::broadcastPackets($this->filterViewersForPosition($pos, $players), $pk); } } } @@ -711,7 +712,7 @@ class World implements ChunkManager{ $this->broadcastPacketToViewers($pos, $e); } }else{ - $this->server->broadcastPackets($this->filterViewersForPosition($pos, $ev->getRecipients()), $pk); + NetworkBroadcastUtils::broadcastPackets($this->filterViewersForPosition($pos, $ev->getRecipients()), $pk); } } } @@ -1021,7 +1022,7 @@ class World implements ChunkManager{ World::getXZ($index, $chunkX, $chunkZ); $chunkPlayers = $this->getChunkPlayers($chunkX, $chunkZ); if(count($chunkPlayers) > 0){ - $this->server->broadcastPackets($chunkPlayers, $entries); + NetworkBroadcastUtils::broadcastPackets($chunkPlayers, $entries); } }