5252import java .nio .file .Files ;
5353import java .nio .file .Path ;
5454import java .text .DecimalFormat ;
55+ import java .time .Duration ;
5556import java .time .Instant ;
5657import java .util .Arrays ;
5758import 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
0 commit comments