PocketMine-MP 5.17.1 git-df4ada81e5d74a14046f27cf44a37dcee69d657e
CameraSetInstruction.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\types\camera;
16
19
21
22 public function __construct(
23 private int $preset,
24 private ?CameraSetInstructionEase $ease,
25 private ?Vector3 $cameraPosition,
26 private ?CameraSetInstructionRotation $rotation,
27 private ?Vector3 $facingPosition,
28 private ?bool $default
29 ){}
30
31 public function getPreset() : int{ return $this->preset; }
32
33 public function getEase() : ?CameraSetInstructionEase{ return $this->ease; }
34
35 public function getCameraPosition() : ?Vector3{ return $this->cameraPosition; }
36
37 public function getRotation() : ?CameraSetInstructionRotation{ return $this->rotation; }
38
39 public function getFacingPosition() : ?Vector3{ return $this->facingPosition; }
40
41 public function getDefault() : ?bool{ return $this->default; }
42
43 public static function read(PacketSerializer $in) : self{
44 $preset = $in->getLInt();
45 $ease = $in->readOptional(fn() => CameraSetInstructionEase::read($in));
46 $cameraPosition = $in->readOptional($in->getVector3(...));
47 $rotation = $in->readOptional(fn() => CameraSetInstructionRotation::read($in));
48 $facingPosition = $in->readOptional($in->getVector3(...));
49 $default = $in->readOptional($in->getBool(...));
50
51 return new self(
52 $preset,
53 $ease,
54 $cameraPosition,
55 $rotation,
56 $facingPosition,
57 $default
58 );
59 }
60
61 public function write(PacketSerializer $out) : void{
62 $out->putLInt($this->preset);
63 $out->writeOptional($this->ease, fn(CameraSetInstructionEase $v) => $v->write($out));
64 $out->writeOptional($this->cameraPosition, $out->putVector3(...));
65 $out->writeOptional($this->rotation, fn(CameraSetInstructionRotation $v) => $v->write($out));
66 $out->writeOptional($this->facingPosition, $out->putVector3(...));
67 $out->writeOptional($this->default, $out->putBool(...));
68 }
69}