From 51a20470f6a1baf5659133ac2d55daf57ef9add5 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 18 Mar 2017 15:03:41 +0000 Subject: [PATCH] Switch back to the old chunk-packet method since MoveEntityPacket and SetEntityMotionPacket no longer have lists --- src/pocketmine/level/Level.php | 55 ++++++++++------------------------ 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index e16d13ad8..4441058ce 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -134,9 +134,6 @@ class Level implements ChunkManager, Metadatable{ /** @var Tile[] */ private $tiles = []; - private $motionToSend = []; - private $moveToSend = []; - /** @var Player[] */ private $players = []; @@ -723,35 +720,6 @@ class Level implements ChunkManager, Metadatable{ $this->checkSleep(); } - foreach($this->moveToSend as $index => $entry){ - Level::getXZ($index, $chunkX, $chunkZ); - foreach($entry as $e){ - $pk = new MoveEntityPacket(); - $pk->eid = $e[0]; - $pk->x = $e[1]; - $pk->y = $e[2]; - $pk->z = $e[3]; - $pk->yaw = $e[4]; - $pk->headYaw = $e[5]; - $pk->pitch = $e[6]; - $this->addChunkPacket($chunkX, $chunkZ, $pk); - } - } - $this->moveToSend = []; - - foreach($this->motionToSend as $index => $entry){ - Level::getXZ($index, $chunkX, $chunkZ); - foreach($entry as $entity){ - $pk = new SetEntityMotionPacket(); - $pk->eid = $entity[0]; - $pk->motionX = $entity[1]; - $pk->motionY = $entity[2]; - $pk->motionZ = $entity[3]; - $this->addChunkPacket($chunkX, $chunkZ, $pk); - } - } - $this->motionToSend = []; - foreach($this->chunkPackets as $index => $entries){ Level::getXZ($index, $chunkX, $chunkZ); $chunkPlayers = $this->getChunkPlayers($chunkX, $chunkZ); @@ -2827,16 +2795,23 @@ class Level implements ChunkManager, Metadatable{ } public function addEntityMotion(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z){ - if(!isset($this->motionToSend[$index = Level::chunkHash($chunkX, $chunkZ)])){ - $this->motionToSend[$index] = []; - } - $this->motionToSend[$index][$entityId] = [$entityId, $x, $y, $z]; + $pk = new SetEntityMotionPacket(); + $pk->eid = $entityId; + $pk->motionX = $x; + $pk->motionY = $y; + $pk->motionZ = $z; + $this->addChunkPacket($chunkX, $chunkZ, $pk); } public function addEntityMovement(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z, float $yaw, float $pitch, $headYaw = null){ - if(!isset($this->moveToSend[$index = Level::chunkHash($chunkX, $chunkZ)])){ - $this->moveToSend[$index] = []; - } - $this->moveToSend[$index][$entityId] = [$entityId, $x, $y, $z, $yaw, $headYaw === null ? $yaw : $headYaw, $pitch]; + $pk = new MoveEntityPacket(); + $pk->eid = $entityId; + $pk->x = $x; + $pk->y = $y; + $pk->z = $z; + $pk->yaw = $yaw; + $pk->pitch = $pitch; + $pk->headYaw = $headYaw ?? $yaw; + $this->addChunkPacket($chunkX, $chunkZ, $pk); } }