This commit is contained in:
Brian Neumann-Fopiano
2026-08-05 02:28:14 -06:00
parent cd217c05f9
commit a66cba6418
5 changed files with 37 additions and 6 deletions
@@ -1,3 +0,0 @@
[10:47:09] [Test worker/INFO]: [STDERR]: [Iris/WARN] Native structure terrain envelope at 0,0 was clipped to Minecraft's 8-chunk structure reference range
[10:47:09] [Test worker/INFO]: [STDERR]: [Iris/WARN] Native structure burial at 0,0 clamped to world floor: wanted -19, used -4
[10:47:09] [Test worker/INFO]: [STDERR]: [Iris/WARN] Native structure burial at 0,0 clamped to world floor: wanted -5, used -2
@@ -975,8 +975,7 @@ public class CommandIris implements DirectorExecutor {
try { try {
IrisData data = IrisData.get(pack); IrisData data = IrisData.get(pack);
for (String key : data.getDimensionLoader().getPossibleKeys()) { for (String key : data.getDimensionLoader().getPossibleKeys()) {
options.add(key); options.add(packDimensionOption(pack.getName(), key));
options.add(pack.getName() + ":" + key);
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Iris.warn("Failed to read dimension keys from pack %s: %s%s", Iris.warn("Failed to read dimension keys from pack %s: %s%s",
@@ -990,6 +989,12 @@ public class CommandIris implements DirectorExecutor {
return new KList<>(options); return new KList<>(options);
} }
static String packDimensionOption(String packName, String dimensionKey) {
return packName.equalsIgnoreCase(dimensionKey)
? packName
: packName + ":" + dimensionKey;
}
@Override @Override
public String toString(String value) { public String toString(String value) {
return value == null ? "" : value; return value == null ? "" : value;
@@ -0,0 +1,21 @@
package art.arcane.iris.core.commands;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class CommandIrisPackDimensionTypeHandlerTest {
@Test
public void matchingPackAndDimensionUsesBarePackName() {
assertEquals("overworld",
CommandIris.PackDimensionTypeHandler.packDimensionOption("overworld", "overworld"));
assertEquals("OverWorld",
CommandIris.PackDimensionTypeHandler.packDimensionOption("OverWorld", "overworld"));
}
@Test
public void differingDimensionUsesExplicitPackReference() {
assertEquals("custom_pack:dimensions/sky",
CommandIris.PackDimensionTypeHandler.packDimensionOption("custom_pack", "dimensions/sky"));
}
}
@@ -168,7 +168,9 @@ public class IrisToolbelt {
} }
String pack = requested.substring(0, separator).trim(); String pack = requested.substring(0, separator).trim();
String dimension = requested.substring(separator + 1).trim(); String dimension = requested.substring(separator + 1).trim();
if (!isSafePackDescriptor(pack) || !isSafeDimensionKey(dimension)) { if (!isSafePackDescriptor(pack)
|| !isSafeDimensionKey(dimension)
|| pack.equalsIgnoreCase(dimension)) {
return null; return null;
} }
return new PackReference(pack, dimension, true); return new PackReference(pack, dimension, true);
@@ -37,6 +37,12 @@ public class IrisToolbeltPackReferenceTest {
assertTrue(reference.explicitDimension()); assertTrue(reference.explicitDimension());
} }
@Test
public void redundantExplicitDimensionIsRejected() {
assertNull(IrisToolbelt.parsePackReference("overworld:overworld"));
assertNull(IrisToolbelt.parsePackReference("OverWorld:overworld"));
}
@Test @Test
public void repositoryShorthandUsesRepositoryAsDefaultDimension() { public void repositoryShorthandUsesRepositoryAsDefaultDimension() {
IrisToolbelt.PackReference reference = IrisToolbelt.parsePackReference("IrisDimensions/overworld/stable"); IrisToolbelt.PackReference reference = IrisToolbelt.parsePackReference("IrisDimensions/overworld/stable");