PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
StructureBlockUpdatePacket.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_BLOCK_UPDATE_PACKET;
23
24 public BlockPosition $blockPosition;
25 public StructureEditorData $structureEditorData;
26 public bool $isPowered;
27 public bool $waterlogged;
28
32 public static function create(BlockPosition $blockPosition, StructureEditorData $structureEditorData, bool $isPowered, bool $waterlogged) : self{
33 $result = new self;
34 $result->blockPosition = $blockPosition;
35 $result->structureEditorData = $structureEditorData;
36 $result->isPowered = $isPowered;
37 $result->waterlogged = $waterlogged;
38 return $result;
39 }
40
41 protected function decodePayload(PacketSerializer $in) : void{
42 $this->blockPosition = $in->getBlockPosition();
43 $this->structureEditorData = $in->getStructureEditorData();
44 $this->isPowered = $in->getBool();
45 $this->waterlogged = $in->getBool();
46 }
47
48 protected function encodePayload(PacketSerializer $out) : void{
49 $out->putBlockPosition($this->blockPosition);
50 $out->putStructureEditorData($this->structureEditorData);
51 $out->putBool($this->isPowered);
52 $out->putBool($this->waterlogged);
53 }
54
55 public function handle(PacketHandlerInterface $handler) : bool{
56 return $handler->handleStructureBlockUpdate($this);
57 }
58}
static create(BlockPosition $blockPosition, StructureEditorData $structureEditorData, bool $isPowered, bool $waterlogged)