PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
CameraAimAssistPreset.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
18use function count;
19
21
27 public function __construct(
28 private string $identifier,
29 private string $categories,
30 private array $exclusionList,
31 private array $liquidTargetingList,
32 private array $itemSettings,
33 private ?string $defaultItemSettings,
34 private ?string $defaultHandSettings,
35 ){}
36
37 public function getIdentifier() : string{ return $this->identifier; }
38
39 public function getCategories() : string{ return $this->categories; }
40
44 public function getExclusionList() : array{ return $this->exclusionList; }
45
49 public function getLiquidTargetingList() : array{ return $this->liquidTargetingList; }
50
54 public function getItemSettings() : array{ return $this->itemSettings; }
55
56 public function getDefaultItemSettings() : ?string{ return $this->defaultItemSettings; }
57
58 public function getDefaultHandSettings() : ?string{ return $this->defaultHandSettings; }
59
60 public static function read(PacketSerializer $in) : self{
61 $identifier = $in->getString();
62 $categories = $in->getString();
63
64 $exclusionList = [];
65 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
66 $exclusionList[] = $in->getString();
67 }
68
69 $liquidTargetingList = [];
70 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
71 $liquidTargetingList[] = $in->getString();
72 }
73
74 $itemSettings = [];
75 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
76 $itemSettings[] = CameraAimAssistPresetItemSettings::read($in);
77 }
78
79 $defaultItemSettings = $in->readOptional(fn() => $in->getString());
80 $defaultHandSettings = $in->readOptional(fn() => $in->getString());
81
82 return new self(
83 $identifier,
84 $categories,
85 $exclusionList,
86 $liquidTargetingList,
87 $itemSettings,
88 $defaultItemSettings,
89 $defaultHandSettings
90 );
91 }
92
93 public function write(PacketSerializer $out) : void{
94 $out->putString($this->identifier);
95 $out->putString($this->categories);
96
97 $out->putUnsignedVarInt(count($this->exclusionList));
98 foreach($this->exclusionList as $exclusion){
99 $out->putString($exclusion);
100 }
101
102 $out->putUnsignedVarInt(count($this->liquidTargetingList));
103 foreach($this->liquidTargetingList as $liquidTargeting){
104 $out->putString($liquidTargeting);
105 }
106
107 $out->putUnsignedVarInt(count($this->itemSettings));
108 foreach($this->itemSettings as $itemSetting){
109 $itemSetting->write($out);
110 }
111
112 $out->writeOptional($this->defaultItemSettings, fn(string $v) => $out->putString($v));
113 $out->writeOptional($this->defaultHandSettings, fn(string $v) => $out->putString($v));
114 }
115}
__construct(private string $identifier, private string $categories, private array $exclusionList, private array $liquidTargetingList, private array $itemSettings, private ?string $defaultItemSettings, private ?string $defaultHandSettings,)