Skip to content

Commit 2271457

Browse files
committed
feat: 添加世界出生点信息项
1 parent 1bd1e6c commit 2271457

9 files changed

Lines changed: 33 additions & 23 deletions

File tree

HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldInfoPage.java

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import java.nio.file.Files;
5353
import java.nio.file.Path;
5454
import java.text.DecimalFormat;
55+
import java.time.Duration;
5556
import java.time.Instant;
5657
import java.util.Arrays;
5758
import java.util.Locale;
@@ -217,6 +218,25 @@ private void updateControls() {
217218
}
218219
}
219220

221+
BorderPane worldSpawnPoint = new BorderPane();
222+
{
223+
setLeftLabel(worldSpawnPoint, "world.info.spawn");
224+
setRightTextLabel(worldSpawnPoint, () -> {
225+
if (dataTag.get("spawn") instanceof CompoundTag spawnTag && spawnTag.get("pos") instanceof IntArrayTag posTag) {
226+
return Dimension.of(spawnTag.get("dimension") instanceof StringTag dimensionTag
227+
? dimensionTag
228+
: new StringTag("SpawnDimension", "minecraft:overworld"))
229+
.formatPosition(posTag);
230+
} else if (dataTag.get("SpawnX") instanceof IntTag intX
231+
&& dataTag.get("SpawnY") instanceof IntTag intY
232+
&& dataTag.get("SpawnZ") instanceof IntTag intZ) {
233+
return Dimension.OVERWORLD.formatPosition(intX.getValue(), intY.getValue(), intZ.getValue());
234+
} else {
235+
return "";
236+
}
237+
});
238+
}
239+
220240
BorderPane lastPlayedPane = new BorderPane();
221241
{
222242
setLeftLabel(lastPlayedPane, "world.info.last_played");
@@ -228,8 +248,8 @@ private void updateControls() {
228248
setLeftLabel(timePane, "world.info.time");
229249
setRightTextLabel(timePane, () -> {
230250
if (dataTag.get("Time") instanceof LongTag timeTag) {
231-
long days = timeTag.getValue() / 24000;
232-
return i18n("world.info.time.format", days);
251+
Duration duration = Duration.ofSeconds(timeTag.getValue() / 20);
252+
return i18n("world.info.time.format", duration.toDays(), duration.toHoursPart(), duration.toMinutesPart());
233253
} else {
234254
return "";
235255
}
@@ -291,7 +311,7 @@ private void updateControls() {
291311
}
292312

293313
worldInfo.getContent().setAll(
294-
worldNamePane, gameVersionPane, iconPane, seedPane, lastPlayedPane, timePane,
314+
worldNamePane, gameVersionPane, iconPane, seedPane, worldSpawnPoint, lastPlayedPane, timePane,
295315
allowCheatsButton, generateFeaturesButton, difficultyPane, difficultyLockPane);
296316

297317
rootPane.getChildren().addAll(ComponentList.createComponentListTitle(i18n("world.info")), worldInfo);
@@ -345,11 +365,8 @@ private void updateControls() {
345365
} else if (playerTag.get("SpawnX") instanceof IntTag intX
346366
&& playerTag.get("SpawnY") instanceof IntTag intY
347367
&& playerTag.get("SpawnZ") instanceof IntTag intZ) { // Valid before 25w07a
348-
Dimension dimension;
349368
// SpawnDimension tag is valid after 20w12a. Prior to this version, the game did not record the respawn point dimension and respawned in the Overworld.
350-
return Dimension.of(playerTag.get("SpawnDimension") instanceof StringTag dimensionTag
351-
? dimensionTag
352-
: new StringTag("SpawnDimension", "minecraft:overworld"))
369+
return (playerTag.get("SpawnDimension") instanceof StringTag dimensionTag ? Dimension.of(dimensionTag) : Dimension.OVERWORLD)
353370
.formatPosition(intX.getValue(), intY.getValue(), intZ.getValue());
354371
}
355372

HMCL/src/main/resources/assets/lang/I18N.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,8 +1196,9 @@ world.info.player.location=Location
11961196
world.info.player.spawn=Spawn Location
11971197
world.info.player.xp_level=Experience Level
11981198
world.info.random_seed=Seed
1199-
world.info.time=Game Time
1200-
world.info.time.format=%s days
1199+
world.info.spawn=World Spawn Location
1200+
world.info.time=Play Time
1201+
world.info.time.format=%d days %d hours %d minutes
12011202
world.load.fail=Failed to load world
12021203
world.locked=In use
12031204
world.locked.failed=The world is currently in use. Please close the game and try again.

HMCL/src/main/resources/assets/lang/I18N_ar.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,8 +1153,6 @@ world.info.player.location=الموقع
11531153
world.info.player.spawn=موقع الظهور
11541154
world.info.player.xp_level=مستوى الخبرة
11551155
world.info.random_seed=البذرة
1156-
world.info.time=وقت اللعبة
1157-
world.info.time.format=%s أيام
11581156
world.locked=قيد الاستخدام
11591157
world.locked.failed=العالم قيد الاستخدام حاليًا. يرجى إغلاق اللعبة والمحاولة مرة أخرى.
11601158
world.manage=العوالم

HMCL/src/main/resources/assets/lang/I18N_es.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,8 +1160,6 @@ world.info.player.location=Ubicación
11601160
world.info.player.spawn=Ubicación de desove
11611161
world.info.player.xp_level=Nivel de experiencia
11621162
world.info.random_seed=Semilla
1163-
world.info.time=Tiempo de juego
1164-
world.info.time.format=%s días
11651163
world.locked=En uso
11661164
world.locked.failed=El mundo está actualmente en uso. Por favor, cierra el juego e inténtalo de nuevo.
11671165
world.manage=Mundos

HMCL/src/main/resources/assets/lang/I18N_lzh.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,6 @@ world.info.player.location=所
945945
world.info.player.spawn=床/復生錨之所
946946
world.info.player.xp_level=經驗之層
947947
world.info.random_seed=
948-
world.info.time=戲之時辰
949-
world.info.time.format=%s 日
950948
world.locked=見用
951949
world.manage=司生界
952950
world.manage.button=司生界

HMCL/src/main/resources/assets/lang/I18N_ru.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,8 +1152,6 @@ world.info.player.location=Расположение
11521152
world.info.player.spawn=Точка возрождения
11531153
world.info.player.xp_level=Уровень опыта
11541154
world.info.random_seed=Ключ генератора мира
1155-
world.info.time=Время игры
1156-
world.info.time.format=%s дн.
11571155
world.locked=В эксплуатации
11581156
world.locked.failed=В настоящее время мир находится в эксплуатации. Закройте игру и попробуйте снова.
11591157
world.manage=Миры

HMCL/src/main/resources/assets/lang/I18N_uk.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,6 @@ world.info.player.location=Місцезнаходження
10971097
world.info.player.spawn=Місце появи
10981098
world.info.player.xp_level=Рівень досвіду
10991099
world.info.random_seed=Насіння
1100-
world.info.time=Час гри
1101-
world.info.time.format=%s днів
11021100
world.locked=Використовується
11031101
world.locked.failed=Світ наразі використовується. Закрийте гру та спробуйте знову.
11041102
world.manage=Світи

HMCL/src/main/resources/assets/lang/I18N_zh.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,9 @@ world.info.player.location=位置
983983
world.info.player.spawn=床/重生錨位置
984984
world.info.player.xp_level=經驗等級
985985
world.info.random_seed=種子碼
986-
world.info.time=遊戲內時間
987-
world.info.time.format=%s 天
986+
world.info.spawn=世界重生點
987+
world.info.time=遊戲時間
988+
world.info.time.format=%d 天 %d 小時 %d 分鐘
988989
world.load.fail=世界載入失敗
989990
world.locked=使用中
990991
world.locked.failed=該世界正在使用中,請關閉遊戲後重試。

HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,9 @@ world.info.player.location=位置
988988
world.info.player.spawn=床/重生锚位置
989989
world.info.player.xp_level=经验等级
990990
world.info.random_seed=种子
991-
world.info.time=游戏内时间
992-
world.info.time.format=%s 天
991+
world.info.spawn=世界出生点
992+
world.info.time=游戏时长
993+
world.info.time.format=%d 天 %d 小时 %d 分钟
993994
world.load.fail=世界加载失败
994995
world.locked=使用中
995996
world.locked.failed=该世界正在使用中,请关闭游戏后重试。

0 commit comments

Comments
 (0)