Skip to content

Commit 1bd1e6c

Browse files
committed
feat: 添加饱食度信息项
1 parent 9dfd5b5 commit 1bd1e6c

4 files changed

Lines changed: 24 additions & 14 deletions

File tree

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

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -337,26 +337,20 @@ private void updateControls() {
337337
setLeftLabel(spawnPane, "world.info.player.spawn");
338338
setRightTextLabel(spawnPane, () -> {
339339

340-
341340
if (playerTag.get("respawn") instanceof CompoundTag respawnTag
342341
&& respawnTag.get("dimension") instanceof StringTag dimensionTag
343342
&& respawnTag.get("pos") instanceof IntArrayTag intArrayTag
344-
&& intArrayTag.length() >= 3
345-
) { // Valid after 25w07a
343+
&& intArrayTag.length() >= 3) { // Valid after 25w07a
346344
return Dimension.of(dimensionTag).formatPosition(intArrayTag);
347-
348345
} else if (playerTag.get("SpawnX") instanceof IntTag intX
349346
&& playerTag.get("SpawnY") instanceof IntTag intY
350347
&& playerTag.get("SpawnZ") instanceof IntTag intZ) { // Valid before 25w07a
351348
Dimension dimension;
352349
// SpawnDimension tag is valid after 20w12a. Prior to this version, the game did not record the respawn point dimension and respawned in the Overworld.
353-
if (playerTag.get("SpawnDimension") instanceof StringTag dimensionTag) {
354-
dimension = Dimension.of(dimensionTag);
355-
} else {
356-
dimension = Dimension.of(new StringTag("SpawnDimension", "minecraft:overworld"));
357-
}
358-
359-
return dimension.formatPosition(intX.getValue(), intY.getValue(), intZ.getValue());
350+
return Dimension.of(playerTag.get("SpawnDimension") instanceof StringTag dimensionTag
351+
? dimensionTag
352+
: new StringTag("SpawnDimension", "minecraft:overworld"))
353+
.formatPosition(intX.getValue(), intY.getValue(), intZ.getValue());
360354
}
361355

362356
return "";
@@ -426,6 +420,19 @@ private void updateControls() {
426420
}
427421
}
428422

423+
BorderPane foodSaturationPane = new BorderPane();
424+
{
425+
setLeftLabel(foodSaturationPane, "world.info.player.food_saturation_level");
426+
JFXTextField foodSaturationField = new JFXTextField();
427+
setRightTextField(foodSaturationPane, foodSaturationField, 50);
428+
429+
if (playerTag.get("foodSaturationLevel") instanceof FloatTag foodSaturationTag) {
430+
bindTagAndTextField(foodSaturationTag, foodSaturationField);
431+
} else {
432+
foodSaturationField.setDisable(true);
433+
}
434+
}
435+
429436
BorderPane xpLevelPane = new BorderPane();
430437
{
431438
setLeftLabel(xpLevelPane, "world.info.player.xp_level");
@@ -440,8 +447,8 @@ private void updateControls() {
440447
}
441448

442449
playerInfo.getContent().setAll(
443-
locationPane, lastDeathLocationPane, spawnPane,
444-
playerGameTypePane, healthPane, foodLevelPane, xpLevelPane
450+
locationPane, lastDeathLocationPane, spawnPane, playerGameTypePane,
451+
healthPane, foodLevelPane, foodSaturationPane, xpLevelPane
445452
);
446453

447454
rootPane.getChildren().addAll(ComponentList.createComponentListTitle(i18n("world.info.player")), playerInfo);
@@ -457,7 +464,7 @@ private void setLeftLabel(BorderPane borderPane, @PropertyKey(resourceBundle = "
457464
private void setRightTextField(BorderPane borderPane, JFXTextField textField, int perfWidth) {
458465
textField.setDisable(worldManagePage.isReadOnly());
459466
textField.setPrefWidth(perfWidth);
460-
textField.setAlignment(Pos.CENTER_RIGHT);
467+
BorderPane.setAlignment(textField, Pos.CENTER_RIGHT);
461468
borderPane.setRight(textField);
462469
}
463470

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,7 @@ world.info.last_played=Last Played
11831183
world.info.generate_features=Generate Structures
11841184
world.info.player=Player Information
11851185
world.info.player.food_level=Hunger Level
1186+
world.info.player.food_saturation_level=Saturation
11861187
world.info.player.game_type=Game Mode
11871188
world.info.player.game_type.adventure=Adventure
11881189
world.info.player.game_type.creative=Creative

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ world.info.last_played=上一次遊戲時間
970970
world.info.generate_features=生成建築
971971
world.info.player=玩家資訊
972972
world.info.player.food_level=饑餓值
973+
world.info.player.food_saturation_level=飽食度
973974
world.info.player.game_type=遊戲模式
974975
world.info.player.game_type.adventure=冒險
975976
world.info.player.game_type.creative=創造

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,7 @@ world.info.last_played=上一次游戏时间
975975
world.info.generate_features=生成建筑
976976
world.info.player=玩家信息
977977
world.info.player.food_level=饥饿值
978+
world.info.player.food_saturation_level=饱和度
978979
world.info.player.game_type=游戏模式
979980
world.info.player.game_type.adventure=冒险
980981
world.info.player.game_type.creative=创造

0 commit comments

Comments
 (0)