Added resource packs support

This commit is contained in:
Dylan K. Taylor
2017-03-10 20:00:31 +00:00
parent 1f2b584400
commit d41bdfc31c
12 changed files with 370 additions and 40 deletions

View File

@ -25,19 +25,20 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\NetworkSession;
use pocketmine\resourcepacks\ResourcePack;
use pocketmine\resourcepacks\ResourcePackInfoEntry;
class ResourcePacksInfoPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::RESOURCE_PACKS_INFO_PACKET;
public $mustAccept = false; //if true, forces client to use selected resource packs
/** @var ResourcePackInfoEntry[] */
/** @var ResourcePack[] */
public $behaviorPackEntries = [];
/** @var ResourcePackInfoEntry[] */
/** @var ResourcePack[] */
public $resourcePackEntries = [];
public function decode(){
$this->mustAccept = $this->getBool();
/*$this->mustAccept = $this->getBool();
$behaviorPackCount = $this->getLShort();
while($behaviorPackCount-- > 0){
$id = $this->getString();
@ -52,7 +53,7 @@ class ResourcePacksInfoPacket extends DataPacket{
$version = $this->getString();
$size = $this->getLLong();
$this->resourcePackEntries[] = new ResourcePackInfoEntry($id, $version, $size);
}
}*/
}
public function encode(){
@ -62,13 +63,13 @@ class ResourcePacksInfoPacket extends DataPacket{
$this->putLShort(count($this->behaviorPackEntries));
foreach($this->behaviorPackEntries as $entry){
$this->putString($entry->getPackId());
$this->putString($entry->getVersion());
$this->putString($entry->getPackVersion());
$this->putLLong($entry->getPackSize());
}
$this->putLShort(count($this->resourcePackEntries));
foreach($this->resourcePackEntries as $entry){
$this->putString($entry->getPackId());
$this->putString($entry->getVersion());
$this->putString($entry->getPackVersion());
$this->putLLong($entry->getPackSize());
}
}