diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldInfoPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldInfoPage.java index 58facec73..34d109304 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldInfoPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldInfoPage.java @@ -361,14 +361,27 @@ public final class WorldInfoPage extends SpinnerPane { playerGameTypePane.setRight(gameTypeBox); Tag tag = player.get("playerGameType"); + Tag hardcoreTag = dataTag.get("hardcore"); + boolean isHardcore = hardcoreTag instanceof ByteTag && ((ByteTag) hardcoreTag).getValue() == 1; + if (tag instanceof IntTag) { IntTag intTag = (IntTag) tag; - GameType gameType = GameType.of(intTag.getValue()); + GameType gameType = GameType.of(intTag.getValue(), isHardcore); if (gameType != null) { gameTypeBox.setValue(gameType); gameTypeBox.valueProperty().addListener((o, oldValue, newValue) -> { if (newValue != null) { - intTag.setValue(newValue.ordinal()); + if (newValue == GameType.HARDCORE) { + intTag.setValue(0); // survival (hardcore worlds are survival+hardcore flag) + if (hardcoreTag instanceof ByteTag) { + ((ByteTag) hardcoreTag).setValue((byte) 1); + } + } else { + intTag.setValue(newValue.ordinal()); + if (hardcoreTag instanceof ByteTag) { + ((ByteTag) hardcoreTag).setValue((byte) 0); + } + } saveLevelDat(); } }); @@ -606,12 +619,13 @@ public final class WorldInfoPage extends SpinnerPane { } private enum GameType { - SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR; + SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR, HARDCORE; static final ObservableList items = FXCollections.observableList(Arrays.asList(values())); - static GameType of(int d) { - return d >= 0 && d <= items.size() ? items.get(d) : null; + static GameType of(int d, boolean hardcore) { + if (hardcore && d == 0) return HARDCORE; // hardcore + survival + return d >= 0 && d < 4 ? items.get(d) : null; } @Override diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index 9f8b80f95..4f8ff362d 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -1140,6 +1140,7 @@ world.info.player.food_level=Hunger Level world.info.player.game_type=Game Mode world.info.player.game_type.adventure=Adventure world.info.player.game_type.creative=Creative +world.info.player.game_type.hardcore=Hardcore world.info.player.game_type.spectator=Spectator world.info.player.game_type.survival=Survival world.info.player.health=Health diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 266e9a199..eb2b63aa4 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -945,6 +945,7 @@ world.info.player.food_level=饑餓值 world.info.player.game_type=遊戲模式 world.info.player.game_type.adventure=冒險 world.info.player.game_type.creative=創造 +world.info.player.game_type.hardcore=極限 world.info.player.game_type.spectator=旁觀者 world.info.player.game_type.survival=生存 world.info.player.health=生命值 diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index 5800684d8..5b6a11b01 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -956,6 +956,7 @@ world.info.player.food_level=饥饿值 world.info.player.game_type=游戏模式 world.info.player.game_type.adventure=冒险 world.info.player.game_type.creative=创造 +world.info.player.game_type.hardcore=极限 world.info.player.game_type.spectator=旁观者 world.info.player.game_type.survival=生存 world.info.player.health=生命值