mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 17:59:41 +00:00
Fixed encode/decode of ResourcePacksInfoPacket and ResourcePackClientResponsePacket
This commit is contained in:
parent
1ee689e759
commit
0cd1e82c52
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user