From fe2e96345bd161bc8628140817f6ef947d05e228 Mon Sep 17 00:00:00 2001 From: Glavo Date: Thu, 11 Sep 2025 00:05:23 +0800 Subject: [PATCH] =?UTF-8?q?[release/3.6]=20=E4=BF=AE=E5=A4=8D=E4=B8=96?= =?UTF-8?q?=E7=95=8C=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=98=BE=E7=A4=BA=E6=9E=81=E9=99=90=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20(#4446)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/HMCL-dev/HMCL/pull/4321 Co-authored-by: Wulian233 <1055917385@qq.com> --- .../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 58facec738..34d109304c 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 240fa7e068..bc31ada0c5 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -1142,6 +1142,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 2fcce57959..41627fa6db 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -940,6 +940,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 8d0d096952..81dd6554d9 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -951,6 +951,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=生命值