PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
ResourcePackDataInfoPacket.php
1<?php
2
3/*
4 * This file is part of BedrockProtocol.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6 *
7 * BedrockProtocol is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol;
16
19
21 public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_DATA_INFO_PACKET;
22
23 public string $packId;
24 public int $maxChunkSize;
25 public int $chunkCount;
26 public int $compressedPackSize;
27 public string $sha256;
28 public bool $isPremium = false;
29 public int $packType = ResourcePackType::RESOURCES; //TODO: check the values for this
30
34 public static function create(
35 string $packId,
36 int $maxChunkSize,
37 int $chunkCount,
38 int $compressedPackSize,
39 string $sha256,
40 bool $isPremium,
41 int $packType,
42 ) : self{
43 $result = new self;
44 $result->packId = $packId;
45 $result->maxChunkSize = $maxChunkSize;
46 $result->chunkCount = $chunkCount;
47 $result->compressedPackSize = $compressedPackSize;
48 $result->sha256 = $sha256;
49 $result->isPremium = $isPremium;
50 $result->packType = $packType;
51 return $result;
52 }
53
54 protected function decodePayload(PacketSerializer $in) : void{
55 $this->packId = $in->getString();
56 $this->maxChunkSize = $in->getLInt();
57 $this->chunkCount = $in->getLInt();
58 $this->compressedPackSize = $in->getLLong();
59 $this->sha256 = $in->getString();
60 $this->isPremium = $in->getBool();
61 $this->packType = $in->getByte();
62 }
63
64 protected function encodePayload(PacketSerializer $out) : void{
65 $out->putString($this->packId);
66 $out->putLInt($this->maxChunkSize);
67 $out->putLInt($this->chunkCount);
68 $out->putLLong($this->compressedPackSize);
69 $out->putString($this->sha256);
70 $out->putBool($this->isPremium);
71 $out->putByte($this->packType);
72 }
73
74 public function handle(PacketHandlerInterface $handler) : bool{
75 return $handler->handleResourcePackDataInfo($this);
76 }
77}
static create(string $packId, int $maxChunkSize, int $chunkCount, int $compressedPackSize, string $sha256, bool $isPremium, int $packType,)