From 0cd1e82c521b31cd0ca70c9ef6999da033ea9eb4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 24 Feb 2017 13:28:11 +0000 Subject: [PATCH] Fixed encode/decode of ResourcePacksInfoPacket and ResourcePackClientResponsePacket --- .../ResourcePackClientResponsePacket.php | 18 +++++++++++++----- .../protocol/ResourcePacksInfoPacket.php | 19 +++++++++++++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/pocketmine/network/protocol/ResourcePackClientResponsePacket.php b/src/pocketmine/network/protocol/ResourcePackClientResponsePacket.php index 42a714f03..e74740649 100644 --- a/src/pocketmine/network/protocol/ResourcePackClientResponsePacket.php +++ b/src/pocketmine/network/protocol/ResourcePackClientResponsePacket.php @@ -27,16 +27,24 @@ namespace pocketmine\network\protocol; class ResourcePackClientResponsePacket extends DataPacket{ const NETWORK_ID = Info::RESOURCE_PACK_CLIENT_RESPONSE_PACKET; - public $unknownByte; - public $unknownShort; + public $status; //TODO: add constants for status types + public $packIds = []; public function decode(){ - $this->unknownByte = $this->getByte(); - $this->unknownShort = $this->getShort(); + $this->status = $this->getByte(); + $entryCount = $this->getLShort(); + while($entryCount-- > 0){ + $this->packIds[] = $this->getString(); + } } public function encode(){ - + $this->reset(); + $this->putByte($this->status); + $this->putLShort(count($this->packIds)); + foreach($this->packIds as $id){ + $this->putString($id); + } } } \ No newline at end of file diff --git a/src/pocketmine/network/protocol/ResourcePacksInfoPacket.php b/src/pocketmine/network/protocol/ResourcePacksInfoPacket.php index 26aa79beb..0f844cee3 100644 --- a/src/pocketmine/network/protocol/ResourcePacksInfoPacket.php +++ b/src/pocketmine/network/protocol/ResourcePacksInfoPacket.php @@ -36,20 +36,35 @@ class ResourcePacksInfoPacket extends DataPacket{ public $resourcePackEntries = []; public function decode(){ + $this->mustAccept = $this->getBool(); + $behaviorPackCount = $this->getLShort(); + while($behaviorPackCount-- > 0){ + $id = $this->getString(); + $version = $this->getString(); + $size = $this->getLLong(); + $this->behaviorPackEntries[] = new ResourcePackInfoEntry($id, $version, $size); + } + $resourcePackCount = $this->getLShort(); + while($resourcePackCount-- > 0){ + $id = $this->getString(); + $version = $this->getString(); + $size = $this->getLLong(); + $this->resourcePackEntries[] = new ResourcePackInfoEntry($id, $version, $size); + } } public function encode(){ $this->reset(); $this->putBool($this->mustAccept); - $this->putShort(count($this->behaviorPackEntries)); + $this->putLShort(count($this->behaviorPackEntries)); foreach($this->behaviorPackEntries as $entry){ $this->putString($entry->getPackId()); $this->putString($entry->getVersion()); $this->putLLong($entry->getPackSize()); } - $this->putShort(count($this->resourcePackEntries)); + $this->putLShort(count($this->resourcePackEntries)); foreach($this->resourcePackEntries as $entry){ $this->putString($entry->getPackId()); $this->putString($entry->getVersion());