PocketMine-MP 5.42.2 git-40e2639b20bdc4ddba49d9f7f5fa0d5e92aa266f
Loading...
Searching...
No Matches
CameraRotationOption.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
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
19use pmmp\encoding\LE;
22use function is_int;
23
25
27 private string $easeType;
28
29 public function __construct(
30 private Vector3 $value,
31 private float $time,
32 int|string $easeType,
33 ){
34 $this->easeType = is_int($easeType) ? CameraSetInstructionEaseType::toName($easeType) : $easeType;
35 }
36
37 public function getValue() : Vector3{ return $this->value; }
38
39 public function getTime() : float{ return $this->time; }
40
44 public function getEaseType() : string{ return $this->easeType; }
45
46 public static function read(ByteBufferReader $in) : self{
47 $value = CommonTypes::getVector3($in);
48 $time = LE::readFloat($in);
49 $ease = CommonTypes::getString($in);
50
51 return new self(
52 $value,
53 $time,
54 $ease
55 );
56 }
57
58 public function write(ByteBufferWriter $out) : void{
59 CommonTypes::putVector3($out, $this->value);
60 LE::writeFloat($out, $this->time);
61 CommonTypes::putString($out, $this->easeType);
62 }
63}