0
0
mirror of https://github.com/pmmp/BedrockProtocol.git synced 2025-08-10 09:01:36 +00:00
Files
BedrockProtocol/src/StructureBlockUpdatePacket.php
2022-09-20 19:33:22 +01:00

59 lines
1.9 KiB
PHP

<?php
/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\BlockPosition;
use pocketmine\network\mcpe\protocol\types\StructureEditorData;
class StructureBlockUpdatePacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::STRUCTURE_BLOCK_UPDATE_PACKET;
public BlockPosition $blockPosition;
public StructureEditorData $structureEditorData;
public bool $isPowered;
public bool $waterlogged;
/**
* @generate-create-func
*/
public static function create(BlockPosition $blockPosition, StructureEditorData $structureEditorData, bool $isPowered, bool $waterlogged) : self{
$result = new self;
$result->blockPosition = $blockPosition;
$result->structureEditorData = $structureEditorData;
$result->isPowered = $isPowered;
$result->waterlogged = $waterlogged;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->blockPosition = $in->getBlockPosition();
$this->structureEditorData = $in->getStructureEditorData();
$this->isPowered = $in->getBool();
$this->waterlogged = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putBlockPosition($this->blockPosition);
$out->putStructureEditorData($this->structureEditorData);
$out->putBool($this->isPowered);
$out->putBool($this->waterlogged);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleStructureBlockUpdate($this);
}
}