Spaces:
Build error
Build error
File size: 3,072 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
package net.minecraft.world.level;
import com.mojang.serialization.Dynamic;
import net.minecraft.world.Difficulty;
public final class LevelSettings {
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 p_250485_, GameType p_250207_, boolean p_251631_, Difficulty p_252122_, boolean p_248961_, GameRules p_248536_, WorldDataConfiguration p_249797_
) {
this.levelName = p_250485_;
this.gameType = p_250207_;
this.hardcore = p_251631_;
this.difficulty = p_252122_;
this.allowCommands = p_248961_;
this.gameRules = p_248536_;
this.dataConfiguration = p_249797_;
}
public static LevelSettings parse(Dynamic<?> p_46925_, WorldDataConfiguration p_251697_) {
GameType gametype = GameType.byId(p_46925_.get("GameType").asInt(0));
return new LevelSettings(
p_46925_.get("LevelName").asString(""),
gametype,
p_46925_.get("hardcore").asBoolean(false),
p_46925_.get("Difficulty").asNumber().map(p_46928_ -> Difficulty.byId(p_46928_.byteValue())).result().orElse(Difficulty.NORMAL),
p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE),
new GameRules(p_251697_.enabledFeatures(), p_46925_.get("GameRules")),
p_251697_
);
}
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 p_46923_) {
return new LevelSettings(this.levelName, p_46923_, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, this.dataConfiguration);
}
public LevelSettings withDifficulty(Difficulty p_46919_) {
return new LevelSettings(this.levelName, this.gameType, this.hardcore, p_46919_, this.allowCommands, this.gameRules, this.dataConfiguration);
}
public LevelSettings withDataConfiguration(WorldDataConfiguration p_250867_) {
return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, p_250867_);
}
public LevelSettings copy() {
return new LevelSettings(
this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(this.dataConfiguration.enabledFeatures()), this.dataConfiguration
);
}
} |