PocketMine-MP 5.32.2 git-1ebd7d3960d713d56f77f610fe0c15cdee201069
Loading...
Searching...
No Matches
CameraInstructionPacket.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
22
24 public const NETWORK_ID = ProtocolInfo::CAMERA_INSTRUCTION_PACKET;
25
26 private ?CameraSetInstruction $set;
27 private ?bool $clear;
28 private ?CameraFadeInstruction $fade;
29 private ?CameraTargetInstruction $target;
30 private ?bool $removeTarget;
31 private ?CameraFovInstruction $fieldOfView;
32
36 public static function create(?CameraSetInstruction $set, ?bool $clear, ?CameraFadeInstruction $fade, ?CameraTargetInstruction $target, ?bool $removeTarget, ?CameraFovInstruction $fieldOfView) : self{
37 $result = new self;
38 $result->set = $set;
39 $result->clear = $clear;
40 $result->fade = $fade;
41 $result->target = $target;
42 $result->removeTarget = $removeTarget;
43 $result->fieldOfView = $fieldOfView;
44 return $result;
45 }
46
47 public function getSet() : ?CameraSetInstruction{ return $this->set; }
48
49 public function getClear() : ?bool{ return $this->clear; }
50
51 public function getFade() : ?CameraFadeInstruction{ return $this->fade; }
52
53 public function getTarget() : ?CameraTargetInstruction{ return $this->target; }
54
55 public function getRemoveTarget() : ?bool{ return $this->removeTarget; }
56
57 public function getFieldOfView() : ?CameraFovInstruction{ return $this->fieldOfView; }
58
59 protected function decodePayload(PacketSerializer $in) : void{
60 $this->set = $in->readOptional(fn() => CameraSetInstruction::read($in));
61 $this->clear = $in->readOptional($in->getBool(...));
62 $this->fade = $in->readOptional(fn() => CameraFadeInstruction::read($in));
63 $this->target = $in->readOptional(fn() => CameraTargetInstruction::read($in));
64 $this->removeTarget = $in->readOptional($in->getBool(...));
65 $this->fieldOfView = $in->readOptional(fn() => CameraFovInstruction::read($in));
66 }
67
68 protected function encodePayload(PacketSerializer $out) : void{
69 $out->writeOptional($this->set, fn(CameraSetInstruction $v) => $v->write($out));
70 $out->writeOptional($this->clear, $out->putBool(...));
71 $out->writeOptional($this->fade, fn(CameraFadeInstruction $v) => $v->write($out));
72 $out->writeOptional($this->target, fn(CameraTargetInstruction $v) => $v->write($out));
73 $out->writeOptional($this->removeTarget, $out->putBool(...));
74 $out->writeOptional($this->fieldOfView, fn(CameraFovInstruction $v) => $v->write($out));
75 }
76
77 public function handle(PacketHandlerInterface $handler) : bool{
78 return $handler->handleCameraInstruction($this);
79 }
80}
static create(?CameraSetInstruction $set, ?bool $clear, ?CameraFadeInstruction $fade, ?CameraTargetInstruction $target, ?bool $removeTarget, ?CameraFovInstruction $fieldOfView)