PocketMine-MP
5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
ResourcePackClientResponsePacket.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\Byte;
18
use pmmp\encoding\ByteBufferReader;
19
use pmmp\encoding\ByteBufferWriter;
20
use pmmp\encoding\LE;
21
use
pocketmine\network\mcpe\protocol\serializer\CommonTypes
;
22
use
function
count;
23
24
class
ResourcePackClientResponsePacket
extends
DataPacket
implements
ServerboundPacket
{
25
public
const
NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CLIENT_RESPONSE_PACKET;
26
27
public
const
STATUS_REFUSED = 1;
28
public
const
STATUS_SEND_PACKS = 2;
29
public
const
STATUS_HAVE_ALL_PACKS = 3;
30
public
const
STATUS_COMPLETED = 4;
31
32
public
int
$status;
34
public
array $packIds = [];
35
40
public
static
function
create
(
int
$status, array $packIds) : self{
41
$result = new self;
42
$result->status = $status;
43
$result->packIds = $packIds;
44
return
$result;
45
}
46
47
protected
function
decodePayload
(ByteBufferReader $in) : void{
48
$this->status = Byte::readUnsigned($in);
49
$entryCount = LE::readUnsignedShort($in);
50
$this->packIds = [];
51
while
($entryCount-- > 0){
52
$this->packIds[] = CommonTypes::getString($in);
53
}
54
}
55
56
protected
function
encodePayload
(ByteBufferWriter $out) : void{
57
Byte::writeUnsigned($out, $this->status);
58
LE::writeUnsignedShort($out, count($this->packIds));
59
foreach
($this->packIds as $id){
60
CommonTypes::putString($out, $id);
61
}
62
}
63
64
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
65
return $handler->handleResourcePackClientResponse($this);
66
}
67
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:23
pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket
Definition
ResourcePackClientResponsePacket.php:24
pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket\decodePayload
decodePayload(ByteBufferReader $in)
Definition
ResourcePackClientResponsePacket.php:47
pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket\encodePayload
encodePayload(ByteBufferWriter $out)
Definition
ResourcePackClientResponsePacket.php:56
pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket\handle
handle(PacketHandlerInterface $handler)
Definition
ResourcePackClientResponsePacket.php:64
pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket\create
static create(int $status, array $packIds)
Definition
ResourcePackClientResponsePacket.php:40
pocketmine\network\mcpe\protocol\serializer\CommonTypes
Definition
CommonTypes.php:70
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
pocketmine\network\mcpe\protocol\ServerboundPacket
Definition
ServerboundPacket.php:17
vendor
pocketmine
bedrock-protocol
src
ResourcePackClientResponsePacket.php
Generated by
1.12.0