PocketMine-MP 5.30.2 git-98f04176111e5ecab5e8814ffc69d992bfb64939
Loading...
Searching...
No Matches
LevelSettings.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;
16
21
22final class LevelSettings{
23
24 public int $seed;
25 public SpawnSettings $spawnSettings;
26 public int $generator = GeneratorType::OVERWORLD;
27 public int $worldGamemode;
28 public bool $hardcore = false;
29 public int $difficulty;
30 public BlockPosition $spawnPosition;
31 public bool $hasAchievementsDisabled = true;
32 public int $editorWorldType = EditorWorldType::NON_EDITOR;
33 public bool $createdInEditorMode = false;
34 public bool $exportedFromEditorMode = false;
35 public int $time = -1;
36 public int $eduEditionOffer = EducationEditionOffer::NONE;
37 public bool $hasEduFeaturesEnabled = false;
38 public string $eduProductUUID = "";
39 public float $rainLevel;
40 public float $lightningLevel;
41 public bool $hasConfirmedPlatformLockedContent = false;
42 public bool $isMultiplayerGame = true;
43 public bool $hasLANBroadcast = true;
44 public int $xboxLiveBroadcastMode = MultiplayerGameVisibility::PUBLIC;
45 public int $platformBroadcastMode = MultiplayerGameVisibility::PUBLIC;
46 public bool $commandsEnabled;
47 public bool $isTexturePacksRequired = true;
52 public array $gameRules = [];
53 public Experiments $experiments;
54 public bool $hasBonusChestEnabled = false;
55 public bool $hasStartWithMapEnabled = false;
56 public int $defaultPlayerPermission = PlayerPermissions::MEMBER; //TODO
57
58 public int $serverChunkTickRadius = 4; //TODO (leave as default for now)
59
60 public bool $hasLockedBehaviorPack = false;
61 public bool $hasLockedResourcePack = false;
62 public bool $isFromLockedWorldTemplate = false;
63 public bool $useMsaGamertagsOnly = false;
64 public bool $isFromWorldTemplate = false;
65 public bool $isWorldTemplateOptionLocked = false;
66 public bool $onlySpawnV1Villagers = false;
67 public bool $disablePersona = false;
68 public bool $disableCustomSkins = false;
69 public bool $muteEmoteAnnouncements = false;
70 public string $vanillaVersion = ProtocolInfo::MINECRAFT_VERSION_NETWORK;
71 public int $limitedWorldWidth = 0;
72 public int $limitedWorldLength = 0;
73 public bool $isNewNether = true;
74 public ?EducationUriResource $eduSharedUriResource = null;
75 public ?bool $experimentalGameplayOverride = null;
76 public int $chatRestrictionLevel = ChatRestrictionLevel::NONE;
77 public bool $disablePlayerInteractions = false;
78
79 public string $serverIdentifier = "";
80 public string $worldIdentifier = "";
81 public string $scenarioIdentifier = "";
82 public string $ownerIdentifier = "";
83
88 public static function read(PacketSerializer $in) : self{
89 //TODO: in the future we'll use promoted properties + named arguments for decoding, but for now we stick with
90 //this shitty way to limit BC breaks (needs more R&D)
91 $result = new self;
92 $result->internalRead($in);
93 return $result;
94 }
95
100 private function internalRead(PacketSerializer $in) : void{
101 $this->seed = $in->getLLong();
102 $this->spawnSettings = SpawnSettings::read($in);
103 $this->generator = $in->getVarInt();
104 $this->worldGamemode = $in->getVarInt();
105 $this->hardcore = $in->getBool();
106 $this->difficulty = $in->getVarInt();
107 $this->spawnPosition = $in->getBlockPosition();
108 $this->hasAchievementsDisabled = $in->getBool();
109 $this->editorWorldType = $in->getVarInt();
110 $this->createdInEditorMode = $in->getBool();
111 $this->exportedFromEditorMode = $in->getBool();
112 $this->time = $in->getVarInt();
113 $this->eduEditionOffer = $in->getVarInt();
114 $this->hasEduFeaturesEnabled = $in->getBool();
115 $this->eduProductUUID = $in->getString();
116 $this->rainLevel = $in->getLFloat();
117 $this->lightningLevel = $in->getLFloat();
118 $this->hasConfirmedPlatformLockedContent = $in->getBool();
119 $this->isMultiplayerGame = $in->getBool();
120 $this->hasLANBroadcast = $in->getBool();
121 $this->xboxLiveBroadcastMode = $in->getVarInt();
122 $this->platformBroadcastMode = $in->getVarInt();
123 $this->commandsEnabled = $in->getBool();
124 $this->isTexturePacksRequired = $in->getBool();
125 $this->gameRules = $in->getGameRules();
126 $this->experiments = Experiments::read($in);
127 $this->hasBonusChestEnabled = $in->getBool();
128 $this->hasStartWithMapEnabled = $in->getBool();
129 $this->defaultPlayerPermission = $in->getVarInt();
130 $this->serverChunkTickRadius = $in->getLInt();
131 $this->hasLockedBehaviorPack = $in->getBool();
132 $this->hasLockedResourcePack = $in->getBool();
133 $this->isFromLockedWorldTemplate = $in->getBool();
134 $this->useMsaGamertagsOnly = $in->getBool();
135 $this->isFromWorldTemplate = $in->getBool();
136 $this->isWorldTemplateOptionLocked = $in->getBool();
137 $this->onlySpawnV1Villagers = $in->getBool();
138 $this->disablePersona = $in->getBool();
139 $this->disableCustomSkins = $in->getBool();
140 $this->muteEmoteAnnouncements = $in->getBool();
141 $this->vanillaVersion = $in->getString();
142 $this->limitedWorldWidth = $in->getLInt();
143 $this->limitedWorldLength = $in->getLInt();
144 $this->isNewNether = $in->getBool();
145 $this->eduSharedUriResource = EducationUriResource::read($in);
146 $this->experimentalGameplayOverride = $in->readOptional($in->getBool(...));
147 $this->chatRestrictionLevel = $in->getByte();
148 $this->disablePlayerInteractions = $in->getBool();
149 $this->serverIdentifier = $in->getString();
150 $this->worldIdentifier = $in->getString();
151 $this->scenarioIdentifier = $in->getString();
152 $this->ownerIdentifier = $in->getString();
153 }
154
155 public function write(PacketSerializer $out) : void{
156 $out->putLLong($this->seed);
157 $this->spawnSettings->write($out);
158 $out->putVarInt($this->generator);
159 $out->putVarInt($this->worldGamemode);
160 $out->putBool($this->hardcore);
161 $out->putVarInt($this->difficulty);
162 $out->putBlockPosition($this->spawnPosition);
163 $out->putBool($this->hasAchievementsDisabled);
164 $out->putVarInt($this->editorWorldType);
165 $out->putBool($this->createdInEditorMode);
166 $out->putBool($this->exportedFromEditorMode);
167 $out->putVarInt($this->time);
168 $out->putVarInt($this->eduEditionOffer);
169 $out->putBool($this->hasEduFeaturesEnabled);
170 $out->putString($this->eduProductUUID);
171 $out->putLFloat($this->rainLevel);
172 $out->putLFloat($this->lightningLevel);
173 $out->putBool($this->hasConfirmedPlatformLockedContent);
174 $out->putBool($this->isMultiplayerGame);
175 $out->putBool($this->hasLANBroadcast);
176 $out->putVarInt($this->xboxLiveBroadcastMode);
177 $out->putVarInt($this->platformBroadcastMode);
178 $out->putBool($this->commandsEnabled);
179 $out->putBool($this->isTexturePacksRequired);
180 $out->putGameRules($this->gameRules);
181 $this->experiments->write($out);
182 $out->putBool($this->hasBonusChestEnabled);
183 $out->putBool($this->hasStartWithMapEnabled);
184 $out->putVarInt($this->defaultPlayerPermission);
185 $out->putLInt($this->serverChunkTickRadius);
186 $out->putBool($this->hasLockedBehaviorPack);
187 $out->putBool($this->hasLockedResourcePack);
188 $out->putBool($this->isFromLockedWorldTemplate);
189 $out->putBool($this->useMsaGamertagsOnly);
190 $out->putBool($this->isFromWorldTemplate);
191 $out->putBool($this->isWorldTemplateOptionLocked);
192 $out->putBool($this->onlySpawnV1Villagers);
193 $out->putBool($this->disablePersona);
194 $out->putBool($this->disableCustomSkins);
195 $out->putBool($this->muteEmoteAnnouncements);
196 $out->putString($this->vanillaVersion);
197 $out->putLInt($this->limitedWorldWidth);
198 $out->putLInt($this->limitedWorldLength);
199 $out->putBool($this->isNewNether);
200 ($this->eduSharedUriResource ?? new EducationUriResource("", ""))->write($out);
201 $out->writeOptional($this->experimentalGameplayOverride, $out->putBool(...));
202 $out->putByte($this->chatRestrictionLevel);
203 $out->putBool($this->disablePlayerInteractions);
204 $out->putString($this->serverIdentifier);
205 $out->putString($this->worldIdentifier);
206 $out->putString($this->scenarioIdentifier);
207 $out->putString($this->ownerIdentifier);
208 }
209}