mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
Implement difficulty per-world (#878)
* Moved Server::getDifficultyFromString() to Level * Added ability to set difficulty in worlds section of pocketmine.yml for generation
This commit is contained in:
@ -168,7 +168,7 @@ class LevelDB extends BaseLevelProvider{
|
||||
$levelData = new CompoundTag("", [
|
||||
//Vanilla fields
|
||||
new IntTag("DayCycleStopTime", -1),
|
||||
new IntTag("Difficulty", 2),
|
||||
new IntTag("Difficulty", Level::getDifficultyFromString((string) ($options["difficulty"] ?? "normal"))),
|
||||
new ByteTag("ForceGameType", 0),
|
||||
new IntTag("GameType", 0),
|
||||
new IntTag("Generator", $generatorType),
|
||||
@ -197,7 +197,7 @@ class LevelDB extends BaseLevelProvider{
|
||||
|
||||
//Additional PocketMine-MP fields
|
||||
new CompoundTag("GameRules", []),
|
||||
new ByteTag("hardcore", 0),
|
||||
new ByteTag("hardcore", ($options["hardcore"] ?? false) === true ? 1 : 0),
|
||||
new StringTag("generatorName", Generator::getGeneratorName($generator)),
|
||||
new StringTag("generatorOptions", $options["preset"] ?? "")
|
||||
]);
|
||||
@ -253,6 +253,14 @@ class LevelDB extends BaseLevelProvider{
|
||||
return ["preset" => $this->levelData["generatorOptions"]];
|
||||
}
|
||||
|
||||
public function getDifficulty() : int{
|
||||
return isset($this->levelData->Difficulty) ? $this->levelData->Difficulty->getValue() : Level::DIFFICULTY_NORMAL;
|
||||
}
|
||||
|
||||
public function setDifficulty(int $difficulty){
|
||||
$this->levelData->Difficulty = new IntTag("Difficulty", $difficulty);
|
||||
}
|
||||
|
||||
public function getLoadedChunks() : array{
|
||||
return $this->chunks;
|
||||
}
|
||||
|
Reference in New Issue
Block a user