PocketMine-MP 5.25.1 git-694aa17cc916a954b10fe12721c81b1dc73eecd5
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 array $exclusionList,
30 private array $liquidTargetingList,
31 private array $itemSettings,
32 private ?string $defaultItemSettings,
33 private ?string $defaultHandSettings,
34 ){}
35
36 public function getIdentifier() : string{ return $this->identifier; }
37
41 public function getExclusionList() : array{ return $this->exclusionList; }
42
46 public function getLiquidTargetingList() : array{ return $this->liquidTargetingList; }
47
51 public function getItemSettings() : array{ return $this->itemSettings; }
52
53 public function getDefaultItemSettings() : ?string{ return $this->defaultItemSettings; }
54
55 public function getDefaultHandSettings() : ?string{ return $this->defaultHandSettings; }
56
57 public static function read(PacketSerializer $in) : self{
58 $identifier = $in->getString();
59
60 $exclusionList = [];
61 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
62 $exclusionList[] = $in->getString();
63 }
64
65 $liquidTargetingList = [];
66 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
67 $liquidTargetingList[] = $in->getString();
68 }
69
70 $itemSettings = [];
71 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
72 $itemSettings[] = CameraAimAssistPresetItemSettings::read($in);
73 }
74
75 $defaultItemSettings = $in->readOptional(fn() => $in->getString());
76 $defaultHandSettings = $in->readOptional(fn() => $in->getString());
77
78 return new self(
79 $identifier,
80 $exclusionList,
81 $liquidTargetingList,
82 $itemSettings,
83 $defaultItemSettings,
84 $defaultHandSettings
85 );
86 }
87
88 public function write(PacketSerializer $out) : void{
89 $out->putString($this->identifier);
90
91 $out->putUnsignedVarInt(count($this->exclusionList));
92 foreach($this->exclusionList as $exclusion){
93 $out->putString($exclusion);
94 }
95
96 $out->putUnsignedVarInt(count($this->liquidTargetingList));
97 foreach($this->liquidTargetingList as $liquidTargeting){
98 $out->putString($liquidTargeting);
99 }
100
101 $out->putUnsignedVarInt(count($this->itemSettings));
102 foreach($this->itemSettings as $itemSetting){
103 $itemSetting->write($out);
104 }
105
106 $out->writeOptional($this->defaultItemSettings, fn(string $v) => $out->putString($v));
107 $out->writeOptional($this->defaultHandSettings, fn(string $v) => $out->putString($v));
108 }
109}
__construct(private string $identifier, private array $exclusionList, private array $liquidTargetingList, private array $itemSettings, private ?string $defaultItemSettings, private ?string $defaultHandSettings,)