PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
Loading...
Searching...
No Matches
ClientCacheBlobStatusPacket.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
18use function count;
19
21 public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_BLOB_STATUS_PACKET;
22
24 private array $hitHashes = [];
26 private array $missHashes = [];
27
33 public static function create(array $hitHashes, array $missHashes) : self{
34 $result = new self;
35 $result->hitHashes = $hitHashes;
36 $result->missHashes = $missHashes;
37 return $result;
38 }
39
43 public function getHitHashes() : array{
44 return $this->hitHashes;
45 }
46
50 public function getMissHashes() : array{
51 return $this->missHashes;
52 }
53
54 protected function decodePayload(PacketSerializer $in) : void{
55 $missCount = $in->getUnsignedVarInt();
56 $hitCount = $in->getUnsignedVarInt();
57 for($i = 0; $i < $missCount; ++$i){
58 $this->missHashes[] = $in->getLLong();
59 }
60 for($i = 0; $i < $hitCount; ++$i){
61 $this->hitHashes[] = $in->getLLong();
62 }
63 }
64
65 protected function encodePayload(PacketSerializer $out) : void{
66 $out->putUnsignedVarInt(count($this->missHashes));
67 $out->putUnsignedVarInt(count($this->hitHashes));
68 foreach($this->missHashes as $hash){
69 $out->putLLong($hash);
70 }
71 foreach($this->hitHashes as $hash){
72 $out->putLLong($hash);
73 }
74 }
75
76 public function handle(PacketHandlerInterface $handler) : bool{
77 return $handler->handleClientCacheBlobStatus($this);
78 }
79}