PocketMine-MP 5.25.1 git-694aa17cc916a954b10fe12721c81b1dc73eecd5
Loading...
Searching...
No Matches
CameraAimAssistInstructionPacket.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
18use pocketmine\network\mcpe\protocol\types\camera\CameraAimAssistActionType;
19
21 public const NETWORK_ID = ProtocolInfo::CAMERA_AIM_ASSIST_INSTRUCTION_PACKET;
22
23 private string $presetId;
24 private CameraAimAssistActionType $actionType;
25 private bool $allowAimAssist;
26
30 public static function create(string $presetId, CameraAimAssistActionType $actionType, bool $allowAimAssist) : self{
31 $result = new self;
32 $result->presetId = $presetId;
33 $result->actionType = $actionType;
34 $result->allowAimAssist = $allowAimAssist;
35 return $result;
36 }
37
38 public function getPresetId() : string{ return $this->presetId; }
39
40 public function getActionType() : CameraAimAssistActionType{ return $this->actionType; }
41
42 public function getAllowAimAssist() : bool{ return $this->allowAimAssist; }
43
44 protected function decodePayload(PacketSerializer $in) : void{
45 $this->presetId = $in->getString();
46 $this->actionType = CameraAimAssistActionType::fromPacket($in->getByte());
47 $this->allowAimAssist = $in->getBool();
48 }
49
50 protected function encodePayload(PacketSerializer $out) : void{
51 $out->putString($this->presetId);
52 $out->putByte($this->actionType->value);
53 $out->putBool($this->allowAimAssist);
54 }
55
56 public function handle(PacketHandlerInterface $handler) : bool{
57 return $handler->handleCameraAimAssistInstruction($this);
58 }
59}
static create(string $presetId, CameraAimAssistActionType $actionType, bool $allowAimAssist)