PocketMine-MP
5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
StructureTemplateDataResponsePacket.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
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
;
18
use
pocketmine\network\mcpe\protocol\types\CacheableNbt
;
19
20
class
StructureTemplateDataResponsePacket
extends
DataPacket
implements
ClientboundPacket
{
21
public
const
NETWORK_ID = ProtocolInfo::STRUCTURE_TEMPLATE_DATA_RESPONSE_PACKET;
22
23
public
const
TYPE_FAILURE = 0;
24
public
const
TYPE_EXPORT = 1;
25
public
const
TYPE_QUERY = 2;
26
27
public
string
$structureTemplateName;
29
public
?
CacheableNbt
$nbt
;
30
public
int
$responseType;
31
36
public
static
function
create
(
string
$structureTemplateName, ?
CacheableNbt
$nbt
,
int
$responseType) : self{
37
$result = new self;
38
$result->structureTemplateName = $structureTemplateName;
39
$result->nbt =
$nbt
;
40
$result->responseType = $responseType;
41
return
$result;
42
}
43
44
protected
function
decodePayload
(
PacketSerializer
$in) : void{
45
$this->structureTemplateName = $in->getString();
46
if
($in->
getBool
()){
47
$this->nbt = new CacheableNbt($in->getNbtCompoundRoot());
48
}
49
$this->responseType = $in->
getByte
();
50
}
51
52
protected
function
encodePayload
(
PacketSerializer
$out) : void{
53
$out->putString($this->structureTemplateName);
54
$out->putBool($this->nbt !==
null
);
55
if
($this->nbt !==
null
){
56
$out->put($this->nbt->getEncodedNbt());
57
}
58
$out->putByte($this->responseType);
59
}
60
61
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
62
return $handler->handleStructureTemplateDataResponse($this);
63
}
64
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\StructureTemplateDataResponsePacket
Definition
StructureTemplateDataResponsePacket.php:20
pocketmine\network\mcpe\protocol\StructureTemplateDataResponsePacket\handle
handle(PacketHandlerInterface $handler)
Definition
StructureTemplateDataResponsePacket.php:61
pocketmine\network\mcpe\protocol\StructureTemplateDataResponsePacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
StructureTemplateDataResponsePacket.php:44
pocketmine\network\mcpe\protocol\StructureTemplateDataResponsePacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
StructureTemplateDataResponsePacket.php:52
pocketmine\network\mcpe\protocol\StructureTemplateDataResponsePacket\create
static create(string $structureTemplateName, ?CacheableNbt $nbt, int $responseType)
Definition
StructureTemplateDataResponsePacket.php:36
pocketmine\network\mcpe\protocol\StructureTemplateDataResponsePacket\$nbt
CacheableNbt $nbt
Definition
StructureTemplateDataResponsePacket.php:29
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\network\mcpe\protocol\types\CacheableNbt
Definition
CacheableNbt.php:24
pocketmine\utils\BinaryStream\getBool
getBool()
Definition
BinaryStream.php:105
pocketmine\utils\BinaryStream\getByte
getByte()
Definition
BinaryStream.php:117
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
StructureTemplateDataResponsePacket.php
Generated by
1.12.0