mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 02:04:51 +00:00
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:
1 parent
b00e28e42e
commit
1ed1044474
385 files changed
+48102
-535
No files matched your search
+104
@@ -0,0 +1,104 @@
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.handlers.DimensionHandler;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.pack.datapack.DataVersion;
|
||||
import art.arcane.iris.pack.datapack.export.WorldgenExportRequest;
|
||||
import art.arcane.volmlib.util.director.annotations.Director;
|
||||
import art.arcane.volmlib.util.director.annotations.Param;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
public class CommandDatapackExportContractTest {
|
||||
private static final List<String> NAMES = List.of(
|
||||
"dimension", "version", "mode", "namespace", "output", "format", "objects", "replace");
|
||||
private static final List<String> DEFAULTS = List.of(
|
||||
Param.NO_DEFAULT, "", "overworld", "iris_export", "", "zip", "true", "false");
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void exportParametersAreNamedInOrder() throws Exception {
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Parameter parameter : exportMethod().getParameters()) {
|
||||
names.add(parameter.getAnnotation(Param.class).name());
|
||||
}
|
||||
|
||||
assertEquals(NAMES, names);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dimensionIsPositionalAndEveryOtherParameterIsKeyedWithItsDefault() throws Exception {
|
||||
Parameter[] parameters = exportMethod().getParameters();
|
||||
List<String> defaults = new ArrayList<>();
|
||||
for (Parameter parameter : parameters) {
|
||||
defaults.add(parameter.getAnnotation(Param.class).defaultValue());
|
||||
}
|
||||
|
||||
assertEquals(DEFAULTS, defaults);
|
||||
assertEquals(DimensionHandler.class, parameters[0].getAnnotation(Param.class).customHandler());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exportCommandAndParametersUseRegisteredDescriptions() throws Exception {
|
||||
Method export = exportMethod();
|
||||
Director director = export.getAnnotation(Director.class);
|
||||
|
||||
assertNotNull(director);
|
||||
assertEquals(0L, Arrays.stream(director.aliases()).filter((String alias) -> !alias.isBlank()).count());
|
||||
assertNotNull(director.descriptionKey(), IrisLanguage.catalog().key(director.descriptionKey()));
|
||||
for (Parameter parameter : export.getParameters()) {
|
||||
String key = parameter.getAnnotation(Param.class).descriptionKey();
|
||||
assertNotNull(key, IrisLanguage.catalog().key(key));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validRequestResolvesItsTarget() {
|
||||
assertSame(DataVersion.V26_3, CommandDatapack.validateExport(request().build()));
|
||||
assertSame(DataVersion.V26_3, CommandDatapack.validateExport(request().version("26.3").build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unsupportedArgumentsAreRejectedWithSharedMessages() {
|
||||
assertEquals("Unsupported datapack export version '1.21.1'. Supported: 26.3",
|
||||
reason(request().version("1.21.1").build()));
|
||||
assertEquals("Unsupported datapack export version '26.2'. Supported: 26.3",
|
||||
reason(request().version("26.2").build()));
|
||||
assertEquals("Unknown export mode 'nether'. Expected: preset, dimension, overworld",
|
||||
reason(request().mode("nether").build()));
|
||||
assertEquals("Export format must be directory or zip.", reason(request().format("rar").build()));
|
||||
}
|
||||
|
||||
private WorldgenExportRequest.Builder request() {
|
||||
Path root = temporaryFolder.getRoot().toPath();
|
||||
return WorldgenExportRequest.builder()
|
||||
.pack(root.resolve("packs").resolve("overworld"))
|
||||
.dimension("overworld")
|
||||
.exportRoot(root.resolve("exports"));
|
||||
}
|
||||
|
||||
private static String reason(WorldgenExportRequest request) {
|
||||
return assertThrows(IllegalArgumentException.class, () -> CommandDatapack.validateExport(request)).getMessage();
|
||||
}
|
||||
|
||||
private static Method exportMethod() throws NoSuchMethodException {
|
||||
return CommandDatapack.class.getDeclaredMethod("export", IrisDimension.class, String.class, String.class,
|
||||
String.class, String.class, String.class, boolean.class, boolean.class);
|
||||
}
|
||||
}
|
||||
-19
@@ -17,7 +17,6 @@ import art.arcane.iris.structure.authoring.StructureOwnershipManifest;
|
||||
import art.arcane.iris.structure.authoring.StructureSource;
|
||||
import art.arcane.iris.structure.authoring.StructureTransactionWriter;
|
||||
import art.arcane.iris.structure.conversion.IrisStructureAdoptionInputKind;
|
||||
import art.arcane.iris.structure.export.VanillaJigsawExportFormat;
|
||||
import art.arcane.iris.world.IrisCreator;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.pack.value.IrisDirection;
|
||||
@@ -413,24 +412,6 @@ public class CommandJigsawContractTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exportOutputIsOneSafeChildArtifact() {
|
||||
Path root = Path.of("build", "jigsaw-exports").toAbsolutePath().normalize();
|
||||
|
||||
assertEquals(root.resolve("village.zip"), CommandJigsawExports.resolveExportDestination(
|
||||
root, "village", VanillaJigsawExportFormat.ZIP));
|
||||
assertEquals(root.resolve("village"), CommandJigsawExports.resolveExportDestination(
|
||||
root, "village", VanillaJigsawExportFormat.DIRECTORY));
|
||||
assertThrows(IllegalArgumentException.class, () -> CommandJigsawExports.resolveExportDestination(
|
||||
root, "", VanillaJigsawExportFormat.DIRECTORY));
|
||||
assertThrows(IllegalArgumentException.class, () -> CommandJigsawExports.resolveExportDestination(
|
||||
root, ".", VanillaJigsawExportFormat.DIRECTORY));
|
||||
assertThrows(IllegalArgumentException.class, () -> CommandJigsawExports.resolveExportDestination(
|
||||
root, "../all-exports", VanillaJigsawExportFormat.DIRECTORY));
|
||||
assertThrows(IllegalArgumentException.class, () -> CommandJigsawExports.resolveExportDestination(
|
||||
root, "nested/export", VanillaJigsawExportFormat.DIRECTORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exportLeaseRejectsDuplicatePlayerAndDestination() {
|
||||
UUID firstPlayer = UUID.randomUUID();
|
||||
|
||||
Reference in new issue
Block a user