PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
StructureTemplateDataRequestPacket.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
20
22 public const NETWORK_ID = ProtocolInfo::STRUCTURE_TEMPLATE_DATA_REQUEST_PACKET;
23
24 public const TYPE_EXPORT_FROM_SAVE_MODE = 1;
25 public const TYPE_EXPORT_FROM_LOAD_MODE = 2;
26 public const TYPE_QUERY_SAVED_STRUCTURE = 3;
27
28 public string $structureTemplateName;
29 public BlockPosition $structureBlockPosition;
30 public StructureSettings $structureSettings;
31 public int $requestType;
32
36 public static function create(string $structureTemplateName, BlockPosition $structureBlockPosition, StructureSettings $structureSettings, int $requestType) : self{
37 $result = new self;
38 $result->structureTemplateName = $structureTemplateName;
39 $result->structureBlockPosition = $structureBlockPosition;
40 $result->structureSettings = $structureSettings;
41 $result->requestType = $requestType;
42 return $result;
43 }
44
45 protected function decodePayload(PacketSerializer $in) : void{
46 $this->structureTemplateName = $in->getString();
47 $this->structureBlockPosition = $in->getBlockPosition();
48 $this->structureSettings = $in->getStructureSettings();
49 $this->requestType = $in->getByte();
50 }
51
52 protected function encodePayload(PacketSerializer $out) : void{
53 $out->putString($this->structureTemplateName);
54 $out->putBlockPosition($this->structureBlockPosition);
55 $out->putStructureSettings($this->structureSettings);
56 $out->putByte($this->requestType);
57 }
58
59 public function handle(PacketHandlerInterface $handler) : bool{
60 return $handler->handleStructureTemplateDataRequest($this);
61 }
62}
static create(string $structureTemplateName, BlockPosition $structureBlockPosition, StructureSettings $structureSettings, int $requestType)