Datapack export

- /iris datapack export compiles one pack dimension into a worldgen datapack for Minecraft 26.3 and later
- Bukkit and mod loaders take the same version, mode, namespace, output, format, objects and replace arguments
- The default overworld mode replaces the Overworld of a new world with the default world type
- Preset and dimension modes write a selectable world preset or a separate dimension
- The export runs in the background and publishes the zip or folder atomically
- Pack compiler stages turn noise, terrain, caves, subterrain, biomes, surface, decoration, objects and structures into a version-neutral IR
- Capability lowering fits every field to 26.3 density function ranges
- Disjoint min and max nodes fold to the input that always wins
- The 26.3 writer emits density functions, noise settings, biomes, features, structures, presets and dimensions
- Every export carries the Iris logo as its pack.png
- Unused objects, templates and features are pruned from the output
- The pruner keeps pack.png without reading references from its bytes
- Imported pack datapacks are bundled into the export
- Every approximation reports an export limit diagnostic
- Generation cost is counted against a node budget and reported as a warning
- Cave biomes over the wall palette limit use the closest kept palette
- Jigsaw exports share the template encoder, block states, destinations and publisher with the worldgen export
- DataVersion carries the pack format minor and world data version
- Both platforms expose vanilla data from the server classpath
- GoldenHashEngine and the export probes share one chunk spiral scan
- Headless 26.3 probes measure export cost and compare column and chunk likeness against Iris
- Real-codec tests decode the exported resources with the 26.3 registries
- Paper registry tests run in isolated registry scopes
- Command help and messages cover the export in every language file
This commit is contained in:
Brian Neumann-Fopiano committed 2026-10-30 22:59:04 -04:00
1 parent b00e28e42e
commit 1ed1044474
385 files changed
+48102 -535

No files matched your search

@@ -0,0 +1,50 @@
package art.arcane.iris.modded;
import art.arcane.iris.platform.ClasspathVanillaDataSource;
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeModdedServer;
import art.arcane.volmlib.nativelib.terrain.NativeWorld;
import net.minecraft.SharedConstants;
import net.minecraft.server.Bootstrap;
import net.minecraft.server.level.ServerLevel;
import org.junit.BeforeClass;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ModdedVanillaDataTest {
private static final String PLAINS = "data/minecraft/worldgen/biome/plains.json";
private static final String BIOME_TAGS = "data/minecraft/tags/worldgen/biome";
@BeforeClass
public static void bootstrapRegistries() {
SharedConstants.tryDetectVersion();
Bootstrap.bootStrap();
}
@Test
public void overworldLevelClassReadsTheGameVanillaData() {
NativeModdedServer server = mock(NativeModdedServer.class);
NativeWorld overworld = mock(NativeWorld.class);
when(overworld.nativeHandle()).thenReturn(mock(ServerLevel.class));
when(server.overworld()).thenReturn(overworld);
Class<?> anchor = ModdedPlatform.overworldClass(server);
assertSame(ServerLevel.class, anchor);
ClasspathVanillaDataSource source = new ClasspathVanillaDataSource(() -> anchor);
String plains = new String(source.read(PLAINS).orElseThrow(), StandardCharsets.UTF_8);
assertTrue(plains.contains("\"temperature\""));
assertTrue(source.list(BIOME_TAGS).contains(BIOME_TAGS + "/is_overworld.json"));
}
@Test
public void vanillaDataNeedsALoadedOverworld() {
NativeModdedServer server = mock(NativeModdedServer.class);
assertThrows(IllegalStateException.class, () -> ModdedPlatform.overworldClass(null));
assertThrows(IllegalStateException.class, () -> ModdedPlatform.overworldClass(server));
}
}
@@ -63,6 +63,9 @@ public class IrisModdedCommandParityTest {
CommandNode<CommandSourceStack> studio = child(iris, "studio");
child(studio, "package");
child(studio, "pkg");
CommandNode<CommandSourceStack> datapackExport = child(child(iris, "datapack"), "export");
assertNotNull(datapackExport.getCommand());
assertNotNull(child(datapackExport, "args").getCommand());
CommandNode<CommandSourceStack> download = child(iris, "download");
CommandNode<CommandSourceStack> source = child(download, "source");
@@ -211,6 +214,8 @@ public class IrisModdedCommandParityTest {
assertTrue(root.stream().anyMatch((String line) -> line.startsWith("/iris teleport <dimension> [player] (tp) - ")));
assertTrue(ModdedCommandHelp.consoleLines("pregen").stream().anyMatch((String line) ->
line.startsWith("/iris pregen start <radius> [dimension] [at] [x] [z] [gui] [sync] [nocache] - ")));
assertTrue(ModdedCommandHelp.consoleLines("datapack").stream().anyMatch((String line) ->
line.startsWith("/iris datapack export <dimension> [version=] [mode=overworld] [namespace=iris_export] [output=] [format=zip] [objects=true] [replace=false] - ")));
}
private static CommandNode<CommandSourceStack> child(
@@ -0,0 +1,87 @@
package art.arcane.iris.modded.command;
import art.arcane.iris.pack.datapack.DataVersion;
import art.arcane.iris.pack.datapack.export.WorldgenExportRequest;
import org.junit.Test;
import java.nio.file.Path;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
public class ModdedDatapackExportArgumentsTest {
@Test
public void unknownKeyFails() {
assertEquals("unknown option 'seed'", reason("overworld seed=1"));
assertEquals("unknown option 'Version'", reason("overworld Version=26.3"));
}
@Test
public void duplicateKeyFails() {
assertEquals("option 'replace' given twice", reason("overworld replace=true replace=false"));
assertEquals("option 'version' given twice", reason("overworld version= version=26.3"));
}
@Test
public void firstBareTokenIsDimension() {
ModdedDatapackExportArguments arguments = ModdedDatapackExportArguments.parse(
" version=26.3 overworld mode=dimension namespace=worlds output=export_one format=directory objects=false replace=true ");
assertEquals("overworld", arguments.dimension());
assertEquals("26.3", arguments.version());
assertEquals("dimension", arguments.mode());
assertEquals("worlds", arguments.namespace());
assertEquals("export_one", arguments.output());
assertEquals("directory", arguments.format());
assertFalse(arguments.objects());
assertTrue(arguments.replace());
assertSame(DataVersion.V26_3, arguments.target());
assertEquals("unexpected argument 'underworld'", reason("overworld underworld"));
assertEquals("missing dimension", reason(" "));
assertEquals("missing dimension", reason("version=26.3"));
}
@Test
public void defaultsMatchBukkit() {
ModdedDatapackExportArguments arguments = ModdedDatapackExportArguments.parse("overworld");
assertEquals("", arguments.version());
assertEquals("overworld", arguments.mode());
assertEquals("iris_export", arguments.namespace());
assertEquals("", arguments.output());
assertEquals("zip", arguments.format());
assertTrue(arguments.objects());
assertFalse(arguments.replace());
assertSame(DataVersion.V26_3, arguments.target());
Path pack = Path.of("packs", "overworld");
Path exportRoot = Path.of("exports", "datapacks");
WorldgenExportRequest expected = WorldgenExportRequest.builder()
.pack(pack)
.dimension("overworld")
.exportRoot(exportRoot)
.build();
assertEquals(expected, arguments.toRequest(pack, exportRoot));
}
@Test
public void unsupportedValuesFailWithSharedMessages() {
assertEquals("Unsupported datapack export version '1.21.1'. Supported: 26.3",
reason("overworld version=1.21.1"));
assertEquals("Unsupported datapack export version '26.2'. Supported: 26.3",
reason("overworld version=26.2"));
assertEquals("Unknown export mode 'nether'. Expected: preset, dimension, overworld",
reason("overworld mode=nether"));
assertEquals("Export format must be directory or zip.", reason("overworld format=rar"));
assertEquals("objects must be true or false", reason("overworld objects=yes"));
assertEquals("replace must be true or false", reason("overworld replace=1"));
assertEquals("invalid dimension key 'a..b'", reason("a..b"));
}
private static String reason(String raw) {
return assertThrows(IllegalArgumentException.class, () -> ModdedDatapackExportArguments.parse(raw)).getMessage();
}
}