PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
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
20
22
23 public function __construct(
24 private int $preset,
25 private ?CameraSetInstructionEase $ease,
26 private ?Vector3 $cameraPosition,
27 private ?CameraSetInstructionRotation $rotation,
28 private ?Vector3 $facingPosition,
29 private ?Vector2 $viewOffset,
30 private ?Vector3 $entityOffset,
31 private ?bool $default
32 ){}
33
34 public function getPreset() : int{ return $this->preset; }
35
36 public function getEase() : ?CameraSetInstructionEase{ return $this->ease; }
37
38 public function getCameraPosition() : ?Vector3{ return $this->cameraPosition; }
39
40 public function getRotation() : ?CameraSetInstructionRotation{ return $this->rotation; }
41
42 public function getFacingPosition() : ?Vector3{ return $this->facingPosition; }
43
44 public function getViewOffset() : ?Vector2{ return $this->viewOffset; }
45
46 public function getEntityOffset() : ?Vector3{ return $this->entityOffset; }
47
48 public function getDefault() : ?bool{ return $this->default; }
49
50 public static function read(PacketSerializer $in) : self{
51 $preset = $in->getLInt();
52 $ease = $in->readOptional(fn() => CameraSetInstructionEase::read($in));
53 $cameraPosition = $in->readOptional($in->getVector3(...));
54 $rotation = $in->readOptional(fn() => CameraSetInstructionRotation::read($in));
55 $facingPosition = $in->readOptional($in->getVector3(...));
56 $viewOffset = $in->readOptional($in->getVector2(...));
57 $entityOffset = $in->readOptional($in->getVector3(...));
58 $default = $in->readOptional($in->getBool(...));
59
60 return new self(
61 $preset,
62 $ease,
63 $cameraPosition,
64 $rotation,
65 $facingPosition,
66 $viewOffset,
67 $entityOffset,
68 $default
69 );
70 }
71
72 public function write(PacketSerializer $out) : void{
73 $out->putLInt($this->preset);
74 $out->writeOptional($this->ease, fn(CameraSetInstructionEase $v) => $v->write($out));
75 $out->writeOptional($this->cameraPosition, $out->putVector3(...));
76 $out->writeOptional($this->rotation, fn(CameraSetInstructionRotation $v) => $v->write($out));
77 $out->writeOptional($this->facingPosition, $out->putVector3(...));
78 $out->writeOptional($this->viewOffset, $out->putVector2(...));
79 $out->writeOptional($this->entityOffset, $out->putVector3(...));
80 $out->writeOptional($this->default, $out->putBool(...));
81 }
82}