PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
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
35 public static function create(array $categories, array $presets) : self{
36 $result = new self;
37 $result->categories = $categories;
38 $result->presets = $presets;
39 return $result;
40 }
41
45 public function getCategories() : array{ return $this->categories; }
46
50 public function getPresets() : array{ return $this->presets; }
51
52 protected function decodePayload(PacketSerializer $in) : void{
53 $this->categories = [];
54 for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
55 $this->categories[] = CameraAimAssistCategories::read($in);
56 }
57
58 $this->presets = [];
59 for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
60 $this->presets[] = CameraAimAssistPreset::read($in);
61 }
62 }
63
64 protected function encodePayload(PacketSerializer $out) : void{
65 $out->putUnsignedVarInt(count($this->categories));
66 foreach($this->categories as $category){
67 $category->write($out);
68 }
69
70 $out->putUnsignedVarInt(count($this->presets));
71 foreach($this->presets as $preset){
72 $preset->write($out);
73 }
74 }
75
76 public function handle(PacketHandlerInterface $handler) : bool{
77 return $handler->handleCameraAimAssistPresets($this);
78 }
79}