From 1ddb73595dcefebe8c4de2e756f7606a20270256 Mon Sep 17 00:00:00 2001 From: Wulian233 <1055917385@qq.com> Date: Wed, 27 Aug 2025 21:41:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=96=E7=95=8C=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E4=B8=8D=E6=94=AF=E6=8C=81=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=9E=81=E9=99=90=E6=A8=A1=E5=BC=8F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#4321)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmcl/ui/versions/WorldInfoPage.java | 24 +++++++++++++++---- .../resources/assets/lang/I18N.properties | 1 + .../resources/assets/lang/I18N_zh.properties | 1 + .../assets/lang/I18N_zh_CN.properties | 1 + 4 files changed, 22 insertions(+), 5 deletions(-) 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=生命值