mirror of
https://github.com/pmmp/BedrockProtocol.git
synced 2025-08-06 15:21:39 +00:00
61 lines
2.1 KiB
PHP
61 lines
2.1 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\camera\CameraFadeInstruction;
|
|
use pocketmine\network\mcpe\protocol\types\camera\CameraSetInstruction;
|
|
|
|
class CameraInstructionPacket extends DataPacket implements ClientboundPacket{
|
|
public const NETWORK_ID = ProtocolInfo::CAMERA_INSTRUCTION_PACKET;
|
|
|
|
private ?CameraSetInstruction $set;
|
|
private ?bool $clear;
|
|
private ?CameraFadeInstruction $fade;
|
|
|
|
/**
|
|
* @generate-create-func
|
|
*/
|
|
public static function create(?CameraSetInstruction $set, ?bool $clear, ?CameraFadeInstruction $fade) : self{
|
|
$result = new self;
|
|
$result->set = $set;
|
|
$result->clear = $clear;
|
|
$result->fade = $fade;
|
|
return $result;
|
|
}
|
|
|
|
public function getSet() : ?CameraSetInstruction{ return $this->set; }
|
|
|
|
public function getClear() : ?bool{ return $this->clear; }
|
|
|
|
public function getFade() : ?CameraFadeInstruction{ return $this->fade; }
|
|
|
|
protected function decodePayload(PacketSerializer $in) : void{
|
|
$this->set = $in->readOptional(fn() => CameraSetInstruction::read($in));
|
|
$this->clear = $in->readOptional($in->getBool(...));
|
|
$this->fade = $in->readOptional(fn() => CameraFadeInstruction::read($in));
|
|
}
|
|
|
|
protected function encodePayload(PacketSerializer $out) : void{
|
|
$out->writeOptional($this->set, fn(CameraSetInstruction $v) => $v->write($out));
|
|
$out->writeOptional($this->clear, $out->putBool(...));
|
|
$out->writeOptional($this->fade, fn(CameraFadeInstruction $v) => $v->write($out));
|
|
}
|
|
|
|
public function handle(PacketHandlerInterface $handler) : bool{
|
|
return $handler->handleCameraInstruction($this);
|
|
}
|
|
}
|