mirror of
https://github.com/pmmp/BedrockProtocol.git
synced 2025-08-25 04:52:38 +00:00
58 lines
1.7 KiB
PHP
58 lines
1.7 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;
|
|
|
|
class LecternUpdatePacket extends DataPacket implements ServerboundPacket{
|
|
public const NETWORK_ID = ProtocolInfo::LECTERN_UPDATE_PACKET;
|
|
|
|
public int $page;
|
|
public int $totalPages;
|
|
public BlockPosition $blockPosition;
|
|
public bool $dropBook;
|
|
|
|
/**
|
|
* @generate-create-func
|
|
*/
|
|
public static function create(int $page, int $totalPages, BlockPosition $blockPosition, bool $dropBook) : self{
|
|
$result = new self;
|
|
$result->page = $page;
|
|
$result->totalPages = $totalPages;
|
|
$result->blockPosition = $blockPosition;
|
|
$result->dropBook = $dropBook;
|
|
return $result;
|
|
}
|
|
|
|
protected function decodePayload(PacketSerializer $in) : void{
|
|
$this->page = $in->getByte();
|
|
$this->totalPages = $in->getByte();
|
|
$this->blockPosition = $in->getBlockPosition();
|
|
$this->dropBook = $in->getBool();
|
|
}
|
|
|
|
protected function encodePayload(PacketSerializer $out) : void{
|
|
$out->putByte($this->page);
|
|
$out->putByte($this->totalPages);
|
|
$out->putBlockPosition($this->blockPosition);
|
|
$out->putBool($this->dropBook);
|
|
}
|
|
|
|
public function handle(PacketHandlerInterface $handler) : bool{
|
|
return $handler->handleLecternUpdate($this);
|
|
}
|
|
}
|