This commit is contained in:
Brian Neumann-Fopiano
2026-08-11 14:54:53 -04:00
parent dfae45663a
commit 82290a3090
60 changed files with 2901 additions and 716 deletions
@@ -1209,6 +1209,11 @@ public class NMSBinding implements INMSBinding {
worldGenContext.structureManager(), worldGenContext.lightEngine(), worldGenContext.mainThreadExecutor(), worldGenContext.unsavedListener());
worldGenContextField.set(chunkMap, newContext);
net.minecraft.world.level.chunk.ChunkGenerator activeGenerator = level.getChunkSource().getGenerator();
if (activeGenerator != irisGenerator) {
throw new IllegalStateException("Iris generator injection did not become the active Paper chunk generator; active="
+ activeGenerator.getClass().getName());
}
retargetStructureCheck(level, irisGenerator);
}
@@ -213,6 +213,27 @@ public class NMSBindingDatapackStructureScopeTest {
assertFalse(method.contains("retained.fullState()"));
}
@Test
public void injectionVerifiesTheCanonicalPaperGeneratorBeforeStructureRetargeting() throws IOException {
Path chunkGeneratorSource = Path.of(System.getProperty("iris.nmsChunkGeneratorSource"));
String source = Files.readString(chunkGeneratorSource.resolveSibling("NMSBinding.java"));
int methodStart = source.indexOf("public void inject(long seed, Engine engine, World world)");
int methodEnd = source.indexOf("\n @Override\n public DatapackStructureScopeResult", methodStart);
assertTrue(methodStart >= 0);
assertTrue(methodEnd > methodStart);
String method = source.substring(methodStart, methodEnd);
int publication = method.indexOf("worldGenContextField.set(chunkMap, newContext);");
int canonicalRead = method.indexOf("level.getChunkSource().getGenerator()", publication);
int identityGate = method.indexOf("activeGenerator != irisGenerator", canonicalRead);
int structureRetarget = method.indexOf("retargetStructureCheck(level, irisGenerator)", identityGate);
assertTrue(publication >= 0);
assertTrue(canonicalRead > publication);
assertTrue(identityGate > canonicalRead);
assertTrue(structureRetarget > identityGate);
}
private static DatapackStructureScopeIndex index(
List<String> structureKeys,
List<String> structureSetKeys