From 0ab3da88be372a20520d7c4e2809fcecf1bb9aed Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Wed, 13 Aug 2014 19:32:25 +0200 Subject: [PATCH] Send player movements as direct packets --- src/pocketmine/Player.php | 10 +++------- src/pocketmine/entity/Entity.php | 10 ++++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 3001c29845..b529d60ae0 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -81,7 +81,6 @@ use pocketmine\network\protocol\SetSpawnPositionPacket; use pocketmine\network\protocol\SetTimePacket; use pocketmine\network\protocol\StartGamePacket; use pocketmine\network\protocol\TakeItemEntityPacket; -use pocketmine\network\protocol\UnloadChunkPacket; use pocketmine\network\protocol\UpdateBlockPacket; use pocketmine\network\SourceInterface; use pocketmine\permission\PermissibleBase; @@ -499,10 +498,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $entity->despawnFrom($this); } } - /*$pk = new UnloadChunkPacket(); - $pk->chunkX = $x; - $pk->chunkZ = $z; - $this->dataPacket($pk);*/ + $this->getLevel()->freeChunk($x, $z, $this); unset($this->usedChunks[$index]); @@ -2092,7 +2088,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk = new MessagePacket; $pk->source = ""; //Do not use this ;) $pk->message = $this->removeFormat === false ? $m : TextFormat::clean($m); - $this->dataPacket($pk); + $this->directDataPacket($pk); } } } @@ -2286,7 +2282,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk->bodyYaw = $this->yaw; $pk->pitch = $this->pitch; $pk->yaw = $this->yaw; - $this->dataPacket($pk); + $this->directDataPacket($pk); } } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 4b9e60a3ce..0fe24e0ddd 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -53,7 +53,6 @@ use pocketmine\network\protocol\MovePlayerPacket; use pocketmine\network\protocol\RemoveEntityPacket; use pocketmine\network\protocol\SetEntityMotionPacket; use pocketmine\network\protocol\SetTimePacket; -use pocketmine\network\protocol\UnloadChunkPacket; use pocketmine\Network; use pocketmine\Player; use pocketmine\plugin\Plugin; @@ -503,7 +502,10 @@ abstract class Entity extends Position implements Metadatable{ [$this->id, $this->x, $this->y, $this->z, $this->yaw, $this->pitch] ]; } - Server::broadcastPacket($this->hasSpawned, $pk); + + foreach($this->hasSpawned as $player){ + $player->directDataPacket($pk); + } } if(($this->lastMotionX != $this->motionX or $this->lastMotionY != $this->motionY or $this->lastMotionZ != $this->motionZ)){ @@ -658,10 +660,6 @@ abstract class Entity extends Position implements Metadatable{ $entity->despawnFrom($this); } - /*$pk = new UnloadChunkPacket(); - $pk->chunkX = $X; - $pk->chunkZ = $Z; - $this->dataPacket($pk);*/ } $this->getLevel()->freeAllChunks($this); }