PocketMine-MP
5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
ClientCacheMissResponsePacket.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
13
declare(strict_types=1);
14
15
namespace
pocketmine\network\mcpe\protocol;
16
17
use pmmp\encoding\ByteBufferReader;
18
use pmmp\encoding\ByteBufferWriter;
19
use pmmp\encoding\LE;
20
use pmmp\encoding\VarInt;
21
use
pocketmine\network\mcpe\protocol\serializer\CommonTypes
;
22
use
pocketmine\network\mcpe\protocol\types\ChunkCacheBlob
;
23
use
function
count;
24
25
class
ClientCacheMissResponsePacket
extends
DataPacket
implements
ClientboundPacket
{
26
public
const
NETWORK_ID = ProtocolInfo::CLIENT_CACHE_MISS_RESPONSE_PACKET;
27
29
private
array $blobs = [];
30
35
public
static
function
create
(array $blobs) : self{
36
$result = new self;
37
$result->blobs = $blobs;
38
return
$result;
39
}
40
44
public
function
getBlobs
() : array{
45
return $this->blobs;
46
}
47
48
protected
function
decodePayload
(ByteBufferReader $in) : void{
49
for($i = 0, $count = VarInt::readUnsignedInt($in); $i < $count; ++$i){
50
$hash = LE::readUnsignedLong($in);
51
$payload = CommonTypes::getString($in);
52
$this->blobs[] =
new
ChunkCacheBlob
($hash, $payload);
53
}
54
}
55
56
protected
function
encodePayload
(ByteBufferWriter $out) : void{
57
VarInt::writeUnsignedInt($out, count($this->blobs));
58
foreach
($this->blobs as $blob){
59
LE::writeUnsignedLong($out, $blob->getHash());
60
CommonTypes::putString($out, $blob->getPayload());
61
}
62
}
63
64
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
65
return $handler->handleClientCacheMissResponse($this);
66
}
67
}
pocketmine\network\mcpe\protocol\ClientCacheMissResponsePacket
Definition
ClientCacheMissResponsePacket.php:25
pocketmine\network\mcpe\protocol\ClientCacheMissResponsePacket\handle
handle(PacketHandlerInterface $handler)
Definition
ClientCacheMissResponsePacket.php:64
pocketmine\network\mcpe\protocol\ClientCacheMissResponsePacket\encodePayload
encodePayload(ByteBufferWriter $out)
Definition
ClientCacheMissResponsePacket.php:56
pocketmine\network\mcpe\protocol\ClientCacheMissResponsePacket\decodePayload
decodePayload(ByteBufferReader $in)
Definition
ClientCacheMissResponsePacket.php:48
pocketmine\network\mcpe\protocol\ClientCacheMissResponsePacket\getBlobs
getBlobs()
Definition
ClientCacheMissResponsePacket.php:44
pocketmine\network\mcpe\protocol\ClientCacheMissResponsePacket\create
static create(array $blobs)
Definition
ClientCacheMissResponsePacket.php:35
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:23
pocketmine\network\mcpe\protocol\serializer\CommonTypes
Definition
CommonTypes.php:70
pocketmine\network\mcpe\protocol\types\ChunkCacheBlob
Definition
ChunkCacheBlob.php:17
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
ClientCacheMissResponsePacket.php
Generated by
1.12.0