PocketMine-MP 5.25.1 git-694aa17cc916a954b10fe12721c81b1dc73eecd5
Loading...
Searching...
No Matches
CameraAimAssistPresetsPacket.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
20use function count;
21
23 public const NETWORK_ID = ProtocolInfo::CAMERA_AIM_ASSIST_PRESETS_PACKET;
24
26 private array $categories;
28 private array $presets;
29 private int $operation;
30
36 public static function create(array $categories, array $presets, int $operation) : self{
37 $result = new self;
38 $result->categories = $categories;
39 $result->presets = $presets;
40 $result->operation = $operation;
41 return $result;
42 }
43
47 public function getCategories() : array{ return $this->categories; }
48
52 public function getPresets() : array{ return $this->presets; }
53
54 public function getOperation() : int{ return $this->operation; }
55
56 protected function decodePayload(PacketSerializer $in) : void{
57 $this->categories = [];
58 for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
59 $this->categories[] = CameraAimAssistCategories::read($in);
60 }
61
62 $this->presets = [];
63 for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
64 $this->presets[] = CameraAimAssistPreset::read($in);
65 }
66
67 $this->operation = $in->getByte();
68 }
69
70 protected function encodePayload(PacketSerializer $out) : void{
71 $out->putUnsignedVarInt(count($this->categories));
72 foreach($this->categories as $category){
73 $category->write($out);
74 }
75
76 $out->putUnsignedVarInt(count($this->presets));
77 foreach($this->presets as $preset){
78 $preset->write($out);
79 }
80
81 $out->putByte($this->operation);
82 }
83
84 public function handle(PacketHandlerInterface $handler) : bool{
85 return $handler->handleCameraAimAssistPresets($this);
86 }
87}
static create(array $categories, array $presets, int $operation)