mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 03:06:55 +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:
@ -248,7 +248,8 @@ class McRegion extends BaseLevelProvider{
|
||||
}
|
||||
//TODO, add extra details
|
||||
$levelData = new CompoundTag("Data", [
|
||||
new ByteTag("hardcore", 0),
|
||||
new ByteTag("hardcore", ($options["hardcore"] ?? false) === true ? 1 : 0),
|
||||
new ByteTag("Difficulty", Level::getDifficultyFromString((string) ($options["difficulty"] ?? "normal"))),
|
||||
new ByteTag("initialized", 1),
|
||||
new IntTag("GameType", 0),
|
||||
new IntTag("generatorVersion", 1), //2 in MCPE
|
||||
@ -282,6 +283,14 @@ class McRegion 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 ByteTag("Difficulty", $difficulty);
|
||||
}
|
||||
|
||||
public function getChunk(int $chunkX, int $chunkZ, bool $create = false){
|
||||
$index = Level::chunkHash($chunkX, $chunkZ);
|
||||
if(isset($this->chunks[$index])){
|
||||
|
Reference in New Issue
Block a user