Labeled world rows by dimension

- /iris worlds and /iris info label each row with its own dimension key instead of the shared generator identity
- Dropped the redundant world= field now that the row label carries the dimension key
- Rows for worlds whose engine has not started use the same dimension key label
- Listing tests assert per-world row labels, including an unstarted engine row
This commit is contained in:
Brian Neumann-Fopiano
2026-10-15 09:29:56 -04:00
parent 0c9ae9ed4d
commit 9a241b85cb
2 changed files with 41 additions and 10 deletions
@@ -294,13 +294,11 @@ public final class IrisModdedCommands {
}
Engine engine = irisGenerator.engineIfBound();
if (engine == null) {
lines.add(irisIdentity + ": pack=" + irisGenerator.dimensionKey()
+ " world=" + dimensionId + " (engine not started yet)");
lines.add(dimensionId + ": pack=" + irisGenerator.dimensionKey() + " (engine not started yet)");
continue;
}
String featureStatus = irisGenerator.importedFeaturesStatus();
lines.add(irisIdentity + ": pack=" + engine.getDimension().getLoadKey()
+ " world=" + dimensionId
lines.add(dimensionId + ": pack=" + engine.getDimension().getLoadKey()
+ (showSeed ? " seed=" + engine.getWorld().getRawWorldSeed() : "")
+ " height=" + engine.getMinHeight() + ".." + engine.getMaxHeight()
+ " generated=" + engine.getEngineData().getStatistics().getChunksGenerated()
@@ -67,8 +67,8 @@ public class IrisModdedWorldListingTest {
assertEquals(1, IrisModdedCommands.info(source, null));
}
String alphaRow = row(output, "world=iris:alpha");
String betaRow = row(output, "world=iris:beta");
String alphaRow = row(output, "iris:alpha");
String betaRow = row(output, "iris:beta");
assertTrue(alphaRow, alphaRow.contains(" seed=424242 "));
assertTrue(alphaRow, alphaRow.contains(" generated=1089 "));
assertTrue(betaRow, betaRow.contains(" seed=-77 "));
@@ -78,6 +78,39 @@ public class IrisModdedWorldListingTest {
}
}
@Test
public void worldsLabelsEachRowWithItsOwnWorldKey() {
NativeWorld alpha = level("iris:alpha");
NativeWorld beta = level("iris:beta");
NativeWorld gamma = level("iris:gamma");
NativeModdedServer server = mock(NativeModdedServer.class);
when(server.worlds()).thenReturn(List.of(alpha, beta, gamma));
List<String> output = new ArrayList<>();
NativeCommandSource source = source(server, null, true, output);
IrisModdedChunkGenerator alphaGenerator = generator("overworld:overworld", engine(424242L, 1089));
IrisModdedChunkGenerator betaGenerator = generator("overworld:overworld", engine(-77L, 0));
IrisModdedChunkGenerator gammaGenerator = generator("overworld:overworld", null);
try (MockedStatic<NativeWorldGenerators> generators = mockStatic(NativeWorldGenerators.class)) {
generators.when(() -> NativeWorldGenerators.find(alpha, IrisModdedChunkGenerator.class))
.thenReturn(alphaGenerator);
generators.when(() -> NativeWorldGenerators.find(beta, IrisModdedChunkGenerator.class))
.thenReturn(betaGenerator);
generators.when(() -> NativeWorldGenerators.find(gamma, IrisModdedChunkGenerator.class))
.thenReturn(gammaGenerator);
assertEquals(1, IrisModdedCommands.info(source, null));
}
assertTrue(row(output, "iris:alpha").startsWith("iris:alpha: pack=overworld "));
assertTrue(row(output, "iris:beta").startsWith("iris:beta: pack=overworld "));
assertEquals("iris:gamma: pack=overworld:overworld (engine not started yet)", row(output, "iris:gamma"));
for (String line : output) {
assertFalse(line, line.startsWith("iris:overworld"));
assertFalse(line, line.contains(" world="));
}
}
@Test
public void worldsOmitsTheSeedForPlayersBelowGamemaster() {
NativeWorld alpha = level("iris:alpha");
@@ -94,7 +127,7 @@ public class IrisModdedWorldListingTest {
assertEquals(1, IrisModdedCommands.info(source, null));
}
String alphaRow = row(output, "world=iris:alpha");
String alphaRow = row(output, "iris:alpha");
assertFalse(alphaRow, alphaRow.contains("seed="));
assertTrue(alphaRow, alphaRow.contains(" generated=1089 "));
}
@@ -170,12 +203,12 @@ public class IrisModdedWorldListingTest {
return engine;
}
private static String row(List<String> output, String marker) {
private static String row(List<String> output, String label) {
for (String line : output) {
if (line.contains(marker + " ")) {
if (line.startsWith(label + ": ")) {
return line;
}
}
throw new AssertionError("No row containing '" + marker + "' in " + output);
throw new AssertionError("No row labeled '" + label + "' in " + output);
}
}