PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
Loading...
Searching...
No Matches
CameraShakePacket.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
18
20 public const NETWORK_ID = ProtocolInfo::CAMERA_SHAKE_PACKET;
21
22 public const TYPE_POSITIONAL = 0;
23 public const TYPE_ROTATIONAL = 1;
24
25 public const ACTION_ADD = 0;
26 public const ACTION_STOP = 1;
27
28 private float $intensity;
29 private float $duration;
30 private int $shakeType;
31 private int $shakeAction;
32
36 public static function create(float $intensity, float $duration, int $shakeType, int $shakeAction) : self{
37 $result = new self;
38 $result->intensity = $intensity;
39 $result->duration = $duration;
40 $result->shakeType = $shakeType;
41 $result->shakeAction = $shakeAction;
42 return $result;
43 }
44
45 public function getIntensity() : float{ return $this->intensity; }
46
47 public function getDuration() : float{ return $this->duration; }
48
49 public function getShakeType() : int{ return $this->shakeType; }
50
51 public function getShakeAction() : int{ return $this->shakeAction; }
52
53 protected function decodePayload(PacketSerializer $in) : void{
54 $this->intensity = $in->getLFloat();
55 $this->duration = $in->getLFloat();
56 $this->shakeType = $in->getByte();
57 $this->shakeAction = $in->getByte();
58 }
59
60 protected function encodePayload(PacketSerializer $out) : void{
61 $out->putLFloat($this->intensity);
62 $out->putLFloat($this->duration);
63 $out->putByte($this->shakeType);
64 $out->putByte($this->shakeAction);
65 }
66
67 public function handle(PacketHandlerInterface $handler) : bool{
68 return $handler->handleCameraShake($this);
69 }
70}
static create(float $intensity, float $duration, int $shakeType, int $shakeAction)