89 lines
3.4 KiB
Java
89 lines
3.4 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.logging.LogUtils
|
|
* com.mojang.serialization.Dynamic
|
|
* org.slf4j.Logger
|
|
*/
|
|
package net.minecraft.world.level;
|
|
|
|
import com.mojang.logging.LogUtils;
|
|
import com.mojang.serialization.Dynamic;
|
|
import net.minecraft.world.Difficulty;
|
|
import net.minecraft.world.level.GameType;
|
|
import net.minecraft.world.level.WorldDataConfiguration;
|
|
import net.minecraft.world.level.gamerules.GameRules;
|
|
import org.slf4j.Logger;
|
|
|
|
public final class LevelSettings {
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
private final String levelName;
|
|
private final GameType gameType;
|
|
private final boolean hardcore;
|
|
private final Difficulty difficulty;
|
|
private final boolean allowCommands;
|
|
private final GameRules gameRules;
|
|
private final WorldDataConfiguration dataConfiguration;
|
|
|
|
public LevelSettings(String levelName, GameType gameType, boolean hardcore, Difficulty difficulty, boolean allowCommands, GameRules gameRules, WorldDataConfiguration dataConfiguration) {
|
|
this.levelName = levelName;
|
|
this.gameType = gameType;
|
|
this.hardcore = hardcore;
|
|
this.difficulty = difficulty;
|
|
this.allowCommands = allowCommands;
|
|
this.gameRules = gameRules;
|
|
this.dataConfiguration = dataConfiguration;
|
|
}
|
|
|
|
public static LevelSettings parse(Dynamic<?> input, WorldDataConfiguration loadConfig) {
|
|
GameType gameType = GameType.byId(input.get("GameType").asInt(0));
|
|
return new LevelSettings(input.get("LevelName").asString(""), gameType, input.get("hardcore").asBoolean(false), input.get("Difficulty").asNumber().map(n -> Difficulty.byId(n.byteValue())).result().orElse(Difficulty.NORMAL), input.get("allowCommands").asBoolean(gameType == GameType.CREATIVE), (GameRules)GameRules.codec(loadConfig.enabledFeatures()).parse(input.get("game_rules").orElseEmptyMap()).resultOrPartial(arg_0 -> ((Logger)LOGGER).warn(arg_0)).orElseThrow(), loadConfig);
|
|
}
|
|
|
|
public String levelName() {
|
|
return this.levelName;
|
|
}
|
|
|
|
public GameType gameType() {
|
|
return this.gameType;
|
|
}
|
|
|
|
public boolean hardcore() {
|
|
return this.hardcore;
|
|
}
|
|
|
|
public Difficulty difficulty() {
|
|
return this.difficulty;
|
|
}
|
|
|
|
public boolean allowCommands() {
|
|
return this.allowCommands;
|
|
}
|
|
|
|
public GameRules gameRules() {
|
|
return this.gameRules;
|
|
}
|
|
|
|
public WorldDataConfiguration getDataConfiguration() {
|
|
return this.dataConfiguration;
|
|
}
|
|
|
|
public LevelSettings withGameType(GameType gameType) {
|
|
return new LevelSettings(this.levelName, gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, this.dataConfiguration);
|
|
}
|
|
|
|
public LevelSettings withDifficulty(Difficulty difficulty) {
|
|
return new LevelSettings(this.levelName, this.gameType, this.hardcore, difficulty, this.allowCommands, this.gameRules, this.dataConfiguration);
|
|
}
|
|
|
|
public LevelSettings withDataConfiguration(WorldDataConfiguration dataConfiguration) {
|
|
return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, dataConfiguration);
|
|
}
|
|
|
|
public LevelSettings copy() {
|
|
return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(this.dataConfiguration.enabledFeatures()), this.dataConfiguration);
|
|
}
|
|
}
|
|
|