mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 01:34:04 +00:00
Let the structure model and the assembler speak the api
This commit is contained in:
1 parent
6ecfbbaa6e
commit
ff23e2fb7b
122 files changed
+3030
-2014
No files matched your search
-6
@@ -19,7 +19,6 @@
|
|||||||
package art.arcane.iris.core.structure;
|
package art.arcane.iris.core.structure;
|
||||||
|
|
||||||
import art.arcane.iris.Iris;
|
import art.arcane.iris.Iris;
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.pack.BrokenPackException;
|
import art.arcane.iris.core.pack.BrokenPackException;
|
||||||
import art.arcane.iris.core.runtime.StudioOpenCoordinator;
|
import art.arcane.iris.core.runtime.StudioOpenCoordinator;
|
||||||
import art.arcane.iris.core.service.JigsawStudioService;
|
import art.arcane.iris.core.service.JigsawStudioService;
|
||||||
@@ -46,11 +45,6 @@ public final class BukkitJigsawStudioHost implements JigsawStudioHost {
|
|||||||
return Iris.jigsawStudio();
|
return Iris.jigsawStudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IrisData dataOf(ToolPack pack) {
|
|
||||||
return IrisToolPack.dataOf(pack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String packKey(ToolPack pack) {
|
public String packKey(ToolPack pack) {
|
||||||
return IrisToolPack.dataOf(pack).getDataFolder().getName();
|
return IrisToolPack.dataOf(pack).getDataFolder().getName();
|
||||||
|
|||||||
@@ -63,8 +63,14 @@ public final class IrisModuleHost {
|
|||||||
"iris:spawn", "iris:prepare", "iris:anchor", "iris:validate", "iris:bore", "iris:blocks", "iris:stilt", "iris:vacuum",
|
"iris:spawn", "iris:prepare", "iris:anchor", "iris:validate", "iris:bore", "iris:blocks", "iris:stilt", "iris:vacuum",
|
||||||
"iris:snow", "iris:vanilla-features", "iris:carve", "iris:deposit", "iris:decorant", "iris:terrain", "iris:objects",
|
"iris:snow", "iris:vanilla-features", "iris:carve", "iris:deposit", "iris:decorant", "iris:terrain", "iris:objects",
|
||||||
"iris:floating");
|
"iris:floating");
|
||||||
/** Iris's pack object model: built-in settings may hold these classes, which Iris reads and describes itself. */
|
/**
|
||||||
public static final String HOST_TYPE_PACKAGE = "art.arcane.iris.engine.object";
|
* Iris's pack object model: built-in settings may hold these classes, which Iris reads and describes itself. The
|
||||||
|
* structure model (engine.object.structure) is not among them: it speaks the api's vocabulary and its module describes it.
|
||||||
|
*/
|
||||||
|
public static final String[] HOST_TYPE_PACKAGES = Stream.of("annotations", "compatibility", "image", "material", "noise",
|
||||||
|
"placement", "prefab", "runtime", "terrain", "value", "world")
|
||||||
|
.map(subpackage -> "art.arcane.iris.engine.object." + subpackage)
|
||||||
|
.toArray(String[]::new);
|
||||||
private static final String[] JAR_COPY_FOLDER = {"cache", "module-jars"};
|
private static final String[] JAR_COPY_FOLDER = {"cache", "module-jars"};
|
||||||
private static final String BUNDLED_JAR_RESOURCE = "/" + MissingBuiltInModules.JAR_NAME;
|
private static final String BUNDLED_JAR_RESOURCE = "/" + MissingBuiltInModules.JAR_NAME;
|
||||||
private static final String BUNDLED_JAR_TEMPORARY_PREFIX = "iris-built-in-modules-";
|
private static final String BUNDLED_JAR_TEMPORARY_PREFIX = "iris-built-in-modules-";
|
||||||
@@ -98,14 +104,14 @@ public final class IrisModuleHost {
|
|||||||
|
|
||||||
/** Whether {@code type} is one of Iris's own classes that built-in settings may hold. */
|
/** Whether {@code type} is one of Iris's own classes that built-in settings may hold. */
|
||||||
public static boolean isHostType(Class<?> type) {
|
public static boolean isHostType(Class<?> type) {
|
||||||
return type.getName().startsWith(HOST_TYPE_PACKAGE + ".");
|
return Stream.of(HOST_TYPE_PACKAGES).anyMatch(hostPackage -> type.getName().startsWith(hostPackage + "."));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ModuleHost build() {
|
private static ModuleHost build() {
|
||||||
return ModuleHost.of(builtInModules())
|
return ModuleHost.of(builtInModules())
|
||||||
.exposing(EXPOSED_PACKAGES.toArray(String[]::new))
|
.exposing(EXPOSED_PACKAGES.toArray(String[]::new))
|
||||||
.reservingFields(ModuleTargets.reservedFields())
|
.reservingFields(ModuleTargets.reservedFields())
|
||||||
.describingHostTypesIn(HOST_TYPE_PACKAGE)
|
.describingHostTypesIn(HOST_TYPE_PACKAGES)
|
||||||
.reservingFolders(IrisData.ownFolderNames().toArray(String[]::new))
|
.reservingFolders(IrisData.ownFolderNames().toArray(String[]::new))
|
||||||
.bundlingJars(bundledJars())
|
.bundlingJars(bundledJars())
|
||||||
.copyingJarsTo(jarCopyRoot())
|
.copyingJarsTo(jarCopyRoot())
|
||||||
|
|||||||
@@ -28,9 +28,11 @@ import com.volmit.config.PackSettings;
|
|||||||
import com.volmit.config.SettingsStack;
|
import com.volmit.config.SettingsStack;
|
||||||
import com.volmit.resource.PackResources;
|
import com.volmit.resource.PackResources;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The settings a whole pack declares, for validators: every dimension of the pack, then every region, then every
|
* The settings a whole pack declares, for validators: every dimension of the pack, then every region, then every
|
||||||
@@ -51,6 +53,12 @@ final class PackDeclaredSettings implements PackSettings {
|
|||||||
return data.getPackResources();
|
return data.getPackResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The pack's folder is offered as a {@link File}, for checks that read the files of the pack as written. */
|
||||||
|
@Override
|
||||||
|
public <T> Optional<T> extension(Class<T> type) {
|
||||||
|
return HostExtensions.as(type, type == File.class ? data.getDataFolder() : null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||||
List<Entry<F>> entries = new ArrayList<>();
|
List<Entry<F>> entries = new ArrayList<>();
|
||||||
|
|||||||
@@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
package art.arcane.iris.core.modules;
|
package art.arcane.iris.core.modules;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.engine.framework.StructureAssembler;
|
import art.arcane.iris.engine.framework.StructureAssembler;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure assembly for Iris's own tools, the commands and studio, which run outside any module's stage, service or hook and so
|
* Structure assembly for Iris's own tools, the commands and studio, which run outside any module's stage, service or hook and so
|
||||||
@@ -31,8 +31,8 @@ public final class StructureAssemblies {
|
|||||||
private StructureAssemblies() {
|
private StructureAssemblies() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The assembler of {@code structure}, compiled from the pack {@code data} serves, for a start at {@code origin}. */
|
/** The assembler of {@code structure}, the structure {@code structureKey} of {@code pack}, for a start at {@code origin}. */
|
||||||
public static StructureAssembler forData(IrisData data, IrisStructure structure, IrisPosition origin) {
|
public static StructureAssembler forPack(PackResources pack, String structureKey, IrisStructure structure, BlockPosition origin) {
|
||||||
return StructureAssembler.forData(data, structure, origin, IrisModuleHost.hostLog());
|
return StructureAssembler.forPack(pack, structureKey, structure, origin, IrisModuleHost.hostLog());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,13 +20,12 @@ package art.arcane.iris.core.modules;
|
|||||||
|
|
||||||
import art.arcane.iris.core.structure.StructureIndexService;
|
import art.arcane.iris.core.structure.StructureIndexService;
|
||||||
import art.arcane.iris.core.structure.tooling.PlatformStructuresAccess;
|
import art.arcane.iris.core.structure.tooling.PlatformStructuresAccess;
|
||||||
import art.arcane.iris.core.tooling.IrisToolPack;
|
|
||||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
import com.volmit.resource.ResourceId;
|
import com.volmit.resource.ResourceId;
|
||||||
import com.volmit.tooling.Argument;
|
import com.volmit.tooling.Argument;
|
||||||
import com.volmit.tooling.Command;
|
import com.volmit.tooling.Command;
|
||||||
@@ -79,7 +78,7 @@ final class StructureCommands {
|
|||||||
ResourceId id = context.get(STRUCTURE);
|
ResourceId id = context.get(STRUCTURE);
|
||||||
IrisStructure structure = context.pack().resources().require(StructureResources.STRUCTURES, id);
|
IrisStructure structure = context.pack().resources().require(StructureResources.STRUCTURES, id);
|
||||||
StructureAssemblyResult assembly = StructureAssemblies
|
StructureAssemblyResult assembly = StructureAssemblies
|
||||||
.forData(IrisToolPack.dataOf(context.pack()), structure, new IrisPosition(0, INFO_ORIGIN_Y, 0))
|
.forPack(context.pack().resources(), id.path(), structure, new BlockPosition(0, INFO_ORIGIN_Y, 0))
|
||||||
.assemble(new RNG(INFO_SAMPLE_SEED));
|
.assemble(new RNG(INFO_SAMPLE_SEED));
|
||||||
if (!assembly.hasOutput()) {
|
if (!assembly.hasOutput()) {
|
||||||
context.sender().error("Structure " + id + " assembled 0 pieces (check startPool '" + structure.getStartPool() + "')");
|
context.sender().error("Structure " + id + " assembled 0 pieces (check startPool '" + structure.getStartPool() + "')");
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ package art.arcane.iris.core.modules;
|
|||||||
|
|
||||||
import art.arcane.iris.core.structure.tooling.JigsawCommands;
|
import art.arcane.iris.core.structure.tooling.JigsawCommands;
|
||||||
import art.arcane.iris.core.structure.tooling.JigsawStudioHost;
|
import art.arcane.iris.core.structure.tooling.JigsawStudioHost;
|
||||||
|
import art.arcane.iris.engine.framework.structure.JigsawStructureAssembly;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureLocating;
|
import art.arcane.iris.engine.framework.structure.StructureLocating;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.StructureAssembly;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureValidator;
|
import art.arcane.iris.engine.framework.structure.StructureValidator;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureVanillaStructures;
|
import art.arcane.iris.engine.framework.structure.StructureVanillaStructures;
|
||||||
@@ -61,6 +63,7 @@ public final class StructureModelModule implements IrisModule {
|
|||||||
public void setup(ModuleSetup setup) {
|
public void setup(ModuleSetup setup) {
|
||||||
var registry = setup.registry();
|
var registry = setup.registry();
|
||||||
registry.registerValidator(new StructureValidator());
|
registry.registerValidator(new StructureValidator());
|
||||||
|
registry.registerService(StructureAssembly.class, new JigsawStructureAssembly(setup.log()));
|
||||||
registry.registerService(StructureLocator.class, new StructureLocating());
|
registry.registerService(StructureLocator.class, new StructureLocating());
|
||||||
registry.registerService(VanillaStructures.class, new StructureVanillaStructures());
|
registry.registerService(VanillaStructures.class, new StructureVanillaStructures());
|
||||||
setup.tooling().registerCommand(StructureCommands.root());
|
setup.tooling().registerCommand(StructureCommands.root());
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package art.arcane.iris.core.pack;
|
package art.arcane.iris.core.pack;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
import art.arcane.iris.builtin.structure.IrisStructureRef;
|
import art.arcane.iris.builtin.structure.IrisStructureRef;
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||||
@@ -60,6 +61,13 @@ public final class ModuleResourceClosure {
|
|||||||
private static final String JSON_EXTENSION = ".json";
|
private static final String JSON_EXTENSION = ".json";
|
||||||
private static final int PRETTY_INDENT = 4;
|
private static final int PRETTY_INDENT = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The structure model ships with Iris while the loot kind ships in the built-in modules jar, so the model cannot name
|
||||||
|
* the kind with {@code @ResourceRef} (a pack without the jar could not load it). Until both move into the jar the
|
||||||
|
* closure knows this one reference.
|
||||||
|
*/
|
||||||
|
private static final Field STRUCTURE_LOOT_FIELD = structureLootField();
|
||||||
|
|
||||||
private final IrisData data;
|
private final IrisData data;
|
||||||
private final Map<Class<?>, ResourceKind<?>> kindsByType = new HashMap<>();
|
private final Map<Class<?>, ResourceKind<?>> kindsByType = new HashMap<>();
|
||||||
private final Map<ResourceKind<?>, Map<String, Object>> found = new LinkedHashMap<>();
|
private final Map<ResourceKind<?>, Map<String, Object>> found = new LinkedHashMap<>();
|
||||||
@@ -164,6 +172,14 @@ public final class ModuleResourceClosure {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Field structureLootField() {
|
||||||
|
try {
|
||||||
|
return IrisStructure.class.getDeclaredField("loot");
|
||||||
|
} catch (NoSuchFieldException missing) {
|
||||||
|
throw new IllegalStateException("The structure model has no loot field", missing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** The class of the resources the field names by key, or null when it names none. */
|
/** The class of the resources the field names by key, or null when it names none. */
|
||||||
private static Class<?> referencedType(Field field) {
|
private static Class<?> referencedType(Field field) {
|
||||||
ResourceRef reference = field.getAnnotation(ResourceRef.class);
|
ResourceRef reference = field.getAnnotation(ResourceRef.class);
|
||||||
@@ -173,6 +189,9 @@ public final class ModuleResourceClosure {
|
|||||||
if (field.isAnnotationPresent(IrisStructureRef.class)) {
|
if (field.isAnnotationPresent(IrisStructureRef.class)) {
|
||||||
return IrisStructure.class;
|
return IrisStructure.class;
|
||||||
}
|
}
|
||||||
|
if (field.equals(STRUCTURE_LOOT_FIELD)) {
|
||||||
|
return LootTable.class;
|
||||||
|
}
|
||||||
RegistryListResource registry = field.getAnnotation(RegistryListResource.class);
|
RegistryListResource registry = field.getAnnotation(RegistryListResource.class);
|
||||||
return registry == null ? null : registry.value();
|
return registry == null ? null : registry.value();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package art.arcane.iris.core.runtime.jigsaw;
|
package art.arcane.iris.core.runtime.jigsaw;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
|
|
||||||
public enum JigsawPlanarDirection {
|
public enum JigsawPlanarDirection {
|
||||||
NORTH(1),
|
NORTH(1),
|
||||||
@@ -18,12 +18,12 @@ public enum JigsawPlanarDirection {
|
|||||||
return bit;
|
return bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisDirection irisDirection() {
|
public JigsawDirection direction() {
|
||||||
return switch (this) {
|
return switch (this) {
|
||||||
case NORTH -> IrisDirection.NORTH_NEGATIVE_Z;
|
case NORTH -> JigsawDirection.NORTH_NEGATIVE_Z;
|
||||||
case EAST -> IrisDirection.EAST_POSITIVE_X;
|
case EAST -> JigsawDirection.EAST_POSITIVE_X;
|
||||||
case SOUTH -> IrisDirection.SOUTH_POSITIVE_Z;
|
case SOUTH -> JigsawDirection.SOUTH_POSITIVE_Z;
|
||||||
case WEST -> IrisDirection.WEST_NEGATIVE_X;
|
case WEST -> JigsawDirection.WEST_NEGATIVE_X;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-26
@@ -9,14 +9,13 @@ import art.arcane.iris.core.structure.authoring.StructureWriteOptions;
|
|||||||
import art.arcane.iris.core.structure.authoring.StructureWriteResult;
|
import art.arcane.iris.core.structure.authoring.StructureWriteResult;
|
||||||
import art.arcane.iris.engine.framework.structure.PlanarJigsawWorkcellResolver;
|
import art.arcane.iris.engine.framework.structure.PlanarJigsawWorkcellResolver;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResourceBundleGraphCompiler;
|
import art.arcane.iris.engine.framework.structure.StructureResourceBundleGraphCompiler;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||||
@@ -91,14 +90,14 @@ public final class JigsawStudioGraphEditor {
|
|||||||
.setObject(normalizedPiece)
|
.setObject(normalizedPiece)
|
||||||
.setRotatable(true);
|
.setRotatable(true);
|
||||||
if (topology != null) {
|
if (topology != null) {
|
||||||
IrisPosition cellSize = new IrisPosition(
|
BlockPosition cellSize = new BlockPosition(
|
||||||
dimensions.width(), dimensions.height(), dimensions.depth());
|
dimensions.width(), dimensions.height(), dimensions.depth());
|
||||||
for (JigsawPlanarDirection planarDirection : topology.directions()) {
|
for (JigsawPlanarDirection planarDirection : topology.directions()) {
|
||||||
IrisDirection direction = planarDirection.irisDirection();
|
JigsawDirection direction = planarDirection.direction();
|
||||||
piece.getConnectors().add(new IrisJigsawConnector()
|
piece.getConnectors().add(new IrisJigsawConnector()
|
||||||
.setPosition(IrisJigsawConnector.canonicalPlanarPosition(cellSize, direction))
|
.setPosition(IrisJigsawConnector.canonicalPlanarPosition(cellSize, direction))
|
||||||
.setDirection(direction)
|
.setDirection(direction)
|
||||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||||
.setPool(normalizedPool)
|
.setPool(normalizedPool)
|
||||||
.setName("iris:planar")
|
.setName("iris:planar")
|
||||||
.setTargetName("iris:planar")
|
.setTargetName("iris:planar")
|
||||||
@@ -632,11 +631,11 @@ public final class JigsawStudioGraphEditor {
|
|||||||
Path packRoot,
|
Path packRoot,
|
||||||
String structureKey,
|
String structureKey,
|
||||||
String pieceKey,
|
String pieceKey,
|
||||||
IrisPosition position,
|
BlockPosition position,
|
||||||
String channel
|
String channel
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
String normalizedPiece = JigsawStudioProjectCreator.Options.requireResourceKey(pieceKey);
|
String normalizedPiece = JigsawStudioProjectCreator.Options.requireResourceKey(pieceKey);
|
||||||
IrisPosition connectorPosition = Objects.requireNonNull(position, "Jigsaw connector position");
|
BlockPosition connectorPosition = Objects.requireNonNull(position, "Jigsaw connector position");
|
||||||
String normalizedChannel = normalizeChannel(channel);
|
String normalizedChannel = normalizeChannel(channel);
|
||||||
OwnedGraph graph = loadOwnedGraph(packRoot, structureKey);
|
OwnedGraph graph = loadOwnedGraph(packRoot, structureKey);
|
||||||
String pieceResource = "jigsaw-pieces/" + normalizedPiece + ".json";
|
String pieceResource = "jigsaw-pieces/" + normalizedPiece + ".json";
|
||||||
@@ -669,8 +668,8 @@ public final class JigsawStudioGraphEditor {
|
|||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
throw new IOException("Piece '" + normalizedPiece + "' has no connector at "
|
throw new IOException("Piece '" + normalizedPiece + "' has no connector at "
|
||||||
+ connectorPosition.getX() + "," + connectorPosition.getY() + ","
|
+ connectorPosition.x() + "," + connectorPosition.y() + ","
|
||||||
+ connectorPosition.getZ());
|
+ connectorPosition.z());
|
||||||
}
|
}
|
||||||
return write(graph, bundle.build());
|
return write(graph, bundle.build());
|
||||||
}
|
}
|
||||||
@@ -1301,7 +1300,7 @@ public final class JigsawStudioGraphEditor {
|
|||||||
connectorResize.targetCanonical(),
|
connectorResize.targetCanonical(),
|
||||||
resizedSourceDimensions,
|
resizedSourceDimensions,
|
||||||
quarterTurns);
|
quarterTurns);
|
||||||
connectorResize.connector().setPosition(sourcePosition.toIrisPosition());
|
connectorResize.connector().setPosition(sourcePosition.toBlockPosition());
|
||||||
if (!connectorResize.sourceCanonical().equals(connectorResize.targetCanonical())) {
|
if (!connectorResize.sourceCanonical().equals(connectorResize.targetCanonical())) {
|
||||||
relocatedConnectors++;
|
relocatedConnectors++;
|
||||||
}
|
}
|
||||||
@@ -1370,9 +1369,9 @@ public final class JigsawStudioGraphEditor {
|
|||||||
List<ConnectorResize> planned = new ArrayList<>(connectors.size());
|
List<ConnectorResize> planned = new ArrayList<>(connectors.size());
|
||||||
Set<LocalPosition> sourcePositions = new LinkedHashSet<>();
|
Set<LocalPosition> sourcePositions = new LinkedHashSet<>();
|
||||||
Set<LocalPosition> targetPositions = new LinkedHashSet<>();
|
Set<LocalPosition> targetPositions = new LinkedHashSet<>();
|
||||||
IrisPosition sourceSize = dimensionsPosition(sourceDimensions);
|
BlockPosition sourceSize = dimensionsPosition(sourceDimensions);
|
||||||
IrisPosition canonicalSize = dimensionsPosition(canonicalDimensions);
|
BlockPosition canonicalSize = dimensionsPosition(canonicalDimensions);
|
||||||
IrisPosition targetSize = dimensionsPosition(targetDimensions);
|
BlockPosition targetSize = dimensionsPosition(targetDimensions);
|
||||||
for (int index = 0; index < connectors.size(); index++) {
|
for (int index = 0; index < connectors.size(); index++) {
|
||||||
IrisJigsawConnector connector = connectors.get(index);
|
IrisJigsawConnector connector = connectors.get(index);
|
||||||
if (connector == null || connector.getPosition() == null || connector.getDirection() == null
|
if (connector == null || connector.getPosition() == null || connector.getDirection() == null
|
||||||
@@ -1396,7 +1395,7 @@ public final class JigsawStudioGraphEditor {
|
|||||||
sourceDimensions.width(),
|
sourceDimensions.width(),
|
||||||
sourceDimensions.depth(),
|
sourceDimensions.depth(),
|
||||||
quarterTurns);
|
quarterTurns);
|
||||||
IrisDirection canonicalDirection = rotateHorizontalDirection(
|
JigsawDirection canonicalDirection = rotateHorizontalDirection(
|
||||||
connector.getDirection(),
|
connector.getDirection(),
|
||||||
quarterTurns);
|
quarterTurns);
|
||||||
LocalPosition expectedSource = LocalPosition.from(IrisJigsawConnector.canonicalPlanarPosition(
|
LocalPosition expectedSource = LocalPosition.from(IrisJigsawConnector.canonicalPlanarPosition(
|
||||||
@@ -1585,7 +1584,7 @@ public final class JigsawStudioGraphEditor {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisDirection rotateHorizontalDirection(IrisDirection direction, int quarterTurns) {
|
private static JigsawDirection rotateHorizontalDirection(JigsawDirection direction, int quarterTurns) {
|
||||||
JigsawPlanarDirection planarDirection = switch (direction) {
|
JigsawPlanarDirection planarDirection = switch (direction) {
|
||||||
case NORTH_NEGATIVE_Z -> JigsawPlanarDirection.NORTH;
|
case NORTH_NEGATIVE_Z -> JigsawPlanarDirection.NORTH;
|
||||||
case EAST_POSITIVE_X -> JigsawPlanarDirection.EAST;
|
case EAST_POSITIVE_X -> JigsawPlanarDirection.EAST;
|
||||||
@@ -1594,11 +1593,11 @@ public final class JigsawStudioGraphEditor {
|
|||||||
case UP_POSITIVE_Y, DOWN_NEGATIVE_Y -> throw new IllegalArgumentException(
|
case UP_POSITIVE_Y, DOWN_NEGATIVE_Y -> throw new IllegalArgumentException(
|
||||||
"Planar connector direction must be horizontal");
|
"Planar connector direction must be horizontal");
|
||||||
};
|
};
|
||||||
return planarDirection.rotateClockwise(quarterTurns).irisDirection();
|
return planarDirection.rotateClockwise(quarterTurns).direction();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisPosition dimensionsPosition(JigsawStudioCellDimensions dimensions) {
|
private static BlockPosition dimensionsPosition(JigsawStudioCellDimensions dimensions) {
|
||||||
return new IrisPosition(dimensions.width(), dimensions.height(), dimensions.depth());
|
return new BlockPosition(dimensions.width(), dimensions.height(), dimensions.depth());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean inside(LocalPosition position, JigsawStudioCellDimensions dimensions) {
|
private static boolean inside(LocalPosition position, JigsawStudioCellDimensions dimensions) {
|
||||||
@@ -1831,10 +1830,6 @@ public final class JigsawStudioGraphEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private record LocalPosition(int x, int y, int z) {
|
private record LocalPosition(int x, int y, int z) {
|
||||||
private static LocalPosition from(IrisPosition position) {
|
|
||||||
return new LocalPosition(position.getX(), position.getY(), position.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LocalPosition from(BlockPosition position) {
|
private static LocalPosition from(BlockPosition position) {
|
||||||
return new LocalPosition(position.x(), position.y(), position.z());
|
return new LocalPosition(position.x(), position.y(), position.z());
|
||||||
}
|
}
|
||||||
@@ -1843,10 +1838,6 @@ public final class JigsawStudioGraphEditor {
|
|||||||
return new BlockPosition(x, y, z);
|
return new BlockPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisPosition toIrisPosition() {
|
|
||||||
return new IrisPosition(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String describe() {
|
private String describe() {
|
||||||
return x + "," + y + "," + z;
|
return x + "," + y + "," + z;
|
||||||
}
|
}
|
||||||
|
|||||||
+53
-41
@@ -1,23 +1,23 @@
|
|||||||
package art.arcane.iris.core.runtime.jigsaw;
|
package art.arcane.iris.core.runtime.jigsaw;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.structure.authoring.StructureKey;
|
import art.arcane.iris.core.structure.authoring.StructureKey;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureOwnershipManifest;
|
import art.arcane.iris.core.structure.authoring.StructureOwnershipManifest;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureTransactionWriter;
|
import art.arcane.iris.core.structure.authoring.StructureTransactionWriter;
|
||||||
import art.arcane.iris.engine.framework.structure.PlanarJigsawWorkcellResolver;
|
import art.arcane.iris.engine.framework.structure.PlanarJigsawWorkcellResolver;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
|
import com.volmit.tooling.ToolPack;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.LinkOption;
|
import java.nio.file.LinkOption;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -38,20 +38,24 @@ public final class JigsawStudioGraphMapper {
|
|||||||
private JigsawStudioGraphMapper() {
|
private JigsawStudioGraphMapper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JigsawStudioLayout map(IrisData data, IrisStructure structure) {
|
/**
|
||||||
Objects.requireNonNull(data, "Jigsaw Studio graph mapping requires pack data");
|
* The studio layout of {@code structure}, the structure {@code structureKey} of {@code pack}, whose files are below {@code packRoot}.
|
||||||
|
*/
|
||||||
|
public static JigsawStudioLayout map(ToolPack pack, Path packRoot, String structureKey, IrisStructure structure) {
|
||||||
|
Source data = new Source(Objects.requireNonNull(pack, "Jigsaw Studio graph mapping requires a pack").resources(),
|
||||||
|
Objects.requireNonNull(packRoot, "Jigsaw Studio graph mapping requires the pack folder"), structureKey);
|
||||||
Objects.requireNonNull(structure, "Jigsaw Studio graph mapping requires a structure");
|
Objects.requireNonNull(structure, "Jigsaw Studio graph mapping requires a structure");
|
||||||
JigsawStudioMode mode = structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW
|
JigsawStudioMode mode = structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW
|
||||||
? JigsawStudioMode.PLANAR_JIGSAW
|
? JigsawStudioMode.PLANAR_JIGSAW
|
||||||
: JigsawStudioMode.SPATIAL_JIGSAW;
|
: JigsawStudioMode.SPATIAL_JIGSAW;
|
||||||
JigsawStudioVariantCatalog catalog = catalog(data, structure, mode);
|
JigsawStudioVariantCatalog catalog = catalog(data, structure, mode);
|
||||||
IrisPosition configuredCell = structure.getCellSize();
|
BlockPosition configuredCell = structure.getCellSize();
|
||||||
JigsawStudioCellDimensions dimensions = configuredCell == null
|
JigsawStudioCellDimensions dimensions = configuredCell == null
|
||||||
? new JigsawStudioCellDimensions(15, 15, 15)
|
? new JigsawStudioCellDimensions(15, 15, 15)
|
||||||
: new JigsawStudioCellDimensions(
|
: new JigsawStudioCellDimensions(
|
||||||
Math.max(1, configuredCell.getX()),
|
Math.max(1, configuredCell.x()),
|
||||||
Math.max(1, configuredCell.getY()),
|
Math.max(1, configuredCell.y()),
|
||||||
Math.max(1, configuredCell.getZ()));
|
Math.max(1, configuredCell.z()));
|
||||||
if (mode == JigsawStudioMode.SPATIAL_JIGSAW) {
|
if (mode == JigsawStudioMode.SPATIAL_JIGSAW) {
|
||||||
dimensions = expandSpatialDimensions(data, catalog, dimensions);
|
dimensions = expandSpatialDimensions(data, catalog, dimensions);
|
||||||
return JigsawStudioLayout.createSpatial(
|
return JigsawStudioLayout.createSpatial(
|
||||||
@@ -77,11 +81,18 @@ public final class JigsawStudioGraphMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static JigsawStudioVariantCatalog catalog(
|
public static JigsawStudioVariantCatalog catalog(
|
||||||
IrisData data,
|
ToolPack pack,
|
||||||
|
Path packRoot,
|
||||||
|
String structureKey,
|
||||||
IrisStructure structure,
|
IrisStructure structure,
|
||||||
JigsawStudioMode mode
|
JigsawStudioMode mode
|
||||||
) {
|
) {
|
||||||
IrisData source = Objects.requireNonNull(data, "Jigsaw Studio catalog pack data");
|
return catalog(new Source(Objects.requireNonNull(pack, "Jigsaw Studio catalog pack").resources(),
|
||||||
|
Objects.requireNonNull(packRoot, "Jigsaw Studio catalog pack folder"), structureKey), structure, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JigsawStudioVariantCatalog catalog(Source data, IrisStructure structure, JigsawStudioMode mode) {
|
||||||
|
Source source = data;
|
||||||
IrisStructure root = Objects.requireNonNull(structure, "Jigsaw Studio catalog structure");
|
IrisStructure root = Objects.requireNonNull(structure, "Jigsaw Studio catalog structure");
|
||||||
JigsawStudioMode activeMode = Objects.requireNonNull(mode, "Jigsaw Studio catalog mode");
|
JigsawStudioMode activeMode = Objects.requireNonNull(mode, "Jigsaw Studio catalog mode");
|
||||||
OwnedResources owned = ownedResources(source, root);
|
OwnedResources owned = ownedResources(source, root);
|
||||||
@@ -123,37 +134,34 @@ public final class JigsawStudioGraphMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static JigsawStudioCellDimensions expandSpatialDimensions(
|
static JigsawStudioCellDimensions expandSpatialDimensions(
|
||||||
IrisData data,
|
Source data,
|
||||||
JigsawStudioVariantCatalog catalog,
|
JigsawStudioVariantCatalog catalog,
|
||||||
JigsawStudioCellDimensions configured
|
JigsawStudioCellDimensions configured
|
||||||
) {
|
) {
|
||||||
if (data.getObjectLoader() == null) {
|
|
||||||
return configured;
|
|
||||||
}
|
|
||||||
int width = configured.width();
|
int width = configured.width();
|
||||||
int height = configured.height();
|
int height = configured.height();
|
||||||
int depth = configured.depth();
|
int depth = configured.depth();
|
||||||
for (JigsawStudioVariant variant : catalog.spatialVariants()) {
|
for (JigsawStudioVariant variant : catalog.spatialVariants()) {
|
||||||
IrisObject object = data.getObjectLoader().load(variant.objectKey());
|
ObjectFrame object = data.objectFrame(variant.objectKey());
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int objectWidth = object.getW();
|
int objectWidth = object.width();
|
||||||
int objectDepth = object.getD();
|
int objectDepth = object.depth();
|
||||||
if (variant.rotatable()) {
|
if (variant.rotatable()) {
|
||||||
int horizontalSpan = Math.max(objectWidth, objectDepth);
|
int horizontalSpan = Math.max(objectWidth, objectDepth);
|
||||||
objectWidth = horizontalSpan;
|
objectWidth = horizontalSpan;
|
||||||
objectDepth = horizontalSpan;
|
objectDepth = horizontalSpan;
|
||||||
}
|
}
|
||||||
width = Math.max(width, objectWidth);
|
width = Math.max(width, objectWidth);
|
||||||
height = Math.max(height, object.getH());
|
height = Math.max(height, object.height());
|
||||||
depth = Math.max(depth, objectDepth);
|
depth = Math.max(depth, objectDepth);
|
||||||
}
|
}
|
||||||
return new JigsawStudioCellDimensions(width, height, depth);
|
return new JigsawStudioCellDimensions(width, height, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void traversePools(
|
private static void traversePools(
|
||||||
IrisData data,
|
Source data,
|
||||||
JigsawStudioMode mode,
|
JigsawStudioMode mode,
|
||||||
OwnedResources owned,
|
OwnedResources owned,
|
||||||
ArrayDeque<String> pools,
|
ArrayDeque<String> pools,
|
||||||
@@ -166,7 +174,7 @@ public final class JigsawStudioGraphMapper {
|
|||||||
if (!visitedPools.add(poolKey)) {
|
if (!visitedPools.add(poolKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisJigsawPool pool = StructureResources.pool(data.getPackResources(), poolKey);
|
IrisJigsawPool pool = StructureResources.pool(data.resources(), poolKey);
|
||||||
if (pool == null) {
|
if (pool == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -180,7 +188,7 @@ public final class JigsawStudioGraphMapper {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String pieceKey = entry.getPiece();
|
String pieceKey = entry.getPiece();
|
||||||
IrisJigsawPiece piece = StructureResources.piece(data.getPackResources(), pieceKey);
|
IrisJigsawPiece piece = StructureResources.piece(data.resources(), pieceKey);
|
||||||
if (piece == null || piece.getObject() == null || piece.getObject().isBlank()) {
|
if (piece == null || piece.getObject() == null || piece.getObject().isBlank()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -202,7 +210,7 @@ public final class JigsawStudioGraphMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addOwnedVariant(
|
private static void addOwnedVariant(
|
||||||
IrisData data,
|
Source data,
|
||||||
JigsawStudioMode mode,
|
JigsawStudioMode mode,
|
||||||
OwnedResources owned,
|
OwnedResources owned,
|
||||||
String pieceKey,
|
String pieceKey,
|
||||||
@@ -211,21 +219,20 @@ public final class JigsawStudioGraphMapper {
|
|||||||
if (variants.containsKey(pieceKey)) {
|
if (variants.containsKey(pieceKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IrisJigsawPiece piece = StructureResources.piece(data.getPackResources(), pieceKey);
|
IrisJigsawPiece piece = StructureResources.piece(data.resources(), pieceKey);
|
||||||
if (piece == null || piece.getObject() == null || piece.getObject().isBlank()) {
|
if (piece == null || piece.getObject() == null || piece.getObject().isBlank()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
variants.put(pieceKey, new MutableVariant(pieceKey, piece, mode, owned.owns(pieceKey, piece.getObject())));
|
variants.put(pieceKey, new MutableVariant(pieceKey, piece, mode, owned.owns(pieceKey, piece.getObject())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OwnedResources ownedResources(IrisData data, IrisStructure structure) {
|
private static OwnedResources ownedResources(Source data, IrisStructure structure) {
|
||||||
String structureKey = structure.getLoadKey();
|
String structureKey = data.structureKey();
|
||||||
File dataFolder = data.getDataFolder();
|
if (structureKey == null || structureKey.isBlank()) {
|
||||||
if (structureKey == null || structureKey.isBlank() || dataFolder == null) {
|
|
||||||
return OwnedResources.empty();
|
return OwnedResources.empty();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Path root = dataFolder.toPath().toAbsolutePath().normalize();
|
Path root = data.root().toAbsolutePath().normalize();
|
||||||
StructureTransactionWriter writer = new StructureTransactionWriter(root);
|
StructureTransactionWriter writer = new StructureTransactionWriter(root);
|
||||||
Path manifestPath = writer.ownershipManifestPath(StructureKey.parse(structureKey, "iris"));
|
Path manifestPath = writer.ownershipManifestPath(StructureKey.parse(structureKey, "iris"));
|
||||||
if (!Files.isRegularFile(manifestPath, LinkOption.NOFOLLOW_LINKS)) {
|
if (!Files.isRegularFile(manifestPath, LinkOption.NOFOLLOW_LINKS)) {
|
||||||
@@ -255,7 +262,7 @@ public final class JigsawStudioGraphMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int directionBit(IrisDirection direction) {
|
private static int directionBit(JigsawDirection direction) {
|
||||||
return switch (direction) {
|
return switch (direction) {
|
||||||
case NORTH_NEGATIVE_Z -> JigsawPlanarDirection.NORTH.bit();
|
case NORTH_NEGATIVE_Z -> JigsawPlanarDirection.NORTH.bit();
|
||||||
case EAST_POSITIVE_X -> JigsawPlanarDirection.EAST.bit();
|
case EAST_POSITIVE_X -> JigsawPlanarDirection.EAST.bit();
|
||||||
@@ -310,7 +317,7 @@ public final class JigsawStudioGraphMapper {
|
|||||||
memberships.add(membership);
|
memberships.add(membership);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JigsawStudioVariant build(IrisData data) {
|
private JigsawStudioVariant build(Source data) {
|
||||||
Optional<JigsawStudioCellDimensions> dimensions = objectDimensions(data, piece, mode);
|
Optional<JigsawStudioCellDimensions> dimensions = objectDimensions(data, piece, mode);
|
||||||
return new JigsawStudioVariant(
|
return new JigsawStudioVariant(
|
||||||
pieceKey,
|
pieceKey,
|
||||||
@@ -329,21 +336,18 @@ public final class JigsawStudioGraphMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Optional<JigsawStudioCellDimensions> objectDimensions(
|
private static Optional<JigsawStudioCellDimensions> objectDimensions(
|
||||||
IrisData data,
|
Source data,
|
||||||
IrisJigsawPiece piece,
|
IrisJigsawPiece piece,
|
||||||
JigsawStudioMode mode
|
JigsawStudioMode mode
|
||||||
) {
|
) {
|
||||||
if (data.getObjectLoader() == null) {
|
ObjectFrame object = data.objectFrame(piece.getObject());
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
IrisObject object = data.getObjectLoader().load(piece.getObject());
|
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
JigsawStudioCellDimensions sourceDimensions = new JigsawStudioCellDimensions(
|
JigsawStudioCellDimensions sourceDimensions = new JigsawStudioCellDimensions(
|
||||||
object.getW(),
|
object.width(),
|
||||||
object.getH(),
|
object.height(),
|
||||||
object.getD());
|
object.depth());
|
||||||
if (mode == JigsawStudioMode.SPATIAL_JIGSAW) {
|
if (mode == JigsawStudioMode.SPATIAL_JIGSAW) {
|
||||||
return Optional.of(sourceDimensions);
|
return Optional.of(sourceDimensions);
|
||||||
}
|
}
|
||||||
@@ -359,6 +363,14 @@ public final class JigsawStudioGraphMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** What the mapper reads: the pack's resources, its folder for the ownership manifests, and the key of the mapped structure. */
|
||||||
|
record Source(PackResources resources, Path root, String structureKey) {
|
||||||
|
/** The declared size of the object the pack key {@code key} names; null when the pack has none. */
|
||||||
|
private ObjectFrame objectFrame(String key) {
|
||||||
|
return resources.objects().sizeOf(resources.idOf(key)).map(ObjectFrame::of).orElse(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private record OwnedResources(
|
private record OwnedResources(
|
||||||
Set<String> pieceKeys,
|
Set<String> pieceKeys,
|
||||||
Set<String> poolKeys,
|
Set<String> poolKeys,
|
||||||
|
|||||||
+25
-25
@@ -11,7 +11,7 @@ import art.arcane.iris.core.structure.authoring.StructureWriteResult;
|
|||||||
import art.arcane.iris.engine.framework.structure.StructureResourceBundleGraphCompiler;
|
import art.arcane.iris.engine.framework.structure.StructureResourceBundleGraphCompiler;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawCompatibility;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawCompatibility;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
@@ -21,8 +21,8 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcell;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcell;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
@@ -36,13 +36,13 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public final class JigsawStudioProjectCreator {
|
public final class JigsawStudioProjectCreator {
|
||||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||||
private static final List<IrisDirection> SPATIAL_CONNECTOR_ORDER = List.of(
|
private static final List<JigsawDirection> SPATIAL_CONNECTOR_ORDER = List.of(
|
||||||
IrisDirection.NORTH_NEGATIVE_Z,
|
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
IrisDirection.SOUTH_POSITIVE_Z,
|
JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
IrisDirection.EAST_POSITIVE_X,
|
JigsawDirection.EAST_POSITIVE_X,
|
||||||
IrisDirection.WEST_NEGATIVE_X,
|
JigsawDirection.WEST_NEGATIVE_X,
|
||||||
IrisDirection.UP_POSITIVE_Y,
|
JigsawDirection.UP_POSITIVE_Y,
|
||||||
IrisDirection.DOWN_NEGATIVE_Y);
|
JigsawDirection.DOWN_NEGATIVE_Y);
|
||||||
|
|
||||||
private JigsawStudioProjectCreator() {
|
private JigsawStudioProjectCreator() {
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ public final class JigsawStudioProjectCreator {
|
|||||||
.setMode(toModelMode(options.mode()))
|
.setMode(toModelMode(options.mode()))
|
||||||
.setCompatibility(toModelCompatibility(options.compatibilityTarget()))
|
.setCompatibility(toModelCompatibility(options.compatibilityTarget()))
|
||||||
.setBranchFailurePolicy(toBranchFailurePolicy(options.compatibilityTarget()))
|
.setBranchFailurePolicy(toBranchFailurePolicy(options.compatibilityTarget()))
|
||||||
.setCellSize(new IrisPosition(
|
.setCellSize(new BlockPosition(
|
||||||
options.cellDimensions().width(),
|
options.cellDimensions().width(),
|
||||||
options.cellDimensions().height(),
|
options.cellDimensions().height(),
|
||||||
options.cellDimensions().depth()));
|
options.cellDimensions().depth()));
|
||||||
@@ -123,7 +123,7 @@ public final class JigsawStudioProjectCreator {
|
|||||||
Options options
|
Options options
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
JigsawStudioCellDimensions dimensions = options.cellDimensions();
|
JigsawStudioCellDimensions dimensions = options.cellDimensions();
|
||||||
IrisPosition size = new IrisPosition(dimensions.width(), dimensions.height(), dimensions.depth());
|
BlockPosition size = new BlockPosition(dimensions.width(), dimensions.height(), dimensions.depth());
|
||||||
String piecePoolKey = options.structureKey() + "/pieces";
|
String piecePoolKey = options.structureKey() + "/pieces";
|
||||||
String capPoolKey = options.structureKey() + "/caps";
|
String capPoolKey = options.structureKey() + "/caps";
|
||||||
IrisJigsawPool piecePool = new IrisJigsawPool().setFallback(capPoolKey);
|
IrisJigsawPool piecePool = new IrisJigsawPool().setFallback(capPoolKey);
|
||||||
@@ -209,13 +209,13 @@ public final class JigsawStudioProjectCreator {
|
|||||||
.setRotatable(true)
|
.setRotatable(true)
|
||||||
.setRules(new IrisJigsawPieceRules().setMaximumPlacements(16));
|
.setRules(new IrisJigsawPieceRules().setMaximumPlacements(16));
|
||||||
for (int index = 0; index < connectorCount; index++) {
|
for (int index = 0; index < connectorCount; index++) {
|
||||||
IrisDirection direction = SPATIAL_CONNECTOR_ORDER.get(index);
|
JigsawDirection direction = SPATIAL_CONNECTOR_ORDER.get(index);
|
||||||
piece.getConnectors().add(new IrisJigsawConnector()
|
piece.getConnectors().add(new IrisJigsawConnector()
|
||||||
.setPosition(spatialConnectorPosition(dimensions, direction))
|
.setPosition(spatialConnectorPosition(dimensions, direction))
|
||||||
.setDirection(direction)
|
.setDirection(direction)
|
||||||
.setTop(direction.isVertical()
|
.setTop(direction.isVertical()
|
||||||
? IrisDirection.NORTH_NEGATIVE_Z
|
? JigsawDirection.NORTH_NEGATIVE_Z
|
||||||
: IrisDirection.UP_POSITIVE_Y)
|
: JigsawDirection.UP_POSITIVE_Y)
|
||||||
.setPool(poolKey)
|
.setPool(poolKey)
|
||||||
.setName("iris:spatial")
|
.setName("iris:spatial")
|
||||||
.setTargetName("iris:spatial")
|
.setTargetName("iris:spatial")
|
||||||
@@ -225,36 +225,36 @@ public final class JigsawStudioProjectCreator {
|
|||||||
return piece;
|
return piece;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisPosition spatialConnectorPosition(
|
private static BlockPosition spatialConnectorPosition(
|
||||||
JigsawStudioCellDimensions dimensions,
|
JigsawStudioCellDimensions dimensions,
|
||||||
IrisDirection direction
|
JigsawDirection direction
|
||||||
) {
|
) {
|
||||||
int centerX = dimensions.width() / 2;
|
int centerX = dimensions.width() / 2;
|
||||||
int centerY = dimensions.height() / 2;
|
int centerY = dimensions.height() / 2;
|
||||||
int centerZ = dimensions.depth() / 2;
|
int centerZ = dimensions.depth() / 2;
|
||||||
return switch (direction) {
|
return switch (direction) {
|
||||||
case NORTH_NEGATIVE_Z -> new IrisPosition(centerX, centerY, 0);
|
case NORTH_NEGATIVE_Z -> new BlockPosition(centerX, centerY, 0);
|
||||||
case SOUTH_POSITIVE_Z -> new IrisPosition(centerX, centerY, dimensions.depth() - 1);
|
case SOUTH_POSITIVE_Z -> new BlockPosition(centerX, centerY, dimensions.depth() - 1);
|
||||||
case EAST_POSITIVE_X -> new IrisPosition(dimensions.width() - 1, centerY, centerZ);
|
case EAST_POSITIVE_X -> new BlockPosition(dimensions.width() - 1, centerY, centerZ);
|
||||||
case WEST_NEGATIVE_X -> new IrisPosition(0, centerY, centerZ);
|
case WEST_NEGATIVE_X -> new BlockPosition(0, centerY, centerZ);
|
||||||
case UP_POSITIVE_Y -> new IrisPosition(centerX, dimensions.height() - 1, centerZ);
|
case UP_POSITIVE_Y -> new BlockPosition(centerX, dimensions.height() - 1, centerZ);
|
||||||
case DOWN_NEGATIVE_Y -> new IrisPosition(centerX, 0, centerZ);
|
case DOWN_NEGATIVE_Y -> new BlockPosition(centerX, 0, centerZ);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisJigsawPiece planarPiece(
|
private static IrisJigsawPiece planarPiece(
|
||||||
String objectKey,
|
String objectKey,
|
||||||
String poolKey,
|
String poolKey,
|
||||||
IrisPosition dimensions,
|
BlockPosition dimensions,
|
||||||
JigsawPlanarArchetype archetype
|
JigsawPlanarArchetype archetype
|
||||||
) {
|
) {
|
||||||
IrisJigsawPiece piece = new IrisJigsawPiece().setObject(objectKey).setRotatable(true);
|
IrisJigsawPiece piece = new IrisJigsawPiece().setObject(objectKey).setRotatable(true);
|
||||||
for (JigsawPlanarDirection planarDirection : archetype.canonicalTopology().directions()) {
|
for (JigsawPlanarDirection planarDirection : archetype.canonicalTopology().directions()) {
|
||||||
IrisDirection direction = planarDirection.irisDirection();
|
JigsawDirection direction = planarDirection.direction();
|
||||||
piece.getConnectors().add(new IrisJigsawConnector()
|
piece.getConnectors().add(new IrisJigsawConnector()
|
||||||
.setPosition(IrisJigsawConnector.canonicalPlanarPosition(dimensions, direction))
|
.setPosition(IrisJigsawConnector.canonicalPlanarPosition(dimensions, direction))
|
||||||
.setDirection(direction)
|
.setDirection(direction)
|
||||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||||
.setPool(poolKey)
|
.setPool(poolKey)
|
||||||
.setName("iris:planar")
|
.setName("iris:planar")
|
||||||
.setTargetName("iris:planar")
|
.setTargetName("iris:planar")
|
||||||
|
|||||||
+13
-7
@@ -12,9 +12,7 @@ import art.arcane.iris.engine.framework.structure.StructureResourceBundleGraphCo
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
@@ -22,6 +20,7 @@ import com.google.gson.JsonElement;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -270,17 +269,24 @@ public final class JigsawStudioStructureEditor {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Path objectPath = resolveOwnedResource(root, relativePath);
|
Path objectPath = resolveOwnedResource(root, relativePath);
|
||||||
IrisBlockVector size = IrisObject.sampleSize(objectPath.toFile());
|
int[] size = sampleSize(objectPath);
|
||||||
if (size.getBlockX() > dimensions.width()
|
if (size[0] > dimensions.width()
|
||||||
|| size.getBlockY() > dimensions.height()
|
|| size[1] > dimensions.height()
|
||||||
|| size.getBlockZ() > dimensions.depth()) {
|
|| size[2] > dimensions.depth()) {
|
||||||
throw new IOException("Owned object '" + relativePath + "' is "
|
throw new IOException("Owned object '" + relativePath + "' is "
|
||||||
+ size.getBlockX() + "x" + size.getBlockY() + "x" + size.getBlockZ()
|
+ size[0] + "x" + size[1] + "x" + size[2]
|
||||||
+ " and does not fit the requested cell bounds");
|
+ " and does not fit the requested cell bounds");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The declared width, height and depth in the header of an {@code .iob} file. */
|
||||||
|
private static int[] sampleSize(Path objectPath) throws IOException {
|
||||||
|
try (DataInputStream header = new DataInputStream(Files.newInputStream(objectPath))) {
|
||||||
|
return new int[]{header.readInt(), header.readInt(), header.readInt()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static byte[] updateCellSize(
|
private static byte[] updateCellSize(
|
||||||
byte[] content,
|
byte[] content,
|
||||||
JigsawStudioCellDimensions dimensions,
|
JigsawStudioCellDimensions dimensions,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package art.arcane.iris.core.runtime.jigsaw;
|
package art.arcane.iris.core.runtime.jigsaw;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -61,8 +61,8 @@ public record JigsawStudioVariant(
|
|||||||
.canonicalToSourceQuarterTurns(topology);
|
.canonicalToSourceQuarterTurns(topology);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisPosition sourceToCanonicalPosition(
|
public BlockPosition sourceToCanonicalPosition(
|
||||||
IrisPosition sourcePosition,
|
BlockPosition sourcePosition,
|
||||||
JigsawStudioCellDimensions sourceDimensions
|
JigsawStudioCellDimensions sourceDimensions
|
||||||
) {
|
) {
|
||||||
return rotatePosition(
|
return rotatePosition(
|
||||||
@@ -71,8 +71,8 @@ public record JigsawStudioVariant(
|
|||||||
sourceToCanonicalQuarterTurns());
|
sourceToCanonicalQuarterTurns());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisPosition canonicalToSourcePosition(
|
public BlockPosition canonicalToSourcePosition(
|
||||||
IrisPosition canonicalPosition,
|
BlockPosition canonicalPosition,
|
||||||
JigsawStudioCellDimensions sourceDimensions
|
JigsawStudioCellDimensions sourceDimensions
|
||||||
) {
|
) {
|
||||||
JigsawStudioCellDimensions canonicalDimensions = canonicalDimensions(sourceDimensions);
|
JigsawStudioCellDimensions canonicalDimensions = canonicalDimensions(sourceDimensions);
|
||||||
@@ -98,34 +98,34 @@ public record JigsawStudioVariant(
|
|||||||
return !memberships.isEmpty();
|
return !memberships.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisPosition rotatePosition(
|
private static BlockPosition rotatePosition(
|
||||||
IrisPosition position,
|
BlockPosition position,
|
||||||
JigsawStudioCellDimensions dimensions,
|
JigsawStudioCellDimensions dimensions,
|
||||||
int quarterTurns
|
int quarterTurns
|
||||||
) {
|
) {
|
||||||
IrisPosition source = Objects.requireNonNull(position, "Jigsaw Studio variant position");
|
BlockPosition source = Objects.requireNonNull(position, "Jigsaw Studio variant position");
|
||||||
JigsawStudioCellDimensions bounds = Objects.requireNonNull(
|
JigsawStudioCellDimensions bounds = Objects.requireNonNull(
|
||||||
dimensions,
|
dimensions,
|
||||||
"Jigsaw Studio variant position bounds");
|
"Jigsaw Studio variant position bounds");
|
||||||
if (source.getX() < 0 || source.getX() >= bounds.width()
|
if (source.x() < 0 || source.x() >= bounds.width()
|
||||||
|| source.getY() < 0 || source.getY() >= bounds.height()
|
|| source.y() < 0 || source.y() >= bounds.height()
|
||||||
|| source.getZ() < 0 || source.getZ() >= bounds.depth()) {
|
|| source.z() < 0 || source.z() >= bounds.depth()) {
|
||||||
throw new IllegalArgumentException("Jigsaw Studio variant position is outside its object bounds");
|
throw new IllegalArgumentException("Jigsaw Studio variant position is outside its object bounds");
|
||||||
}
|
}
|
||||||
return switch (Math.floorMod(quarterTurns, 4)) {
|
return switch (Math.floorMod(quarterTurns, 4)) {
|
||||||
case 0 -> new IrisPosition(source.getX(), source.getY(), source.getZ());
|
case 0 -> new BlockPosition(source.x(), source.y(), source.z());
|
||||||
case 1 -> new IrisPosition(
|
case 1 -> new BlockPosition(
|
||||||
bounds.depth() - 1 - source.getZ(),
|
bounds.depth() - 1 - source.z(),
|
||||||
source.getY(),
|
source.y(),
|
||||||
source.getX());
|
source.x());
|
||||||
case 2 -> new IrisPosition(
|
case 2 -> new BlockPosition(
|
||||||
bounds.width() - 1 - source.getX(),
|
bounds.width() - 1 - source.x(),
|
||||||
source.getY(),
|
source.y(),
|
||||||
bounds.depth() - 1 - source.getZ());
|
bounds.depth() - 1 - source.z());
|
||||||
case 3 -> new IrisPosition(
|
case 3 -> new BlockPosition(
|
||||||
source.getZ(),
|
source.z(),
|
||||||
source.getY(),
|
source.y(),
|
||||||
bounds.width() - 1 - source.getX());
|
bounds.width() - 1 - source.x());
|
||||||
default -> throw new IllegalStateException("Unreachable Jigsaw Studio rotation");
|
default -> throw new IllegalStateException("Unreachable Jigsaw Studio rotation");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
import com.volmit.block.BlockRegistry;
|
import com.volmit.block.BlockRegistry;
|
||||||
import com.volmit.block.BlockState;
|
import com.volmit.block.BlockState;
|
||||||
|
|
||||||
@@ -39,8 +39,8 @@ public final class JigsawStudioBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** {@code state} turned like {@code rotation}; null when the registry cannot turn the block. */
|
/** {@code state} turned like {@code rotation}; null when the registry cannot turn the block. */
|
||||||
public static BlockState rotated(BlockRegistry registry, BlockState state, ObjectTurn rotation) {
|
public static BlockState rotated(BlockRegistry registry, BlockState state, PieceTurn rotation) {
|
||||||
if (!rotation.canRotate()) {
|
if (rotation.quarterTurns() == 0) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
return registry.tryRotate(state, rotation.blockTurn()).orElse(null);
|
return registry.tryRotate(state, rotation.blockTurn()).orElse(null);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMarkerKeyCodec;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMarkerKeyCodec;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -31,7 +31,7 @@ final class JigsawStudioMarkerParser {
|
|||||||
throw new IllegalArgumentException("Unsupported jigsaw joint '" + jointName + "'", exception);
|
throw new IllegalArgumentException("Unsupported jigsaw joint '" + jointName + "'", exception);
|
||||||
}
|
}
|
||||||
return new IrisJigsawConnector()
|
return new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition(x, y, z))
|
.setPosition(new BlockPosition(x, y, z))
|
||||||
.setDirection(directions.front())
|
.setDirection(directions.front())
|
||||||
.setTop(directions.top())
|
.setTop(directions.top())
|
||||||
.setPool(JigsawStudioMarkerKeyCodec.decodePool(requiredString(properties, "pool")))
|
.setPool(JigsawStudioMarkerKeyCodec.decodePool(requiredString(properties, "pool")))
|
||||||
@@ -48,18 +48,18 @@ final class JigsawStudioMarkerParser {
|
|||||||
static Directions directions(String orientation) {
|
static Directions directions(String orientation) {
|
||||||
String name = Objects.requireNonNull(orientation, "Jigsaw orientation").toLowerCase(Locale.ROOT);
|
String name = Objects.requireNonNull(orientation, "Jigsaw orientation").toLowerCase(Locale.ROOT);
|
||||||
return switch (name) {
|
return switch (name) {
|
||||||
case "down_east" -> new Directions(IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.EAST_POSITIVE_X);
|
case "down_east" -> new Directions(JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.EAST_POSITIVE_X);
|
||||||
case "down_north" -> new Directions(IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.NORTH_NEGATIVE_Z);
|
case "down_north" -> new Directions(JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
case "down_south" -> new Directions(IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.SOUTH_POSITIVE_Z);
|
case "down_south" -> new Directions(JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
case "down_west" -> new Directions(IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.WEST_NEGATIVE_X);
|
case "down_west" -> new Directions(JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.WEST_NEGATIVE_X);
|
||||||
case "up_east" -> new Directions(IrisDirection.UP_POSITIVE_Y, IrisDirection.EAST_POSITIVE_X);
|
case "up_east" -> new Directions(JigsawDirection.UP_POSITIVE_Y, JigsawDirection.EAST_POSITIVE_X);
|
||||||
case "up_north" -> new Directions(IrisDirection.UP_POSITIVE_Y, IrisDirection.NORTH_NEGATIVE_Z);
|
case "up_north" -> new Directions(JigsawDirection.UP_POSITIVE_Y, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
case "up_south" -> new Directions(IrisDirection.UP_POSITIVE_Y, IrisDirection.SOUTH_POSITIVE_Z);
|
case "up_south" -> new Directions(JigsawDirection.UP_POSITIVE_Y, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
case "up_west" -> new Directions(IrisDirection.UP_POSITIVE_Y, IrisDirection.WEST_NEGATIVE_X);
|
case "up_west" -> new Directions(JigsawDirection.UP_POSITIVE_Y, JigsawDirection.WEST_NEGATIVE_X);
|
||||||
case "west_up" -> new Directions(IrisDirection.WEST_NEGATIVE_X, IrisDirection.UP_POSITIVE_Y);
|
case "west_up" -> new Directions(JigsawDirection.WEST_NEGATIVE_X, JigsawDirection.UP_POSITIVE_Y);
|
||||||
case "east_up" -> new Directions(IrisDirection.EAST_POSITIVE_X, IrisDirection.UP_POSITIVE_Y);
|
case "east_up" -> new Directions(JigsawDirection.EAST_POSITIVE_X, JigsawDirection.UP_POSITIVE_Y);
|
||||||
case "north_up" -> new Directions(IrisDirection.NORTH_NEGATIVE_Z, IrisDirection.UP_POSITIVE_Y);
|
case "north_up" -> new Directions(JigsawDirection.NORTH_NEGATIVE_Z, JigsawDirection.UP_POSITIVE_Y);
|
||||||
case "south_up" -> new Directions(IrisDirection.SOUTH_POSITIVE_Z, IrisDirection.UP_POSITIVE_Y);
|
case "south_up" -> new Directions(JigsawDirection.SOUTH_POSITIVE_Z, JigsawDirection.UP_POSITIVE_Y);
|
||||||
default -> throw new IllegalArgumentException("Unsupported jigsaw orientation '" + orientation + "'");
|
default -> throw new IllegalArgumentException("Unsupported jigsaw orientation '" + orientation + "'");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ final class JigsawStudioMarkerParser {
|
|||||||
return (int) longValue;
|
return (int) longValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
record Directions(IrisDirection front, IrisDirection top) {
|
record Directions(JigsawDirection front, JigsawDirection top) {
|
||||||
Directions {
|
Directions {
|
||||||
Objects.requireNonNull(front, "Jigsaw front direction");
|
Objects.requireNonNull(front, "Jigsaw front direction");
|
||||||
Objects.requireNonNull(top, "Jigsaw top direction");
|
Objects.requireNonNull(top, "Jigsaw top direction");
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
|
||||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
|
||||||
import com.volmit.ModuleLog;
|
import com.volmit.ModuleLog;
|
||||||
import com.volmit.block.BlockRegistry;
|
import com.volmit.block.BlockRegistry;
|
||||||
import com.volmit.block.BlockState;
|
import com.volmit.block.BlockState;
|
||||||
import com.volmit.object.ObjectBlock;
|
import com.volmit.object.ObjectBlock;
|
||||||
|
import com.volmit.object.PlaceableObject;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
import com.volmit.tooling.world.ToolWorld;
|
import com.volmit.tooling.world.ToolWorld;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -39,7 +40,8 @@ public final class JigsawStudioPreviewRenderer {
|
|||||||
this.log = Objects.requireNonNull(log, "Jigsaw Studio preview log");
|
this.log = Objects.requireNonNull(log, "Jigsaw Studio preview log");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PreviewPlan plan(List<PlacedStructurePiece> pieces, BlockRegistry registry) throws IOException {
|
public static PreviewPlan plan(List<PlacedStructurePiece> pieces, PackResources pack) throws IOException {
|
||||||
|
BlockRegistry registry = pack.blocks();
|
||||||
List<PlacedStructurePiece> source = List.copyOf(Objects.requireNonNull(
|
List<PlacedStructurePiece> source = List.copyOf(Objects.requireNonNull(
|
||||||
pieces,
|
pieces,
|
||||||
"Jigsaw Studio preview pieces"));
|
"Jigsaw Studio preview pieces"));
|
||||||
@@ -64,7 +66,7 @@ public final class JigsawStudioPreviewRenderer {
|
|||||||
maximumX = Math.max(maximumX, piece.getMaxX());
|
maximumX = Math.max(maximumX, piece.getMaxX());
|
||||||
maximumY = Math.max(maximumY, piece.getMaxY());
|
maximumY = Math.max(maximumY, piece.getMaxY());
|
||||||
maximumZ = Math.max(maximumZ, piece.getMaxZ());
|
maximumZ = Math.max(maximumZ, piece.getMaxZ());
|
||||||
appendObject(blocks, piece, registry);
|
appendObject(blocks, piece, pack);
|
||||||
appendFinalStates(blocks, piece, registry);
|
appendFinalStates(blocks, piece, registry);
|
||||||
if (blocks.size() > MAX_BLOCKS) {
|
if (blocks.size() > MAX_BLOCKS) {
|
||||||
throw new IOException("The seed-1337 preview exceeds the Studio render limit of "
|
throw new IOException("The seed-1337 preview exceeds the Studio render limit of "
|
||||||
@@ -188,19 +190,17 @@ public final class JigsawStudioPreviewRenderer {
|
|||||||
private static void appendObject(
|
private static void appendObject(
|
||||||
Map<BlockPosition, String> blocks,
|
Map<BlockPosition, String> blocks,
|
||||||
PlacedStructurePiece piece,
|
PlacedStructurePiece piece,
|
||||||
BlockRegistry registry
|
PackResources pack
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
ObjectTurn rotation = piece.getRotation();
|
PieceTurn rotation = piece.getRotation();
|
||||||
for (ObjectBlock block : piece.getObject().geometry().blocks()) {
|
PlaceableObject object = pack.objects().object(pack.idOf(piece.getObjectKey()))
|
||||||
IrisBlockVector rotated = rotation.rotate(new IrisBlockVector(
|
.orElseThrow(() -> new IOException("Jigsaw Studio preview cannot find object '" + piece.getObjectKey() + "'"));
|
||||||
block.position().x(), block.position().y(), block.position().z()));
|
for (ObjectBlock block : object.geometry().blocks()) {
|
||||||
|
com.volmit.geometry.BlockPosition rotated = rotation.rotate(block.position());
|
||||||
putState(
|
putState(
|
||||||
blocks,
|
blocks,
|
||||||
new BlockPosition(
|
new BlockPosition(piece.getX() + rotated.x(), piece.getY() + rotated.y(), piece.getZ() + rotated.z()),
|
||||||
piece.getX() + rotated.getBlockX(),
|
JigsawStudioBlocks.rotated(pack.blocks(), block.state(), rotation),
|
||||||
piece.getY() + rotated.getBlockY(),
|
|
||||||
piece.getZ() + rotated.getBlockZ()),
|
|
||||||
JigsawStudioBlocks.rotated(registry, block.state(), rotation),
|
|
||||||
"object block");
|
"object block");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,7 +210,7 @@ public final class JigsawStudioPreviewRenderer {
|
|||||||
PlacedStructurePiece piece,
|
PlacedStructurePiece piece,
|
||||||
BlockRegistry registry
|
BlockRegistry registry
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
ObjectTurn rotation = piece.getRotation();
|
PieceTurn rotation = piece.getRotation();
|
||||||
if (piece.getPiece().getConnectors() == null) {
|
if (piece.getPiece().getConnectors() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -218,18 +218,14 @@ public final class JigsawStudioPreviewRenderer {
|
|||||||
if (connector == null || connector.getPosition() == null) {
|
if (connector == null || connector.getPosition() == null) {
|
||||||
throw new IOException("Jigsaw Studio preview contains an incomplete connector");
|
throw new IOException("Jigsaw Studio preview contains an incomplete connector");
|
||||||
}
|
}
|
||||||
IrisBlockVector signed = new IrisBlockVector(
|
com.volmit.geometry.BlockPosition rotated = rotation.rotate(new com.volmit.geometry.BlockPosition(
|
||||||
connector.getPosition().getX() - piece.getObject().center().x(),
|
connector.getPosition().x() - piece.getObject().center().x(),
|
||||||
connector.getPosition().getY() - piece.getObject().center().y(),
|
connector.getPosition().y() - piece.getObject().center().y(),
|
||||||
connector.getPosition().getZ() - piece.getObject().center().z());
|
connector.getPosition().z() - piece.getObject().center().z()));
|
||||||
IrisBlockVector rotated = rotation.rotate(signed);
|
|
||||||
BlockState source = registry.find(connector.getFinalState()).orElse(null);
|
BlockState source = registry.find(connector.getFinalState()).orElse(null);
|
||||||
putState(
|
putState(
|
||||||
blocks,
|
blocks,
|
||||||
new BlockPosition(
|
new BlockPosition(piece.getX() + rotated.x(), piece.getY() + rotated.y(), piece.getZ() + rotated.z()),
|
||||||
piece.getX() + rotated.getBlockX(),
|
|
||||||
piece.getY() + rotated.getBlockY(),
|
|
||||||
piece.getZ() + rotated.getBlockZ()),
|
|
||||||
source == null ? null : JigsawStudioBlocks.rotated(registry, source, rotation),
|
source == null ? null : JigsawStudioBlocks.rotated(registry, source, rotation),
|
||||||
"connector final state");
|
"connector final state");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioLayout;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioLayout;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMode;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMode;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioSession;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioSession;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariantCatalog;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariantCatalog;
|
||||||
|
import com.volmit.tooling.ToolPack;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -31,7 +31,7 @@ public final class JigsawStudioRegistry {
|
|||||||
JigsawStudioMode mode,
|
JigsawStudioMode mode,
|
||||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||||
JigsawStudioCellDimensions cellDimensions,
|
JigsawStudioCellDimensions cellDimensions,
|
||||||
IrisData source
|
ToolPack source
|
||||||
) {
|
) {
|
||||||
JigsawStudioLayout layout = JigsawStudioLayout.create(
|
JigsawStudioLayout layout = JigsawStudioLayout.create(
|
||||||
mode,
|
mode,
|
||||||
@@ -55,7 +55,7 @@ public final class JigsawStudioRegistry {
|
|||||||
JigsawStudioMode mode,
|
JigsawStudioMode mode,
|
||||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||||
JigsawStudioCellDimensions cellDimensions,
|
JigsawStudioCellDimensions cellDimensions,
|
||||||
IrisData source,
|
ToolPack source,
|
||||||
JigsawStudioLayout initialLayout
|
JigsawStudioLayout initialLayout
|
||||||
) {
|
) {
|
||||||
return activate(
|
return activate(
|
||||||
@@ -76,7 +76,7 @@ public final class JigsawStudioRegistry {
|
|||||||
JigsawStudioMode mode,
|
JigsawStudioMode mode,
|
||||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||||
JigsawStudioCellDimensions cellDimensions,
|
JigsawStudioCellDimensions cellDimensions,
|
||||||
IrisData source,
|
ToolPack source,
|
||||||
JigsawStudioLayout initialLayout,
|
JigsawStudioLayout initialLayout,
|
||||||
UUID ownerId
|
UUID ownerId
|
||||||
) {
|
) {
|
||||||
@@ -109,7 +109,7 @@ public final class JigsawStudioRegistry {
|
|||||||
JigsawStudioMode mode,
|
JigsawStudioMode mode,
|
||||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||||
JigsawStudioCellDimensions cellDimensions,
|
JigsawStudioCellDimensions cellDimensions,
|
||||||
IrisData source,
|
ToolPack source,
|
||||||
JigsawStudioLayout initialLayout,
|
JigsawStudioLayout initialLayout,
|
||||||
UUID ownerId,
|
UUID ownerId,
|
||||||
UUID preservedRequestId
|
UUID preservedRequestId
|
||||||
@@ -299,7 +299,7 @@ public final class JigsawStudioRegistry {
|
|||||||
JigsawStudioMode mode,
|
JigsawStudioMode mode,
|
||||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||||
JigsawStudioCellDimensions cellDimensions,
|
JigsawStudioCellDimensions cellDimensions,
|
||||||
IrisData source,
|
ToolPack source,
|
||||||
JigsawStudioLayout initialLayout,
|
JigsawStudioLayout initialLayout,
|
||||||
UUID ownerId
|
UUID ownerId
|
||||||
) {
|
) {
|
||||||
@@ -311,6 +311,7 @@ public final class JigsawStudioRegistry {
|
|||||||
compatibilityTarget,
|
compatibilityTarget,
|
||||||
cellDimensions,
|
cellDimensions,
|
||||||
source,
|
source,
|
||||||
|
JigsawStudioRequest.rootOf(source),
|
||||||
ownerId);
|
ownerId);
|
||||||
JigsawStudioLayout layout = Objects.requireNonNull(initialLayout, "Initial Jigsaw Studio layout");
|
JigsawStudioLayout layout = Objects.requireNonNull(initialLayout, "Initial Jigsaw Studio layout");
|
||||||
if (layout.mode() != mode) {
|
if (layout.mode() != mode) {
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMode;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMode;
|
||||||
|
import com.volmit.tooling.ToolPack;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UncheckedIOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/** What one open Jigsaw Studio was asked to edit, and who owns it. */
|
/**
|
||||||
|
* What one open Jigsaw Studio was asked to edit, and who owns it.
|
||||||
|
*
|
||||||
|
* @param source the pack whose structure is edited
|
||||||
|
* @param packRoot the pack's folder, which the graph editors write below, as {@link ToolPack#edit} hands it out
|
||||||
|
*/
|
||||||
public record JigsawStudioRequest(
|
public record JigsawStudioRequest(
|
||||||
UUID requestId,
|
UUID requestId,
|
||||||
String packKey,
|
String packKey,
|
||||||
@@ -16,9 +24,33 @@ public record JigsawStudioRequest(
|
|||||||
JigsawStudioMode mode,
|
JigsawStudioMode mode,
|
||||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||||
JigsawStudioCellDimensions cellDimensions,
|
JigsawStudioCellDimensions cellDimensions,
|
||||||
IrisData source,
|
ToolPack source,
|
||||||
|
Path packRoot,
|
||||||
UUID ownerId
|
UUID ownerId
|
||||||
) {
|
) {
|
||||||
|
/** The folder of {@code pack}. */
|
||||||
|
public static Path rootOf(ToolPack pack) {
|
||||||
|
try {
|
||||||
|
return pack.edit(root -> root);
|
||||||
|
} catch (IOException failure) {
|
||||||
|
throw new UncheckedIOException("Cannot reach the folder of the pack", failure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Makes {@code pack} read its files again after a tool changed them. */
|
||||||
|
public static void reload(ToolPack pack) {
|
||||||
|
try {
|
||||||
|
pack.edit(root -> null);
|
||||||
|
} catch (IOException failure) {
|
||||||
|
throw new UncheckedIOException("Cannot reload the pack", failure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Makes the pack read the files again after the studio changed them. */
|
||||||
|
public void reloadSource() {
|
||||||
|
reload(source);
|
||||||
|
}
|
||||||
|
|
||||||
public JigsawStudioRequest {
|
public JigsawStudioRequest {
|
||||||
requestId = Objects.requireNonNull(requestId, "Jigsaw Studio request ID");
|
requestId = Objects.requireNonNull(requestId, "Jigsaw Studio request ID");
|
||||||
packKey = requireKey(packKey, "pack");
|
packKey = requireKey(packKey, "pack");
|
||||||
@@ -29,7 +61,8 @@ public record JigsawStudioRequest(
|
|||||||
"Jigsaw Studio compatibility target"
|
"Jigsaw Studio compatibility target"
|
||||||
);
|
);
|
||||||
cellDimensions = Objects.requireNonNull(cellDimensions, "Jigsaw Studio cell dimensions");
|
cellDimensions = Objects.requireNonNull(cellDimensions, "Jigsaw Studio cell dimensions");
|
||||||
source = Objects.requireNonNull(source, "Jigsaw Studio source data");
|
source = Objects.requireNonNull(source, "Jigsaw Studio source pack");
|
||||||
|
packRoot = Objects.requireNonNull(packRoot, "Jigsaw Studio pack folder");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String requireKey(String value, String name) {
|
private static String requireKey(String value, String name) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarArchetype;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarArchetype;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarDirection;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarDirection;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarTopology;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarTopology;
|
||||||
@@ -36,12 +35,11 @@ import art.arcane.iris.engine.framework.structure.StructureGraphCompiler;
|
|||||||
import art.arcane.iris.engine.framework.structure.StructureGraphDiagnostic;
|
import art.arcane.iris.engine.framework.structure.StructureGraphDiagnostic;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureGraphResolver;
|
import art.arcane.iris.engine.framework.structure.StructureGraphResolver;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResourceBundleGraphCompiler;
|
import art.arcane.iris.engine.framework.structure.StructureResourceBundleGraphCompiler;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import art.arcane.iris.engine.platform.studio.generators.JigsawStudioGenerator;
|
import art.arcane.iris.engine.platform.studio.generators.JigsawStudioGenerator;
|
||||||
@@ -138,9 +136,9 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
"help", "list", "me", "msg", "ping", "pl", "plugins", "r", "reply", "rules",
|
"help", "list", "me", "msg", "ping", "pl", "plugins", "r", "reply", "rules",
|
||||||
"say", "tell", "ver", "version", "w", "whisper");
|
"say", "tell", "ver", "version", "w", "whisper");
|
||||||
private static final Comparator<IrisJigsawConnector> NEW_CONNECTOR_SOURCE_POSITION_ORDER = Comparator
|
private static final Comparator<IrisJigsawConnector> NEW_CONNECTOR_SOURCE_POSITION_ORDER = Comparator
|
||||||
.comparingInt((IrisJigsawConnector connector) -> connector.getPosition().getX())
|
.comparingInt((IrisJigsawConnector connector) -> connector.getPosition().x())
|
||||||
.thenComparingInt(connector -> connector.getPosition().getY())
|
.thenComparingInt(connector -> connector.getPosition().y())
|
||||||
.thenComparingInt(connector -> connector.getPosition().getZ());
|
.thenComparingInt(connector -> connector.getPosition().z());
|
||||||
private final ModuleLog log;
|
private final ModuleLog log;
|
||||||
private final JigsawStudioRegistry registry = new JigsawStudioRegistry();
|
private final JigsawStudioRegistry registry = new JigsawStudioRegistry();
|
||||||
private final JigsawStudioScheduler scheduler;
|
private final JigsawStudioScheduler scheduler;
|
||||||
@@ -999,7 +997,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
throw new IOException("Jigsaw Studio undo failed: "
|
throw new IOException("Jigsaw Studio undo failed: "
|
||||||
+ writeFailure(result.writeResult()));
|
+ writeFailure(result.writeResult()));
|
||||||
}
|
}
|
||||||
request.source().invalidateStructureResources();
|
request.reloadSource();
|
||||||
JigsawStudioLayout restoredLayout = loadMappedLayout(studio);
|
JigsawStudioLayout restoredLayout = loadMappedLayout(studio);
|
||||||
VariantReloadRequest reload = activeReloads.get(result.pieceKey());
|
VariantReloadRequest reload = activeReloads.get(result.pieceKey());
|
||||||
Optional<VariantReloadRequest> activeReload = reload == null
|
Optional<VariantReloadRequest> activeReload = reload == null
|
||||||
@@ -1380,7 +1378,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
archetype,
|
archetype,
|
||||||
dimensions);
|
dimensions);
|
||||||
}
|
}
|
||||||
request.source().invalidateStructureResources();
|
request.reloadSource();
|
||||||
String resizeSummary = capacityResult == null
|
String resizeSummary = capacityResult == null
|
||||||
? ""
|
? ""
|
||||||
: " Verified " + capacityResult.checkedVariants() + " existing variant"
|
: " Verified " + capacityResult.checkedVariants() + " existing variant"
|
||||||
@@ -2379,7 +2377,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BlockPosition playerAt = player.position();
|
BlockPosition playerAt = player.position();
|
||||||
IrisPosition origin = new IrisPosition(playerAt.x(), playerAt.y(), playerAt.z());
|
BlockPosition origin = new BlockPosition(playerAt.x(), playerAt.y(), playerAt.z());
|
||||||
JigsawStudioRequest request = studio.generator().getRequest();
|
JigsawStudioRequest request = studio.generator().getRequest();
|
||||||
ToolPack pack = studio.generator().getPack();
|
ToolPack pack = studio.generator().getPack();
|
||||||
scheduler.async(() -> {
|
scheduler.async(() -> {
|
||||||
@@ -2389,8 +2387,8 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
if (structure == null) {
|
if (structure == null) {
|
||||||
throw new IOException("The active structure resource no longer exists");
|
throw new IOException("The active structure resource no longer exists");
|
||||||
}
|
}
|
||||||
StructureAssembler assembler = StructureAssembler.forData(
|
StructureAssembler assembler = StructureAssembler.forPack(
|
||||||
request.source(), structure, origin, pack.log());
|
request.source().resources(), request.structureKey(), structure, origin, pack.log());
|
||||||
StructureAssemblyResult assembly = assembler.assemble(new RNG(seed));
|
StructureAssemblyResult assembly = assembler.assemble(new RNG(seed));
|
||||||
if (!assembly.hasOutput()) {
|
if (!assembly.hasOutput()) {
|
||||||
message(player, "The active graph assembled zero preview pieces.");
|
message(player, "The active graph assembled zero preview pieces.");
|
||||||
@@ -2515,8 +2513,9 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
throw new IOException("The active structure resource no longer exists");
|
throw new IOException("The active structure resource no longer exists");
|
||||||
}
|
}
|
||||||
StructureGraphCompilation compilation = StructureGraphCompiler.compile(
|
StructureGraphCompilation compilation = StructureGraphCompiler.compile(
|
||||||
|
request.structureKey(),
|
||||||
structure,
|
structure,
|
||||||
StructureGraphResolver.forData(request.source()));
|
StructureGraphResolver.forPack(request.source().resources()));
|
||||||
StructureGraphDiagnostic firstError = firstDiagnostic(
|
StructureGraphDiagnostic firstError = firstDiagnostic(
|
||||||
compilation,
|
compilation,
|
||||||
StructureGraphDiagnostic.Severity.ERROR);
|
StructureGraphDiagnostic.Severity.ERROR);
|
||||||
@@ -2526,7 +2525,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
generation,
|
generation,
|
||||||
firstError.code() + ": " + firstError.message());
|
firstError.code() + ": " + firstError.message());
|
||||||
} else {
|
} else {
|
||||||
IrisPosition origin = previewOrigin(studio.generator().getLayout(), structure);
|
BlockPosition origin = previewOrigin(studio.generator().getLayout(), structure);
|
||||||
StructureAssembler assembler = StructureAssembler.forCompilation(compilation, origin);
|
StructureAssembler assembler = StructureAssembler.forCompilation(compilation, origin);
|
||||||
StructureAssemblyResult assembly = assembler.assemble(new RNG(PREVIEW_SEED));
|
StructureAssemblyResult assembly = assembler.assemble(new RNG(PREVIEW_SEED));
|
||||||
computation = evaluationForAssembly(
|
computation = evaluationForAssembly(
|
||||||
@@ -2535,7 +2534,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
compilation,
|
compilation,
|
||||||
assembly,
|
assembly,
|
||||||
studio.generator().getLayout().mode(),
|
studio.generator().getLayout().mode(),
|
||||||
studio.generator().getPack().resources().blocks());
|
studio.generator().getPack().resources());
|
||||||
}
|
}
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
reportError(exception);
|
reportError(exception);
|
||||||
@@ -2550,7 +2549,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
StructureGraphCompilation compilation,
|
StructureGraphCompilation compilation,
|
||||||
StructureAssemblyResult assembly,
|
StructureAssemblyResult assembly,
|
||||||
JigsawStudioMode mode,
|
JigsawStudioMode mode,
|
||||||
BlockRegistry blocks
|
PackResources pack
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
if (assembly.status().isFailure()) {
|
if (assembly.status().isFailure()) {
|
||||||
return invalidEvaluation(
|
return invalidEvaluation(
|
||||||
@@ -2574,7 +2573,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
JigsawStudioPreviewRenderer.PreviewPlan.empty());
|
JigsawStudioPreviewRenderer.PreviewPlan.empty());
|
||||||
}
|
}
|
||||||
List<PlacedStructurePiece> aligned = alignPreviewPieces(assembly.pieces(), mode);
|
List<PlacedStructurePiece> aligned = alignPreviewPieces(assembly.pieces(), mode);
|
||||||
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(aligned, blocks);
|
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(aligned, pack);
|
||||||
StructureGraphDiagnostic firstWarning = firstDiagnostic(
|
StructureGraphDiagnostic firstWarning = firstDiagnostic(
|
||||||
compilation,
|
compilation,
|
||||||
StructureGraphDiagnostic.Severity.WARNING);
|
StructureGraphDiagnostic.Severity.WARNING);
|
||||||
@@ -2667,9 +2666,9 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisPosition previewOrigin(JigsawStudioLayout layout, IrisStructure structure) {
|
private static BlockPosition previewOrigin(JigsawStudioLayout layout, IrisStructure structure) {
|
||||||
int radius = Math.max(1, structure.getMaxSizeChunks()) * 16;
|
int radius = Math.max(1, structure.getMaxSizeChunks()) * 16;
|
||||||
return new IrisPosition(
|
return new BlockPosition(
|
||||||
-radius - 32,
|
-radius - 32,
|
||||||
0,
|
0,
|
||||||
Math.max(16, layout.extentZ() / 2));
|
Math.max(16, layout.extentZ() / 2));
|
||||||
@@ -2691,6 +2690,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
for (PlacedStructurePiece piece : pieces) {
|
for (PlacedStructurePiece piece : pieces) {
|
||||||
aligned.add(new PlacedStructurePiece(
|
aligned.add(new PlacedStructurePiece(
|
||||||
piece.getPiece(),
|
piece.getPiece(),
|
||||||
|
piece.getObjectKey(),
|
||||||
piece.getObject(),
|
piece.getObject(),
|
||||||
piece.getX(),
|
piece.getX(),
|
||||||
piece.getY() + shiftY,
|
piece.getY() + shiftY,
|
||||||
@@ -3709,13 +3709,12 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
|
|
||||||
private static JigsawStudioLayout loadMappedLayout(ActiveStudio studio) throws IOException {
|
private static JigsawStudioLayout loadMappedLayout(ActiveStudio studio) throws IOException {
|
||||||
JigsawStudioRequest request = studio.generator().getRequest();
|
JigsawStudioRequest request = studio.generator().getRequest();
|
||||||
IrisData source = request.source();
|
request.reloadSource();
|
||||||
source.invalidateStructureResources();
|
IrisStructure structure = StructureResources.structure(request.source().resources(), request.structureKey());
|
||||||
IrisStructure structure = StructureResources.structure(source.getPackResources(), request.structureKey());
|
|
||||||
if (structure == null) {
|
if (structure == null) {
|
||||||
throw new IOException("The structure could not be reloaded after the graph transaction");
|
throw new IOException("The structure could not be reloaded after the graph transaction");
|
||||||
}
|
}
|
||||||
return JigsawStudioGraphMapper.map(source, structure);
|
return JigsawStudioGraphMapper.map(request.source(), request.packRoot(), request.structureKey(), structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showAssemblyPreview(ToolPlayer player, List<PlacedStructurePiece> pieces) {
|
public boolean showAssemblyPreview(ToolPlayer player, List<PlacedStructurePiece> pieces) {
|
||||||
@@ -5774,7 +5773,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
int sourceDepth = (quarterTurns & 1) == 0
|
int sourceDepth = (quarterTurns & 1) == 0
|
||||||
? displayDimensions.depth()
|
? displayDimensions.depth()
|
||||||
: displayDimensions.width();
|
: displayDimensions.width();
|
||||||
ObjectTurn rotation = ObjectTurn.of(0, -90.0D * quarterTurns, 0);
|
PieceTurn rotation = PieceTurn.aroundY(-90 * quarterTurns);
|
||||||
Map<LocalPosition, IrisJigsawConnector> displayed = new HashMap<>(source.getConnectors().size());
|
Map<LocalPosition, IrisJigsawConnector> displayed = new HashMap<>(source.getConnectors().size());
|
||||||
for (IrisJigsawConnector sourceConnector : source.getConnectors()) {
|
for (IrisJigsawConnector sourceConnector : source.getConnectors()) {
|
||||||
LocalPosition sourcePosition = connectorPosition(sourceConnector, "source piece");
|
LocalPosition sourcePosition = connectorPosition(sourceConnector, "source piece");
|
||||||
@@ -5786,9 +5785,9 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
sourceDepth,
|
sourceDepth,
|
||||||
quarterTurns);
|
quarterTurns);
|
||||||
IrisJigsawConnector connector = CapturedConnector.from(sourceConnector).toConnector()
|
IrisJigsawConnector connector = CapturedConnector.from(sourceConnector).toConnector()
|
||||||
.setPosition(new IrisPosition(position.x(), position.y(), position.z()))
|
.setPosition(new BlockPosition(position.x(), position.y(), position.z()))
|
||||||
.setDirection(rotation.rotate(sourceConnector.getDirection()))
|
.setDirection(sourceConnector.getDirection().turnedBy(rotation.quarterTurns()))
|
||||||
.setTop(rotation.rotate(sourceConnector.getTop()));
|
.setTop(sourceConnector.getTop().turnedBy(rotation.quarterTurns()));
|
||||||
if (displayed.put(position, connector) != null) {
|
if (displayed.put(position, connector) != null) {
|
||||||
throw new IOException("Jigsaw Studio source piece has duplicate displayed connector position "
|
throw new IOException("Jigsaw Studio source piece has duplicate displayed connector position "
|
||||||
+ connectorLocation(position));
|
+ connectorLocation(position));
|
||||||
@@ -5903,7 +5902,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
: captureBounds.dimensions().width();
|
: captureBounds.dimensions().width();
|
||||||
int sourceHeight = captureBounds.dimensions().height();
|
int sourceHeight = captureBounds.dimensions().height();
|
||||||
List<ObjectBlock> objectBlocks = new ArrayList<>();
|
List<ObjectBlock> objectBlocks = new ArrayList<>();
|
||||||
ObjectTurn inverseRotation = ObjectTurn.of(0, 90.0D * quarterTurns, 0);
|
PieceTurn inverseRotation = PieceTurn.aroundY(90 * quarterTurns);
|
||||||
List<IrisJigsawConnector> connectors = new ArrayList<>();
|
List<IrisJigsawConnector> connectors = new ArrayList<>();
|
||||||
Set<LocalPosition> capturedBlocks = new HashSet<>();
|
Set<LocalPosition> capturedBlocks = new HashSet<>();
|
||||||
Set<LocalPosition> capturedConnectors = new HashSet<>();
|
Set<LocalPosition> capturedConnectors = new HashSet<>();
|
||||||
@@ -5959,9 +5958,9 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
}
|
}
|
||||||
IrisJigsawConnector connector = capturedConnector.toConnector();
|
IrisJigsawConnector connector = capturedConnector.toConnector();
|
||||||
if (quarterTurns != 0) {
|
if (quarterTurns != 0) {
|
||||||
connector.setPosition(new IrisPosition(position.x(), position.y(), position.z()));
|
connector.setPosition(new BlockPosition(position.x(), position.y(), position.z()));
|
||||||
connector.setDirection(inverseRotation.rotate(connector.getDirection()));
|
connector.setDirection(connector.getDirection().turnedBy(inverseRotation.quarterTurns()));
|
||||||
connector.setTop(inverseRotation.rotate(connector.getTop()));
|
connector.setTop(connector.getTop().turnedBy(inverseRotation.quarterTurns()));
|
||||||
BlockState finalState = registry.find(connector.getFinalState()).orElse(null);
|
BlockState finalState = registry.find(connector.getFinalState()).orElse(null);
|
||||||
if (finalState == null) {
|
if (finalState == null) {
|
||||||
throw new IOException("Captured connector final state cannot be parsed at "
|
throw new IOException("Captured connector final state cannot be parsed at "
|
||||||
@@ -6051,8 +6050,8 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
if (connector == null || connector.getPosition() == null) {
|
if (connector == null || connector.getPosition() == null) {
|
||||||
throw new IOException("Jigsaw Studio " + owner + " contains a connector without a position");
|
throw new IOException("Jigsaw Studio " + owner + " contains a connector without a position");
|
||||||
}
|
}
|
||||||
IrisPosition position = connector.getPosition();
|
BlockPosition position = connector.getPosition();
|
||||||
return new LocalPosition(position.getX(), position.getY(), position.getZ());
|
return new LocalPosition(position.x(), position.y(), position.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String connectorLocation(LocalPosition position) {
|
private static String connectorLocation(LocalPosition position) {
|
||||||
@@ -6478,24 +6477,24 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
? displayDimensions.depth()
|
? displayDimensions.depth()
|
||||||
: displayDimensions.width();
|
: displayDimensions.width();
|
||||||
LocalPosition position = inversePosition(
|
LocalPosition position = inversePosition(
|
||||||
captured.getPosition().getX(),
|
captured.getPosition().x(),
|
||||||
captured.getPosition().getY(),
|
captured.getPosition().y(),
|
||||||
captured.getPosition().getZ(),
|
captured.getPosition().z(),
|
||||||
sourceWidth,
|
sourceWidth,
|
||||||
sourceDepth,
|
sourceDepth,
|
||||||
quarterTurns);
|
quarterTurns);
|
||||||
ObjectTurn inverseRotation = ObjectTurn.of(0, 90.0D * quarterTurns, 0);
|
PieceTurn inverseRotation = PieceTurn.aroundY(90 * quarterTurns);
|
||||||
IrisJigsawConnector sourceOriented = CapturedConnector.from(captured).toConnector()
|
IrisJigsawConnector sourceOriented = CapturedConnector.from(captured).toConnector()
|
||||||
.setPosition(new IrisPosition(position.x(), position.y(), position.z()))
|
.setPosition(new BlockPosition(position.x(), position.y(), position.z()))
|
||||||
.setDirection(inverseRotation.rotate(captured.getDirection()))
|
.setDirection(captured.getDirection().turnedBy(inverseRotation.quarterTurns()))
|
||||||
.setTop(inverseRotation.rotate(captured.getTop()));
|
.setTop(captured.getTop().turnedBy(inverseRotation.quarterTurns()));
|
||||||
restoreCapturedMetadata(sourceOriented, sourcePiece);
|
restoreCapturedMetadata(sourceOriented, sourcePiece);
|
||||||
captured.setName(sourceOriented.getName());
|
captured.setName(sourceOriented.getName());
|
||||||
captured.setTargetName(sourceOriented.getTargetName());
|
captured.setTargetName(sourceOriented.getTargetName());
|
||||||
captured.setChannel(sourceOriented.getChannel());
|
captured.setChannel(sourceOriented.getChannel());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisJigsawConnector connectorAt(IrisJigsawPiece piece, IrisPosition position) {
|
private static IrisJigsawConnector connectorAt(IrisJigsawPiece piece, BlockPosition position) {
|
||||||
if (piece == null || piece.getConnectors() == null || position == null) {
|
if (piece == null || piece.getConnectors() == null || position == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -7087,7 +7086,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
}
|
}
|
||||||
for (JigsawStudioGenerator.RenderedConnector renderedConnector : rendered.connectors()) {
|
for (JigsawStudioGenerator.RenderedConnector renderedConnector : rendered.connectors()) {
|
||||||
IrisJigsawConnector connector = renderedConnector.connector();
|
IrisJigsawConnector connector = renderedConnector.connector();
|
||||||
IrisDirection direction = connector.getDirection();
|
JigsawDirection direction = connector.getDirection();
|
||||||
drawConnectorLine(
|
drawConnectorLine(
|
||||||
playerLocation,
|
playerLocation,
|
||||||
bay.bounds().originX() + renderedConnector.x() + 0.5D,
|
bay.bounds().originX() + renderedConnector.x() + 0.5D,
|
||||||
@@ -7107,7 +7106,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
double startX,
|
double startX,
|
||||||
double startY,
|
double startY,
|
||||||
double startZ,
|
double startZ,
|
||||||
IrisDirection direction,
|
JigsawDirection direction,
|
||||||
int color,
|
int color,
|
||||||
ParticleBudget budget
|
ParticleBudget budget
|
||||||
) {
|
) {
|
||||||
@@ -8182,8 +8181,8 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int z,
|
int z,
|
||||||
IrisDirection direction,
|
JigsawDirection direction,
|
||||||
IrisDirection top,
|
JigsawDirection top,
|
||||||
String pool,
|
String pool,
|
||||||
String name,
|
String name,
|
||||||
String targetName,
|
String targetName,
|
||||||
@@ -8206,11 +8205,11 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
|
|
||||||
static CapturedConnector from(IrisJigsawConnector connector) {
|
static CapturedConnector from(IrisJigsawConnector connector) {
|
||||||
IrisJigsawConnector source = Objects.requireNonNull(connector, "Jigsaw Studio captured connector");
|
IrisJigsawConnector source = Objects.requireNonNull(connector, "Jigsaw Studio captured connector");
|
||||||
IrisPosition position = source.getPosition();
|
BlockPosition position = source.getPosition();
|
||||||
return new CapturedConnector(
|
return new CapturedConnector(
|
||||||
position.getX(),
|
position.x(),
|
||||||
position.getY(),
|
position.y(),
|
||||||
position.getZ(),
|
position.z(),
|
||||||
source.getDirection(),
|
source.getDirection(),
|
||||||
source.getTop(),
|
source.getTop(),
|
||||||
source.getPool(),
|
source.getPool(),
|
||||||
@@ -8225,7 +8224,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
|||||||
|
|
||||||
IrisJigsawConnector toConnector() {
|
IrisJigsawConnector toConnector() {
|
||||||
return new IrisJigsawConnector()
|
return new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition(x, y, z))
|
.setPosition(new BlockPosition(x, y, z))
|
||||||
.setDirection(direction)
|
.setDirection(direction)
|
||||||
.setTop(top)
|
.setTop(top)
|
||||||
.setPool(pool)
|
.setPool(pool)
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.core.structure.export;
|
||||||
|
|
||||||
|
import com.volmit.block.BlockRegistry;
|
||||||
|
import com.volmit.block.BlockState;
|
||||||
|
import com.volmit.block.BlockTrait;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
import com.volmit.object.BlockEntityData;
|
||||||
|
import com.volmit.object.ObjectBlock;
|
||||||
|
import com.volmit.object.PlaceableObject;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What an exporter reads of a pack object: its declared size and its blocks and block entities at positions counted from
|
||||||
|
* the object's corner, with the blocks only the platform can place or that need a block entity noted.
|
||||||
|
*
|
||||||
|
* @param customBlocks where the stored block is a custom-content block
|
||||||
|
* @param blocksNeedingEntity where the stored block is of a kind that carries a block entity
|
||||||
|
*/
|
||||||
|
public record ObjectContents(int width, int height, int depth, Map<BlockPosition, BlockState> blocks,
|
||||||
|
Map<BlockPosition, BlockEntityData> blockEntities, Set<BlockPosition> customBlocks,
|
||||||
|
Set<BlockPosition> blocksNeedingEntity) {
|
||||||
|
public ObjectContents {
|
||||||
|
blocks = Map.copyOf(blocks);
|
||||||
|
blockEntities = Map.copyOf(blockEntities);
|
||||||
|
customBlocks = Set.copyOf(customBlocks);
|
||||||
|
blocksNeedingEntity = Set.copyOf(blocksNeedingEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An object with these blocks and nothing special about any of them. */
|
||||||
|
public static ObjectContents plain(int width, int height, int depth, Map<BlockPosition, BlockState> blocks,
|
||||||
|
Map<BlockPosition, BlockEntityData> blockEntities) {
|
||||||
|
return new ObjectContents(width, height, depth, blocks, blockEntities, Set.of(), Set.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@code object} as its blocks lie in its declared box; {@code registry} says which are custom or hold block entities. */
|
||||||
|
public static ObjectContents of(PlaceableObject object, BlockRegistry registry) {
|
||||||
|
BlockPosition center = object.center();
|
||||||
|
Map<BlockPosition, BlockState> blocks = new LinkedHashMap<>();
|
||||||
|
Map<BlockPosition, BlockEntityData> entities = new LinkedHashMap<>();
|
||||||
|
Set<BlockPosition> custom = new LinkedHashSet<>();
|
||||||
|
Set<BlockPosition> needingEntity = new LinkedHashSet<>();
|
||||||
|
for (ObjectBlock block : object.geometry().blocks()) {
|
||||||
|
BlockPosition position = block.position().add(center);
|
||||||
|
blocks.put(position, block.state());
|
||||||
|
block.blockEntity().ifPresent(entity -> entities.put(position, entity));
|
||||||
|
if (registry.hasTrait(block.state(), BlockTrait.CUSTOM)) {
|
||||||
|
custom.add(position);
|
||||||
|
}
|
||||||
|
if (registry.hasTrait(block.state(), BlockTrait.STORAGE)) {
|
||||||
|
needingEntity.add(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ObjectContents(object.width(), object.height(), object.depth(), blocks, entities, custom, needingEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The block the object's offsets count from, relative to its corner. */
|
||||||
|
public BlockPosition center() {
|
||||||
|
return new BlockPosition(width / 2, height / 2, depth / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
-38
@@ -13,8 +13,6 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceRules;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceRules;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||||
import com.volmit.block.BlockState;
|
import com.volmit.block.BlockState;
|
||||||
@@ -66,10 +64,11 @@ final class VanillaJigsawExportCompiler {
|
|||||||
return rejected(diagnostics);
|
return rejected(diagnostics);
|
||||||
}
|
}
|
||||||
|
|
||||||
validateStructure(structure, request.settings(), diagnostics);
|
validateStructure(request.source().structureKey(), structure, request.settings(), diagnostics);
|
||||||
StructureGraphCompilation graphCompilation;
|
StructureGraphCompilation graphCompilation;
|
||||||
try {
|
try {
|
||||||
graphCompilation = StructureGraphCompiler.compile(structure, request.source().resolver());
|
graphCompilation = StructureGraphCompiler.compile(
|
||||||
|
request.source().structureKey(), structure, request.source().resolver());
|
||||||
} catch (RuntimeException exception) {
|
} catch (RuntimeException exception) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.GRAPH_VALIDATION,
|
VanillaJigsawExportDiagnostic.Code.GRAPH_VALIDATION,
|
||||||
@@ -79,7 +78,7 @@ final class VanillaJigsawExportCompiler {
|
|||||||
}
|
}
|
||||||
addGraphDiagnostics(graphCompilation, diagnostics);
|
addGraphDiagnostics(graphCompilation, diagnostics);
|
||||||
CompiledStructureGraph graph = graphCompilation.getGraph();
|
CompiledStructureGraph graph = graphCompilation.getGraph();
|
||||||
validateGraph(graph, diagnostics);
|
validateGraph(graph, request.source(), diagnostics);
|
||||||
if (hasErrors(diagnostics)) {
|
if (hasErrors(diagnostics)) {
|
||||||
return rejected(diagnostics);
|
return rejected(diagnostics);
|
||||||
}
|
}
|
||||||
@@ -167,6 +166,7 @@ final class VanillaJigsawExportCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void validateStructure(
|
private void validateStructure(
|
||||||
|
String structureKey,
|
||||||
IrisStructure structure,
|
IrisStructure structure,
|
||||||
VanillaJigsawExportSettings settings,
|
VanillaJigsawExportSettings settings,
|
||||||
List<VanillaJigsawExportDiagnostic> diagnostics
|
List<VanillaJigsawExportDiagnostic> diagnostics
|
||||||
@@ -174,50 +174,50 @@ final class VanillaJigsawExportCompiler {
|
|||||||
if (structure.resolvedCompatibility() != IrisJigsawCompatibility.VANILLA_PORTABLE) {
|
if (structure.resolvedCompatibility() != IrisJigsawCompatibility.VANILLA_PORTABLE) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_COMPATIBILITY,
|
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_COMPATIBILITY,
|
||||||
structureKey(structure),
|
structureKey,
|
||||||
"Strict export requires compatibility VANILLA_PORTABLE.");
|
"Strict export requires compatibility VANILLA_PORTABLE.");
|
||||||
}
|
}
|
||||||
if (!structure.stampsPiecesWhereAssembled()) {
|
if (!structure.stampsPiecesWhereAssembled()) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_PLACE_MODE,
|
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_PLACE_MODE,
|
||||||
structureKey(structure),
|
structureKey,
|
||||||
"Vanilla export requires placeMode STRUCTURE_PIECE; Iris terrain and stilt modes have no vanilla jigsaw equivalent.");
|
"Vanilla export requires placeMode STRUCTURE_PIECE; Iris terrain and stilt modes have no vanilla jigsaw equivalent.");
|
||||||
}
|
}
|
||||||
if (structure.getEdit() != null && !structure.getEdit().isEmpty()) {
|
if (structure.getEdit() != null && !structure.getEdit().isEmpty()) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_EDIT,
|
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_EDIT,
|
||||||
structureKey(structure),
|
structureKey,
|
||||||
"Structure-wide Iris block edits cannot be represented losslessly by vanilla template pools.");
|
"Structure-wide Iris block edits cannot be represented losslessly by vanilla template pools.");
|
||||||
}
|
}
|
||||||
if (structure.getLoot() != null && !structure.getLoot().isEmpty()) {
|
if (structure.getLoot() != null && !structure.getLoot().isEmpty()) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_LOOT,
|
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_LOOT,
|
||||||
structureKey(structure),
|
structureKey,
|
||||||
"Structure-wide Iris loot injection cannot be represented losslessly by this vanilla exporter.");
|
"Structure-wide Iris loot injection cannot be represented losslessly by this vanilla exporter.");
|
||||||
}
|
}
|
||||||
if (structure.getThemeSets() != null && !structure.getThemeSets().isEmpty()) {
|
if (structure.getThemeSets() != null && !structure.getThemeSets().isEmpty()) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_THEME_METADATA,
|
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_THEME_METADATA,
|
||||||
structureKey(structure),
|
structureKey,
|
||||||
"Coherent Iris theme selection has no lossless vanilla jigsaw representation.");
|
"Coherent Iris theme selection has no lossless vanilla jigsaw representation.");
|
||||||
}
|
}
|
||||||
if (structure.isRequireCaps()) {
|
if (structure.isRequireCaps()) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_REQUIRED_CAPS,
|
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_REQUIRED_CAPS,
|
||||||
structureKey(structure),
|
structureKey,
|
||||||
"Vanilla jigsaws cannot enforce Iris requireCaps terminal-closure semantics.");
|
"Vanilla jigsaws cannot enforce Iris requireCaps terminal-closure semantics.");
|
||||||
}
|
}
|
||||||
if (structure.getMaxDepth() < 1 || structure.getMaxDepth() > MAX_DEPTH) {
|
if (structure.getMaxDepth() < 1 || structure.getMaxDepth() > MAX_DEPTH) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.INVALID_MAX_DEPTH,
|
VanillaJigsawExportDiagnostic.Code.INVALID_MAX_DEPTH,
|
||||||
structureKey(structure),
|
structureKey,
|
||||||
"Minecraft 26.2 jigsaw size must be within 0..20; Iris export requires 1..20.");
|
"Minecraft 26.2 jigsaw size must be within 0..20; Iris export requires 1..20.");
|
||||||
}
|
}
|
||||||
long horizontalDistance = (long) structure.getMaxSizeChunks() * 16L;
|
long horizontalDistance = (long) structure.getMaxSizeChunks() * 16L;
|
||||||
if (horizontalDistance < 1L || horizontalDistance > MAX_HORIZONTAL_DISTANCE) {
|
if (horizontalDistance < 1L || horizontalDistance > MAX_HORIZONTAL_DISTANCE) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.INVALID_MAX_DISTANCE,
|
VanillaJigsawExportDiagnostic.Code.INVALID_MAX_DISTANCE,
|
||||||
structureKey(structure),
|
structureKey,
|
||||||
"Iris maxSizeChunks maps to " + horizontalDistance
|
"Iris maxSizeChunks maps to " + horizontalDistance
|
||||||
+ " blocks, outside Minecraft 26.2's 1..128 horizontal limit.");
|
+ " blocks, outside Minecraft 26.2's 1..128 horizontal limit.");
|
||||||
}
|
}
|
||||||
@@ -226,7 +226,7 @@ final class VanillaJigsawExportCompiler {
|
|||||||
if (horizontalDistance + terrainPadding > MAX_HORIZONTAL_DISTANCE) {
|
if (horizontalDistance + terrainPadding > MAX_HORIZONTAL_DISTANCE) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.INVALID_MAX_DISTANCE,
|
VanillaJigsawExportDiagnostic.Code.INVALID_MAX_DISTANCE,
|
||||||
structureKey(structure),
|
structureKey,
|
||||||
"Horizontal distance plus vanilla terrain-adaptation padding must not exceed 128 blocks.");
|
"Horizontal distance plus vanilla terrain-adaptation padding must not exceed 128 blocks.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,6 +250,7 @@ final class VanillaJigsawExportCompiler {
|
|||||||
|
|
||||||
private void validateGraph(
|
private void validateGraph(
|
||||||
CompiledStructureGraph graph,
|
CompiledStructureGraph graph,
|
||||||
|
VanillaJigsawExportSource source,
|
||||||
List<VanillaJigsawExportDiagnostic> diagnostics
|
List<VanillaJigsawExportDiagnostic> diagnostics
|
||||||
) {
|
) {
|
||||||
Map<IrisJigsawWorkcellArchetype, PlanarJigsawWorkcellResolver.ResolvedWorkcell> workcells =
|
Map<IrisJigsawWorkcellArchetype, PlanarJigsawWorkcellResolver.ResolvedWorkcell> workcells =
|
||||||
@@ -275,7 +276,7 @@ final class VanillaJigsawExportCompiler {
|
|||||||
pieceKey,
|
pieceKey,
|
||||||
"Iris piece keys must be valid lowercase resource paths for vanilla export.");
|
"Iris piece keys must be valid lowercase resource paths for vanilla export.");
|
||||||
}
|
}
|
||||||
validatePiece(graph, pieceKey, pieceEntry.getValue(), diagnostics);
|
validatePiece(graph, source, pieceKey, pieceEntry.getValue(), diagnostics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,6 +335,7 @@ final class VanillaJigsawExportCompiler {
|
|||||||
|
|
||||||
private void validatePiece(
|
private void validatePiece(
|
||||||
CompiledStructureGraph graph,
|
CompiledStructureGraph graph,
|
||||||
|
VanillaJigsawExportSource source,
|
||||||
String pieceKey,
|
String pieceKey,
|
||||||
IrisJigsawPiece piece,
|
IrisJigsawPiece piece,
|
||||||
List<VanillaJigsawExportDiagnostic> diagnostics
|
List<VanillaJigsawExportDiagnostic> diagnostics
|
||||||
@@ -367,7 +369,7 @@ final class VanillaJigsawExportCompiler {
|
|||||||
pieceKey,
|
pieceKey,
|
||||||
"Vanilla template pools cannot serialize Iris collidable=false assembly metadata.");
|
"Vanilla template pools cannot serialize Iris collidable=false assembly metadata.");
|
||||||
}
|
}
|
||||||
IrisObject object = graph.getObjects().get(trim(piece.getObject()));
|
ObjectContents object = source.contents(trim(piece.getObject()));
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -377,10 +379,10 @@ final class VanillaJigsawExportCompiler {
|
|||||||
|
|
||||||
private void validateObject(
|
private void validateObject(
|
||||||
String pieceKey,
|
String pieceKey,
|
||||||
IrisObject object,
|
ObjectContents object,
|
||||||
List<VanillaJigsawExportDiagnostic> diagnostics
|
List<VanillaJigsawExportDiagnostic> diagnostics
|
||||||
) {
|
) {
|
||||||
IrisObject.ApiContents contents = object.apiContents();
|
ObjectContents contents = object;
|
||||||
if (!contents.blockEntities().isEmpty()) {
|
if (!contents.blockEntities().isEmpty()) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_TILE_DATA,
|
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_TILE_DATA,
|
||||||
@@ -391,13 +393,13 @@ final class VanillaJigsawExportCompiler {
|
|||||||
BlockState state = entry.getValue();
|
BlockState state = entry.getValue();
|
||||||
BlockPosition position = entry.getKey();
|
BlockPosition position = entry.getKey();
|
||||||
String resource = pieceKey + "@" + new IrisBlockVector(
|
String resource = pieceKey + "@" + new IrisBlockVector(
|
||||||
position.x() - object.getCenter().getX(),
|
position.x() - object.center().x(),
|
||||||
position.y() - object.getCenter().getY(),
|
position.y() - object.center().y(),
|
||||||
position.z() - object.getCenter().getZ());
|
position.z() - object.center().z());
|
||||||
int x = position.x();
|
int x = position.x();
|
||||||
int y = position.y();
|
int y = position.y();
|
||||||
int z = position.z();
|
int z = position.z();
|
||||||
if (x < 0 || x >= object.getW() || y < 0 || y >= object.getH() || z < 0 || z >= object.getD()) {
|
if (x < 0 || x >= object.width() || y < 0 || y >= object.height() || z < 0 || z >= object.depth()) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.INVALID_BLOCK_STATE,
|
VanillaJigsawExportDiagnostic.Code.INVALID_BLOCK_STATE,
|
||||||
resource,
|
resource,
|
||||||
@@ -440,14 +442,14 @@ final class VanillaJigsawExportCompiler {
|
|||||||
CompiledStructureGraph graph,
|
CompiledStructureGraph graph,
|
||||||
String pieceKey,
|
String pieceKey,
|
||||||
IrisJigsawPiece piece,
|
IrisJigsawPiece piece,
|
||||||
IrisObject object,
|
ObjectContents object,
|
||||||
List<VanillaJigsawExportDiagnostic> diagnostics
|
List<VanillaJigsawExportDiagnostic> diagnostics
|
||||||
) {
|
) {
|
||||||
if (piece.getConnectors() == null) {
|
if (piece.getConnectors() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<String> positions = new LinkedHashSet<>();
|
Set<String> positions = new LinkedHashSet<>();
|
||||||
Map<BlockPosition, BlockState> storedBlocks = object.apiContents().blocks();
|
Map<BlockPosition, BlockState> storedBlocks = object.blocks();
|
||||||
for (int index = 0; index < piece.getConnectors().size(); index++) {
|
for (int index = 0; index < piece.getConnectors().size(); index++) {
|
||||||
IrisJigsawConnector connector = piece.getConnectors().get(index);
|
IrisJigsawConnector connector = piece.getConnectors().get(index);
|
||||||
if (connector == null) {
|
if (connector == null) {
|
||||||
@@ -477,11 +479,11 @@ final class VanillaJigsawExportCompiler {
|
|||||||
resource,
|
resource,
|
||||||
exception.getMessage() == null ? "Connector orientation is incomplete." : exception.getMessage());
|
exception.getMessage() == null ? "Connector orientation is incomplete." : exception.getMessage());
|
||||||
}
|
}
|
||||||
IrisPosition position = connector.getPosition();
|
BlockPosition position = connector.getPosition();
|
||||||
if (position == null || !inside(position, object)) {
|
if (position == null || !inside(position, object)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String positionKey = position.getX() + "," + position.getY() + "," + position.getZ();
|
String positionKey = position.x() + "," + position.y() + "," + position.z();
|
||||||
if (!positions.add(positionKey)) {
|
if (!positions.add(positionKey)) {
|
||||||
addError(diagnostics,
|
addError(diagnostics,
|
||||||
VanillaJigsawExportDiagnostic.Code.DUPLICATE_CONNECTOR_POSITION,
|
VanillaJigsawExportDiagnostic.Code.DUPLICATE_CONNECTOR_POSITION,
|
||||||
@@ -523,8 +525,8 @@ final class VanillaJigsawExportCompiler {
|
|||||||
exception.getMessage());
|
exception.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IrisPosition position = connector.getPosition();
|
BlockPosition position = connector.getPosition();
|
||||||
BlockState objectState = storedBlocks.get(new BlockPosition(position.getX(), position.getY(), position.getZ()));
|
BlockState objectState = storedBlocks.get(position);
|
||||||
String expectedSource = objectState == null ? "minecraft:structure_void" : objectState.key();
|
String expectedSource = objectState == null ? "minecraft:structure_void" : objectState.key();
|
||||||
try {
|
try {
|
||||||
VanillaBlockState expected = VanillaBlockState.parse(expectedSource);
|
VanillaBlockState expected = VanillaBlockState.parse(expectedSource);
|
||||||
@@ -567,7 +569,7 @@ final class VanillaJigsawExportCompiler {
|
|||||||
if (!pieceEnabled(workcells, pieceEntry.getValue())) {
|
if (!pieceEnabled(workcells, pieceEntry.getValue())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisObject object = graph.getObjects().get(trim(pieceEntry.getValue().getObject()));
|
ObjectContents object = request.source().contents(trim(pieceEntry.getValue().getObject()));
|
||||||
byte[] template = encoder.encode(
|
byte[] template = encoder.encode(
|
||||||
object,
|
object,
|
||||||
pieceEntry.getValue(),
|
pieceEntry.getValue(),
|
||||||
@@ -757,10 +759,10 @@ final class VanillaJigsawExportCompiler {
|
|||||||
return request.namespace() + ":" + request.resourcePath() + "/piece/" + pieceKey;
|
return request.namespace() + ":" + request.resourcePath() + "/piece/" + pieceKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean inside(IrisPosition position, IrisObject object) {
|
private boolean inside(BlockPosition position, ObjectContents object) {
|
||||||
return position.getX() >= 0 && position.getX() < object.getW()
|
return position.x() >= 0 && position.x() < object.width()
|
||||||
&& position.getY() >= 0 && position.getY() < object.getH()
|
&& position.y() >= 0 && position.y() < object.height()
|
||||||
&& position.getZ() >= 0 && position.getZ() < object.getD();
|
&& position.z() >= 0 && position.z() < object.depth();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasErrors(List<VanillaJigsawExportDiagnostic> diagnostics) {
|
private boolean hasErrors(List<VanillaJigsawExportDiagnostic> diagnostics) {
|
||||||
@@ -789,11 +791,6 @@ final class VanillaJigsawExportCompiler {
|
|||||||
message));
|
message));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String structureKey(IrisStructure structure) {
|
|
||||||
String key = structure.getLoadKey();
|
|
||||||
return key == null || key.isBlank() ? "<unloaded>" : key;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String trim(String value) {
|
private String trim(String value) {
|
||||||
return value == null ? "" : value.trim();
|
return value == null ? "" : value.trim();
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-12
@@ -1,48 +1,57 @@
|
|||||||
package art.arcane.iris.core.structure.export;
|
package art.arcane.iris.core.structure.export;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.engine.framework.structure.StructureGraphResolver;
|
import art.arcane.iris.engine.framework.structure.StructureGraphResolver;
|
||||||
|
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public final class VanillaJigsawExportSource {
|
public final class VanillaJigsawExportSource {
|
||||||
private final String structureKey;
|
private final String structureKey;
|
||||||
private final IrisData data;
|
private final PackResources pack;
|
||||||
private final IrisStructure structure;
|
private final IrisStructure structure;
|
||||||
private final StructureGraphResolver resolver;
|
private final StructureGraphResolver resolver;
|
||||||
|
private final Function<String, ObjectContents> objects;
|
||||||
|
|
||||||
private VanillaJigsawExportSource(
|
private VanillaJigsawExportSource(
|
||||||
String structureKey,
|
String structureKey,
|
||||||
IrisData data,
|
PackResources pack,
|
||||||
IrisStructure structure,
|
IrisStructure structure,
|
||||||
StructureGraphResolver resolver
|
StructureGraphResolver resolver,
|
||||||
|
Function<String, ObjectContents> objects
|
||||||
) {
|
) {
|
||||||
this.structureKey = requireKey(structureKey);
|
this.structureKey = requireKey(structureKey);
|
||||||
this.data = data;
|
this.pack = pack;
|
||||||
this.structure = structure;
|
this.structure = structure;
|
||||||
this.resolver = resolver;
|
this.resolver = resolver;
|
||||||
|
this.objects = objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VanillaJigsawExportSource forData(IrisData data, String structureKey) {
|
public static VanillaJigsawExportSource forPack(PackResources pack, String structureKey) {
|
||||||
|
Objects.requireNonNull(pack);
|
||||||
return new VanillaJigsawExportSource(
|
return new VanillaJigsawExportSource(
|
||||||
structureKey,
|
structureKey,
|
||||||
Objects.requireNonNull(data),
|
pack,
|
||||||
null,
|
null,
|
||||||
StructureGraphResolver.forData(data));
|
StructureGraphResolver.forPack(pack),
|
||||||
|
key -> pack.objects().object(pack.idOf(key)).map(object -> ObjectContents.of(object, pack.blocks())).orElse(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A source of {@code structure} whose pieces' objects {@code objects} reads, for a structure that is not in a pack. */
|
||||||
public static VanillaJigsawExportSource forStructure(
|
public static VanillaJigsawExportSource forStructure(
|
||||||
String structureKey,
|
String structureKey,
|
||||||
IrisStructure structure,
|
IrisStructure structure,
|
||||||
StructureGraphResolver resolver
|
StructureGraphResolver resolver,
|
||||||
|
Function<String, ObjectContents> objects
|
||||||
) {
|
) {
|
||||||
return new VanillaJigsawExportSource(
|
return new VanillaJigsawExportSource(
|
||||||
structureKey,
|
structureKey,
|
||||||
null,
|
null,
|
||||||
Objects.requireNonNull(structure),
|
Objects.requireNonNull(structure),
|
||||||
Objects.requireNonNull(resolver));
|
Objects.requireNonNull(resolver),
|
||||||
|
Objects.requireNonNull(objects));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String structureKey() {
|
public String structureKey() {
|
||||||
@@ -53,13 +62,18 @@ public final class VanillaJigsawExportSource {
|
|||||||
if (structure != null) {
|
if (structure != null) {
|
||||||
return structure;
|
return structure;
|
||||||
}
|
}
|
||||||
return StructureResources.structure(data.getPackResources(), structureKey);
|
return StructureResources.structure(pack, structureKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StructureGraphResolver resolver() {
|
public StructureGraphResolver resolver() {
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** What the object the pack key {@code objectKey} names holds; null when there is none. */
|
||||||
|
public ObjectContents contents(String objectKey) {
|
||||||
|
return objects.apply(objectKey);
|
||||||
|
}
|
||||||
|
|
||||||
private static String requireKey(String value) {
|
private static String requireKey(String value) {
|
||||||
String key = Objects.requireNonNull(value).trim();
|
String key = Objects.requireNonNull(value).trim();
|
||||||
if (key.isEmpty()) {
|
if (key.isEmpty()) {
|
||||||
|
|||||||
+15
-17
@@ -1,10 +1,8 @@
|
|||||||
package art.arcane.iris.core.structure.export;
|
package art.arcane.iris.core.structure.export;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.volmlib.util.nbt.io.NBTUtil;
|
import art.arcane.volmlib.util.nbt.io.NBTUtil;
|
||||||
import art.arcane.volmlib.util.nbt.io.NamedTag;
|
import art.arcane.volmlib.util.nbt.io.NamedTag;
|
||||||
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
||||||
@@ -29,7 +27,7 @@ final class VanillaStructureTemplateEncoder {
|
|||||||
.thenComparingInt(entry -> entry.position().z());
|
.thenComparingInt(entry -> entry.position().z());
|
||||||
|
|
||||||
byte[] encode(
|
byte[] encode(
|
||||||
IrisObject object,
|
ObjectContents object,
|
||||||
IrisJigsawPiece piece,
|
IrisJigsawPiece piece,
|
||||||
Function<String, String> poolIdentifier
|
Function<String, String> poolIdentifier
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
@@ -49,7 +47,7 @@ final class VanillaStructureTemplateEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag root = new CompoundTag();
|
CompoundTag root = new CompoundTag();
|
||||||
root.put("size", intList(object.getW(), object.getH(), object.getD()));
|
root.put("size", intList(object.width(), object.height(), object.depth()));
|
||||||
root.put("palette", palette(paletteStates));
|
root.put("palette", palette(paletteStates));
|
||||||
root.put("blocks", blocks(orderedBlocks, paletteIndexes));
|
root.put("blocks", blocks(orderedBlocks, paletteIndexes));
|
||||||
root.put("entities", new ListTag<>(CompoundTag.class));
|
root.put("entities", new ListTag<>(CompoundTag.class));
|
||||||
@@ -60,9 +58,9 @@ final class VanillaStructureTemplateEncoder {
|
|||||||
return output.toByteArray();
|
return output.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<BlockPosition, BlockEntry> objectBlocks(IrisObject object) {
|
private Map<BlockPosition, BlockEntry> objectBlocks(ObjectContents object) {
|
||||||
Map<BlockPosition, BlockEntry> blocks = new LinkedHashMap<>();
|
Map<BlockPosition, BlockEntry> blocks = new LinkedHashMap<>();
|
||||||
for (var entry : object.apiContents().blocks().entrySet()) {
|
for (var entry : object.blocks().entrySet()) {
|
||||||
BlockPosition position = new BlockPosition(entry.getKey().x(), entry.getKey().y(), entry.getKey().z());
|
BlockPosition position = new BlockPosition(entry.getKey().x(), entry.getKey().y(), entry.getKey().z());
|
||||||
VanillaBlockState state = VanillaBlockState.parse(entry.getValue().key());
|
VanillaBlockState state = VanillaBlockState.parse(entry.getValue().key());
|
||||||
blocks.put(position, new BlockEntry(position, state, null));
|
blocks.put(position, new BlockEntry(position, state, null));
|
||||||
@@ -76,9 +74,9 @@ final class VanillaStructureTemplateEncoder {
|
|||||||
Function<String, String> poolIdentifier
|
Function<String, String> poolIdentifier
|
||||||
) {
|
) {
|
||||||
for (IrisJigsawConnector connector : piece.getConnectors()) {
|
for (IrisJigsawConnector connector : piece.getConnectors()) {
|
||||||
IrisPosition sourcePosition = connector.getPosition();
|
var sourcePosition = connector.getPosition();
|
||||||
BlockPosition position = new BlockPosition(
|
BlockPosition position = new BlockPosition(
|
||||||
sourcePosition.getX(), sourcePosition.getY(), sourcePosition.getZ());
|
sourcePosition.x(), sourcePosition.y(), sourcePosition.z());
|
||||||
String orientation = orientation(connector.getDirection(), connector.getTop());
|
String orientation = orientation(connector.getDirection(), connector.getTop());
|
||||||
VanillaBlockState state = VanillaBlockState.parse(
|
VanillaBlockState state = VanillaBlockState.parse(
|
||||||
"minecraft:jigsaw[orientation=" + orientation + "]");
|
"minecraft:jigsaw[orientation=" + orientation + "]");
|
||||||
@@ -100,23 +98,23 @@ final class VanillaStructureTemplateEncoder {
|
|||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String orientation(IrisDirection front, IrisDirection top) {
|
static String orientation(JigsawDirection front, JigsawDirection top) {
|
||||||
if (front == IrisDirection.UP_POSITIVE_Y || front == IrisDirection.DOWN_NEGATIVE_Y) {
|
if (front == JigsawDirection.UP_POSITIVE_Y || front == JigsawDirection.DOWN_NEGATIVE_Y) {
|
||||||
if (top == IrisDirection.NORTH_NEGATIVE_Z
|
if (top == JigsawDirection.NORTH_NEGATIVE_Z
|
||||||
|| top == IrisDirection.SOUTH_POSITIVE_Z
|
|| top == JigsawDirection.SOUTH_POSITIVE_Z
|
||||||
|| top == IrisDirection.EAST_POSITIVE_X
|
|| top == JigsawDirection.EAST_POSITIVE_X
|
||||||
|| top == IrisDirection.WEST_NEGATIVE_X) {
|
|| top == JigsawDirection.WEST_NEGATIVE_X) {
|
||||||
return directionName(front) + "_" + directionName(top);
|
return directionName(front) + "_" + directionName(top);
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Vertical jigsaw fronts require a horizontal top direction");
|
throw new IllegalArgumentException("Vertical jigsaw fronts require a horizontal top direction");
|
||||||
}
|
}
|
||||||
if (top != IrisDirection.UP_POSITIVE_Y) {
|
if (top != JigsawDirection.UP_POSITIVE_Y) {
|
||||||
throw new IllegalArgumentException("Horizontal jigsaw fronts require an upward top direction");
|
throw new IllegalArgumentException("Horizontal jigsaw fronts require an upward top direction");
|
||||||
}
|
}
|
||||||
return directionName(front) + "_up";
|
return directionName(front) + "_up";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String directionName(IrisDirection direction) {
|
private static String directionName(JigsawDirection direction) {
|
||||||
return switch (direction) {
|
return switch (direction) {
|
||||||
case UP_POSITIVE_Y -> "up";
|
case UP_POSITIVE_Y -> "up";
|
||||||
case DOWN_NEGATIVE_Y -> "down";
|
case DOWN_NEGATIVE_Y -> "down";
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package art.arcane.iris.core.structure.tooling;
|
package art.arcane.iris.core.structure.tooling;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.service.JigsawStudioRequest;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureKey;
|
import art.arcane.iris.core.structure.authoring.StructureKey;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureOwnershipManifest;
|
import art.arcane.iris.core.structure.authoring.StructureOwnershipManifest;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureTransactionWriter;
|
import art.arcane.iris.core.structure.authoring.StructureTransactionWriter;
|
||||||
@@ -82,7 +82,6 @@ final class AdoptionCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StudioUse use = begun.get();
|
StudioUse use = begun.get();
|
||||||
IrisData data = use.host().dataOf(context.pack());
|
|
||||||
String sourceKey;
|
String sourceKey;
|
||||||
Optional<StructureKey> targetKey;
|
Optional<StructureKey> targetKey;
|
||||||
IrisStructureAdoptionStrategy adoptionStrategy;
|
IrisStructureAdoptionStrategy adoptionStrategy;
|
||||||
@@ -91,14 +90,14 @@ final class AdoptionCommands {
|
|||||||
sourceKey = parseAdoptionSource(context.get(SOURCE));
|
sourceKey = parseAdoptionSource(context.get(SOURCE));
|
||||||
targetKey = parseAdoptionTarget(context.get(TARGET));
|
targetKey = parseAdoptionTarget(context.get(TARGET));
|
||||||
adoptionStrategy = parseAdoptionStrategy(context.get(STRATEGY));
|
adoptionStrategy = parseAdoptionStrategy(context.get(STRATEGY));
|
||||||
root = canonicalAdoptionRoot(data.getDataFolder().toPath());
|
root = canonicalAdoptionRoot(JigsawStudioRequest.rootOf(context.pack()));
|
||||||
} catch (IOException | IllegalArgumentException exception) {
|
} catch (IOException | IllegalArgumentException exception) {
|
||||||
use.error("Could not inspect adoption source: " + exception.getMessage());
|
use.error("Could not inspect adoption source: " + exception.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID ownerId = use.player().id();
|
UUID ownerId = use.player().id();
|
||||||
use.say(TextColor.GRAY, "Inspecting Jigsaw adoption source '" + sourceKey + "' asynchronously...");
|
use.say(TextColor.GRAY, "Inspecting Jigsaw adoption source '" + sourceKey + "' asynchronously...");
|
||||||
runAdoptionInspect(use, ownerId, data, root, sourceKey, targetKey, adoptionStrategy);
|
runAdoptionInspect(use, ownerId, root, sourceKey, targetKey, adoptionStrategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void apply(CommandContext context) {
|
private void apply(CommandContext context) {
|
||||||
@@ -176,7 +175,6 @@ final class AdoptionCommands {
|
|||||||
private static void runAdoptionInspect(
|
private static void runAdoptionInspect(
|
||||||
StudioUse use,
|
StudioUse use,
|
||||||
UUID ownerId,
|
UUID ownerId,
|
||||||
IrisData data,
|
|
||||||
Path root,
|
Path root,
|
||||||
String sourceKey,
|
String sourceKey,
|
||||||
Optional<StructureKey> targetKey,
|
Optional<StructureKey> targetKey,
|
||||||
@@ -197,13 +195,12 @@ final class AdoptionCommands {
|
|||||||
failure = throwable;
|
failure = throwable;
|
||||||
use.pack().log().error("Failed to inspect Jigsaw adoption source '" + sourceKey + "'.", throwable);
|
use.pack().log().error("Failed to inspect Jigsaw adoption source '" + sourceKey + "'.", throwable);
|
||||||
}
|
}
|
||||||
finishAdoptionInspect(use, ownerId, data, service, plan, failure);
|
finishAdoptionInspect(use, ownerId, service, plan, failure);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void finishAdoptionInspect(
|
private static void finishAdoptionInspect(
|
||||||
StudioUse use,
|
StudioUse use,
|
||||||
UUID ownerId,
|
UUID ownerId,
|
||||||
IrisData data,
|
|
||||||
IrisStructureAdoptionService service,
|
IrisStructureAdoptionService service,
|
||||||
IrisStructureAdoptionPlan plan,
|
IrisStructureAdoptionPlan plan,
|
||||||
Throwable failure
|
Throwable failure
|
||||||
@@ -216,7 +213,7 @@ final class AdoptionCommands {
|
|||||||
pruneAdoptionPlanBindings();
|
pruneAdoptionPlanBindings();
|
||||||
if (service.plan(plan.planId()).isPresent()) {
|
if (service.plan(plan.planId()).isPresent()) {
|
||||||
ADOPTION_PLANS.put(plan.planId(), new AdoptionPlanBinding(
|
ADOPTION_PLANS.put(plan.planId(), new AdoptionPlanBinding(
|
||||||
ownerId, use.pack(), data, service, plan));
|
ownerId, use.pack(), service, plan));
|
||||||
}
|
}
|
||||||
reportAdoptionPlan(use, plan);
|
reportAdoptionPlan(use, plan);
|
||||||
}
|
}
|
||||||
@@ -236,7 +233,7 @@ final class AdoptionCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StructureKey target = result.receipt().orElseThrow().targetStructure();
|
StructureKey target = result.receipt().orElseThrow().targetStructure();
|
||||||
binding.data().invalidateStructureResources();
|
JigsawStudioRequest.reload(binding.pack());
|
||||||
StudioLifecycleCommands.openProject(use.onPack(binding.pack()), target.path());
|
StudioLifecycleCommands.openProject(use.onPack(binding.pack()), target.path());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +334,6 @@ final class AdoptionCommands {
|
|||||||
private record AdoptionPlanBinding(
|
private record AdoptionPlanBinding(
|
||||||
UUID ownerId,
|
UUID ownerId,
|
||||||
ToolPack pack,
|
ToolPack pack,
|
||||||
IrisData data,
|
|
||||||
IrisStructureAdoptionService service,
|
IrisStructureAdoptionService service,
|
||||||
IrisStructureAdoptionPlan plan
|
IrisStructureAdoptionPlan plan
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -31,10 +31,9 @@ import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariant;
|
|||||||
import art.arcane.iris.core.service.JigsawStudioService;
|
import art.arcane.iris.core.service.JigsawStudioService;
|
||||||
import art.arcane.iris.core.structure.tooling.GraphMutations.PieceWorkcellResolution;
|
import art.arcane.iris.core.structure.tooling.GraphMutations.PieceWorkcellResolution;
|
||||||
import art.arcane.iris.core.structure.tooling.StudioSessions.ActiveContext;
|
import art.arcane.iris.core.structure.tooling.StudioSessions.ActiveContext;
|
||||||
|
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import com.volmit.geometry.BlockPosition;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import com.volmit.tooling.Argument;
|
import com.volmit.tooling.Argument;
|
||||||
import com.volmit.tooling.Command;
|
import com.volmit.tooling.Command;
|
||||||
@@ -208,20 +207,20 @@ final class GraphEditCommands {
|
|||||||
use.error("The active variant is read-only. Adopt it into this project before editing it.");
|
use.error("The active variant is read-only. Adopt it into this project before editing it.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IrisObject object = active.request().source().getObjectLoader().load(activeVariant.objectKey());
|
ObjectFrame object = GraphMutations.objectFrame(active, activeVariant.objectKey());
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
use.error("The active variant object '" + activeVariant.objectKey() + "' is missing.");
|
use.error("The active variant object '" + activeVariant.objectKey() + "' is missing.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IrisPosition canonicalPosition = new IrisPosition(
|
BlockPosition canonicalPosition = new BlockPosition(
|
||||||
target.x() - bay.bounds().originX(),
|
target.x() - bay.bounds().originX(),
|
||||||
target.y() - bay.bounds().originY(),
|
target.y() - bay.bounds().originY(),
|
||||||
target.z() - bay.bounds().originZ());
|
target.z() - bay.bounds().originZ());
|
||||||
IrisPosition position;
|
BlockPosition position;
|
||||||
try {
|
try {
|
||||||
position = activeVariant.canonicalToSourcePosition(
|
position = activeVariant.canonicalToSourcePosition(
|
||||||
canonicalPosition,
|
canonicalPosition,
|
||||||
new JigsawStudioCellDimensions(object.getW(), object.getH(), object.getD()));
|
new JigsawStudioCellDimensions(object.width(), object.height(), object.depth()));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
use.error("Connector channel update failed: " + exception.getMessage());
|
use.error("Connector channel update failed: " + exception.getMessage());
|
||||||
return;
|
return;
|
||||||
@@ -232,7 +231,7 @@ final class GraphEditCommands {
|
|||||||
: channel.trim();
|
: channel.trim();
|
||||||
runGraphMutation(use, active, () -> {
|
runGraphMutation(use, active, () -> {
|
||||||
JigsawStudioGraphEditor.updateConnectorChannel(
|
JigsawStudioGraphEditor.updateConnectorChannel(
|
||||||
active.request().source().getDataFolder().toPath(),
|
active.request().packRoot(),
|
||||||
active.request().structureKey(),
|
active.request().structureKey(),
|
||||||
activeVariant.pieceKey(),
|
activeVariant.pieceKey(),
|
||||||
position,
|
position,
|
||||||
@@ -242,8 +241,8 @@ final class GraphEditCommands {
|
|||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"Persisted connector channel '" + normalized + "' on piece '"
|
"Persisted connector channel '" + normalized + "' on piece '"
|
||||||
+ activeVariant.pieceKey() + "' at " + position.getX() + "," + position.getY()
|
+ activeVariant.pieceKey() + "' at " + position.x() + "," + position.y()
|
||||||
+ "," + position.getZ() + ".");
|
+ "," + position.z() + ".");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,7 +280,7 @@ final class GraphEditCommands {
|
|||||||
String fallback = NONE.equalsIgnoreCase(fallbackPoolKey) ? "" : fallbackPoolKey;
|
String fallback = NONE.equalsIgnoreCase(fallbackPoolKey) ? "" : fallbackPoolKey;
|
||||||
runGraphMutation(use, active, () -> {
|
runGraphMutation(use, active, () -> {
|
||||||
JigsawStudioGraphEditor.createPool(
|
JigsawStudioGraphEditor.createPool(
|
||||||
active.request().source().getDataFolder().toPath(),
|
active.request().packRoot(),
|
||||||
active.request().structureKey(),
|
active.request().structureKey(),
|
||||||
poolKey,
|
poolKey,
|
||||||
fallback);
|
fallback);
|
||||||
@@ -334,7 +333,7 @@ final class GraphEditCommands {
|
|||||||
String topologyText = selectedTopology == null ? "blank spatial" : selectedTopology.name();
|
String topologyText = selectedTopology == null ? "blank spatial" : selectedTopology.name();
|
||||||
runGraphMutation(use, active, () -> {
|
runGraphMutation(use, active, () -> {
|
||||||
JigsawStudioGraphEditor.createPiece(
|
JigsawStudioGraphEditor.createPiece(
|
||||||
active.request().source().getDataFolder().toPath(),
|
active.request().packRoot(),
|
||||||
active.request().structureKey(),
|
active.request().structureKey(),
|
||||||
poolKey,
|
poolKey,
|
||||||
pieceKey,
|
pieceKey,
|
||||||
@@ -363,7 +362,7 @@ final class GraphEditCommands {
|
|||||||
String poolKey = context.get(OWNED_POOL);
|
String poolKey = context.get(OWNED_POOL);
|
||||||
String pieceKey = context.get(EXISTING_PIECE);
|
String pieceKey = context.get(EXISTING_PIECE);
|
||||||
int weight = context.get(OPTIONAL_WEIGHT).intValue();
|
int weight = context.get(OPTIONAL_WEIGHT).intValue();
|
||||||
IrisJigsawPiece piece = StructureResources.piece(active.request().source().getPackResources(), pieceKey);
|
IrisJigsawPiece piece = StructureResources.piece(active.request().source().resources(), pieceKey);
|
||||||
if (piece == null) {
|
if (piece == null) {
|
||||||
use.error("No jigsaw piece '" + pieceKey + "' exists in this pack.");
|
use.error("No jigsaw piece '" + pieceKey + "' exists in this pack.");
|
||||||
return;
|
return;
|
||||||
@@ -372,7 +371,7 @@ final class GraphEditCommands {
|
|||||||
use.error("Jigsaw piece '" + pieceKey + "' does not declare an object.");
|
use.error("Jigsaw piece '" + pieceKey + "' does not declare an object.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IrisObject object = active.request().source().getObjectLoader().load(piece.getObject());
|
ObjectFrame object = GraphMutations.objectFrame(active, piece.getObject());
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
use.error("Jigsaw piece '" + pieceKey + "' has no loadable object.");
|
use.error("Jigsaw piece '" + pieceKey + "' has no loadable object.");
|
||||||
return;
|
return;
|
||||||
@@ -386,10 +385,10 @@ final class GraphEditCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!resolution.fits()) {
|
if (!resolution.fits()) {
|
||||||
IrisPosition required = resolution.requiredDimensions();
|
BlockPosition required = resolution.requiredDimensions();
|
||||||
JigsawStudioCellDimensions capacity = resolution.workcell().capacity();
|
JigsawStudioCellDimensions capacity = resolution.workcell().capacity();
|
||||||
use.error("Jigsaw piece '" + pieceKey + "' requires " + required.getX() + "x"
|
use.error("Jigsaw piece '" + pieceKey + "' requires " + required.x() + "x"
|
||||||
+ required.getY() + "x" + required.getZ() + " in " + resolution.workcell().displayName()
|
+ required.y() + "x" + required.z() + " in " + resolution.workcell().displayName()
|
||||||
+ ", but that workcell capacity is " + capacity.width() + "x" + capacity.height()
|
+ ", but that workcell capacity is " + capacity.width() + "x" + capacity.height()
|
||||||
+ "x" + capacity.depth() + ".");
|
+ "x" + capacity.depth() + ".");
|
||||||
return;
|
return;
|
||||||
@@ -397,7 +396,7 @@ final class GraphEditCommands {
|
|||||||
String objectKey = piece.getObject();
|
String objectKey = piece.getObject();
|
||||||
runGraphMutation(use, active, () -> {
|
runGraphMutation(use, active, () -> {
|
||||||
if (!JigsawStudioGraphEditor.ownsPiece(
|
if (!JigsawStudioGraphEditor.ownsPiece(
|
||||||
active.request().source().getDataFolder().toPath(),
|
active.request().packRoot(),
|
||||||
active.request().structureKey(),
|
active.request().structureKey(),
|
||||||
pieceKey,
|
pieceKey,
|
||||||
objectKey)) {
|
objectKey)) {
|
||||||
@@ -405,7 +404,7 @@ final class GraphEditCommands {
|
|||||||
+ "use piece create for a new owned piece");
|
+ "use piece create for a new owned piece");
|
||||||
}
|
}
|
||||||
JigsawStudioPoolEditor.PoolUpdate update = JigsawStudioPoolEditor.addPiece(
|
JigsawStudioPoolEditor.PoolUpdate update = JigsawStudioPoolEditor.addPiece(
|
||||||
active.request().source().getDataFolder().toPath(),
|
active.request().packRoot(),
|
||||||
active.request().structureKey(),
|
active.request().structureKey(),
|
||||||
poolKey,
|
poolKey,
|
||||||
pieceKey,
|
pieceKey,
|
||||||
@@ -442,7 +441,7 @@ final class GraphEditCommands {
|
|||||||
String pieceKey = selected.pieceKey();
|
String pieceKey = selected.pieceKey();
|
||||||
runGraphMutation(use, active, () -> {
|
runGraphMutation(use, active, () -> {
|
||||||
JigsawStudioPoolEditor.PoolUpdate update = JigsawStudioPoolEditor.removePiece(
|
JigsawStudioPoolEditor.PoolUpdate update = JigsawStudioPoolEditor.removePiece(
|
||||||
active.request().source().getDataFolder().toPath(),
|
active.request().packRoot(),
|
||||||
active.request().structureKey(),
|
active.request().structureKey(),
|
||||||
poolKey,
|
poolKey,
|
||||||
pieceKey);
|
pieceKey);
|
||||||
@@ -482,7 +481,7 @@ final class GraphEditCommands {
|
|||||||
String pieceKey = selected.pieceKey();
|
String pieceKey = selected.pieceKey();
|
||||||
runGraphMutation(use, active, () -> {
|
runGraphMutation(use, active, () -> {
|
||||||
JigsawStudioGraphEditor.updateRotatable(
|
JigsawStudioGraphEditor.updateRotatable(
|
||||||
active.request().source().getDataFolder().toPath(),
|
active.request().packRoot(),
|
||||||
active.request().structureKey(),
|
active.request().structureKey(),
|
||||||
pieceKey,
|
pieceKey,
|
||||||
rotatable);
|
rotatable);
|
||||||
@@ -585,7 +584,7 @@ final class GraphEditCommands {
|
|||||||
String pieceKey = selected.pieceKey();
|
String pieceKey = selected.pieceKey();
|
||||||
runGraphMutation(use, active, () -> {
|
runGraphMutation(use, active, () -> {
|
||||||
JigsawStudioPoolEditor.WeightUpdate update = JigsawStudioPoolEditor.updateWeight(
|
JigsawStudioPoolEditor.WeightUpdate update = JigsawStudioPoolEditor.updateWeight(
|
||||||
active.request().source().getDataFolder().toPath(),
|
active.request().packRoot(),
|
||||||
active.request().structureKey(),
|
active.request().structureKey(),
|
||||||
poolKey,
|
poolKey,
|
||||||
pieceKey,
|
pieceKey,
|
||||||
@@ -727,7 +726,7 @@ final class GraphEditCommands {
|
|||||||
}
|
}
|
||||||
runGraphMutation(use, active, () -> {
|
runGraphMutation(use, active, () -> {
|
||||||
JigsawStudioStructureEditor.updateLimits(
|
JigsawStudioStructureEditor.updateLimits(
|
||||||
active.request().source().getDataFolder().toPath(),
|
active.request().packRoot(),
|
||||||
active.request().structureKey(),
|
active.request().structureKey(),
|
||||||
maxDepth,
|
maxDepth,
|
||||||
maxSizeChunks);
|
maxSizeChunks);
|
||||||
@@ -755,7 +754,7 @@ final class GraphEditCommands {
|
|||||||
String fallback = NONE.equalsIgnoreCase(fallbackPoolKey) ? "" : fallbackPoolKey;
|
String fallback = NONE.equalsIgnoreCase(fallbackPoolKey) ? "" : fallbackPoolKey;
|
||||||
runGraphMutation(use, active, () -> {
|
runGraphMutation(use, active, () -> {
|
||||||
JigsawStudioPoolEditor.PoolUpdate update = JigsawStudioPoolEditor.updateFallback(
|
JigsawStudioPoolEditor.PoolUpdate update = JigsawStudioPoolEditor.updateFallback(
|
||||||
active.request().source().getDataFolder().toPath(),
|
active.request().packRoot(),
|
||||||
active.request().structureKey(),
|
active.request().structureKey(),
|
||||||
poolKey,
|
poolKey,
|
||||||
fallback);
|
fallback);
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package art.arcane.iris.core.structure.tooling;
|
package art.arcane.iris.core.structure.tooling;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarArchetype;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarArchetype;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioBay;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioBay;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
||||||
@@ -26,16 +25,18 @@ import art.arcane.iris.core.runtime.jigsaw.JigsawStudioGraphMapper;
|
|||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioLayout;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioLayout;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMode;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMode;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariant;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariant;
|
||||||
|
import art.arcane.iris.core.service.JigsawStudioRequest;
|
||||||
import art.arcane.iris.core.service.JigsawStudioService;
|
import art.arcane.iris.core.service.JigsawStudioService;
|
||||||
import art.arcane.iris.core.structure.tooling.StudioSessions.ActiveContext;
|
import art.arcane.iris.core.structure.tooling.StudioSessions.ActiveContext;
|
||||||
|
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||||
import art.arcane.iris.engine.framework.structure.PlanarJigsawWorkcellResolver;
|
import art.arcane.iris.engine.framework.structure.PlanarJigsawWorkcellResolver;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -58,13 +59,19 @@ final class GraphMutations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static JigsawStudioLayout loadPersistedLayout(ActiveContext context) throws IOException {
|
static JigsawStudioLayout loadPersistedLayout(ActiveContext context) throws IOException {
|
||||||
IrisData source = context.request().source();
|
JigsawStudioRequest request = context.request();
|
||||||
source.invalidateStructureResources();
|
request.reloadSource();
|
||||||
IrisStructure structure = StructureResources.structure(source.getPackResources(), context.request().structureKey());
|
IrisStructure structure = StructureResources.structure(request.source().resources(), request.structureKey());
|
||||||
if (structure == null) {
|
if (structure == null) {
|
||||||
throw new IOException("The structure could not be reloaded after the graph transaction");
|
throw new IOException("The structure could not be reloaded after the graph transaction");
|
||||||
}
|
}
|
||||||
return JigsawStudioGraphMapper.map(source, structure);
|
return JigsawStudioGraphMapper.map(request.source(), request.packRoot(), request.structureKey(), structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The declared size of the pack object {@code objectKey} names in the studio's pack; null when it has none. */
|
||||||
|
static ObjectFrame objectFrame(ActiveContext context, String objectKey) {
|
||||||
|
PackResources resources = context.request().source().resources();
|
||||||
|
return resources.objects().sizeOf(resources.idOf(objectKey)).map(ObjectFrame::of).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JigsawStudioService.CommandGraphMutationResult mappedMutationResult(
|
static JigsawStudioService.CommandGraphMutationResult mappedMutationResult(
|
||||||
@@ -93,23 +100,23 @@ final class GraphMutations {
|
|||||||
static PieceWorkcellResolution resolvePieceWorkcell(
|
static PieceWorkcellResolution resolvePieceWorkcell(
|
||||||
JigsawStudioLayout layout,
|
JigsawStudioLayout layout,
|
||||||
IrisJigsawPiece piece,
|
IrisJigsawPiece piece,
|
||||||
IrisObject object
|
ObjectFrame object
|
||||||
) {
|
) {
|
||||||
JigsawStudioLayout activeLayout = Objects.requireNonNull(layout, "Jigsaw Studio layout");
|
JigsawStudioLayout activeLayout = Objects.requireNonNull(layout, "Jigsaw Studio layout");
|
||||||
IrisJigsawPiece activePiece = Objects.requireNonNull(piece, "Jigsaw piece");
|
IrisJigsawPiece activePiece = Objects.requireNonNull(piece, "Jigsaw piece");
|
||||||
IrisObject activeObject = Objects.requireNonNull(object, "Jigsaw piece object");
|
ObjectFrame activeObject = Objects.requireNonNull(object, "Jigsaw piece object");
|
||||||
String workcellId;
|
String workcellId;
|
||||||
IrisPosition requiredDimensions;
|
BlockPosition requiredDimensions;
|
||||||
if (activeLayout.mode() == JigsawStudioMode.PLANAR_JIGSAW) {
|
if (activeLayout.mode() == JigsawStudioMode.PLANAR_JIGSAW) {
|
||||||
IrisJigsawWorkcellArchetype modelArchetype = IrisJigsawWorkcellArchetype.fromPiece(activePiece);
|
IrisJigsawWorkcellArchetype modelArchetype = IrisJigsawWorkcellArchetype.fromPiece(activePiece);
|
||||||
workcellId = JigsawPlanarArchetype.fromModel(modelArchetype).stableId();
|
workcellId = JigsawPlanarArchetype.fromModel(modelArchetype).stableId();
|
||||||
requiredDimensions = PlanarJigsawWorkcellResolver.canonicalDimensions(activePiece, activeObject);
|
requiredDimensions = PlanarJigsawWorkcellResolver.canonicalDimensions(activePiece, activeObject);
|
||||||
} else {
|
} else {
|
||||||
workcellId = JigsawStudioLayout.SPATIAL_WORKCELL_ID;
|
workcellId = JigsawStudioLayout.SPATIAL_WORKCELL_ID;
|
||||||
requiredDimensions = new IrisPosition(
|
requiredDimensions = new BlockPosition(
|
||||||
activeObject.getW(),
|
activeObject.width(),
|
||||||
activeObject.getH(),
|
activeObject.height(),
|
||||||
activeObject.getD());
|
activeObject.depth());
|
||||||
}
|
}
|
||||||
JigsawStudioBay workcell = activeLayout.get(workcellId);
|
JigsawStudioBay workcell = activeLayout.get(workcellId);
|
||||||
if (workcell == null) {
|
if (workcell == null) {
|
||||||
@@ -120,7 +127,7 @@ final class GraphMutations {
|
|||||||
|
|
||||||
static String nextThemeKey(ActiveContext context) throws IOException {
|
static String nextThemeKey(ActiveContext context) throws IOException {
|
||||||
IrisStructure structure = StructureResources.structure(
|
IrisStructure structure = StructureResources.structure(
|
||||||
context.request().source().getPackResources(),
|
context.request().source().resources(),
|
||||||
context.request().structureKey());
|
context.request().structureKey());
|
||||||
if (structure == null) {
|
if (structure == null) {
|
||||||
throw new IOException("The active jigsaw structure could not be loaded");
|
throw new IOException("The active jigsaw structure could not be loaded");
|
||||||
@@ -146,7 +153,7 @@ final class GraphMutations {
|
|||||||
|
|
||||||
record PieceWorkcellResolution(
|
record PieceWorkcellResolution(
|
||||||
JigsawStudioBay workcell,
|
JigsawStudioBay workcell,
|
||||||
IrisPosition requiredDimensions
|
BlockPosition requiredDimensions
|
||||||
) {
|
) {
|
||||||
PieceWorkcellResolution {
|
PieceWorkcellResolution {
|
||||||
workcell = Objects.requireNonNull(workcell, "Jigsaw Studio workcell");
|
workcell = Objects.requireNonNull(workcell, "Jigsaw Studio workcell");
|
||||||
@@ -155,9 +162,9 @@ final class GraphMutations {
|
|||||||
|
|
||||||
boolean fits() {
|
boolean fits() {
|
||||||
JigsawStudioCellDimensions capacity = workcell.capacity();
|
JigsawStudioCellDimensions capacity = workcell.capacity();
|
||||||
return requiredDimensions.getX() <= capacity.width()
|
return requiredDimensions.x() <= capacity.width()
|
||||||
&& requiredDimensions.getY() <= capacity.height()
|
&& requiredDimensions.y() <= capacity.height()
|
||||||
&& requiredDimensions.getZ() <= capacity.depth();
|
&& requiredDimensions.z() <= capacity.depth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,8 +103,8 @@ final class JigsawExportCommand {
|
|||||||
VanillaJigsawExportRequest request;
|
VanillaJigsawExportRequest request;
|
||||||
try {
|
try {
|
||||||
request = VanillaJigsawExportRequest.builder(
|
request = VanillaJigsawExportRequest.builder(
|
||||||
VanillaJigsawExportSource.forData(
|
VanillaJigsawExportSource.forPack(
|
||||||
active.request().source(), active.request().structureKey()), destination)
|
active.request().source().resources(), active.request().structureKey()), destination)
|
||||||
.namespace(context.get(NAMESPACE))
|
.namespace(context.get(NAMESPACE))
|
||||||
.resourcePath(active.request().structureKey())
|
.resourcePath(active.request().structureKey())
|
||||||
.format(exportFormat)
|
.format(exportFormat)
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package art.arcane.iris.core.structure.tooling;
|
package art.arcane.iris.core.structure.tooling;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.service.JigsawStudioService;
|
import art.arcane.iris.core.service.JigsawStudioService;
|
||||||
import com.volmit.tooling.Sender;
|
import com.volmit.tooling.Sender;
|
||||||
import com.volmit.tooling.ToolPack;
|
import com.volmit.tooling.ToolPack;
|
||||||
@@ -28,16 +27,13 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* What the jigsaw commands need from the server that runs the Jigsaw Studio and that no api type offers: the studio
|
* What the jigsaw commands need from the server that runs the Jigsaw Studio and that no api type offers: the studio
|
||||||
* itself, the pack's data, whether a pack may open a studio, and the server's one open studio. The adapter that runs a
|
* itself, whether a pack may open a studio, and the server's one open studio. The adapter that runs a
|
||||||
* studio implements it; a platform without one has none, and the commands then say so.
|
* studio implements it; a platform without one has none, and the commands then say so.
|
||||||
*/
|
*/
|
||||||
public interface JigsawStudioHost {
|
public interface JigsawStudioHost {
|
||||||
/** The studio, which keeps the sessions of its players. */
|
/** The studio, which keeps the sessions of its players. */
|
||||||
JigsawStudioService studio();
|
JigsawStudioService studio();
|
||||||
|
|
||||||
/** The pack's data, for the resources the studio still reads through it. */
|
|
||||||
IrisData dataOf(ToolPack pack);
|
|
||||||
|
|
||||||
/** The key the studio files {@code pack} under. */
|
/** The key the studio files {@code pack} under. */
|
||||||
String packKey(ToolPack pack);
|
String packKey(ToolPack pack);
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package art.arcane.iris.core.structure.tooling;
|
package art.arcane.iris.core.structure.tooling;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioBay;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioBay;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
||||||
@@ -295,7 +294,6 @@ final class StudioLifecycleCommands {
|
|||||||
use.error("The current Jigsaw Studio is waiting for autosave. Wait for it to finish or close with discard=true.");
|
use.error("The current Jigsaw Studio is waiting for autosave. Wait for it to finish or close with discard=true.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IrisData data = host.dataOf(pack);
|
|
||||||
IrisStructure irisStructure = StructureResources.structure(pack.resources(), structure);
|
IrisStructure irisStructure = StructureResources.structure(pack.resources(), structure);
|
||||||
if (irisStructure == null) {
|
if (irisStructure == null) {
|
||||||
use.error("No Iris jigsaw structure '" + structure + "' exists in this pack.");
|
use.error("No Iris jigsaw structure '" + structure + "' exists in this pack.");
|
||||||
@@ -304,7 +302,7 @@ final class StudioLifecycleCommands {
|
|||||||
|
|
||||||
JigsawStudioLayout layout;
|
JigsawStudioLayout layout;
|
||||||
try {
|
try {
|
||||||
layout = JigsawStudioGraphMapper.map(data, irisStructure);
|
layout = JigsawStudioGraphMapper.map(pack, JigsawStudioRequest.rootOf(pack), structure, irisStructure);
|
||||||
} catch (RuntimeException exception) {
|
} catch (RuntimeException exception) {
|
||||||
pack.log().error("Failed to map Jigsaw Studio graph '" + structure + "'.", exception);
|
pack.log().error("Failed to map Jigsaw Studio graph '" + structure + "'.", exception);
|
||||||
use.error("Could not map this jigsaw graph: " + exception.getMessage());
|
use.error("Could not map this jigsaw graph: " + exception.getMessage());
|
||||||
@@ -341,7 +339,7 @@ final class StudioLifecycleCommands {
|
|||||||
layout.mode(),
|
layout.mode(),
|
||||||
compatibilityOf(irisStructure),
|
compatibilityOf(irisStructure),
|
||||||
layout.cellDimensions(),
|
layout.cellDimensions(),
|
||||||
data,
|
pack,
|
||||||
layout,
|
layout,
|
||||||
playerId,
|
playerId,
|
||||||
closingRequestId);
|
closingRequestId);
|
||||||
|
|||||||
@@ -19,17 +19,16 @@
|
|||||||
package art.arcane.iris.engine.framework;
|
package art.arcane.iris.engine.framework;
|
||||||
|
|
||||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||||
|
import art.arcane.iris.engine.framework.structure.ColumnHeights;
|
||||||
import art.arcane.iris.engine.framework.structure.NativeStartPlanner;
|
import art.arcane.iris.engine.framework.structure.NativeStartPlanner;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.assembly.AssembledPiece;
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.engine.framework.structure.assembly.Assembly;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureGraphCatalog;
|
import art.arcane.iris.engine.framework.structure.assembly.StructureAssembly;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureGraphCompilation;
|
import art.arcane.iris.engine.framework.structure.assembly.StructureStamp;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
import art.arcane.iris.engine.framework.structure.assembly.Viability;
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
|
||||||
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
||||||
import art.arcane.iris.builtin.structure.StructureCarveShape;
|
import art.arcane.iris.builtin.structure.StructureCarveShape;
|
||||||
import art.arcane.iris.builtin.structure.StructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
@@ -39,9 +38,9 @@ import art.arcane.iris.builtin.structure.NativeStructureSuppression;
|
|||||||
import art.arcane.iris.builtin.structure.StructureDistribution;
|
import art.arcane.iris.builtin.structure.StructureDistribution;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import art.arcane.iris.core.modules.IrisModuleHost;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import com.volmit.ModuleLog;
|
import com.volmit.resource.PackResources;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
import com.volmit.resource.ResourceId;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -171,7 +170,7 @@ public final class IrisStructureLocator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (StructurePlacement placement : index(engine).placements) {
|
for (StructurePlacement placement : index(engine).placements) {
|
||||||
if (placement.hasIrisStructures() && matches(placement, key, engine.getData())) {
|
if (placement.hasIrisStructures() && matches(placement, key, engine)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -516,32 +515,33 @@ public final class IrisStructureLocator {
|
|||||||
if (selectedKey == null || selectedKey.isBlank()) {
|
if (selectedKey == null || selectedKey.isBlank()) {
|
||||||
throw new IllegalStateException("Iris structure placement selected a blank structure key");
|
throw new IllegalStateException("Iris structure placement selected a blank structure key");
|
||||||
}
|
}
|
||||||
IrisStructure structure = StructureResources.structure(engine.getData().getPackResources(), selectedKey);
|
PackResources pack = engine.getData().getPackResources();
|
||||||
if (structure == null) {
|
ResourceId structureId = pack.idOf(selectedKey);
|
||||||
|
StructureAssembly provider = providerOf(engine, structureId);
|
||||||
|
if (provider == null) {
|
||||||
throw new IllegalStateException("Iris structure placement references missing structure '"
|
throw new IllegalStateException("Iris structure placement references missing structure '"
|
||||||
+ selectedKey + "'");
|
+ selectedKey + "'");
|
||||||
}
|
}
|
||||||
StructureGraphCompilation compilation = StructureGraphCatalog.compile(engine.getData(), structure, IrisModuleHost.hostLog());
|
if (!provider.viability(pack, structureId).isViable()) {
|
||||||
if (!compilation.isAssemblyViable()) {
|
|
||||||
throw new IllegalStateException("Iris structure '" + selectedKey
|
throw new IllegalStateException("Iris structure '" + selectedKey
|
||||||
+ "' has no runtime-viable assembly graph");
|
+ "' has no runtime-viable assembly graph");
|
||||||
}
|
}
|
||||||
|
|
||||||
StructureAssembler assembler = StructureAssembler.forData(
|
Assembly assembly = provider.assemble(pack, structureId, new BlockPosition(originX, baseY, originZ), rng)
|
||||||
engine.getData(), structure, new IrisPosition(originX, baseY, originZ), IrisModuleHost.hostLog());
|
.orElseThrow();
|
||||||
StructureAssemblyResult assembly = assembler.assemble(rng);
|
|
||||||
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
|
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
|
||||||
assembly.hasOutput(), "runtime assembly produced " + assembly.status() + ": " + assembly.detail())) {
|
assembly.hasOutput(), "runtime assembly produced " + assembly.status() + ": " + assembly.detail())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
KList<PlacedStructurePiece> pieces = new KList<>(assembly.pieces());
|
StructureStamp stamp = provider.stamp(pack, structureId).orElseThrow();
|
||||||
|
KList<AssembledPiece> pieces = new KList<>(assembly.pieces());
|
||||||
pieces = alignCavePieces(pieces, placement, baseY);
|
pieces = alignCavePieces(pieces, placement, baseY);
|
||||||
pieces = alignSurfacePieces(pieces, placement, structure, baseY);
|
pieces = alignSurfacePieces(pieces, placement, stamp, baseY);
|
||||||
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
|
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
|
||||||
pieces != null && !pieces.isEmpty(), "surface alignment produced no pieces")) {
|
pieces != null && !pieces.isEmpty(), "surface alignment produced no pieces")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
boolean exactY = hasExactY(placement, structure, pieces);
|
boolean exactY = hasExactY(placement, stamp, pieces);
|
||||||
|
|
||||||
int worldMin = engine.getMinHeight() + 1;
|
int worldMin = engine.getMinHeight() + 1;
|
||||||
int worldMax = engine.getMinHeight() + engine.getHeight() - 1;
|
int worldMax = engine.getMinHeight() + engine.getHeight() - 1;
|
||||||
@@ -569,7 +569,7 @@ public final class IrisStructureLocator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long configuredRadius = (long) Math.max(1, structure.getMaxSizeChunks()) * 16L;
|
long configuredRadius = (long) Math.max(1, provider.reachChunks(pack, structureId).orElse(1)) * 16L;
|
||||||
int structureRadius = (int) Math.min(Integer.MAX_VALUE, configuredRadius);
|
int structureRadius = (int) Math.min(Integer.MAX_VALUE, configuredRadius);
|
||||||
boolean withinBounds = fitsHorizontalBounds(pieces, originX, originZ, structureRadius)
|
boolean withinBounds = fitsHorizontalBounds(pieces, originX, originZ, structureRadius)
|
||||||
&& (!exactY || fitsVerticalBounds(pieces, worldMin, worldMax));
|
&& (!exactY || fitsVerticalBounds(pieces, worldMin, worldMax));
|
||||||
@@ -577,7 +577,29 @@ public final class IrisStructureLocator {
|
|||||||
"assembled pieces exceed the configured structure or world bounds")) {
|
"assembled pieces exceed the configured structure or world bounds")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new ResolvedPlacement(placement, selectedKey, structure, pieces, rng, originX, baseY, originZ, exactY);
|
return new ResolvedPlacement(placement, selectedKey, stamp, pieces, rng, originX, baseY, originZ, exactY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The first provider of {@link StructureAssembly} among the modules of the engine's pack that knows {@code structure};
|
||||||
|
* null when none does.
|
||||||
|
*/
|
||||||
|
public static StructureAssembly providerOf(Engine engine, ResourceId structure) {
|
||||||
|
PackResources pack = engine.getData().getPackResources();
|
||||||
|
for (StructureAssembly provider : engine.getGeneration().world().services(StructureAssembly.class)) {
|
||||||
|
if (provider.knows(pack, structure)) {
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** How the pieces of the pack structure {@code key} are stamped; null when no module knows the structure. */
|
||||||
|
public static StructureStamp stampOf(Engine engine, String key) {
|
||||||
|
PackResources pack = engine.getData().getPackResources();
|
||||||
|
ResourceId structure = pack.idOf(key);
|
||||||
|
StructureAssembly provider = providerOf(engine, structure);
|
||||||
|
return provider == null ? null : provider.stamp(pack, structure).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean requirePlacementOutput(StructurePlacement placement, String structureKey,
|
public static boolean requirePlacementOutput(StructurePlacement placement, String structureKey,
|
||||||
@@ -599,7 +621,7 @@ public final class IrisStructureLocator {
|
|||||||
+ ". Native generation is suppressed and will not be used as a fallback");
|
+ ". Native generation is suppressed and will not be used as a fallback");
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean fitsWorldBounds(KList<PlacedStructurePiece> pieces, int worldMin, int worldMax,
|
static boolean fitsWorldBounds(KList<AssembledPiece> pieces, int worldMin, int worldMax,
|
||||||
int originX, int originZ, int structureRadius) {
|
int originX, int originZ, int structureRadius) {
|
||||||
int[] bounds = computeBounds(pieces);
|
int[] bounds = computeBounds(pieces);
|
||||||
if (bounds == null) {
|
if (bounds == null) {
|
||||||
@@ -610,7 +632,6 @@ public final class IrisStructureLocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ResolvedStart resolveInChunk(Engine engine, String key, int cx, int cz) {
|
private static ResolvedStart resolveInChunk(Engine engine, String key, int cx, int cz) {
|
||||||
IrisData data = engine.getData();
|
|
||||||
String normalizedKey = normalize(key);
|
String normalizedKey = normalize(key);
|
||||||
if (hasNativePlacement(engine, key)) {
|
if (hasNativePlacement(engine, key)) {
|
||||||
for (NativeStartPlanner.Plan plan : NativeStartPlanner.plansAt(engine, cx, cz)) {
|
for (NativeStartPlanner.Plan plan : NativeStartPlanner.plansAt(engine, cx, cz)) {
|
||||||
@@ -621,7 +642,7 @@ public final class IrisStructureLocator {
|
|||||||
}
|
}
|
||||||
KList<StructurePlacement> placements = StructurePlacementScope.placementsAt(engine, cx, cz);
|
KList<StructurePlacement> placements = StructurePlacementScope.placementsAt(engine, cx, cz);
|
||||||
for (StructurePlacement placement : placements) {
|
for (StructurePlacement placement : placements) {
|
||||||
if (!matches(placement, key, data)) {
|
if (!matches(placement, key, engine)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (placement.hasNativeStructures()) {
|
if (placement.hasNativeStructures()) {
|
||||||
@@ -676,7 +697,7 @@ public final class IrisStructureLocator {
|
|||||||
return randomInclusive(rng, bandMin, bandMax);
|
return randomInclusive(rng, bandMin, bandMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Integer resolveVerticalShift(KList<PlacedStructurePiece> pieces, StructurePlacement placement,
|
static Integer resolveVerticalShift(KList<AssembledPiece> pieces, StructurePlacement placement,
|
||||||
int baseY, int worldMin, int worldMax) {
|
int baseY, int worldMin, int worldMax) {
|
||||||
int[] bounds = computeBounds(pieces);
|
int[] bounds = computeBounds(pieces);
|
||||||
if (bounds == null) {
|
if (bounds == null) {
|
||||||
@@ -701,7 +722,7 @@ public final class IrisStructureLocator {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Integer resolveUndergroundBurialShift(Engine engine, KList<PlacedStructurePiece> pieces,
|
static Integer resolveUndergroundBurialShift(Engine engine, KList<AssembledPiece> pieces,
|
||||||
StructurePlacement placement, int baseY,
|
StructurePlacement placement, int baseY,
|
||||||
int worldMin, int worldMax) {
|
int worldMin, int worldMax) {
|
||||||
int[] bounds = computeBounds(pieces);
|
int[] bounds = computeBounds(pieces);
|
||||||
@@ -729,8 +750,7 @@ public final class IrisStructureLocator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Long2IntOpenHashMap surfaceHeights = new Long2IntOpenHashMap();
|
ColumnHeights surfaceHeights = new ColumnHeights(Integer.MIN_VALUE);
|
||||||
surfaceHeights.defaultReturnValue(Integer.MIN_VALUE);
|
|
||||||
if (bore || forceCarve && carveShape == StructureCarveShape.BOX) {
|
if (bore || forceCarve && carveShape == StructureCarveShape.BOX) {
|
||||||
maximumShift = resolveBurialEnvelopeShift(
|
maximumShift = resolveBurialEnvelopeShift(
|
||||||
engine,
|
engine,
|
||||||
@@ -746,14 +766,14 @@ public final class IrisStructureLocator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (PlacedStructurePiece piece : pieces) {
|
for (AssembledPiece piece : pieces) {
|
||||||
maximumShift = resolveBurialEnvelopeShift(
|
maximumShift = resolveBurialEnvelopeShift(
|
||||||
engine,
|
engine,
|
||||||
piece.getMinX() - sideExtension,
|
piece.minX() - sideExtension,
|
||||||
piece.getMaxX() + sideExtension,
|
piece.maxX() + sideExtension,
|
||||||
piece.getMinZ() - sideExtension,
|
piece.minZ() - sideExtension,
|
||||||
piece.getMaxZ() + sideExtension,
|
piece.maxZ() + sideExtension,
|
||||||
piece.getMaxY() + topExtension,
|
piece.maxY() + topExtension,
|
||||||
maximumShift,
|
maximumShift,
|
||||||
surfaceHeights
|
surfaceHeights
|
||||||
);
|
);
|
||||||
@@ -767,7 +787,7 @@ public final class IrisStructureLocator {
|
|||||||
|
|
||||||
private static int resolveBurialEnvelopeShift(Engine engine, int minX, int maxX, int minZ, int maxZ,
|
private static int resolveBurialEnvelopeShift(Engine engine, int minX, int maxX, int minZ, int maxZ,
|
||||||
int envelopeTopY, int maximumShift,
|
int envelopeTopY, int maximumShift,
|
||||||
Long2IntOpenHashMap surfaceHeights) {
|
ColumnHeights surfaceHeights) {
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; x++) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
long columnKey = ((long) x << 32) ^ (z & 0xffffffffL);
|
long columnKey = ((long) x << 32) ^ (z & 0xffffffffL);
|
||||||
@@ -793,8 +813,8 @@ public final class IrisStructureLocator {
|
|||||||
return placement.structures().get(rng.nextInt(placement.structures().size()));
|
return placement.structures().get(rng.nextInt(placement.structures().size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
static KList<PlacedStructurePiece> alignCavePieces(
|
static KList<AssembledPiece> alignCavePieces(
|
||||||
KList<PlacedStructurePiece> pieces,
|
KList<AssembledPiece> pieces,
|
||||||
StructurePlacement placement,
|
StructurePlacement placement,
|
||||||
int anchorY
|
int anchorY
|
||||||
) {
|
) {
|
||||||
@@ -815,24 +835,24 @@ public final class IrisStructureLocator {
|
|||||||
return shiftPieces(pieces, anchorY - targetY);
|
return shiftPieces(pieces, anchorY - targetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KList<PlacedStructurePiece> alignSurfacePieces(KList<PlacedStructurePiece> pieces,
|
private static KList<AssembledPiece> alignSurfacePieces(KList<AssembledPiece> pieces,
|
||||||
StructurePlacement placement,
|
StructurePlacement placement,
|
||||||
IrisStructure structure, int baseY) {
|
StructureStamp stamp, int baseY) {
|
||||||
if (placement.isAnchoredUnderground() || pieces.size() <= 1
|
if (placement.isAnchoredUnderground() || pieces.size() <= 1
|
||||||
|| structure.getPlaceMode().placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
|| stamp.placeMode().placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
||||||
return pieces;
|
return pieces;
|
||||||
}
|
}
|
||||||
int[] bounds = computeBounds(pieces);
|
int[] bounds = computeBounds(pieces);
|
||||||
return bounds == null ? pieces : shiftPieces(pieces, baseY - bounds[1]);
|
return bounds == null ? pieces : shiftPieces(pieces, baseY - bounds[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean hasExactY(StructurePlacement placement, IrisStructure structure,
|
static boolean hasExactY(StructurePlacement placement, StructureStamp stamp,
|
||||||
KList<PlacedStructurePiece> pieces) {
|
KList<AssembledPiece> pieces) {
|
||||||
return placement.isAnchoredUnderground() || pieces.size() > 1
|
return placement.isAnchoredUnderground() || pieces.size() > 1
|
||||||
|| structure.getPlaceMode().placeMode().has(PlaceTrait.FREE_HEIGHT);
|
|| stamp.placeMode().placeMode().has(PlaceTrait.FREE_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean fitsVerticalBounds(KList<PlacedStructurePiece> pieces, int worldMin, int worldMax) {
|
private static boolean fitsVerticalBounds(KList<AssembledPiece> pieces, int worldMin, int worldMax) {
|
||||||
int[] bounds = computeBounds(pieces);
|
int[] bounds = computeBounds(pieces);
|
||||||
return bounds != null && fitsVerticalBounds(bounds, worldMin, worldMax);
|
return bounds != null && fitsVerticalBounds(bounds, worldMin, worldMax);
|
||||||
}
|
}
|
||||||
@@ -841,7 +861,7 @@ public final class IrisStructureLocator {
|
|||||||
return bounds[1] >= worldMin && bounds[4] <= worldMax;
|
return bounds[1] >= worldMin && bounds[4] <= worldMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean fitsHorizontalBounds(KList<PlacedStructurePiece> pieces, int originX, int originZ,
|
private static boolean fitsHorizontalBounds(KList<AssembledPiece> pieces, int originX, int originZ,
|
||||||
int structureRadius) {
|
int structureRadius) {
|
||||||
int[] bounds = computeBounds(pieces);
|
int[] bounds = computeBounds(pieces);
|
||||||
return bounds != null && fitsHorizontalBounds(bounds, originX, originZ, structureRadius);
|
return bounds != null && fitsHorizontalBounds(bounds, originX, originZ, structureRadius);
|
||||||
@@ -852,18 +872,15 @@ public final class IrisStructureLocator {
|
|||||||
&& bounds[2] >= originZ - structureRadius && bounds[5] <= originZ + structureRadius;
|
&& bounds[2] >= originZ - structureRadius && bounds[5] <= originZ + structureRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KList<PlacedStructurePiece> shiftPieces(KList<PlacedStructurePiece> pieces, int shiftY) {
|
private static KList<AssembledPiece> shiftPieces(KList<AssembledPiece> pieces, int shiftY) {
|
||||||
KList<PlacedStructurePiece> shifted = new KList<>();
|
KList<AssembledPiece> shifted = new KList<>();
|
||||||
for (PlacedStructurePiece piece : pieces) {
|
for (AssembledPiece piece : pieces) {
|
||||||
shifted.add(new PlacedStructurePiece(
|
shifted.add(piece.shiftedUp(shiftY));
|
||||||
piece.getPiece(), piece.getObject(), piece.getX(), piece.getY() + shiftY, piece.getZ(), piece.getRotation(),
|
|
||||||
piece.getMinX(), piece.getMinY() + shiftY, piece.getMinZ(),
|
|
||||||
piece.getMaxX(), piece.getMaxY() + shiftY, piece.getMaxZ()));
|
|
||||||
}
|
}
|
||||||
return shifted;
|
return shifted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] computeBounds(KList<PlacedStructurePiece> pieces) {
|
private static int[] computeBounds(KList<AssembledPiece> pieces) {
|
||||||
if (pieces == null || pieces.isEmpty()) {
|
if (pieces == null || pieces.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -873,13 +890,13 @@ public final class IrisStructureLocator {
|
|||||||
int maxX = Integer.MIN_VALUE;
|
int maxX = Integer.MIN_VALUE;
|
||||||
int maxY = Integer.MIN_VALUE;
|
int maxY = Integer.MIN_VALUE;
|
||||||
int maxZ = Integer.MIN_VALUE;
|
int maxZ = Integer.MIN_VALUE;
|
||||||
for (PlacedStructurePiece piece : pieces) {
|
for (AssembledPiece piece : pieces) {
|
||||||
minX = Math.min(minX, piece.getMinX());
|
minX = Math.min(minX, piece.minX());
|
||||||
minY = Math.min(minY, piece.getMinY());
|
minY = Math.min(minY, piece.minY());
|
||||||
minZ = Math.min(minZ, piece.getMinZ());
|
minZ = Math.min(minZ, piece.minZ());
|
||||||
maxX = Math.max(maxX, piece.getMaxX());
|
maxX = Math.max(maxX, piece.maxX());
|
||||||
maxY = Math.max(maxY, piece.getMaxY());
|
maxY = Math.max(maxY, piece.maxY());
|
||||||
maxZ = Math.max(maxZ, piece.getMaxZ());
|
maxZ = Math.max(maxZ, piece.maxZ());
|
||||||
}
|
}
|
||||||
return new int[]{minX, minY, minZ, maxX, maxY, maxZ};
|
return new int[]{minX, minY, minZ, maxX, maxY, maxZ};
|
||||||
}
|
}
|
||||||
@@ -897,7 +914,7 @@ public final class IrisStructureLocator {
|
|||||||
boolean hasDensity = false;
|
boolean hasDensity = false;
|
||||||
for (StructurePlacement placement : index(engine).placements) {
|
for (StructurePlacement placement : index(engine).placements) {
|
||||||
if (!isSearchablePlacement(engine, placement)
|
if (!isSearchablePlacement(engine, placement)
|
||||||
|| !matches(placement, key, engine.getData())) {
|
|| !matches(placement, key, engine)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (placement.distribution() == StructureDistribution.RANDOM_SPREAD) {
|
if (placement.distribution() == StructureDistribution.RANDOM_SPREAD) {
|
||||||
@@ -1016,8 +1033,8 @@ public final class IrisStructureLocator {
|
|||||||
private record PlacementAnchor(int x, int y, int z) {
|
private record PlacementAnchor(int x, int y, int z) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean matches(StructurePlacement placement, String key, IrisData data) {
|
private static boolean matches(StructurePlacement placement, String key, Engine engine) {
|
||||||
if (placement == null || key == null || data == null) {
|
if (placement == null || key == null || engine == null || engine.getData() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String normalizedKey = normalize(key);
|
String normalizedKey = normalize(key);
|
||||||
@@ -1030,13 +1047,12 @@ public final class IrisStructureLocator {
|
|||||||
if (structureKey == null || structureKey.isBlank()) {
|
if (structureKey == null || structureKey.isBlank()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey);
|
StructureStamp stamp = stampOf(engine, structureKey);
|
||||||
if (structure == null) {
|
if (stamp == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (normalize(structureKey).equals(normalizedKey)
|
if (normalize(structureKey).equals(normalizedKey)
|
||||||
|| normalize(structure.getLoadKey()).equals(normalizedKey)
|
|| normalize(stamp.vanillaSource()).equals(normalizedKey)) {
|
||||||
|| normalize(structure.getVanillaSource()).equals(normalizedKey)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1046,8 +1062,7 @@ public final class IrisStructureLocator {
|
|||||||
static boolean matchesResolved(ResolvedPlacement resolved, String key) {
|
static boolean matchesResolved(ResolvedPlacement resolved, String key) {
|
||||||
String normalizedKey = normalize(key);
|
String normalizedKey = normalize(key);
|
||||||
return normalize(resolved.structureKey()).equals(normalizedKey)
|
return normalize(resolved.structureKey()).equals(normalizedKey)
|
||||||
|| normalize(resolved.structure().getLoadKey()).equals(normalizedKey)
|
|| normalize(resolved.stamp().vanillaSource()).equals(normalizedKey);
|
||||||
|| normalize(resolved.structure().getVanillaSource()).equals(normalizedKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String normalize(String key) {
|
private static String normalize(String key) {
|
||||||
@@ -1072,7 +1087,6 @@ public final class IrisStructureLocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static LocatableIndex buildLocatableIndex(Engine engine) {
|
private static LocatableIndex buildLocatableIndex(Engine engine) {
|
||||||
IrisData data = engine.getData();
|
|
||||||
Set<String> keys = new LinkedHashSet<>();
|
Set<String> keys = new LinkedHashSet<>();
|
||||||
Set<String> normalizedKeys = new LinkedHashSet<>();
|
Set<String> normalizedKeys = new LinkedHashSet<>();
|
||||||
Set<String> editableKeys = new LinkedHashSet<>();
|
Set<String> editableKeys = new LinkedHashSet<>();
|
||||||
@@ -1091,17 +1105,15 @@ public final class IrisStructureLocator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (String structureKey : placement.structures()) {
|
for (String structureKey : placement.structures()) {
|
||||||
IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey);
|
StructureStamp stamp = stampOf(engine, structureKey);
|
||||||
if (structure == null) {
|
if (stamp == null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Iris structure placement references missing structure '" + structureKey + "'");
|
"Iris structure placement references missing structure '" + structureKey + "'");
|
||||||
}
|
}
|
||||||
addLocatableKey(structureKey, keys, normalizedKeys);
|
addLocatableKey(structureKey, keys, normalizedKeys);
|
||||||
addLocatableKey(structureKey, editableKeys, normalizedEditableKeys);
|
addLocatableKey(structureKey, editableKeys, normalizedEditableKeys);
|
||||||
addLocatableKey(structure.getLoadKey(), keys, normalizedKeys);
|
addLocatableKey(stamp.vanillaSource(), keys, normalizedKeys);
|
||||||
addLocatableKey(structure.getLoadKey(), editableKeys, normalizedEditableKeys);
|
addLocatableKey(stamp.vanillaSource(), editableKeys, normalizedEditableKeys);
|
||||||
addLocatableKey(structure.getVanillaSource(), keys, normalizedKeys);
|
|
||||||
addLocatableKey(structure.getVanillaSource(), editableKeys, normalizedEditableKeys);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new LocatableIndex(
|
return new LocatableIndex(
|
||||||
@@ -1123,19 +1135,17 @@ public final class IrisStructureLocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static PlacementIndex build(Engine engine) {
|
private static PlacementIndex build(Engine engine) {
|
||||||
IrisData data = engine.getData();
|
|
||||||
ModuleLog log = IrisModuleHost.hostLog();
|
|
||||||
Set<String> loadKeys = new LinkedHashSet<>();
|
Set<String> loadKeys = new LinkedHashSet<>();
|
||||||
Set<String> normalizedLoadKeys = new LinkedHashSet<>();
|
Set<String> normalizedLoadKeys = new LinkedHashSet<>();
|
||||||
Set<String> vanillaAliases = new LinkedHashSet<>();
|
Set<String> vanillaAliases = new LinkedHashSet<>();
|
||||||
Set<String> suppressedVanillaSources = new LinkedHashSet<>();
|
Set<String> suppressedVanillaSources = new LinkedHashSet<>();
|
||||||
List<StructurePlacement> placements = new ArrayList<>();
|
List<StructurePlacement> placements = new ArrayList<>();
|
||||||
collect(StructurePlacementScope.placementsOf(engine.getDimension()), data, log, loadKeys, normalizedLoadKeys, vanillaAliases,
|
collect(StructurePlacementScope.placementsOf(engine.getDimension()), engine, loadKeys, normalizedLoadKeys, vanillaAliases,
|
||||||
suppressedVanillaSources, placements, true);
|
suppressedVanillaSources, placements, true);
|
||||||
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
|
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
|
||||||
if (regions != null) {
|
if (regions != null) {
|
||||||
for (IrisRegion region : regions) {
|
for (IrisRegion region : regions) {
|
||||||
collect(StructurePlacementScope.placementsOf(region), data, log,
|
collect(StructurePlacementScope.placementsOf(region), engine,
|
||||||
loadKeys, normalizedLoadKeys, vanillaAliases,
|
loadKeys, normalizedLoadKeys, vanillaAliases,
|
||||||
suppressedVanillaSources, placements, false);
|
suppressedVanillaSources, placements, false);
|
||||||
}
|
}
|
||||||
@@ -1143,7 +1153,7 @@ public final class IrisStructureLocator {
|
|||||||
KList<IrisBiome> biomes = engine.getDimension().getReachableBiomes(engine);
|
KList<IrisBiome> biomes = engine.getDimension().getReachableBiomes(engine);
|
||||||
if (biomes != null) {
|
if (biomes != null) {
|
||||||
for (IrisBiome biome : biomes) {
|
for (IrisBiome biome : biomes) {
|
||||||
collect(StructurePlacementScope.placementsOf(biome), data, log,
|
collect(StructurePlacementScope.placementsOf(biome), engine,
|
||||||
loadKeys, normalizedLoadKeys, vanillaAliases,
|
loadKeys, normalizedLoadKeys, vanillaAliases,
|
||||||
suppressedVanillaSources, placements, false);
|
suppressedVanillaSources, placements, false);
|
||||||
}
|
}
|
||||||
@@ -1172,7 +1182,7 @@ public final class IrisStructureLocator {
|
|||||||
return Collections.unmodifiableSet(nativeKeys);
|
return Collections.unmodifiableSet(nativeKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void collect(List<StructurePlacement> source, IrisData data, ModuleLog log, Set<String> loadKeys,
|
private static void collect(List<StructurePlacement> source, Engine engine, Set<String> loadKeys,
|
||||||
Set<String> normalizedLoadKeys, Set<String> vanillaAliases,
|
Set<String> normalizedLoadKeys, Set<String> vanillaAliases,
|
||||||
Set<String> suppressedVanillaSources,
|
Set<String> suppressedVanillaSources,
|
||||||
List<StructurePlacement> placements, boolean allowNativeSuppression) {
|
List<StructurePlacement> placements, boolean allowNativeSuppression) {
|
||||||
@@ -1209,8 +1219,8 @@ public final class IrisStructureLocator {
|
|||||||
? "REPLACE_SOURCE contains a blank Iris structure reference"
|
? "REPLACE_SOURCE contains a blank Iris structure reference"
|
||||||
: "Iris structure placement contains a blank structure reference");
|
: "Iris structure placement contains a blank structure reference");
|
||||||
}
|
}
|
||||||
IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey);
|
StructureStamp stamp = stampOf(engine, structureKey);
|
||||||
if (structure == null) {
|
if (stamp == null) {
|
||||||
throw new IllegalStateException((replacesNative
|
throw new IllegalStateException((replacesNative
|
||||||
? "REPLACE_SOURCE references missing Iris structure '"
|
? "REPLACE_SOURCE references missing Iris structure '"
|
||||||
: "Iris structure placement references missing structure '")
|
: "Iris structure placement references missing structure '")
|
||||||
@@ -1218,20 +1228,18 @@ public final class IrisStructureLocator {
|
|||||||
}
|
}
|
||||||
loadKeys.add(structureKey);
|
loadKeys.add(structureKey);
|
||||||
normalizedLoadKeys.add(normalize(structureKey));
|
normalizedLoadKeys.add(normalize(structureKey));
|
||||||
if (structure.getLoadKey() != null && !structure.getLoadKey().isBlank()) {
|
if (!stamp.vanillaSource().isBlank()) {
|
||||||
loadKeys.add(structure.getLoadKey());
|
vanillaAliases.add(normalize(stamp.vanillaSource()));
|
||||||
normalizedLoadKeys.add(normalize(structure.getLoadKey()));
|
|
||||||
}
|
|
||||||
if (structure.getVanillaSource() != null && !structure.getVanillaSource().isBlank()) {
|
|
||||||
vanillaAliases.add(normalize(structure.getVanillaSource()));
|
|
||||||
}
|
}
|
||||||
if (replacesNative) {
|
if (replacesNative) {
|
||||||
String vanillaSource = structure.getVanillaSource();
|
String vanillaSource = stamp.vanillaSource();
|
||||||
if (vanillaSource == null || !NAMESPACED_RESOURCE_KEY.matcher(vanillaSource).matches()) {
|
if (!NAMESPACED_RESOURCE_KEY.matcher(vanillaSource).matches()) {
|
||||||
throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey
|
throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey
|
||||||
+ "' must declare a valid namespaced vanillaSource");
|
+ "' must declare a valid namespaced vanillaSource");
|
||||||
}
|
}
|
||||||
if (!StructureGraphCatalog.guaranteesRuntimeOutput(data, structure, log)) {
|
PackResources pack = engine.getData().getPackResources();
|
||||||
|
ResourceId structureId = pack.idOf(structureKey);
|
||||||
|
if (providerOf(engine, structureId).viability(pack, structureId) != Viability.GUARANTEED) {
|
||||||
throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey
|
throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey
|
||||||
+ "' is not runtime-viable; native generation will not be used as a fallback");
|
+ "' is not runtime-viable; native generation will not be used as a fallback");
|
||||||
}
|
}
|
||||||
@@ -1242,8 +1250,8 @@ public final class IrisStructureLocator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public record ResolvedPlacement(StructurePlacement placement, String structureKey, IrisStructure structure,
|
public record ResolvedPlacement(StructurePlacement placement, String structureKey, StructureStamp stamp,
|
||||||
KList<PlacedStructurePiece> pieces, RNG rng,
|
KList<AssembledPiece> pieces, RNG rng,
|
||||||
int originX, int baseY, int originZ, boolean exactY) {
|
int originX, int baseY, int originZ, boolean exactY) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
package art.arcane.iris.engine.framework;
|
package art.arcane.iris.engine.framework;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -28,11 +28,14 @@ import lombok.Data;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PlacedStructurePiece {
|
public class PlacedStructurePiece {
|
||||||
private final IrisJigsawPiece piece;
|
private final IrisJigsawPiece piece;
|
||||||
private final IrisObject object;
|
/** The pack key of the piece's object. */
|
||||||
|
private final String objectKey;
|
||||||
|
/** The declared size of the piece's object. */
|
||||||
|
private final ObjectFrame object;
|
||||||
private final int x;
|
private final int x;
|
||||||
private final int y;
|
private final int y;
|
||||||
private final int z;
|
private final int z;
|
||||||
private final ObjectTurn rotation;
|
private final PieceTurn rotation;
|
||||||
private final int minX;
|
private final int minX;
|
||||||
private final int minY;
|
private final int minY;
|
||||||
private final int minZ;
|
private final int minZ;
|
||||||
|
|||||||
@@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
package art.arcane.iris.engine.framework;
|
package art.arcane.iris.engine.framework;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.engine.framework.structure.CompiledStructureGraph;
|
import art.arcane.iris.engine.framework.structure.CompiledStructureGraph;
|
||||||
|
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
import art.arcane.iris.engine.framework.structure.JigsawPoolSelection;
|
import art.arcane.iris.engine.framework.structure.JigsawPoolSelection;
|
||||||
import art.arcane.iris.engine.framework.structure.PlanarJigsawWorkcellResolver;
|
import art.arcane.iris.engine.framework.structure.PlanarJigsawWorkcellResolver;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
||||||
@@ -29,7 +30,7 @@ import art.arcane.iris.engine.framework.structure.StructureGraphCompilation;
|
|||||||
import art.arcane.iris.engine.framework.structure.StructureGraphCompiler;
|
import art.arcane.iris.engine.framework.structure.StructureGraphCompiler;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureGraphDiagnostic;
|
import art.arcane.iris.engine.framework.structure.StructureGraphDiagnostic;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureGraphResolver;
|
import art.arcane.iris.engine.framework.structure.StructureGraphResolver;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
||||||
@@ -37,15 +38,14 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
|
|
||||||
import com.volmit.ModuleLog;
|
import com.volmit.ModuleLog;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -79,9 +79,9 @@ public final class StructureAssembler {
|
|||||||
this.resolver = options.resolver();
|
this.resolver = options.resolver();
|
||||||
this.graph = options.graph();
|
this.graph = options.graph();
|
||||||
this.structure = options.structure();
|
this.structure = options.structure();
|
||||||
this.originX = options.origin().getX();
|
this.originX = options.origin().x();
|
||||||
this.originY = options.origin().getY();
|
this.originY = options.origin().y();
|
||||||
this.originZ = options.origin().getZ();
|
this.originZ = options.origin().z();
|
||||||
this.planarWorkcells = this.structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW
|
this.planarWorkcells = this.structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW
|
||||||
? PlanarJigsawWorkcellResolver.resolve(this.structure)
|
? PlanarJigsawWorkcellResolver.resolve(this.structure)
|
||||||
: Map.of();
|
: Map.of();
|
||||||
@@ -90,23 +90,25 @@ public final class StructureAssembler {
|
|||||||
? this.structure.getMaxSizeChunks() * 16 : 0;
|
? this.structure.getMaxSizeChunks() * 16 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StructureAssembler forData(IrisData data, IrisStructure structure, IrisPosition origin, ModuleLog log) {
|
/** An assembler of {@code structure}, the pack's structure {@code structureKey}, from {@code origin}. */
|
||||||
IrisData activeData = Objects.requireNonNull(data, "Structure assembly data must not be null");
|
public static StructureAssembler forPack(PackResources pack, String structureKey, IrisStructure structure, BlockPosition origin,
|
||||||
|
ModuleLog log) {
|
||||||
|
PackResources activePack = Objects.requireNonNull(pack, "Structure assembly pack must not be null");
|
||||||
IrisStructure activeStructure = Objects.requireNonNull(
|
IrisStructure activeStructure = Objects.requireNonNull(
|
||||||
structure, "Structure assembly structure must not be null");
|
structure, "Structure assembly structure must not be null");
|
||||||
return forCompilation(StructureGraphCatalog.compile(activeData, activeStructure, log), origin);
|
return forCompilation(StructureGraphCatalog.compile(activePack, structureKey, activeStructure, log), origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StructureAssembler forResolver(StructureGraphResolver resolver, IrisStructure structure,
|
public static StructureAssembler forResolver(String structureKey, StructureGraphResolver resolver, IrisStructure structure,
|
||||||
IrisPosition origin) {
|
BlockPosition origin) {
|
||||||
StructureGraphResolver activeResolver = Objects.requireNonNull(
|
StructureGraphResolver activeResolver = Objects.requireNonNull(
|
||||||
resolver, "Structure assembly resolver must not be null");
|
resolver, "Structure assembly resolver must not be null");
|
||||||
IrisStructure activeStructure = Objects.requireNonNull(
|
IrisStructure activeStructure = Objects.requireNonNull(
|
||||||
structure, "Structure assembly structure must not be null");
|
structure, "Structure assembly structure must not be null");
|
||||||
return forCompilation(StructureGraphCompiler.compile(activeStructure, activeResolver), origin);
|
return forCompilation(StructureGraphCompiler.compile(structureKey, activeStructure, activeResolver), origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StructureAssembler forCompilation(StructureGraphCompilation compilation, IrisPosition origin) {
|
public static StructureAssembler forCompilation(StructureGraphCompilation compilation, BlockPosition origin) {
|
||||||
StructureGraphCompilation activeCompilation = Objects.requireNonNull(
|
StructureGraphCompilation activeCompilation = Objects.requireNonNull(
|
||||||
compilation, "Structure graph compilation must not be null");
|
compilation, "Structure graph compilation must not be null");
|
||||||
if (activeCompilation.hasErrors()) {
|
if (activeCompilation.hasErrors()) {
|
||||||
@@ -120,17 +122,17 @@ public final class StructureAssembler {
|
|||||||
public StructureAssemblyResult assemble(RNG rng) {
|
public StructureAssemblyResult assemble(RNG rng) {
|
||||||
Objects.requireNonNull(rng, "Structure assembly RNG must not be null");
|
Objects.requireNonNull(rng, "Structure assembly RNG must not be null");
|
||||||
if (radius == 0) {
|
if (radius == 0) {
|
||||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||||
+ "' has maxSizeChunks outside 1.." + MAX_SIZE_CHUNKS);
|
+ "' has maxSizeChunks outside 1.." + MAX_SIZE_CHUNKS);
|
||||||
}
|
}
|
||||||
if (structure.getMaxDepth() < 1 || structure.getMaxDepth() > MAX_DEPTH) {
|
if (structure.getMaxDepth() < 1 || structure.getMaxDepth() > MAX_DEPTH) {
|
||||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||||
+ "' has maxDepth outside 1.." + MAX_DEPTH);
|
+ "' has maxDepth outside 1.." + MAX_DEPTH);
|
||||||
}
|
}
|
||||||
String startPoolKey = normalize(structure.getStartPool());
|
String startPoolKey = normalize(structure.getStartPool());
|
||||||
IrisJigsawPool startPool = resolver.loadPool(startPoolKey);
|
IrisJigsawPool startPool = resolver.loadPool(startPoolKey);
|
||||||
if (startPool == null || startPool.getPieces() == null || startPool.getPieces().isEmpty()) {
|
if (startPool == null || startPool.getPieces() == null || startPool.getPieces().isEmpty()) {
|
||||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||||
+ "' has no resolvable start pool '" + startPoolKey + "'");
|
+ "' has no resolvable start pool '" + startPoolKey + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +162,7 @@ public final class StructureAssembler {
|
|||||||
}
|
}
|
||||||
IrisJigsawPieceEntry startEntry = weightedPick(startEntries, rng);
|
IrisJigsawPieceEntry startEntry = weightedPick(startEntries, rng);
|
||||||
if (startEntry == null) {
|
if (startEntry == null) {
|
||||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||||
+ "' start pool has no positively weighted entry");
|
+ "' start pool has no positively weighted entry");
|
||||||
}
|
}
|
||||||
if (startEntry.isEmpty()) {
|
if (startEntry.isEmpty()) {
|
||||||
@@ -171,23 +173,23 @@ public final class StructureAssembler {
|
|||||||
String startPieceKey = normalize(startEntry.getPiece());
|
String startPieceKey = normalize(startEntry.getPiece());
|
||||||
IrisJigsawPiece startPiece = resolver.loadPiece(startPieceKey);
|
IrisJigsawPiece startPiece = resolver.loadPiece(startPieceKey);
|
||||||
if (startPiece == null) {
|
if (startPiece == null) {
|
||||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||||
+ "' start pool references missing piece '" + startPieceKey + "'");
|
+ "' start pool references missing piece '" + startPieceKey + "'");
|
||||||
}
|
}
|
||||||
String startObjectKey = normalize(startPiece.getObject());
|
String startObjectKey = normalize(startPiece.getObject());
|
||||||
IrisObject startObject = resolver.loadObject(startObjectKey);
|
ObjectFrame startObject = resolver.loadObject(startObjectKey);
|
||||||
if (startObject == null) {
|
if (startObject == null) {
|
||||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||||
+ "' start piece references missing object '" + startObjectKey + "'");
|
+ "' start piece references missing object '" + startObjectKey + "'");
|
||||||
}
|
}
|
||||||
if (startPiece.getConnectors() == null) {
|
if (startPiece.getConnectors() == null) {
|
||||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||||
+ "' start piece has no connector list");
|
+ "' start piece has no connector list");
|
||||||
}
|
}
|
||||||
|
|
||||||
int startRotY = startPiece.isRotatable() ? Y_DEGREES[rng.i(Y_DEGREES.length)] : 0;
|
int startRotY = startPiece.isRotatable() ? Y_DEGREES[rng.i(Y_DEGREES.length)] : 0;
|
||||||
ObjectTurn startRot = ObjectTurn.of(0, startRotY, 0);
|
PieceTurn startRot = PieceTurn.aroundY(startRotY);
|
||||||
PlacedStructurePiece start = build(startPiece, startObject, originX, originY, originZ, startRot);
|
PlacedStructurePiece start = build(startPiece, startObjectKey, startObject, originX, originY, originZ, startRot);
|
||||||
placed.add(start);
|
placed.add(start);
|
||||||
registerPlacedPiece(consumedConnectors, start, null);
|
registerPlacedPiece(consumedConnectors, start, null);
|
||||||
incrementPlacement(placementCounts, startPieceKey);
|
incrementPlacement(placementCounts, startPieceKey);
|
||||||
@@ -216,7 +218,7 @@ public final class StructureAssembler {
|
|||||||
|
|
||||||
IrisJigsawPool pool = resolver.loadPool(connector.pool);
|
IrisJigsawPool pool = resolver.loadPool(connector.pool);
|
||||||
if (pool == null) {
|
if (pool == null) {
|
||||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||||
+ "' references missing connector pool '" + connector.pool + "'");
|
+ "' references missing connector pool '" + connector.pool + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,7 +382,7 @@ public final class StructureAssembler {
|
|||||||
if (objectKey.isEmpty()) {
|
if (objectKey.isEmpty()) {
|
||||||
throw assemblyFailure("piece '" + pieceName + "' has no object key");
|
throw assemblyFailure("piece '" + pieceName + "' has no object key");
|
||||||
}
|
}
|
||||||
IrisObject object = resolver.loadObject(objectKey);
|
ObjectFrame object = resolver.loadObject(objectKey);
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
throw assemblyFailure("piece '" + pieceName + "' references missing object '"
|
throw assemblyFailure("piece '" + pieceName + "' references missing object '"
|
||||||
+ objectKey + "'");
|
+ objectKey + "'");
|
||||||
@@ -404,27 +406,27 @@ public final class StructureAssembler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisDirection needed = connector.facing.reverse();
|
JigsawDirection needed = connector.facing.reverse();
|
||||||
int[] rotations = piece.isRotatable() ? rotationCandidates(connector.joint, rng) : NO_ROTATION;
|
int[] rotations = piece.isRotatable() ? rotationCandidates(connector.joint, rng) : NO_ROTATION;
|
||||||
for (int yDeg : rotations) {
|
for (int yDeg : rotations) {
|
||||||
ObjectTurn rot = ObjectTurn.of(0, yDeg, 0);
|
PieceTurn rot = PieceTurn.aroundY(yDeg);
|
||||||
IrisDirection rotatedFace = rot.rotate(cb.getDirection());
|
JigsawDirection rotatedFace = rotate(rot, cb.getDirection());
|
||||||
if (rotatedFace != needed) {
|
if (rotatedFace != needed) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (connector.joint == JigsawJoint.ALIGNED && rot.rotate(cb.getTop()) != connector.top) {
|
if (connector.joint == JigsawJoint.ALIGNED && rotate(rot, cb.getTop()) != connector.top) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisPosition rcr = connectorOffset(object, cb, rot);
|
BlockPosition rcr = connectorOffset(object, cb, rot);
|
||||||
int wcx = connector.wx + connector.facing.x();
|
int wcx = connector.wx + connector.facing.x();
|
||||||
int wcy = connector.wy + connector.facing.y();
|
int wcy = connector.wy + connector.facing.y();
|
||||||
int wcz = connector.wz + connector.facing.z();
|
int wcz = connector.wz + connector.facing.z();
|
||||||
int px = wcx - rcr.getX();
|
int px = wcx - rcr.x();
|
||||||
int py = wcy - rcr.getY();
|
int py = wcy - rcr.y();
|
||||||
int pz = wcz - rcr.getZ();
|
int pz = wcz - rcr.z();
|
||||||
|
|
||||||
PlacedStructurePiece candidate = build(piece, object, px, py, pz, rot);
|
PlacedStructurePiece candidate = build(piece, objectKey, object, px, py, pz, rot);
|
||||||
if (!withinRadius(candidate) || collides(placed, candidate)) {
|
if (!withinRadius(candidate) || collides(placed, candidate)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -527,7 +529,7 @@ public final class StructureAssembler {
|
|||||||
|| isMatched(matchedExisting, existingPiece, existingConnector)) {
|
|| isMatched(matchedExisting, existingPiece, existingConnector)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisPosition target = connectorTarget(existingPiece, existingConnector);
|
BlockPosition target = connectorTarget(existingPiece, existingConnector);
|
||||||
if (!contains(candidatePiece, target)) {
|
if (!contains(candidatePiece, target)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -556,7 +558,7 @@ public final class StructureAssembler {
|
|||||||
|| normalize(candidateConnector.getPool()).isEmpty()) {
|
|| normalize(candidateConnector.getPool()).isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisPosition target = connectorTarget(candidatePiece, candidateConnector);
|
BlockPosition target = connectorTarget(candidatePiece, candidateConnector);
|
||||||
PlacedStructurePiece occupied = containingPiece(placed, target);
|
PlacedStructurePiece occupied = containingPiece(placed, target);
|
||||||
if (occupied == null) {
|
if (occupied == null) {
|
||||||
continue;
|
continue;
|
||||||
@@ -706,7 +708,8 @@ public final class StructureAssembler {
|
|||||||
if (piece == null || piece.getConnectors() == null) {
|
if (piece == null || piece.getConnectors() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisObject object = resolver.loadObject(normalize(piece.getObject()));
|
String objectKey = normalize(piece.getObject());
|
||||||
|
ObjectFrame object = resolver.loadObject(objectKey);
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -717,18 +720,19 @@ public final class StructureAssembler {
|
|||||||
}
|
}
|
||||||
int[] rotations = piece.isRotatable() ? Y_DEGREES : NO_ROTATION;
|
int[] rotations = piece.isRotatable() ? Y_DEGREES : NO_ROTATION;
|
||||||
for (int yDegrees : rotations) {
|
for (int yDegrees : rotations) {
|
||||||
ObjectTurn rotation = ObjectTurn.of(0, yDegrees, 0);
|
PieceTurn rotation = PieceTurn.aroundY(yDegrees);
|
||||||
if (rotation.rotate(connector.getDirection()) != source.facing().reverse()
|
if (rotate(rotation, connector.getDirection()) != source.facing().reverse()
|
||||||
|| source.joint() == JigsawJoint.ALIGNED
|
|| source.joint() == JigsawJoint.ALIGNED
|
||||||
&& rotation.rotate(connector.getTop()) != source.top()) {
|
&& rotate(rotation, connector.getTop()) != source.top()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisPosition offset = connectorOffset(object, connector, rotation);
|
BlockPosition offset = connectorOffset(object, connector, rotation);
|
||||||
int logicalX = source.wx() + source.facing().x() - offset.getX();
|
int logicalX = source.wx() + source.facing().x() - offset.x();
|
||||||
int logicalY = source.wy() + source.facing().y() - offset.getY();
|
int logicalY = source.wy() + source.facing().y() - offset.y();
|
||||||
int logicalZ = source.wz() + source.facing().z() - offset.getZ();
|
int logicalZ = source.wz() + source.facing().z() - offset.z();
|
||||||
PlacedStructurePiece reservation = build(
|
PlacedStructurePiece reservation = build(
|
||||||
piece,
|
piece,
|
||||||
|
objectKey,
|
||||||
object,
|
object,
|
||||||
logicalX,
|
logicalX,
|
||||||
logicalY,
|
logicalY,
|
||||||
@@ -749,49 +753,49 @@ public final class StructureAssembler {
|
|||||||
PlacedStructurePiece targetPiece,
|
PlacedStructurePiece targetPiece,
|
||||||
Set<IrisJigsawConnector> unavailable
|
Set<IrisJigsawConnector> unavailable
|
||||||
) {
|
) {
|
||||||
IrisPosition target = connectorTarget(sourcePiece, sourceConnector);
|
BlockPosition target = connectorTarget(sourcePiece, sourceConnector);
|
||||||
IrisDirection sourceFacing = sourcePiece.getRotation().rotate(sourceConnector.getDirection());
|
JigsawDirection sourceFacing = rotate(sourcePiece.getRotation(), sourceConnector.getDirection());
|
||||||
IrisDirection sourceTop = sourcePiece.getRotation().rotate(sourceConnector.getTop());
|
JigsawDirection sourceTop = rotate(sourcePiece.getRotation(), sourceConnector.getTop());
|
||||||
for (IrisJigsawConnector candidate : targetPiece.getPiece().getConnectors()) {
|
for (IrisJigsawConnector candidate : targetPiece.getPiece().getConnectors()) {
|
||||||
if (unavailable.contains(candidate)
|
if (unavailable.contains(candidate)
|
||||||
|| !Objects.equals(sourceConnector.getChannel(), candidate.getChannel())
|
|| !Objects.equals(sourceConnector.getChannel(), candidate.getChannel())
|
||||||
|| !Objects.equals(sourceConnector.getTargetName(), candidate.getName())) {
|
|| !Objects.equals(sourceConnector.getTargetName(), candidate.getName())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisPosition candidatePosition = connectorPosition(targetPiece, candidate);
|
BlockPosition candidatePosition = connectorPosition(targetPiece, candidate);
|
||||||
if (!target.equals(candidatePosition)
|
if (!target.equals(candidatePosition)
|
||||||
|| targetPiece.getRotation().rotate(candidate.getDirection()) != sourceFacing.reverse()) {
|
|| rotate(targetPiece.getRotation(), candidate.getDirection()) != sourceFacing.reverse()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sourceConnector.getJoint() != JigsawJoint.ALIGNED
|
if (sourceConnector.getJoint() != JigsawJoint.ALIGNED
|
||||||
|| targetPiece.getRotation().rotate(candidate.getTop()) == sourceTop) {
|
|| rotate(targetPiece.getRotation(), candidate.getTop()) == sourceTop) {
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisPosition connectorPosition(PlacedStructurePiece piece, IrisJigsawConnector connector) {
|
private BlockPosition connectorPosition(PlacedStructurePiece piece, IrisJigsawConnector connector) {
|
||||||
IrisPosition center = logicalCenter(piece);
|
BlockPosition center = logicalCenter(piece);
|
||||||
IrisPosition offset = connectorOffset(piece.getObject(), connector, piece.getRotation());
|
BlockPosition offset = connectorOffset(piece.getObject(), connector, piece.getRotation());
|
||||||
return new IrisPosition(
|
return new BlockPosition(
|
||||||
center.getX() + offset.getX(),
|
center.x() + offset.x(),
|
||||||
center.getY() + offset.getY(),
|
center.y() + offset.y(),
|
||||||
center.getZ() + offset.getZ());
|
center.z() + offset.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisPosition connectorTarget(PlacedStructurePiece piece, IrisJigsawConnector connector) {
|
private BlockPosition connectorTarget(PlacedStructurePiece piece, IrisJigsawConnector connector) {
|
||||||
IrisPosition position = connectorPosition(piece, connector);
|
BlockPosition position = connectorPosition(piece, connector);
|
||||||
IrisDirection facing = piece.getRotation().rotate(connector.getDirection());
|
JigsawDirection facing = rotate(piece.getRotation(), connector.getDirection());
|
||||||
return new IrisPosition(
|
return new BlockPosition(
|
||||||
position.getX() + facing.x(),
|
position.x() + facing.x(),
|
||||||
position.getY() + facing.y(),
|
position.y() + facing.y(),
|
||||||
position.getZ() + facing.z());
|
position.z() + facing.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlacedStructurePiece containingPiece(
|
private PlacedStructurePiece containingPiece(
|
||||||
KList<PlacedStructurePiece> pieces,
|
KList<PlacedStructurePiece> pieces,
|
||||||
IrisPosition position
|
BlockPosition position
|
||||||
) {
|
) {
|
||||||
for (PlacedStructurePiece piece : pieces) {
|
for (PlacedStructurePiece piece : pieces) {
|
||||||
if (contains(piece, position)) {
|
if (contains(piece, position)) {
|
||||||
@@ -801,10 +805,10 @@ public final class StructureAssembler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean contains(PlacedStructurePiece piece, IrisPosition position) {
|
private boolean contains(PlacedStructurePiece piece, BlockPosition position) {
|
||||||
return position.getX() >= piece.getMinX() && position.getX() <= piece.getMaxX()
|
return position.x() >= piece.getMinX() && position.x() <= piece.getMaxX()
|
||||||
&& position.getY() >= piece.getMinY() && position.getY() <= piece.getMaxY()
|
&& position.y() >= piece.getMinY() && position.y() <= piece.getMaxY()
|
||||||
&& position.getZ() >= piece.getMinZ() && position.getZ() <= piece.getMaxZ();
|
&& position.z() >= piece.getMinZ() && position.z() <= piece.getMaxZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMatched(
|
private boolean isMatched(
|
||||||
@@ -824,24 +828,24 @@ public final class StructureAssembler {
|
|||||||
int targetY,
|
int targetY,
|
||||||
int targetZ
|
int targetZ
|
||||||
) {
|
) {
|
||||||
requireConnector(candidate, candidatePiece.getObject().getLoadKey());
|
requireConnector(candidate, candidatePiece.getObjectKey());
|
||||||
if (!Objects.equals(source.channel(), candidate.getChannel())
|
if (!Objects.equals(source.channel(), candidate.getChannel())
|
||||||
|| !Objects.equals(source.targetName(), candidate.getName())) {
|
|| !Objects.equals(source.targetName(), candidate.getName())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IrisPosition rotated = connectorOffset(
|
BlockPosition rotated = connectorOffset(
|
||||||
candidatePiece.getObject(), candidate, candidatePiece.getRotation());
|
candidatePiece.getObject(), candidate, candidatePiece.getRotation());
|
||||||
IrisPosition center = logicalCenter(candidatePiece);
|
BlockPosition center = logicalCenter(candidatePiece);
|
||||||
if (center.getX() + rotated.getX() != targetX
|
if (center.x() + rotated.x() != targetX
|
||||||
|| center.getY() + rotated.getY() != targetY
|
|| center.y() + rotated.y() != targetY
|
||||||
|| center.getZ() + rotated.getZ() != targetZ) {
|
|| center.z() + rotated.z() != targetZ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (candidatePiece.getRotation().rotate(candidate.getDirection()) != source.facing().reverse()) {
|
if (rotate(candidatePiece.getRotation(), candidate.getDirection()) != source.facing().reverse()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return source.joint() != JigsawJoint.ALIGNED
|
return source.joint() != JigsawJoint.ALIGNED
|
||||||
|| candidatePiece.getRotation().rotate(candidate.getTop()) == source.top();
|
|| rotate(candidatePiece.getRotation(), candidate.getTop()) == source.top();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerPlacedPiece(
|
private void registerPlacedPiece(
|
||||||
@@ -890,15 +894,15 @@ public final class StructureAssembler {
|
|||||||
Deque<PieceExpansion> pending,
|
Deque<PieceExpansion> pending,
|
||||||
Map<PlacedStructurePiece, Map<IrisJigsawConnector, OpenConnector>> openConnectors,
|
Map<PlacedStructurePiece, Map<IrisJigsawConnector, OpenConnector>> openConnectors,
|
||||||
PlacedStructurePiece p,
|
PlacedStructurePiece p,
|
||||||
IrisObject object, int depth, int pieceDepth, IrisJigsawConnector skip,
|
ObjectFrame object, int depth, int pieceDepth, IrisJigsawConnector skip,
|
||||||
int placementPriority) {
|
int placementPriority) {
|
||||||
if (p.getPiece().getConnectors() == null) {
|
if (p.getPiece().getConnectors() == null) {
|
||||||
throw assemblyFailure("placed piece for object '" + object.getLoadKey() + "' has no connector list");
|
throw assemblyFailure("placed piece for object '" + p.getObjectKey() + "' has no connector list");
|
||||||
}
|
}
|
||||||
List<OpenConnector> connectors = new ArrayList<>();
|
List<OpenConnector> connectors = new ArrayList<>();
|
||||||
Map<IrisJigsawConnector, OpenConnector> definitions = new IdentityHashMap<>();
|
Map<IrisJigsawConnector, OpenConnector> definitions = new IdentityHashMap<>();
|
||||||
for (IrisJigsawConnector con : orderedConnectors(p.getPiece().getConnectors(), skip)) {
|
for (IrisJigsawConnector con : orderedConnectors(p.getPiece().getConnectors(), skip)) {
|
||||||
requireConnector(con, object.getLoadKey());
|
requireConnector(con, p.getObjectKey());
|
||||||
if (con.getPool() == null || con.getPool().isBlank()) {
|
if (con.getPool() == null || con.getPool().isBlank()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -914,21 +918,21 @@ public final class StructureAssembler {
|
|||||||
|
|
||||||
private OpenConnector openConnector(
|
private OpenConnector openConnector(
|
||||||
PlacedStructurePiece piece,
|
PlacedStructurePiece piece,
|
||||||
IrisObject object,
|
ObjectFrame object,
|
||||||
IrisJigsawConnector connector,
|
IrisJigsawConnector connector,
|
||||||
int depth,
|
int depth,
|
||||||
int pieceDepth
|
int pieceDepth
|
||||||
) {
|
) {
|
||||||
IrisPosition offset = connectorOffset(object, connector, piece.getRotation());
|
BlockPosition offset = connectorOffset(object, connector, piece.getRotation());
|
||||||
IrisPosition center = logicalCenter(piece);
|
BlockPosition center = logicalCenter(piece);
|
||||||
return new OpenConnector(
|
return new OpenConnector(
|
||||||
piece,
|
piece,
|
||||||
connector,
|
connector,
|
||||||
center.getX() + offset.getX(),
|
center.x() + offset.x(),
|
||||||
center.getY() + offset.getY(),
|
center.y() + offset.y(),
|
||||||
center.getZ() + offset.getZ(),
|
center.z() + offset.z(),
|
||||||
piece.getRotation().rotate(connector.getDirection()),
|
rotate(piece.getRotation(), connector.getDirection()),
|
||||||
piece.getRotation().rotate(connector.getTop()),
|
rotate(piece.getRotation(), connector.getTop()),
|
||||||
normalize(connector.getPool()),
|
normalize(connector.getPool()),
|
||||||
connector.getName(),
|
connector.getName(),
|
||||||
connector.getTargetName(),
|
connector.getTargetName(),
|
||||||
@@ -968,29 +972,30 @@ public final class StructureAssembler {
|
|||||||
throw assemblyFailure("piece expansion queue was unexpectedly empty");
|
throw assemblyFailure("piece expansion queue was unexpectedly empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlacedStructurePiece build(IrisJigsawPiece piece, IrisObject object, int x, int y, int z, ObjectTurn rot) {
|
private PlacedStructurePiece build(IrisJigsawPiece piece, String objectKey, ObjectFrame object, int x, int y, int z, PieceTurn rot) {
|
||||||
int width = Math.max(1, object.getW());
|
int width = Math.max(1, object.width());
|
||||||
int height = Math.max(1, object.getH());
|
int height = Math.max(1, object.height());
|
||||||
int depth = Math.max(1, object.getD());
|
int depth = Math.max(1, object.depth());
|
||||||
if (structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW) {
|
if (structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW) {
|
||||||
IrisPosition dimensions = rotatedDimensions(object, rot);
|
BlockPosition dimensions = rotatedDimensions(object, rot);
|
||||||
IrisPosition offset = planarPlacementOffset(object, rot);
|
BlockPosition offset = planarPlacementOffset(object, rot);
|
||||||
int minX = x - dimensions.getX() / 2;
|
int minX = x - dimensions.x() / 2;
|
||||||
int minY = y - dimensions.getY() / 2;
|
int minY = y - dimensions.y() / 2;
|
||||||
int minZ = z - dimensions.getZ() / 2;
|
int minZ = z - dimensions.z() / 2;
|
||||||
return new PlacedStructurePiece(
|
return new PlacedStructurePiece(
|
||||||
piece,
|
piece,
|
||||||
|
objectKey,
|
||||||
object,
|
object,
|
||||||
x + offset.getX(),
|
x + offset.x(),
|
||||||
y + offset.getY(),
|
y + offset.y(),
|
||||||
z + offset.getZ(),
|
z + offset.z(),
|
||||||
rot,
|
rot,
|
||||||
minX,
|
minX,
|
||||||
minY,
|
minY,
|
||||||
minZ,
|
minZ,
|
||||||
minX + dimensions.getX() - 1,
|
minX + dimensions.x() - 1,
|
||||||
minY + dimensions.getY() - 1,
|
minY + dimensions.y() - 1,
|
||||||
minZ + dimensions.getZ() - 1);
|
minZ + dimensions.z() - 1);
|
||||||
}
|
}
|
||||||
int localMinX = -(width / 2);
|
int localMinX = -(width / 2);
|
||||||
int localMinY = -(height / 2);
|
int localMinY = -(height / 2);
|
||||||
@@ -998,15 +1003,15 @@ public final class StructureAssembler {
|
|||||||
int localMaxX = localMinX + width - 1;
|
int localMaxX = localMinX + width - 1;
|
||||||
int localMaxY = localMinY + height - 1;
|
int localMaxY = localMinY + height - 1;
|
||||||
int localMaxZ = localMinZ + depth - 1;
|
int localMaxZ = localMinZ + depth - 1;
|
||||||
IrisPosition rotatedMin = rot.rotate(new IrisPosition(localMinX, localMinY, localMinZ));
|
BlockPosition rotatedMin = rot.rotate(new BlockPosition(localMinX, localMinY, localMinZ));
|
||||||
IrisPosition rotatedMax = rot.rotate(new IrisPosition(localMaxX, localMaxY, localMaxZ));
|
BlockPosition rotatedMax = rot.rotate(new BlockPosition(localMaxX, localMaxY, localMaxZ));
|
||||||
int minX = Math.min(rotatedMin.getX(), rotatedMax.getX());
|
int minX = Math.min(rotatedMin.x(), rotatedMax.x());
|
||||||
int minY = Math.min(rotatedMin.getY(), rotatedMax.getY());
|
int minY = Math.min(rotatedMin.y(), rotatedMax.y());
|
||||||
int minZ = Math.min(rotatedMin.getZ(), rotatedMax.getZ());
|
int minZ = Math.min(rotatedMin.z(), rotatedMax.z());
|
||||||
int maxX = Math.max(rotatedMin.getX(), rotatedMax.getX());
|
int maxX = Math.max(rotatedMin.x(), rotatedMax.x());
|
||||||
int maxY = Math.max(rotatedMin.getY(), rotatedMax.getY());
|
int maxY = Math.max(rotatedMin.y(), rotatedMax.y());
|
||||||
int maxZ = Math.max(rotatedMin.getZ(), rotatedMax.getZ());
|
int maxZ = Math.max(rotatedMin.z(), rotatedMax.z());
|
||||||
return new PlacedStructurePiece(piece, object, x, y, z, rot,
|
return new PlacedStructurePiece(piece, objectKey, object, x, y, z, rot,
|
||||||
x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ);
|
x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1041,70 +1046,74 @@ public final class StructureAssembler {
|
|||||||
return shuffled;
|
return shuffled;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisPosition centerOf(IrisObject object) {
|
private BlockPosition centerOf(ObjectFrame object) {
|
||||||
return new IrisPosition(object.getW() / 2, object.getH() / 2, object.getD() / 2);
|
return object.center();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisPosition connectorOffset(
|
private BlockPosition connectorOffset(
|
||||||
IrisObject object,
|
ObjectFrame object,
|
||||||
IrisJigsawConnector connector,
|
IrisJigsawConnector connector,
|
||||||
ObjectTurn rotation
|
PieceTurn rotation
|
||||||
) {
|
) {
|
||||||
if (structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW) {
|
if (structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW) {
|
||||||
IrisPosition dimensions = rotatedDimensions(object, rotation);
|
BlockPosition dimensions = rotatedDimensions(object, rotation);
|
||||||
IrisPosition position = IrisJigsawConnector.canonicalPlanarPosition(
|
BlockPosition position = IrisJigsawConnector.canonicalPlanarPosition(
|
||||||
dimensions,
|
dimensions,
|
||||||
rotation.rotate(connector.getDirection()));
|
rotate(rotation, connector.getDirection()));
|
||||||
return new IrisPosition(
|
return new BlockPosition(
|
||||||
position.getX() - dimensions.getX() / 2,
|
position.x() - dimensions.x() / 2,
|
||||||
position.getY() - dimensions.getY() / 2,
|
position.y() - dimensions.y() / 2,
|
||||||
position.getZ() - dimensions.getZ() / 2);
|
position.z() - dimensions.z() / 2);
|
||||||
}
|
}
|
||||||
IrisPosition center = centerOf(object);
|
BlockPosition center = centerOf(object);
|
||||||
IrisPosition relative = new IrisPosition(
|
BlockPosition relative = new BlockPosition(
|
||||||
connector.getPosition().getX() - center.getX(),
|
connector.getPosition().x() - center.x(),
|
||||||
connector.getPosition().getY() - center.getY(),
|
connector.getPosition().y() - center.y(),
|
||||||
connector.getPosition().getZ() - center.getZ());
|
connector.getPosition().z() - center.z());
|
||||||
return rotation.rotate(relative);
|
return rotation.rotate(relative);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisPosition logicalCenter(PlacedStructurePiece piece) {
|
private BlockPosition logicalCenter(PlacedStructurePiece piece) {
|
||||||
if (structure.resolvedMode() != IrisJigsawMode.PLANAR_JIGSAW) {
|
if (structure.resolvedMode() != IrisJigsawMode.PLANAR_JIGSAW) {
|
||||||
return new IrisPosition(piece.getX(), piece.getY(), piece.getZ());
|
return new BlockPosition(piece.getX(), piece.getY(), piece.getZ());
|
||||||
}
|
}
|
||||||
IrisPosition offset = planarPlacementOffset(piece.getObject(), piece.getRotation());
|
BlockPosition offset = planarPlacementOffset(piece.getObject(), piece.getRotation());
|
||||||
return new IrisPosition(
|
return new BlockPosition(
|
||||||
piece.getX() - offset.getX(),
|
piece.getX() - offset.x(),
|
||||||
piece.getY() - offset.getY(),
|
piece.getY() - offset.y(),
|
||||||
piece.getZ() - offset.getZ());
|
piece.getZ() - offset.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisPosition rotatedDimensions(IrisObject object, ObjectTurn rotation) {
|
private BlockPosition rotatedDimensions(ObjectFrame object, PieceTurn rotation) {
|
||||||
int width = Math.max(1, object.getW());
|
int width = Math.max(1, object.width());
|
||||||
int height = Math.max(1, object.getH());
|
int height = Math.max(1, object.height());
|
||||||
int depth = Math.max(1, object.getD());
|
int depth = Math.max(1, object.depth());
|
||||||
return quarterTurns(rotation) % 2 == 0
|
return quarterTurns(rotation) % 2 == 0
|
||||||
? new IrisPosition(width, height, depth)
|
? new BlockPosition(width, height, depth)
|
||||||
: new IrisPosition(depth, height, width);
|
: new BlockPosition(depth, height, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisPosition planarPlacementOffset(IrisObject object, ObjectTurn rotation) {
|
private BlockPosition planarPlacementOffset(ObjectFrame object, PieceTurn rotation) {
|
||||||
int width = Math.max(1, object.getW());
|
int width = Math.max(1, object.width());
|
||||||
int depth = Math.max(1, object.getD());
|
int depth = Math.max(1, object.depth());
|
||||||
return switch (quarterTurns(rotation)) {
|
return switch (quarterTurns(rotation)) {
|
||||||
case 0 -> new IrisPosition();
|
case 0 -> new BlockPosition(0, 0, 0);
|
||||||
case 1 -> new IrisPosition(0, 0, width % 2 == 0 ? -1 : 0);
|
case 1 -> new BlockPosition(0, 0, width % 2 == 0 ? -1 : 0);
|
||||||
case 2 -> new IrisPosition(
|
case 2 -> new BlockPosition(
|
||||||
width % 2 == 0 ? -1 : 0,
|
width % 2 == 0 ? -1 : 0,
|
||||||
0,
|
0,
|
||||||
depth % 2 == 0 ? -1 : 0);
|
depth % 2 == 0 ? -1 : 0);
|
||||||
case 3 -> new IrisPosition(depth % 2 == 0 ? -1 : 0, 0, 0);
|
case 3 -> new BlockPosition(depth % 2 == 0 ? -1 : 0, 0, 0);
|
||||||
default -> throw new IllegalStateException("Unsupported planar quarter-turn count");
|
default -> throw new IllegalStateException("Unsupported planar quarter-turn count");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private int quarterTurns(ObjectTurn rotation) {
|
private static JigsawDirection rotate(PieceTurn turn, JigsawDirection direction) {
|
||||||
return switch (rotation.rotate(IrisDirection.NORTH_NEGATIVE_Z)) {
|
return direction.turnedBy(turn.quarterTurns());
|
||||||
|
}
|
||||||
|
|
||||||
|
private int quarterTurns(PieceTurn rotation) {
|
||||||
|
return switch (rotate(rotation, JigsawDirection.NORTH_NEGATIVE_Z)) {
|
||||||
case NORTH_NEGATIVE_Z -> 0;
|
case NORTH_NEGATIVE_Z -> 0;
|
||||||
case WEST_NEGATIVE_X -> 1;
|
case WEST_NEGATIVE_X -> 1;
|
||||||
case SOUTH_POSITIVE_Z -> 2;
|
case SOUTH_POSITIVE_Z -> 2;
|
||||||
@@ -1280,7 +1289,7 @@ public final class StructureAssembler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private IllegalStateException assemblyFailure(String detail) {
|
private IllegalStateException assemblyFailure(String detail) {
|
||||||
return new IllegalStateException("Structure '" + structure.getLoadKey() + "' assembly failed: " + detail);
|
return new IllegalStateException("Structure '" + graph.getStructureKey() + "' assembly failed: " + detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IllegalStateException invalidGraph(StructureGraphCompilation compilation) {
|
private static IllegalStateException invalidGraph(StructureGraphCompilation compilation) {
|
||||||
@@ -1300,7 +1309,7 @@ public final class StructureAssembler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private record OpenConnector(PlacedStructurePiece sourcePiece, IrisJigsawConnector sourceConnector,
|
private record OpenConnector(PlacedStructurePiece sourcePiece, IrisJigsawConnector sourceConnector,
|
||||||
int wx, int wy, int wz, IrisDirection facing, IrisDirection top,
|
int wx, int wy, int wz, JigsawDirection facing, JigsawDirection top,
|
||||||
String pool, String name,
|
String pool, String name,
|
||||||
String targetName, String channel, JigsawJoint joint, int depth,
|
String targetName, String channel, JigsawJoint joint, int depth,
|
||||||
int pieceDepth, int placementPriority) {
|
int pieceDepth, int placementPriority) {
|
||||||
@@ -1347,7 +1356,7 @@ public final class StructureAssembler {
|
|||||||
|
|
||||||
private record AssemblyOptions(StructureGraphResolver resolver, CompiledStructureGraph graph,
|
private record AssemblyOptions(StructureGraphResolver resolver, CompiledStructureGraph graph,
|
||||||
IrisStructure structure,
|
IrisStructure structure,
|
||||||
IrisPosition origin) {
|
BlockPosition origin) {
|
||||||
private AssemblyOptions {
|
private AssemblyOptions {
|
||||||
Objects.requireNonNull(resolver, "Structure assembly resolver must not be null");
|
Objects.requireNonNull(resolver, "Structure assembly resolver must not be null");
|
||||||
Objects.requireNonNull(graph, "Compiled structure graph must not be null");
|
Objects.requireNonNull(graph, "Compiled structure graph must not be null");
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A height for each world column (keys packed from X and Z), which only grows. It visits its columns in the order the
|
||||||
|
* open-addressing table of the primitive map this replaces did, because the order in which a structure's foundations
|
||||||
|
* are written to the mantle is part of what a world generated: a column map of the standard library would order them
|
||||||
|
* differently.
|
||||||
|
*/
|
||||||
|
public final class ColumnHeights {
|
||||||
|
private static final long PHI = 0x9E3779B97F4A7C15L;
|
||||||
|
private static final int INITIAL_SLOTS = 32;
|
||||||
|
private static final float LOAD_FACTOR = 0.75f;
|
||||||
|
|
||||||
|
/** Receives one column and its height. */
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ColumnVisitor {
|
||||||
|
void visit(long column, int height);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int missing;
|
||||||
|
private long[] keys = new long[INITIAL_SLOTS + 1];
|
||||||
|
private int[] heights = new int[INITIAL_SLOTS + 1];
|
||||||
|
private int slots = INITIAL_SLOTS;
|
||||||
|
private int mask = INITIAL_SLOTS - 1;
|
||||||
|
private int maxFill = maxFill(INITIAL_SLOTS);
|
||||||
|
private boolean hasColumnZero;
|
||||||
|
private int size;
|
||||||
|
|
||||||
|
/** @param missing what {@link #get} answers for a column that has no height */
|
||||||
|
public ColumnHeights(int missing) {
|
||||||
|
this.missing = missing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsKey(long column) {
|
||||||
|
if (column == 0L) {
|
||||||
|
return hasColumnZero;
|
||||||
|
}
|
||||||
|
int slot = slotOf(column);
|
||||||
|
while (keys[slot] != 0L) {
|
||||||
|
if (keys[slot] == column) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
slot = (slot + 1) & mask;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int get(long column) {
|
||||||
|
if (column == 0L) {
|
||||||
|
return hasColumnZero ? heights[slots] : missing;
|
||||||
|
}
|
||||||
|
int slot = slotOf(column);
|
||||||
|
while (keys[slot] != 0L) {
|
||||||
|
if (keys[slot] == column) {
|
||||||
|
return heights[slot];
|
||||||
|
}
|
||||||
|
slot = (slot + 1) & mask;
|
||||||
|
}
|
||||||
|
return missing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(long column, int height) {
|
||||||
|
if (column == 0L) {
|
||||||
|
if (!hasColumnZero) {
|
||||||
|
hasColumnZero = true;
|
||||||
|
grow();
|
||||||
|
}
|
||||||
|
heights[slots] = height;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int slot = slotOf(column);
|
||||||
|
while (keys[slot] != 0L) {
|
||||||
|
if (keys[slot] == column) {
|
||||||
|
heights[slot] = height;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
slot = (slot + 1) & mask;
|
||||||
|
}
|
||||||
|
keys[slot] = column;
|
||||||
|
heights[slot] = height;
|
||||||
|
grow();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Visits the columns in table order: the column 0 first, then the slots from the last to the first. */
|
||||||
|
public void forEach(ColumnVisitor visitor) {
|
||||||
|
int remaining = size;
|
||||||
|
if (hasColumnZero) {
|
||||||
|
visitor.visit(0L, heights[slots]);
|
||||||
|
remaining--;
|
||||||
|
}
|
||||||
|
for (int slot = slots - 1; slot >= 0 && remaining > 0; slot--) {
|
||||||
|
if (keys[slot] != 0L) {
|
||||||
|
visitor.visit(keys[slot], heights[slot]);
|
||||||
|
remaining--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void grow() {
|
||||||
|
if (size++ >= maxFill) {
|
||||||
|
rehash(slotsFor(size + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rehash(int newSlots) {
|
||||||
|
long[] oldKeys = keys;
|
||||||
|
int[] oldHeights = heights;
|
||||||
|
int oldSlots = slots;
|
||||||
|
int newMask = newSlots - 1;
|
||||||
|
long[] newKeys = new long[newSlots + 1];
|
||||||
|
int[] newHeights = new int[newSlots + 1];
|
||||||
|
int source = oldSlots;
|
||||||
|
for (int remaining = size - (hasColumnZero ? 1 : 0); remaining-- != 0; ) {
|
||||||
|
while (oldKeys[--source] == 0L) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int slot = hash(oldKeys[source], newMask);
|
||||||
|
while (newKeys[slot] != 0L) {
|
||||||
|
slot = (slot + 1) & newMask;
|
||||||
|
}
|
||||||
|
newKeys[slot] = oldKeys[source];
|
||||||
|
newHeights[slot] = oldHeights[source];
|
||||||
|
}
|
||||||
|
newHeights[newSlots] = oldHeights[oldSlots];
|
||||||
|
keys = newKeys;
|
||||||
|
heights = newHeights;
|
||||||
|
slots = newSlots;
|
||||||
|
mask = newMask;
|
||||||
|
maxFill = maxFill(newSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int slotOf(long column) {
|
||||||
|
return hash(column, mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int hash(long column, int tableMask) {
|
||||||
|
long mixed = column * PHI;
|
||||||
|
mixed ^= mixed >>> 32;
|
||||||
|
return (int) (mixed ^ (mixed >>> 16)) & tableMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int maxFill(int tableSlots) {
|
||||||
|
return Math.min((int) Math.ceil(tableSlots * LOAD_FACTOR), tableSlots - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The table size for {@code expected} entries: the next power of two of {@code expected / loadFactor}, at least 2. */
|
||||||
|
private static int slotsFor(int expected) {
|
||||||
|
long wanted = Math.max(2L, (long) Math.ceil(expected / LOAD_FACTOR));
|
||||||
|
return (int) Long.highestOneBit(wanted - 1) << 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-10
@@ -2,7 +2,6 @@ package art.arcane.iris.engine.framework.structure;
|
|||||||
|
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -13,14 +12,18 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public final class CompiledStructureGraph {
|
public final class CompiledStructureGraph {
|
||||||
|
private static final String UNKEYED = "<unloaded>";
|
||||||
|
|
||||||
|
private final String structureKey;
|
||||||
private final IrisStructure structure;
|
private final IrisStructure structure;
|
||||||
private final Map<String, IrisJigsawPool> pools;
|
private final Map<String, IrisJigsawPool> pools;
|
||||||
private final Map<String, IrisJigsawPiece> pieces;
|
private final Map<String, IrisJigsawPiece> pieces;
|
||||||
private final Map<String, IrisObject> objects;
|
private final Map<String, ObjectFrame> objects;
|
||||||
private final Set<String> reachablePools;
|
private final Set<String> reachablePools;
|
||||||
private final Set<String> reachablePieces;
|
private final Set<String> reachablePieces;
|
||||||
|
|
||||||
private CompiledStructureGraph(Builder builder) {
|
private CompiledStructureGraph(Builder builder) {
|
||||||
|
structureKey = builder.structureKey;
|
||||||
structure = builder.structure;
|
structure = builder.structure;
|
||||||
pools = Collections.unmodifiableMap(new LinkedHashMap<>(builder.pools));
|
pools = Collections.unmodifiableMap(new LinkedHashMap<>(builder.pools));
|
||||||
pieces = Collections.unmodifiableMap(new LinkedHashMap<>(builder.pieces));
|
pieces = Collections.unmodifiableMap(new LinkedHashMap<>(builder.pieces));
|
||||||
@@ -29,17 +32,17 @@ public final class CompiledStructureGraph {
|
|||||||
reachablePieces = Collections.unmodifiableSet(new LinkedHashSet<>(builder.reachablePieces));
|
reachablePieces = Collections.unmodifiableSet(new LinkedHashSet<>(builder.reachablePieces));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Builder builder(IrisStructure structure) {
|
static Builder builder(String structureKey, IrisStructure structure) {
|
||||||
return new Builder(structure);
|
return new Builder(structureKey, structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisStructure getStructure() {
|
public IrisStructure getStructure() {
|
||||||
return structure;
|
return structure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The pack key of the structure, or a placeholder when the graph was compiled for a structure without one. */
|
||||||
public String getStructureKey() {
|
public String getStructureKey() {
|
||||||
String key = structure.getLoadKey();
|
return structureKey == null || structureKey.isBlank() ? UNKEYED : structureKey;
|
||||||
return key == null || key.isBlank() ? "<unloaded>" : key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, IrisJigsawPool> getPools() {
|
public Map<String, IrisJigsawPool> getPools() {
|
||||||
@@ -50,7 +53,7 @@ public final class CompiledStructureGraph {
|
|||||||
return pieces;
|
return pieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, IrisObject> getObjects() {
|
public Map<String, ObjectFrame> getObjects() {
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,14 +66,16 @@ public final class CompiledStructureGraph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final class Builder {
|
static final class Builder {
|
||||||
|
private final String structureKey;
|
||||||
private final IrisStructure structure;
|
private final IrisStructure structure;
|
||||||
private final Map<String, IrisJigsawPool> pools = new LinkedHashMap<>();
|
private final Map<String, IrisJigsawPool> pools = new LinkedHashMap<>();
|
||||||
private final Map<String, IrisJigsawPiece> pieces = new LinkedHashMap<>();
|
private final Map<String, IrisJigsawPiece> pieces = new LinkedHashMap<>();
|
||||||
private final Map<String, IrisObject> objects = new LinkedHashMap<>();
|
private final Map<String, ObjectFrame> objects = new LinkedHashMap<>();
|
||||||
private final Set<String> reachablePools = new LinkedHashSet<>();
|
private final Set<String> reachablePools = new LinkedHashSet<>();
|
||||||
private final Set<String> reachablePieces = new LinkedHashSet<>();
|
private final Set<String> reachablePieces = new LinkedHashSet<>();
|
||||||
|
|
||||||
private Builder(IrisStructure structure) {
|
private Builder(String structureKey, IrisStructure structure) {
|
||||||
|
this.structureKey = structureKey;
|
||||||
this.structure = Objects.requireNonNull(structure);
|
this.structure = Objects.requireNonNull(structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +87,7 @@ public final class CompiledStructureGraph {
|
|||||||
return pieces;
|
return pieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, IrisObject> objects() {
|
Map<String, ObjectFrame> objects() {
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -1,6 +1,5 @@
|
|||||||
package art.arcane.iris.engine.framework.structure;
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ public final class IrisObjectFrameReader {
|
|||||||
private IrisObjectFrameReader() {
|
private IrisObjectFrameReader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IrisObject readBounds(InputStream stream, String resourceName) throws IOException {
|
public static ObjectFrame readBounds(InputStream stream, String resourceName) throws IOException {
|
||||||
String activeResourceName = resourceName == null || resourceName.isBlank()
|
String activeResourceName = resourceName == null || resourceName.isBlank()
|
||||||
? "<unknown>" : resourceName;
|
? "<unknown>" : resourceName;
|
||||||
try {
|
try {
|
||||||
@@ -41,7 +40,7 @@ public final class IrisObjectFrameReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisObject readBounds(byte[] content, String resourceName) throws IOException {
|
private static ObjectFrame readBounds(byte[] content, String resourceName) throws IOException {
|
||||||
ByteArrayInputStream bytes = new ByteArrayInputStream(content);
|
ByteArrayInputStream bytes = new ByteArrayInputStream(content);
|
||||||
DataInputStream input = new DataInputStream(bytes);
|
DataInputStream input = new DataInputStream(bytes);
|
||||||
int width = input.readInt();
|
int width = input.readInt();
|
||||||
@@ -88,7 +87,7 @@ public final class IrisObjectFrameReader {
|
|||||||
}
|
}
|
||||||
int tileStart = content.length - bytes.available();
|
int tileStart = content.length - bytes.available();
|
||||||
requireCompleteTileFraming(content, tileStart, tileCount, width, height, depth, resourceName);
|
requireCompleteTileFraming(content, tileStart, tileCount, width, height, depth, resourceName);
|
||||||
return new IrisObject(width, height, depth);
|
return new ObjectFrame(width, height, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void requireCompleteTileFraming(
|
private static void requireCompleteTileFraming(
|
||||||
|
|||||||
+107
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||||
|
import art.arcane.iris.engine.framework.StructureAssembler;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.AssembledPiece;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.Assembly;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.StructureAssembly;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.StructureStamp;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.Viability;
|
||||||
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
|
import com.volmit.ModuleLog;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
|
import com.volmit.resource.ResourceId;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How {@code iris:jigsaw} builds the structures of the pack's {@code structures} folder: it assembles them from their
|
||||||
|
* jigsaw pools and pieces ({@link StructureAssembler}) and tells the placement how they are stamped. It knows exactly the
|
||||||
|
* structures the pack has a structure file for.
|
||||||
|
*/
|
||||||
|
public final class JigsawStructureAssembly implements StructureAssembly {
|
||||||
|
private final ModuleLog log;
|
||||||
|
|
||||||
|
public JigsawStructureAssembly(ModuleLog log) {
|
||||||
|
this.log = Objects.requireNonNull(log, "log");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean knows(PackResources pack, ResourceId structure) {
|
||||||
|
return structureOf(pack, structure) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OptionalInt reachChunks(PackResources pack, ResourceId structure) {
|
||||||
|
IrisStructure known = structureOf(pack, structure);
|
||||||
|
return known == null ? OptionalInt.empty() : OptionalInt.of(known.getMaxSizeChunks());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<StructureStamp> stamp(PackResources pack, ResourceId structure) {
|
||||||
|
IrisStructure known = structureOf(pack, structure);
|
||||||
|
if (known == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
List<String> loot = known.getLoot() == null ? List.of()
|
||||||
|
: known.getLoot().stream().filter(table -> table != null && !table.isBlank()).toList();
|
||||||
|
return Optional.of(new StructureStamp(known.getPlaceMode(), known.getEdit(), loot,
|
||||||
|
known.getVanillaSource() == null ? "" : known.getVanillaSource()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Viability viability(PackResources pack, ResourceId structure) {
|
||||||
|
IrisStructure known = structureOf(pack, structure);
|
||||||
|
if (known == null) {
|
||||||
|
return Viability.NOT_VIABLE;
|
||||||
|
}
|
||||||
|
String key = structure.path();
|
||||||
|
if (!StructureGraphCatalog.compile(pack, key, known, log).isAssemblyViable()) {
|
||||||
|
return Viability.NOT_VIABLE;
|
||||||
|
}
|
||||||
|
return StructureGraphCatalog.guaranteesRuntimeOutput(pack, key, known, log) ? Viability.GUARANTEED : Viability.VIABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Assembly> assemble(PackResources pack, ResourceId structure, BlockPosition origin, RNG random) {
|
||||||
|
IrisStructure known = structureOf(pack, structure);
|
||||||
|
if (known == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
StructureAssemblyResult result = StructureAssembler.forPack(pack, structure.path(), known, origin, log).assemble(random);
|
||||||
|
return Optional.of(new Assembly(result.status(), result.detail(), result.pieces().stream()
|
||||||
|
.map(piece -> assembled(pack, piece)).toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AssembledPiece assembled(PackResources pack, PlacedStructurePiece piece) {
|
||||||
|
return new AssembledPiece(pack.idOf(piece.getObjectKey()), piece.getX(), piece.getY(), piece.getZ(), piece.getRotation(),
|
||||||
|
piece.getMinX(), piece.getMinY(), piece.getMinZ(), piece.getMaxX(), piece.getMaxY(), piece.getMaxZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IrisStructure structureOf(PackResources pack, ResourceId structure) {
|
||||||
|
return StructureResources.structure(pack, structure.path());
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-7
@@ -20,7 +20,6 @@ package art.arcane.iris.engine.framework.structure;
|
|||||||
|
|
||||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||||
import art.arcane.iris.core.pack.PackValidationIo;
|
|
||||||
import art.arcane.volmlib.util.json.JSONArray;
|
import art.arcane.volmlib.util.json.JSONArray;
|
||||||
import art.arcane.volmlib.util.json.JSONObject;
|
import art.arcane.volmlib.util.json.JSONObject;
|
||||||
import com.volmit.validation.Problem;
|
import com.volmit.validation.Problem;
|
||||||
@@ -77,14 +76,14 @@ public final class NativeReplacementValidation {
|
|||||||
if (!resourceFolder.isDirectory()) {
|
if (!resourceFolder.isDirectory()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<File> resourceFiles = PackValidationIo.listJsonRecursive(resourceFolder);
|
List<File> resourceFiles = PackJsonFiles.listRecursive(resourceFolder);
|
||||||
resourceFiles.sort(Comparator.comparing(File::getPath));
|
resourceFiles.sort(Comparator.comparing(File::getPath));
|
||||||
for (File resourceFile : resourceFiles) {
|
for (File resourceFile : resourceFiles) {
|
||||||
JSONObject resource = PackValidationIo.readJson(resourceFile);
|
JSONObject resource = PackJsonFiles.read(resourceFile);
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String resourceKey = PackValidationIo.deriveKey(resourceFolder, resourceFile);
|
String resourceKey = PackJsonFiles.keyOf(resourceFolder, resourceFile);
|
||||||
Subject file = Subject.file(folderName + "/" + resourceKey + JSON_EXTENSION);
|
Subject file = Subject.file(folderName + "/" + resourceKey + JSON_EXTENSION);
|
||||||
for (String error : validateResource(folderName, resourceKey, resource, structures, viableStructures, verticalEnvelopes)) {
|
for (String error : validateResource(folderName, resourceKey, resource, structures, viableStructures, verticalEnvelopes)) {
|
||||||
problems.add(Problem.error(file, error));
|
problems.add(Problem.error(file, error));
|
||||||
@@ -97,10 +96,10 @@ public final class NativeReplacementValidation {
|
|||||||
private static Map<String, JSONObject> readStructures(File packFolder) {
|
private static Map<String, JSONObject> readStructures(File packFolder) {
|
||||||
File structuresFolder = new File(packFolder, StructureResources.STRUCTURES.folder());
|
File structuresFolder = new File(packFolder, StructureResources.STRUCTURES.folder());
|
||||||
Map<String, JSONObject> structures = new HashMap<>();
|
Map<String, JSONObject> structures = new HashMap<>();
|
||||||
for (File structureFile : PackValidationIo.listJsonRecursive(structuresFolder)) {
|
for (File structureFile : PackJsonFiles.listRecursive(structuresFolder)) {
|
||||||
JSONObject structure = PackValidationIo.readJson(structureFile);
|
JSONObject structure = PackJsonFiles.read(structureFile);
|
||||||
if (structure != null) {
|
if (structure != null) {
|
||||||
structures.put(PackValidationIo.deriveKey(structuresFolder, structureFile), structure);
|
structures.put(PackJsonFiles.keyOf(structuresFolder, structureFile), structure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return structures;
|
return structures;
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
|
import com.volmit.geometry.BlockBox;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The declared size of a pack object, which is all a jigsaw graph reads of it: connectors are placed against the size, and
|
||||||
|
* its center, which the object's offsets count from, is half the size.
|
||||||
|
*/
|
||||||
|
public record ObjectFrame(int width, int height, int depth) {
|
||||||
|
public static ObjectFrame of(BlockBox size) {
|
||||||
|
return new ObjectFrame(size.maxX() - size.minX(), size.maxY() - size.minY(), size.maxZ() - size.minZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The block the object's offsets count from, relative to its corner. */
|
||||||
|
public BlockPosition center() {
|
||||||
|
return new BlockPosition(width / 2, height / 2, depth / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
|
import art.arcane.volmlib.util.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/** The JSON files of a pack folder as written, for the checks that read values the host would have read as defaults. */
|
||||||
|
final class PackJsonFiles {
|
||||||
|
private static final String JSON_EXTENSION = ".json";
|
||||||
|
|
||||||
|
private PackJsonFiles() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Every {@code .json} file below {@code root}, in no particular order; none when it cannot be listed. */
|
||||||
|
static List<File> listRecursive(File root) {
|
||||||
|
List<File> files = new ArrayList<>();
|
||||||
|
try (Stream<Path> walk = Files.walk(root.toPath())) {
|
||||||
|
walk.filter(Files::isRegularFile)
|
||||||
|
.filter(path -> path.getFileName().toString().endsWith(JSON_EXTENSION))
|
||||||
|
.forEach(path -> files.add(path.toFile()));
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The JSON object {@code file} holds, or null when it cannot be read or parsed. */
|
||||||
|
static JSONObject read(File file) {
|
||||||
|
try {
|
||||||
|
return new JSONObject(Files.readString(file.toPath(), StandardCharsets.UTF_8));
|
||||||
|
} catch (java.io.IOException | RuntimeException unreadable) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The key of {@code file} in {@code folder}: its path below it without {@code .json}, or null for other files. */
|
||||||
|
static String keyOf(File folder, File file) {
|
||||||
|
String relative = folder.toPath().relativize(file.toPath()).toString().replace(File.separatorChar, '/');
|
||||||
|
if (!relative.endsWith(JSON_EXTENSION)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return relative.substring(0, relative.length() - JSON_EXTENSION.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-16
@@ -3,9 +3,8 @@ package art.arcane.iris.engine.framework.structure;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcell;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcell;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
@@ -27,16 +26,16 @@ public final class PlanarJigsawWorkcellResolver {
|
|||||||
EnumMap<IrisJigsawWorkcellArchetype, ResolvedWorkcell> resolved =
|
EnumMap<IrisJigsawWorkcellArchetype, ResolvedWorkcell> resolved =
|
||||||
new EnumMap<>(IrisJigsawWorkcellArchetype.class);
|
new EnumMap<>(IrisJigsawWorkcellArchetype.class);
|
||||||
if (source.getPlanarWorkcells() == null || source.getPlanarWorkcells().isEmpty()) {
|
if (source.getPlanarWorkcells() == null || source.getPlanarWorkcells().isEmpty()) {
|
||||||
IrisPosition fallback = source.getCellSize() == null
|
BlockPosition fallback = source.getCellSize() == null
|
||||||
? new IrisPosition(DEFAULT_SIZE, DEFAULT_SIZE, DEFAULT_SIZE)
|
? new BlockPosition(DEFAULT_SIZE, DEFAULT_SIZE, DEFAULT_SIZE)
|
||||||
: source.getCellSize();
|
: source.getCellSize();
|
||||||
for (IrisJigsawWorkcellArchetype archetype : IrisJigsawWorkcellArchetype.values()) {
|
for (IrisJigsawWorkcellArchetype archetype : IrisJigsawWorkcellArchetype.values()) {
|
||||||
ResolvedWorkcell workcell = new ResolvedWorkcell(
|
ResolvedWorkcell workcell = new ResolvedWorkcell(
|
||||||
archetype,
|
archetype,
|
||||||
"",
|
"",
|
||||||
fallback.getX(),
|
fallback.x(),
|
||||||
fallback.getY(),
|
fallback.y(),
|
||||||
fallback.getZ(),
|
fallback.z(),
|
||||||
true);
|
true);
|
||||||
validate(workcell);
|
validate(workcell);
|
||||||
resolved.put(archetype, workcell);
|
resolved.put(archetype, workcell);
|
||||||
@@ -86,14 +85,14 @@ public final class PlanarJigsawWorkcellResolver {
|
|||||||
return workcell;
|
return workcell;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IrisPosition canonicalDimensions(IrisJigsawPiece piece, IrisObject object) {
|
public static BlockPosition canonicalDimensions(IrisJigsawPiece piece, ObjectFrame object) {
|
||||||
IrisJigsawPiece sourcePiece = Objects.requireNonNull(piece, "Planar jigsaw piece");
|
IrisJigsawPiece sourcePiece = Objects.requireNonNull(piece, "Planar jigsaw piece");
|
||||||
IrisObject sourceObject = Objects.requireNonNull(object, "Planar jigsaw object");
|
ObjectFrame sourceObject = Objects.requireNonNull(object, "Planar jigsaw object");
|
||||||
IrisJigsawWorkcellArchetype archetype = IrisJigsawWorkcellArchetype.fromPiece(sourcePiece);
|
IrisJigsawWorkcellArchetype archetype = IrisJigsawWorkcellArchetype.fromPiece(sourcePiece);
|
||||||
int quarterTurns = archetype.sourceToCanonicalQuarterTurns(sourcePiece);
|
int quarterTurns = archetype.sourceToCanonicalQuarterTurns(sourcePiece);
|
||||||
return Math.floorMod(quarterTurns, 2) == 0
|
return Math.floorMod(quarterTurns, 2) == 0
|
||||||
? new IrisPosition(sourceObject.getW(), sourceObject.getH(), sourceObject.getD())
|
? new BlockPosition(sourceObject.width(), sourceObject.height(), sourceObject.depth())
|
||||||
: new IrisPosition(sourceObject.getD(), sourceObject.getH(), sourceObject.getW());
|
: new BlockPosition(sourceObject.depth(), sourceObject.height(), sourceObject.width());
|
||||||
}
|
}
|
||||||
|
|
||||||
public record ResolvedWorkcell(
|
public record ResolvedWorkcell(
|
||||||
@@ -109,13 +108,13 @@ public final class PlanarJigsawWorkcellResolver {
|
|||||||
displayName = normalizeDisplayName(displayName);
|
displayName = normalizeDisplayName(displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisPosition dimensions() {
|
public BlockPosition dimensions() {
|
||||||
return new IrisPosition(width, height, depth);
|
return new BlockPosition(width, height, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(IrisPosition dimensions) {
|
public boolean contains(BlockPosition dimensions) {
|
||||||
IrisPosition size = Objects.requireNonNull(dimensions, "Planar jigsaw object dimensions");
|
BlockPosition size = Objects.requireNonNull(dimensions, "Planar jigsaw object dimensions");
|
||||||
return size.getX() <= width && size.getY() <= height && size.getZ() <= depth;
|
return size.x() <= width && size.y() <= height && size.z() <= depth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+33
-35
@@ -1,70 +1,69 @@
|
|||||||
package art.arcane.iris.engine.framework.structure;
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.modules.IrisPackResources;
|
|
||||||
import art.arcane.iris.engine.framework.StructureAssembler;
|
import art.arcane.iris.engine.framework.StructureAssembler;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import com.github.benmanes.caffeine.cache.Cache;
|
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
||||||
|
|
||||||
import com.volmit.ModuleLog;
|
import com.volmit.ModuleLog;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiled structure graphs, kept per resource snapshot of the pack: every reload of the pack's resources starts a new
|
* Compiled structure graphs, kept per resource snapshot of the pack: every reload of the pack's resources starts a new
|
||||||
* snapshot ({@link IrisData#getPackResources()}), so nothing stale is ever read and nothing is invalidated by hand.
|
* snapshot ({@link PackResources#snapshotId()}), so nothing stale is ever read and nothing is invalidated by hand.
|
||||||
*/
|
*/
|
||||||
public final class StructureGraphCatalog {
|
public final class StructureGraphCatalog {
|
||||||
private static final Cache<IrisPackResources, ConcurrentMap<String, StructureGraphCompilation>> CACHE =
|
private static final Map<PackResources, ConcurrentMap<String, StructureGraphCompilation>> CACHE =
|
||||||
Caffeine.newBuilder().weakKeys().build();
|
Collections.synchronizedMap(new WeakHashMap<>());
|
||||||
private static final Cache<IrisPackResources, ConcurrentMap<String, Boolean>> RUNTIME_OUTPUT =
|
private static final Map<PackResources, ConcurrentMap<String, Boolean>> RUNTIME_OUTPUT =
|
||||||
Caffeine.newBuilder().weakKeys().build();
|
Collections.synchronizedMap(new WeakHashMap<>());
|
||||||
|
private static final BlockPosition SAMPLE_ORIGIN = new BlockPosition(0, 64, 0);
|
||||||
private static final List<Long> RUNTIME_SAMPLE_SEEDS = List.of(
|
private static final List<Long> RUNTIME_SAMPLE_SEEDS = List.of(
|
||||||
0L, 1L, 2L, 3L, 5L, 8L, 13L, 21L, 34L, 55L, 89L, 144L, 233L, 377L, 610L, 987L);
|
0L, 1L, 2L, 3L, 5L, 8L, 13L, 21L, 34L, 55L, 89L, 144L, 233L, 377L, 610L, 987L);
|
||||||
|
|
||||||
private StructureGraphCatalog() {
|
private StructureGraphCatalog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StructureGraphCompilation compile(IrisData data, IrisStructure structure, ModuleLog log) {
|
/** The compilation of {@code structure}, the pack's structure {@code structureKey} (blank for one that is not in the pack, which is not kept). */
|
||||||
IrisData activeData = Objects.requireNonNull(data);
|
public static StructureGraphCompilation compile(PackResources pack, String structureKey, IrisStructure structure, ModuleLog log) {
|
||||||
|
PackResources activePack = Objects.requireNonNull(pack);
|
||||||
IrisStructure activeStructure = Objects.requireNonNull(structure);
|
IrisStructure activeStructure = Objects.requireNonNull(structure);
|
||||||
String structureKey = activeStructure.getLoadKey();
|
|
||||||
if (structureKey == null || structureKey.isBlank()) {
|
if (structureKey == null || structureKey.isBlank()) {
|
||||||
return compileAndReport(activeData, activeStructure, log);
|
return compileAndReport(activePack, structureKey, activeStructure, log);
|
||||||
}
|
}
|
||||||
ConcurrentMap<String, StructureGraphCompilation> catalog = CACHE.get(
|
ConcurrentMap<String, StructureGraphCompilation> catalog = CACHE.computeIfAbsent(
|
||||||
activeData.getPackResources(), ignored -> new ConcurrentHashMap<>());
|
activePack, ignored -> new ConcurrentHashMap<>());
|
||||||
return catalog.computeIfAbsent(structureKey, ignored -> compileAndReport(activeData, activeStructure, log));
|
return catalog.computeIfAbsent(structureKey, ignored -> compileAndReport(activePack, structureKey, activeStructure, log));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean guaranteesRuntimeOutput(IrisData data, IrisStructure structure, ModuleLog log) {
|
public static boolean guaranteesRuntimeOutput(PackResources pack, String structureKey, IrisStructure structure, ModuleLog log) {
|
||||||
IrisData activeData = Objects.requireNonNull(data);
|
PackResources activePack = Objects.requireNonNull(pack);
|
||||||
IrisStructure activeStructure = Objects.requireNonNull(structure);
|
IrisStructure activeStructure = Objects.requireNonNull(structure);
|
||||||
if (!compile(activeData, activeStructure, log).guaranteesAssemblyOutput()) {
|
if (!compile(activePack, structureKey, activeStructure, log).guaranteesAssemblyOutput()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String structureKey = activeStructure.getLoadKey();
|
|
||||||
if (structureKey == null || structureKey.isBlank()) {
|
if (structureKey == null || structureKey.isBlank()) {
|
||||||
return sampleRuntimeAssembly(activeData, activeStructure, log);
|
return sampleRuntimeAssembly(activePack, structureKey, activeStructure, log);
|
||||||
}
|
}
|
||||||
ConcurrentMap<String, Boolean> catalog = RUNTIME_OUTPUT.get(
|
ConcurrentMap<String, Boolean> catalog = RUNTIME_OUTPUT.computeIfAbsent(
|
||||||
activeData.getPackResources(), ignored -> new ConcurrentHashMap<>());
|
activePack, ignored -> new ConcurrentHashMap<>());
|
||||||
return catalog.computeIfAbsent(
|
return catalog.computeIfAbsent(
|
||||||
structureKey, ignored -> sampleRuntimeAssembly(activeData, activeStructure, log));
|
structureKey, ignored -> sampleRuntimeAssembly(activePack, structureKey, activeStructure, log));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StructureGraphCompilation compileAndReport(IrisData data, IrisStructure structure, ModuleLog log) {
|
private static StructureGraphCompilation compileAndReport(PackResources pack, String structureKey, IrisStructure structure, ModuleLog log) {
|
||||||
StructureGraphCompilation compilation = StructureGraphCompiler.compile(
|
StructureGraphCompilation compilation = StructureGraphCompiler.compile(
|
||||||
structure, StructureGraphResolver.forData(data));
|
structureKey, structure, StructureGraphResolver.forPack(pack));
|
||||||
String structureKey = structure.getLoadKey() == null || structure.getLoadKey().isBlank()
|
String reportedKey = structureKey == null || structureKey.isBlank() ? "<unkeyed>" : structureKey;
|
||||||
? "<unkeyed>" : structure.getLoadKey();
|
|
||||||
for (StructureGraphDiagnostic diagnostic : compilation.getDiagnostics()) {
|
for (StructureGraphDiagnostic diagnostic : compilation.getDiagnostics()) {
|
||||||
String message = "[StructureGraph:" + structureKey + "] " + diagnostic.message();
|
String message = "[StructureGraph:" + reportedKey + "] " + diagnostic.message();
|
||||||
if (diagnostic.severity() == StructureGraphDiagnostic.Severity.ERROR) {
|
if (diagnostic.severity() == StructureGraphDiagnostic.Severity.ERROR) {
|
||||||
log.error(message, null);
|
log.error(message, null);
|
||||||
} else {
|
} else {
|
||||||
@@ -72,17 +71,16 @@ public final class StructureGraphCatalog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!compilation.isAssemblyViable()) {
|
if (!compilation.isAssemblyViable()) {
|
||||||
log.error("[StructureGraph:" + structureKey
|
log.error("[StructureGraph:" + reportedKey
|
||||||
+ "] Graph rejected because deterministic assembly did not complete.", null);
|
+ "] Graph rejected because deterministic assembly did not complete.", null);
|
||||||
}
|
}
|
||||||
return compilation;
|
return compilation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean sampleRuntimeAssembly(IrisData data, IrisStructure structure, ModuleLog log) {
|
private static boolean sampleRuntimeAssembly(PackResources pack, String structureKey, IrisStructure structure, ModuleLog log) {
|
||||||
for (long seed : RUNTIME_SAMPLE_SEEDS) {
|
for (long seed : RUNTIME_SAMPLE_SEEDS) {
|
||||||
try {
|
try {
|
||||||
StructureAssembler assembler = StructureAssembler.forData(
|
StructureAssembler assembler = StructureAssembler.forPack(pack, structureKey, structure, SAMPLE_ORIGIN, log);
|
||||||
data, structure, new IrisPosition(0, 64, 0), log);
|
|
||||||
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
||||||
if (!result.hasOutput()) {
|
if (!result.hasOutput()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+3
-4
@@ -6,7 +6,6 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -96,7 +95,7 @@ public final class StructureGraphCompilation {
|
|||||||
if (piece == null || !JigsawPoolSelection.pieceEligible(piece, theme, 0, 0)) {
|
if (piece == null || !JigsawPoolSelection.pieceEligible(piece, theme, 0, 0)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisObject object = graph.getObjects().get(normalize(piece.getObject()));
|
ObjectFrame object = graph.getObjects().get(normalize(piece.getObject()));
|
||||||
if (object == null || !fitsStartRadius(object)) {
|
if (object == null || !fitsStartRadius(object)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -185,9 +184,9 @@ public final class StructureGraphCompilation {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean fitsStartRadius(IrisObject object) {
|
private boolean fitsStartRadius(ObjectFrame object) {
|
||||||
long radius = (long) graph.getStructure().getMaxSizeChunks() * 16L;
|
long radius = (long) graph.getStructure().getMaxSizeChunks() * 16L;
|
||||||
return axisFitsRadius(object.getW(), radius) && axisFitsRadius(object.getD(), radius);
|
return axisFitsRadius(object.width(), radius) && axisFitsRadius(object.depth(), radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> themes() {
|
private List<String> themes() {
|
||||||
|
|||||||
+48
-47
@@ -2,7 +2,7 @@ package art.arcane.iris.engine.framework.structure;
|
|||||||
|
|
||||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||||
import art.arcane.iris.engine.framework.StructureAssembler;
|
import art.arcane.iris.engine.framework.StructureAssembler;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawCompatibility;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawCompatibility;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
@@ -13,12 +13,11 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceRules;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -44,9 +43,10 @@ public final class StructureGraphCompiler {
|
|||||||
private StructureGraphCompiler() {
|
private StructureGraphCompiler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StructureGraphCompilation compile(IrisStructure structure, StructureGraphResolver resolver) {
|
/** @param structureKey the pack key of {@code structure}, which the diagnostics name it by; blank for one without a key */
|
||||||
|
public static StructureGraphCompilation compile(String structureKey, IrisStructure structure, StructureGraphResolver resolver) {
|
||||||
CompilationState state = new CompilationState(
|
CompilationState state = new CompilationState(
|
||||||
Objects.requireNonNull(structure), Objects.requireNonNull(resolver));
|
structureKey, Objects.requireNonNull(structure), Objects.requireNonNull(resolver));
|
||||||
state.loadClosure();
|
state.loadClosure();
|
||||||
state.detectFallbackCycles();
|
state.detectFallbackCycles();
|
||||||
state.analyzeReachability();
|
state.analyzeReachability();
|
||||||
@@ -66,6 +66,7 @@ public final class StructureGraphCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class CompilationState {
|
private static final class CompilationState {
|
||||||
|
private final String structureKey;
|
||||||
private final IrisStructure structure;
|
private final IrisStructure structure;
|
||||||
private final StructureGraphResolver resolver;
|
private final StructureGraphResolver resolver;
|
||||||
private final CompiledStructureGraph.Builder graph;
|
private final CompiledStructureGraph.Builder graph;
|
||||||
@@ -89,10 +90,11 @@ public final class StructureGraphCompiler {
|
|||||||
private Map<IrisJigsawWorkcellArchetype, PlanarJigsawWorkcellResolver.ResolvedWorkcell>
|
private Map<IrisJigsawWorkcellArchetype, PlanarJigsawWorkcellResolver.ResolvedWorkcell>
|
||||||
planarWorkcells = Map.of();
|
planarWorkcells = Map.of();
|
||||||
|
|
||||||
private CompilationState(IrisStructure structure, StructureGraphResolver resolver) {
|
private CompilationState(String structureKey, IrisStructure structure, StructureGraphResolver resolver) {
|
||||||
|
this.structureKey = structureKey;
|
||||||
this.structure = structure;
|
this.structure = structure;
|
||||||
this.resolver = resolver;
|
this.resolver = resolver;
|
||||||
this.graph = CompiledStructureGraph.builder(structure);
|
this.graph = CompiledStructureGraph.builder(structureKey, structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadClosure() {
|
private void loadClosure() {
|
||||||
@@ -145,7 +147,7 @@ public final class StructureGraphCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void validateThemes() {
|
private void validateThemes() {
|
||||||
KList<IrisJigsawThemeSet> themeSets = structure.getThemeSets();
|
List<IrisJigsawThemeSet> themeSets = structure.getThemeSets();
|
||||||
if (themeSets == null) {
|
if (themeSets == null) {
|
||||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_THEME,
|
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_THEME,
|
||||||
"Structure '" + structureKey() + "' declares a null themeSets list.",
|
"Structure '" + structureKey() + "' declares a null themeSets list.",
|
||||||
@@ -235,7 +237,7 @@ public final class StructureGraphCompiler {
|
|||||||
graph.pools().put(key, pool);
|
graph.pools().put(key, pool);
|
||||||
List<PoolEntryReference> entries = new ArrayList<>();
|
List<PoolEntryReference> entries = new ArrayList<>();
|
||||||
poolEntries.put(key, entries);
|
poolEntries.put(key, entries);
|
||||||
KList<IrisJigsawPieceEntry> configuredEntries = pool.getPieces();
|
List<IrisJigsawPieceEntry> configuredEntries = pool.getPieces();
|
||||||
if (configuredEntries == null || configuredEntries.isEmpty()) {
|
if (configuredEntries == null || configuredEntries.isEmpty()) {
|
||||||
if (key.equals(normalize(structure.getStartPool()))) {
|
if (key.equals(normalize(structure.getStartPool()))) {
|
||||||
addDiagnostic(StructureGraphDiagnostic.Code.EMPTY_START_POOL,
|
addDiagnostic(StructureGraphDiagnostic.Code.EMPTY_START_POOL,
|
||||||
@@ -339,13 +341,13 @@ public final class StructureGraphCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
graph.pieces().put(key, piece);
|
graph.pieces().put(key, piece);
|
||||||
IrisObject object = loadPieceObject(key, piece);
|
ObjectFrame object = loadPieceObject(key, piece);
|
||||||
validatePieceMetadata(key, piece);
|
validatePieceMetadata(key, piece);
|
||||||
scanConnectors(key, piece, object);
|
scanConnectors(key, piece, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validatePieceMetadata(String pieceKey, IrisJigsawPiece piece) {
|
private void validatePieceMetadata(String pieceKey, IrisJigsawPiece piece) {
|
||||||
KList<String> themes = piece.getThemes();
|
List<String> themes = piece.getThemes();
|
||||||
if (themes == null) {
|
if (themes == null) {
|
||||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_THEME,
|
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_THEME,
|
||||||
"Jigsaw piece '" + pieceKey + "' declares a null themes list.",
|
"Jigsaw piece '" + pieceKey + "' declares a null themes list.",
|
||||||
@@ -419,7 +421,7 @@ public final class StructureGraphCompiler {
|
|||||||
&& !rules.isTerminal();
|
&& !rules.isTerminal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisObject loadPieceObject(String pieceKey, IrisJigsawPiece piece) {
|
private ObjectFrame loadPieceObject(String pieceKey, IrisJigsawPiece piece) {
|
||||||
String objectKey = normalize(piece.getObject());
|
String objectKey = normalize(piece.getObject());
|
||||||
pieceObjects.put(pieceKey, objectKey);
|
pieceObjects.put(pieceKey, objectKey);
|
||||||
if (objectKey.isEmpty()) {
|
if (objectKey.isEmpty()) {
|
||||||
@@ -438,7 +440,7 @@ public final class StructureGraphCompiler {
|
|||||||
return graph.objects().get(objectKey);
|
return graph.objects().get(objectKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisObject object = resolver.loadObject(objectKey);
|
ObjectFrame object = resolver.loadObject(objectKey);
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
missingObjects.add(objectKey);
|
missingObjects.add(objectKey);
|
||||||
addDiagnostic(StructureGraphDiagnostic.Code.MISSING_OBJECT,
|
addDiagnostic(StructureGraphDiagnostic.Code.MISSING_OBJECT,
|
||||||
@@ -447,20 +449,20 @@ public final class StructureGraphCompiler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
graph.objects().put(objectKey, object);
|
graph.objects().put(objectKey, object);
|
||||||
if (object.getW() < 1 || object.getH() < 1 || object.getD() < 1) {
|
if (object.width() < 1 || object.height() < 1 || object.depth() < 1) {
|
||||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_OBJECT_BOUNDS,
|
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_OBJECT_BOUNDS,
|
||||||
"Object '" + objectKey + "' used by jigsaw piece '" + pieceKey
|
"Object '" + objectKey + "' used by jigsaw piece '" + pieceKey
|
||||||
+ "' has invalid dimensions " + object.getW() + "x" + object.getH() + "x"
|
+ "' has invalid dimensions " + object.width() + "x" + object.height() + "x"
|
||||||
+ object.getD() + ".",
|
+ object.depth() + ".",
|
||||||
"object-bounds:" + objectKey);
|
"object-bounds:" + objectKey);
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanConnectors(String pieceKey, IrisJigsawPiece piece, IrisObject object) {
|
private void scanConnectors(String pieceKey, IrisJigsawPiece piece, ObjectFrame object) {
|
||||||
List<ConnectorReference> references = new ArrayList<>();
|
List<ConnectorReference> references = new ArrayList<>();
|
||||||
pieceConnectors.put(pieceKey, references);
|
pieceConnectors.put(pieceKey, references);
|
||||||
KList<IrisJigsawConnector> connectors = piece.getConnectors();
|
List<IrisJigsawConnector> connectors = piece.getConnectors();
|
||||||
if (connectors == null) {
|
if (connectors == null) {
|
||||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_CONNECTOR,
|
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_CONNECTOR,
|
||||||
"Jigsaw piece '" + pieceKey + "' declares a null connector list.",
|
"Jigsaw piece '" + pieceKey + "' declares a null connector list.",
|
||||||
@@ -552,7 +554,7 @@ public final class StructureGraphCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean validatePlanarConnector(String pieceKey, int index, IrisJigsawConnector connector,
|
private boolean validatePlanarConnector(String pieceKey, int index, IrisJigsawConnector connector,
|
||||||
IrisObject object, boolean validDirection, boolean validTop,
|
ObjectFrame object, boolean validDirection, boolean validTop,
|
||||||
boolean validPosition) {
|
boolean validPosition) {
|
||||||
if (structure.resolvedMode() != IrisJigsawMode.PLANAR_JIGSAW) {
|
if (structure.resolvedMode() != IrisJigsawMode.PLANAR_JIGSAW) {
|
||||||
return true;
|
return true;
|
||||||
@@ -568,7 +570,7 @@ public final class StructureGraphCompiler {
|
|||||||
"connector:planar-direction:" + pieceKey + ":" + index);
|
"connector:planar-direction:" + pieceKey + ":" + index);
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
if (validTop && connector.getTop() != IrisDirection.UP_POSITIVE_Y) {
|
if (validTop && connector.getTop() != JigsawDirection.UP_POSITIVE_Y) {
|
||||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_PLANAR_CONNECTOR,
|
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_PLANAR_CONNECTOR,
|
||||||
"Jigsaw piece '" + pieceKey + "' connectors[" + index + "] has top "
|
"Jigsaw piece '" + pieceKey + "' connectors[" + index + "] has top "
|
||||||
+ connector.getTop().name()
|
+ connector.getTop().name()
|
||||||
@@ -582,8 +584,8 @@ public final class StructureGraphCompiler {
|
|||||||
|| object == null || !validPosition) {
|
|| object == null || !validPosition) {
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
IrisPosition objectSize = new IrisPosition(object.getW(), object.getH(), object.getD());
|
BlockPosition objectSize = new BlockPosition(object.width(), object.height(), object.depth());
|
||||||
IrisPosition expected = IrisJigsawConnector.canonicalPlanarPosition(
|
BlockPosition expected = IrisJigsawConnector.canonicalPlanarPosition(
|
||||||
objectSize, connector.getDirection());
|
objectSize, connector.getDirection());
|
||||||
if (!expected.equals(connector.getPosition())) {
|
if (!expected.equals(connector.getPosition())) {
|
||||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_PLANAR_CONNECTOR,
|
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_PLANAR_CONNECTOR,
|
||||||
@@ -596,7 +598,7 @@ public final class StructureGraphCompiler {
|
|||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String invalidPositionMessage(String pieceKey, int index, IrisPosition position, IrisObject object) {
|
private String invalidPositionMessage(String pieceKey, int index, BlockPosition position, ObjectFrame object) {
|
||||||
if (position == null) {
|
if (position == null) {
|
||||||
return "Jigsaw piece '" + pieceKey + "' connectors[" + index
|
return "Jigsaw piece '" + pieceKey + "' connectors[" + index
|
||||||
+ "] does not declare a position.";
|
+ "] does not declare a position.";
|
||||||
@@ -606,17 +608,17 @@ public final class StructureGraphCompiler {
|
|||||||
+ "] position " + position + " cannot be checked because its object is missing.";
|
+ "] position " + position + " cannot be checked because its object is missing.";
|
||||||
}
|
}
|
||||||
return "Jigsaw piece '" + pieceKey + "' connectors[" + index + "] position " + position
|
return "Jigsaw piece '" + pieceKey + "' connectors[" + index + "] position " + position
|
||||||
+ " is outside object bounds 0.." + (object.getW() - 1) + ", 0.." + (object.getH() - 1)
|
+ " is outside object bounds 0.." + (object.width() - 1) + ", 0.." + (object.height() - 1)
|
||||||
+ ", 0.." + (object.getD() - 1) + ".";
|
+ ", 0.." + (object.depth() - 1) + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidPosition(IrisPosition position, IrisObject object) {
|
private boolean isValidPosition(BlockPosition position, ObjectFrame object) {
|
||||||
if (position == null || object == null) {
|
if (position == null || object == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return position.getX() >= 0 && position.getX() < object.getW()
|
return position.x() >= 0 && position.x() < object.width()
|
||||||
&& position.getY() >= 0 && position.getY() < object.getH()
|
&& position.y() >= 0 && position.y() < object.height()
|
||||||
&& position.getZ() >= 0 && position.getZ() < object.getD();
|
&& position.z() >= 0 && position.z() < object.depth();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void detectFallbackCycles() {
|
private void detectFallbackCycles() {
|
||||||
@@ -785,21 +787,21 @@ public final class StructureGraphCompiler {
|
|||||||
for (String pieceKey : graph.reachablePieces()) {
|
for (String pieceKey : graph.reachablePieces()) {
|
||||||
IrisJigsawPiece piece = graph.pieces().get(pieceKey);
|
IrisJigsawPiece piece = graph.pieces().get(pieceKey);
|
||||||
String objectKey = pieceObjects.get(pieceKey);
|
String objectKey = pieceObjects.get(pieceKey);
|
||||||
IrisObject object = graph.objects().get(objectKey);
|
ObjectFrame object = graph.objects().get(objectKey);
|
||||||
if (piece == null || object == null) {
|
if (piece == null || object == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PlanarJigsawWorkcellResolver.ResolvedWorkcell workcell =
|
PlanarJigsawWorkcellResolver.ResolvedWorkcell workcell =
|
||||||
PlanarJigsawWorkcellResolver.workcell(planarWorkcells, piece);
|
PlanarJigsawWorkcellResolver.workcell(planarWorkcells, piece);
|
||||||
IrisPosition dimensions = PlanarJigsawWorkcellResolver.canonicalDimensions(piece, object);
|
BlockPosition dimensions = PlanarJigsawWorkcellResolver.canonicalDimensions(piece, object);
|
||||||
if (workcell.contains(dimensions)) {
|
if (workcell.contains(dimensions)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE,
|
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE,
|
||||||
"Object '" + objectKey + "' used by reachable planar piece '" + pieceKey
|
"Object '" + objectKey + "' used by reachable planar piece '" + pieceKey
|
||||||
+ "' is " + object.getW() + "x" + object.getH() + "x" + object.getD()
|
+ "' is " + object.width() + "x" + object.height() + "x" + object.depth()
|
||||||
+ " and canonically occupies " + dimensions.getX() + "x" + dimensions.getY()
|
+ " and canonically occupies " + dimensions.x() + "x" + dimensions.y()
|
||||||
+ "x" + dimensions.getZ() + "; it does not fit " + workcell.archetype()
|
+ "x" + dimensions.z() + "; it does not fit " + workcell.archetype()
|
||||||
+ " workcell " + workcell.width() + "x" + workcell.height() + "x"
|
+ " workcell " + workcell.width() + "x" + workcell.height() + "x"
|
||||||
+ workcell.depth() + ".",
|
+ workcell.depth() + ".",
|
||||||
"object:planar-size:" + pieceKey);
|
"object:planar-size:" + pieceKey);
|
||||||
@@ -985,9 +987,9 @@ public final class StructureGraphCompiler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisDirection sourceDirection = rotateDirection(
|
JigsawDirection sourceDirection = rotateDirection(
|
||||||
sourceConnector.getDirection(), source.rotation());
|
sourceConnector.getDirection(), source.rotation());
|
||||||
IrisDirection candidateDirection = rotateDirection(
|
JigsawDirection candidateDirection = rotateDirection(
|
||||||
candidateConnector.getDirection(), candidateRotation);
|
candidateConnector.getDirection(), candidateRotation);
|
||||||
if (candidateDirection != sourceDirection.reverse()) {
|
if (candidateDirection != sourceDirection.reverse()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -995,8 +997,8 @@ public final class StructureGraphCompiler {
|
|||||||
if (sourceConnector.getJoint() != JigsawJoint.ALIGNED) {
|
if (sourceConnector.getJoint() != JigsawJoint.ALIGNED) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
IrisDirection sourceTop = rotateDirection(sourceConnector.getTop(), source.rotation());
|
JigsawDirection sourceTop = rotateDirection(sourceConnector.getTop(), source.rotation());
|
||||||
IrisDirection candidateTop = rotateDirection(candidateConnector.getTop(), candidateRotation);
|
JigsawDirection candidateTop = rotateDirection(candidateConnector.getTop(), candidateRotation);
|
||||||
return candidateTop == sourceTop;
|
return candidateTop == sourceTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1116,7 +1118,7 @@ public final class StructureGraphCompiler {
|
|||||||
for (long seed : ASSEMBLY_SEEDS) {
|
for (long seed : ASSEMBLY_SEEDS) {
|
||||||
try {
|
try {
|
||||||
StructureAssembler assembler = StructureAssembler.forCompilation(
|
StructureAssembler assembler = StructureAssembler.forCompilation(
|
||||||
compilation, new IrisPosition(0, 64, 0));
|
compilation, new BlockPosition(0, 64, 0));
|
||||||
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
||||||
List<String> pieces = new ArrayList<>(result.pieces().size());
|
List<String> pieces = new ArrayList<>(result.pieces().size());
|
||||||
for (PlacedStructurePiece placed : result.pieces()) {
|
for (PlacedStructurePiece placed : result.pieces()) {
|
||||||
@@ -1175,8 +1177,7 @@ public final class StructureGraphCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String structureKey() {
|
private String structureKey() {
|
||||||
String key = structure.getLoadKey();
|
return structureKey == null || structureKey.isBlank() ? "<unloaded>" : structureKey;
|
||||||
return key == null || key.isBlank() ? "<unloaded>" : key;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1188,18 +1189,18 @@ public final class StructureGraphCompiler {
|
|||||||
return piece.isRotatable() ? Y_ROTATIONS : NO_ROTATION;
|
return piece.isRotatable() ? Y_ROTATIONS : NO_ROTATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisDirection rotateDirection(IrisDirection direction, int degrees) {
|
private static JigsawDirection rotateDirection(JigsawDirection direction, int degrees) {
|
||||||
if (direction.isVertical()) {
|
if (direction.isVertical()) {
|
||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
int turns = Math.floorMod(degrees, 360) / 90;
|
int turns = Math.floorMod(degrees, 360) / 90;
|
||||||
IrisDirection rotated = direction;
|
JigsawDirection rotated = direction;
|
||||||
for (int turn = 0; turn < turns; turn++) {
|
for (int turn = 0; turn < turns; turn++) {
|
||||||
rotated = switch (rotated) {
|
rotated = switch (rotated) {
|
||||||
case NORTH_NEGATIVE_Z -> IrisDirection.WEST_NEGATIVE_X;
|
case NORTH_NEGATIVE_Z -> JigsawDirection.WEST_NEGATIVE_X;
|
||||||
case WEST_NEGATIVE_X -> IrisDirection.SOUTH_POSITIVE_Z;
|
case WEST_NEGATIVE_X -> JigsawDirection.SOUTH_POSITIVE_Z;
|
||||||
case SOUTH_POSITIVE_Z -> IrisDirection.EAST_POSITIVE_X;
|
case SOUTH_POSITIVE_Z -> JigsawDirection.EAST_POSITIVE_X;
|
||||||
case EAST_POSITIVE_X -> IrisDirection.NORTH_NEGATIVE_Z;
|
case EAST_POSITIVE_X -> JigsawDirection.NORTH_NEGATIVE_Z;
|
||||||
case UP_POSITIVE_Y, DOWN_NEGATIVE_Y -> rotated;
|
case UP_POSITIVE_Y, DOWN_NEGATIVE_Y -> rotated;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-14
@@ -1,9 +1,8 @@
|
|||||||
package art.arcane.iris.engine.framework.structure;
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import com.volmit.resource.PackResources;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -12,10 +11,11 @@ public interface StructureGraphResolver {
|
|||||||
|
|
||||||
IrisJigsawPiece loadPiece(String key);
|
IrisJigsawPiece loadPiece(String key);
|
||||||
|
|
||||||
IrisObject loadObject(String key);
|
/** The declared size of the pack object {@code key} names; null when the pack has none. */
|
||||||
|
ObjectFrame loadObject(String key);
|
||||||
|
|
||||||
static StructureGraphResolver forData(IrisData data) {
|
static StructureGraphResolver forPack(PackResources pack) {
|
||||||
return new IrisDataStructureGraphResolver(Objects.requireNonNull(data));
|
return new PackStructureGraphResolver(Objects.requireNonNull(pack));
|
||||||
}
|
}
|
||||||
|
|
||||||
static StructureGraphResolver forCompiledGraph(CompiledStructureGraph graph) {
|
static StructureGraphResolver forCompiledGraph(CompiledStructureGraph graph) {
|
||||||
@@ -23,26 +23,29 @@ public interface StructureGraphResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class IrisDataStructureGraphResolver implements StructureGraphResolver {
|
final class PackStructureGraphResolver implements StructureGraphResolver {
|
||||||
private final IrisData data;
|
private final PackResources pack;
|
||||||
|
|
||||||
IrisDataStructureGraphResolver(IrisData data) {
|
PackStructureGraphResolver(PackResources pack) {
|
||||||
this.data = data;
|
this.pack = pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisJigsawPool loadPool(String key) {
|
public IrisJigsawPool loadPool(String key) {
|
||||||
return StructureResources.pool(data.getPackResources(), key);
|
return StructureResources.pool(pack, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisJigsawPiece loadPiece(String key) {
|
public IrisJigsawPiece loadPiece(String key) {
|
||||||
return StructureResources.piece(data.getPackResources(), key);
|
return StructureResources.piece(pack, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisObject loadObject(String key) {
|
public ObjectFrame loadObject(String key) {
|
||||||
return data.load(IrisObject.class, key, false);
|
if (key == null || key.isBlank()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return pack.objects().sizeOf(pack.idOf(key)).map(ObjectFrame::of).orElse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +67,7 @@ final class CompiledStructureGraphResolver implements StructureGraphResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisObject loadObject(String key) {
|
public ObjectFrame loadObject(String key) {
|
||||||
return graph.getObjects().get(normalize(key));
|
return graph.getObjects().get(normalize(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-25
@@ -18,21 +18,21 @@
|
|||||||
|
|
||||||
package art.arcane.iris.engine.framework.structure;
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||||
import art.arcane.iris.engine.framework.StructureAssembler;
|
import art.arcane.iris.engine.framework.StructureAssembler;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
import com.volmit.resource.ResourceId;
|
import com.volmit.resource.ResourceId;
|
||||||
import com.volmit.validation.Problem;
|
import com.volmit.validation.Problem;
|
||||||
import com.volmit.validation.Severity;
|
import com.volmit.validation.Severity;
|
||||||
import com.volmit.validation.Subject;
|
import com.volmit.validation.Subject;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -65,43 +65,43 @@ public final class StructureGraphValidation {
|
|||||||
private StructureGraphValidation() {
|
private StructureGraphValidation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks every structure of the pack {@code data} holds. */
|
/** Checks every structure of {@code pack}, whose objects are the files below {@code packFolder}. */
|
||||||
public static Validation validate(IrisData data) {
|
public static Validation validate(PackResources pack, File packFolder) {
|
||||||
return validate(data, null);
|
return validate(pack, packFolder, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks the structures of the pack {@code data} holds whose keys are in {@code activeStructureKeys}, or all when it is null. */
|
/** Checks the structures of {@code pack} whose keys are in {@code activeStructureKeys}, or all when it is null. */
|
||||||
public static Validation validate(IrisData data, Set<String> activeStructureKeys) {
|
public static Validation validate(PackResources pack, File packFolder, Set<String> activeStructureKeys) {
|
||||||
List<Problem> problems = new ArrayList<>();
|
List<Problem> problems = new ArrayList<>();
|
||||||
Set<String> replacementOutputStructures = new LinkedHashSet<>();
|
Set<String> replacementOutputStructures = new LinkedHashSet<>();
|
||||||
Map<String, List<SampledVerticalEnvelope>> sampledVerticalEnvelopes = new LinkedHashMap<>();
|
Map<String, List<SampledVerticalEnvelope>> sampledVerticalEnvelopes = new LinkedHashMap<>();
|
||||||
PackStructureResolver resolver = new PackStructureResolver(data);
|
PackStructureResolver resolver = new PackStructureResolver(pack, packFolder);
|
||||||
for (ResourceId id : data.getPackResources().ids(StructureResources.STRUCTURES)) {
|
for (ResourceId id : pack.ids(StructureResources.STRUCTURES)) {
|
||||||
String structureKey = id.path();
|
String structureKey = id.path();
|
||||||
if (activeStructureKeys != null && !activeStructureKeys.contains(structureKey)) {
|
if (activeStructureKeys != null && !activeStructureKeys.contains(structureKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey);
|
IrisStructure structure = StructureResources.structure(pack, structureKey);
|
||||||
if (structure == null) {
|
if (structure == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
validateStructure(structure, resolver, problems, replacementOutputStructures, sampledVerticalEnvelopes);
|
validateStructure(structureKey, structure, resolver, problems, replacementOutputStructures, sampledVerticalEnvelopes);
|
||||||
}
|
}
|
||||||
return new Validation(problems, replacementOutputStructures, sampledVerticalEnvelopes);
|
return new Validation(problems, replacementOutputStructures, sampledVerticalEnvelopes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void validateStructure(
|
private static void validateStructure(
|
||||||
|
String structureKey,
|
||||||
IrisStructure structure,
|
IrisStructure structure,
|
||||||
StructureGraphResolver resolver,
|
StructureGraphResolver resolver,
|
||||||
List<Problem> problems,
|
List<Problem> problems,
|
||||||
Set<String> replacementOutputStructures,
|
Set<String> replacementOutputStructures,
|
||||||
Map<String, List<SampledVerticalEnvelope>> sampledVerticalEnvelopes
|
Map<String, List<SampledVerticalEnvelope>> sampledVerticalEnvelopes
|
||||||
) {
|
) {
|
||||||
String structureKey = structure.getLoadKey();
|
|
||||||
Subject file = Subject.file(StructureResources.STRUCTURES.folder() + "/" + structureKey + JSON_EXTENSION);
|
Subject file = Subject.file(StructureResources.STRUCTURES.folder() + "/" + structureKey + JSON_EXTENSION);
|
||||||
StructureGraphCompilation compilation;
|
StructureGraphCompilation compilation;
|
||||||
try {
|
try {
|
||||||
compilation = StructureGraphCompiler.compile(structure, resolver);
|
compilation = StructureGraphCompiler.compile(structureKey, structure, resolver);
|
||||||
} catch (MalformedObjectResourceException e) {
|
} catch (MalformedObjectResourceException e) {
|
||||||
problems.add(Problem.error(file, e.getMessage()));
|
problems.add(Problem.error(file, e.getMessage()));
|
||||||
return;
|
return;
|
||||||
@@ -139,7 +139,7 @@ public final class StructureGraphValidation {
|
|||||||
for (long seed : GEOMETRY_SAMPLE_SEEDS) {
|
for (long seed : GEOMETRY_SAMPLE_SEEDS) {
|
||||||
try {
|
try {
|
||||||
StructureAssembler assembler = StructureAssembler.forCompilation(
|
StructureAssembler assembler = StructureAssembler.forCompilation(
|
||||||
compilation, new IrisPosition(0, GEOMETRY_SAMPLE_ORIGIN_Y, 0));
|
compilation, new BlockPosition(0, GEOMETRY_SAMPLE_ORIGIN_Y, 0));
|
||||||
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
||||||
if (result.status().isFailure()) {
|
if (result.status().isFailure()) {
|
||||||
failures.add("seed " + seed + " returned " + result.status() + ": " + result.detail());
|
failures.add("seed " + seed + " returned " + result.status() + ": " + result.detail());
|
||||||
@@ -257,28 +257,28 @@ public final class StructureGraphValidation {
|
|||||||
|
|
||||||
/** Pools and pieces from the pack's structure resources; objects as far as their bounds, read from their files once each. */
|
/** Pools and pieces from the pack's structure resources; objects as far as their bounds, read from their files once each. */
|
||||||
private static final class PackStructureResolver implements StructureGraphResolver {
|
private static final class PackStructureResolver implements StructureGraphResolver {
|
||||||
private final IrisData data;
|
private final PackResources pack;
|
||||||
private final Path objectsRoot;
|
private final Path objectsRoot;
|
||||||
private final Map<String, IrisObject> objects = new HashMap<>();
|
private final Map<String, ObjectFrame> objects = new HashMap<>();
|
||||||
private final Set<String> missingObjects = new LinkedHashSet<>();
|
private final Set<String> missingObjects = new LinkedHashSet<>();
|
||||||
|
|
||||||
private PackStructureResolver(IrisData data) {
|
private PackStructureResolver(PackResources pack, File packFolder) {
|
||||||
this.data = data;
|
this.pack = pack;
|
||||||
this.objectsRoot = data.getDataFolder().toPath().toAbsolutePath().normalize().resolve(OBJECTS_FOLDER);
|
this.objectsRoot = packFolder.toPath().toAbsolutePath().normalize().resolve(OBJECTS_FOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisJigsawPool loadPool(String key) {
|
public IrisJigsawPool loadPool(String key) {
|
||||||
return StructureResources.pool(data.getPackResources(), key);
|
return StructureResources.pool(pack, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisJigsawPiece loadPiece(String key) {
|
public IrisJigsawPiece loadPiece(String key) {
|
||||||
return StructureResources.piece(data.getPackResources(), key);
|
return StructureResources.piece(pack, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisObject loadObject(String key) {
|
public ObjectFrame loadObject(String key) {
|
||||||
if (objects.containsKey(key)) {
|
if (objects.containsKey(key)) {
|
||||||
return objects.get(key);
|
return objects.get(key);
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ public final class StructureGraphValidation {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Path file = resolveObject(key);
|
Path file = resolveObject(key);
|
||||||
IrisObject object = file == null ? null : readObjectBounds(file);
|
ObjectFrame object = file == null ? null : readObjectBounds(file);
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
missingObjects.add(key);
|
missingObjects.add(key);
|
||||||
return null;
|
return null;
|
||||||
@@ -306,7 +306,7 @@ public final class StructureGraphValidation {
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisObject readObjectBounds(Path file) {
|
private ObjectFrame readObjectBounds(Path file) {
|
||||||
try (BufferedInputStream input = new BufferedInputStream(Files.newInputStream(file))) {
|
try (BufferedInputStream input = new BufferedInputStream(Files.newInputStream(file))) {
|
||||||
return IrisObjectFrameReader.readBounds(input, file.toString());
|
return IrisObjectFrameReader.readBounds(input, file.toString());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
+12
-15
@@ -22,12 +22,11 @@ import art.arcane.iris.core.structure.authoring.StructureResourceBundle;
|
|||||||
import art.arcane.iris.engine.framework.StructureAssembler;
|
import art.arcane.iris.engine.framework.StructureAssembler;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -49,8 +48,8 @@ public final class StructureResourceBundleGraphCompiler {
|
|||||||
public static List<StructureGraphCompilation> compile(StructureResourceBundle bundle) {
|
public static List<StructureGraphCompilation> compile(StructureResourceBundle bundle) {
|
||||||
BundleGraph graph = parse(Objects.requireNonNull(bundle));
|
BundleGraph graph = parse(Objects.requireNonNull(bundle));
|
||||||
List<StructureGraphCompilation> compilations = new ArrayList<>(graph.structures().size());
|
List<StructureGraphCompilation> compilations = new ArrayList<>(graph.structures().size());
|
||||||
for (IrisStructure structure : graph.structures().values()) {
|
for (Map.Entry<String, IrisStructure> structure : graph.structures().entrySet()) {
|
||||||
compilations.add(StructureGraphCompiler.compile(structure, graph.resolver()));
|
compilations.add(StructureGraphCompiler.compile(structure.getKey(), structure.getValue(), graph.resolver()));
|
||||||
}
|
}
|
||||||
return List.copyOf(compilations);
|
return List.copyOf(compilations);
|
||||||
}
|
}
|
||||||
@@ -60,8 +59,9 @@ public final class StructureResourceBundleGraphCompiler {
|
|||||||
if (graph.structures().isEmpty()) {
|
if (graph.structures().isEmpty()) {
|
||||||
throw new StructureGraphValidationException("Structure bundle does not contain a root structure resource");
|
throw new StructureGraphValidationException("Structure bundle does not contain a root structure resource");
|
||||||
}
|
}
|
||||||
for (IrisStructure structure : graph.structures().values()) {
|
for (Map.Entry<String, IrisStructure> structure : graph.structures().entrySet()) {
|
||||||
StructureGraphCompilation compilation = StructureGraphCompiler.compile(structure, graph.resolver());
|
StructureGraphCompilation compilation = StructureGraphCompiler.compile(
|
||||||
|
structure.getKey(), structure.getValue(), graph.resolver());
|
||||||
if (!compilation.isAssemblyViable()) {
|
if (!compilation.isAssemblyViable()) {
|
||||||
throw new StructureGraphValidationException(
|
throw new StructureGraphValidationException(
|
||||||
"Structure bundle graph is not viable: " + viabilityFailure(compilation));
|
"Structure bundle graph is not viable: " + viabilityFailure(compilation));
|
||||||
@@ -90,14 +90,11 @@ public final class StructureResourceBundleGraphCompiler {
|
|||||||
Map<String, IrisStructure> structures = new LinkedHashMap<>();
|
Map<String, IrisStructure> structures = new LinkedHashMap<>();
|
||||||
Map<String, IrisJigsawPool> pools = new LinkedHashMap<>();
|
Map<String, IrisJigsawPool> pools = new LinkedHashMap<>();
|
||||||
Map<String, IrisJigsawPiece> pieces = new LinkedHashMap<>();
|
Map<String, IrisJigsawPiece> pieces = new LinkedHashMap<>();
|
||||||
Map<String, IrisObject> objects = new LinkedHashMap<>();
|
Map<String, ObjectFrame> objects = new LinkedHashMap<>();
|
||||||
for (StructureResourceBundle.Resource resource : activeBundle.resources().values()) {
|
for (StructureResourceBundle.Resource resource : activeBundle.resources().values()) {
|
||||||
String path = resource.relativePath();
|
String path = resource.relativePath();
|
||||||
if (matches(path, "structures/", ".json")) {
|
if (matches(path, "structures/", ".json")) {
|
||||||
IrisStructure structure = readJson(resource, IrisStructure.class);
|
structures.put(key(path, "structures/", ".json"), readJson(resource, IrisStructure.class));
|
||||||
String key = key(path, "structures/", ".json");
|
|
||||||
structure.setLoadKey(key);
|
|
||||||
structures.put(key, structure);
|
|
||||||
} else if (matches(path, "jigsaw-pools/", ".json")) {
|
} else if (matches(path, "jigsaw-pools/", ".json")) {
|
||||||
pools.put(key(path, "jigsaw-pools/", ".json"), readJson(resource, IrisJigsawPool.class));
|
pools.put(key(path, "jigsaw-pools/", ".json"), readJson(resource, IrisJigsawPool.class));
|
||||||
} else if (matches(path, "jigsaw-pieces/", ".json")) {
|
} else if (matches(path, "jigsaw-pieces/", ".json")) {
|
||||||
@@ -114,7 +111,7 @@ public final class StructureResourceBundleGraphCompiler {
|
|||||||
for (long seed : ASSEMBLY_SEEDS) {
|
for (long seed : ASSEMBLY_SEEDS) {
|
||||||
try {
|
try {
|
||||||
StructureAssembler assembler = StructureAssembler.forCompilation(
|
StructureAssembler assembler = StructureAssembler.forCompilation(
|
||||||
compilation, new IrisPosition(0, 64, 0));
|
compilation, new BlockPosition(0, 64, 0));
|
||||||
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
||||||
if (result.status().isFailure()) {
|
if (result.status().isFailure()) {
|
||||||
throw new StructureGraphValidationException("Structure bundle graph '" + structureKey
|
throw new StructureGraphValidationException("Structure bundle graph '" + structureKey
|
||||||
@@ -157,7 +154,7 @@ public final class StructureResourceBundleGraphCompiler {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisObject readObjectBounds(StructureResourceBundle.Resource resource) {
|
private static ObjectFrame readObjectBounds(StructureResourceBundle.Resource resource) {
|
||||||
try (ByteArrayInputStream input = new ByteArrayInputStream(resource.content())) {
|
try (ByteArrayInputStream input = new ByteArrayInputStream(resource.content())) {
|
||||||
return IrisObjectFrameReader.readBounds(input, resource.relativePath());
|
return IrisObjectFrameReader.readBounds(input, resource.relativePath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -168,7 +165,7 @@ public final class StructureResourceBundleGraphCompiler {
|
|||||||
private record BundleResolver(
|
private record BundleResolver(
|
||||||
Map<String, IrisJigsawPool> pools,
|
Map<String, IrisJigsawPool> pools,
|
||||||
Map<String, IrisJigsawPiece> pieces,
|
Map<String, IrisJigsawPiece> pieces,
|
||||||
Map<String, IrisObject> objects
|
Map<String, ObjectFrame> objects
|
||||||
) implements StructureGraphResolver {
|
) implements StructureGraphResolver {
|
||||||
private BundleResolver {
|
private BundleResolver {
|
||||||
pools = Map.copyOf(pools);
|
pools = Map.copyOf(pools);
|
||||||
@@ -187,7 +184,7 @@ public final class StructureResourceBundleGraphCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisObject loadObject(String key) {
|
public ObjectFrame loadObject(String key) {
|
||||||
return objects.get(key);
|
return objects.get(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-45
@@ -18,11 +18,9 @@
|
|||||||
|
|
||||||
package art.arcane.iris.engine.framework.structure;
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.core.modules.IrisValidationContext;
|
import art.arcane.iris.builtin.structure.StructurePlacementSettings;
|
||||||
import art.arcane.iris.core.pack.PackValidationIo;
|
import com.volmit.config.FeatureSettings;
|
||||||
import art.arcane.volmlib.util.json.JSONArray;
|
|
||||||
import art.arcane.volmlib.util.json.JSONObject;
|
|
||||||
import com.volmit.validation.Problem;
|
import com.volmit.validation.Problem;
|
||||||
import com.volmit.validation.ValidationContext;
|
import com.volmit.validation.ValidationContext;
|
||||||
import com.volmit.validation.Validator;
|
import com.volmit.validation.Validator;
|
||||||
@@ -30,6 +28,7 @@ import com.volmit.validation.Validator;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -43,16 +42,15 @@ import java.util.stream.Collectors;
|
|||||||
* severity; everything else is an error, as when Iris's own pack validator ran these checks.
|
* severity; everything else is an error, as when Iris's own pack validator ran these checks.
|
||||||
*/
|
*/
|
||||||
public final class StructureValidator implements Validator {
|
public final class StructureValidator implements Validator {
|
||||||
private static final List<String> STRUCTURE_HOST_FOLDERS = List.of("dimensions", "regions", "biomes");
|
|
||||||
private static final String STRUCTURES_FIELD = "structures";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(ValidationContext pack) {
|
public void validate(ValidationContext pack) {
|
||||||
IrisData data = IrisValidationContext.of(pack).data();
|
File packFolder = pack.settings().extension(File.class).orElse(null);
|
||||||
StructureGraphValidation.Validation graphs = StructureGraphValidation.validate(data, placedStructureKeys(data.getDataFolder()));
|
StructureGraphValidation.Validation graphs = packFolder == null
|
||||||
|
? new StructureGraphValidation.Validation(List.of(), Set.of(), Map.of())
|
||||||
|
: StructureGraphValidation.validate(pack.resources(), packFolder, placedStructureKeys(pack));
|
||||||
graphs.problems().forEach(pack::report);
|
graphs.problems().forEach(pack::report);
|
||||||
reportUnlessAssemblyReported(pack, StructureReferenceValidation.validate(pack.resources()), graphs.problems());
|
reportUnlessAssemblyReported(pack, StructureReferenceValidation.validate(pack.resources()), graphs.problems());
|
||||||
NativeReplacementValidation.validate(data.getDataFolder(), graphs.replacementOutputStructures(), graphs.sampledVerticalEnvelopes())
|
NativeReplacementValidation.validate(packFolder, graphs.replacementOutputStructures(), graphs.sampledVerticalEnvelopes())
|
||||||
.forEach(pack::report);
|
.forEach(pack::report);
|
||||||
StructurePlacementValidation.validate(pack);
|
StructurePlacementValidation.validate(pack);
|
||||||
ImportedStructuresValidation.validate(pack);
|
ImportedStructuresValidation.validate(pack);
|
||||||
@@ -64,43 +62,14 @@ public final class StructureValidator implements Validator {
|
|||||||
references.stream().filter(problem -> !reported.contains(problem.message())).forEach(pack::report);
|
references.stream().filter(problem -> !reported.contains(problem.message())).forEach(pack::report);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** The keys of the structures the dimensions, regions and biomes of the pack place, whether or not a dimension reaches them. */
|
||||||
* The keys of the structures the dimension, region and biome files of the pack in {@code packFolder} place, read
|
public static Set<String> placedStructureKeys(ValidationContext pack) {
|
||||||
* from their JSON as written, like the other checks of these files.
|
|
||||||
*/
|
|
||||||
public static Set<String> placedStructureKeys(File packFolder) {
|
|
||||||
Set<String> structureKeys = new LinkedHashSet<>();
|
Set<String> structureKeys = new LinkedHashSet<>();
|
||||||
if (packFolder == null || !packFolder.isDirectory()) {
|
for (FeatureSettings.Entry<StructurePlacementSettings> declared : pack.settings().declared(StructurePlacementSettings.class).entries()) {
|
||||||
return structureKeys;
|
for (StructurePlacement placement : declared.value().placements()) {
|
||||||
}
|
placement.structures().stream().filter(key -> key != null && !key.isBlank()).forEach(structureKeys::add);
|
||||||
for (String folderName : STRUCTURE_HOST_FOLDERS) {
|
|
||||||
File resourceFolder = new File(packFolder, folderName);
|
|
||||||
if (!resourceFolder.isDirectory()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (File resourceFile : PackValidationIo.listJsonRecursive(resourceFolder)) {
|
|
||||||
addPlacedKeys(structureKeys, PackValidationIo.readJson(resourceFile));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Set.copyOf(structureKeys);
|
return Set.copyOf(structureKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addPlacedKeys(Set<String> structureKeys, JSONObject resource) {
|
|
||||||
JSONArray placements = resource == null ? null : resource.optJSONArray(STRUCTURES_FIELD);
|
|
||||||
if (placements == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int placementIndex = 0; placementIndex < placements.length(); placementIndex++) {
|
|
||||||
JSONObject placement = placements.optJSONObject(placementIndex);
|
|
||||||
JSONArray references = placement == null ? null : placement.optJSONArray(STRUCTURES_FIELD);
|
|
||||||
if (references == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (int referenceIndex = 0; referenceIndex < references.length(); referenceIndex++) {
|
|
||||||
if (references.opt(referenceIndex) instanceof String structureKey && !structureKey.isBlank()) {
|
|
||||||
structureKeys.add(structureKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework.structure.assembly;
|
||||||
|
|
||||||
|
import com.volmit.resource.ResourceId;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One piece of an assembled structure: the pack object, where its origin lands, how it is turned and the blocks it covers.
|
||||||
|
* Heights are world Y, and the bounds are inclusive.
|
||||||
|
*/
|
||||||
|
public record AssembledPiece(ResourceId object, int x, int y, int z, PieceTurn turn,
|
||||||
|
int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||||
|
public AssembledPiece {
|
||||||
|
Objects.requireNonNull(object, "object");
|
||||||
|
Objects.requireNonNull(turn, "turn");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This piece moved up by {@code shiftY} blocks. */
|
||||||
|
public AssembledPiece shiftedUp(int shiftY) {
|
||||||
|
return new AssembledPiece(object, x, y + shiftY, z, turn, minX, minY + shiftY, minZ, maxX, maxY + shiftY, maxZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework.structure.assembly;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.framework.structure.StructureAssemblyStatus;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/** What a {@link StructureAssembly} built: how the assembly ended, why when it did not complete, and the pieces in placement order. */
|
||||||
|
public record Assembly(StructureAssemblyStatus status, String detail, List<AssembledPiece> pieces) {
|
||||||
|
public Assembly {
|
||||||
|
Objects.requireNonNull(status, "status");
|
||||||
|
Objects.requireNonNull(detail, "detail");
|
||||||
|
pieces = List.copyOf(pieces);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether the assembly completed with pieces to place. */
|
||||||
|
public boolean hasOutput() {
|
||||||
|
return status == StructureAssemblyStatus.COMPLETE && !pieces.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework.structure.assembly;
|
||||||
|
|
||||||
|
import com.volmit.block.BlockTurn;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How a structure's assembly turns a piece: around the vertical axis by whole quarter turns, in the direction Iris's
|
||||||
|
* object rotation turns (north becomes west).
|
||||||
|
*
|
||||||
|
* @param yDegrees degrees around Y; a multiple of 90
|
||||||
|
*/
|
||||||
|
public record PieceTurn(int yDegrees) {
|
||||||
|
public static final PieceTurn NONE = new PieceTurn(0);
|
||||||
|
|
||||||
|
private static final int QUARTER_TURN_DEGREES = 90;
|
||||||
|
private static final int QUARTER_TURNS_PER_CIRCLE = 4;
|
||||||
|
|
||||||
|
public PieceTurn {
|
||||||
|
if (yDegrees % QUARTER_TURN_DEGREES != 0) {
|
||||||
|
throw new IllegalArgumentException("A piece turns by whole quarter turns, not " + yDegrees + " degrees");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PieceTurn aroundY(int yDegrees) {
|
||||||
|
return new PieceTurn(yDegrees);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The quarter turns this turn makes, 0 to 3. */
|
||||||
|
public int quarterTurns() {
|
||||||
|
return Math.floorMod(yDegrees / QUARTER_TURN_DEGREES, QUARTER_TURNS_PER_CIRCLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The directions this turn turns, for the facing, axis and connections of block states. */
|
||||||
|
public BlockTurn blockTurn() {
|
||||||
|
return (x, y, z) -> switch (quarterTurns()) {
|
||||||
|
case 1 -> new BlockTurn.Direction(z, y, -x);
|
||||||
|
case 2 -> new BlockTurn.Direction(-x, y, -z);
|
||||||
|
case 3 -> new BlockTurn.Direction(-z, y, x);
|
||||||
|
default -> new BlockTurn.Direction(x, y, z);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@code position} turned around the origin. */
|
||||||
|
public BlockPosition rotate(BlockPosition position) {
|
||||||
|
return switch (quarterTurns()) {
|
||||||
|
case 1 -> new BlockPosition(position.z(), position.y(), -position.x());
|
||||||
|
case 2 -> new BlockPosition(-position.x(), position.y(), -position.z());
|
||||||
|
case 3 -> new BlockPosition(-position.z(), position.y(), position.x());
|
||||||
|
default -> position;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+56
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework.structure.assembly;
|
||||||
|
|
||||||
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
|
import com.volmit.resource.ResourceId;
|
||||||
|
import com.volmit.service.Providers;
|
||||||
|
import com.volmit.service.Service;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the pieces of a structure the pack names; the placement decides where they go and fits them to the terrain.
|
||||||
|
* Every method answers empty, or {@link Viability#NOT_VIABLE}, for a structure this provider does not know, so a module
|
||||||
|
* offering another kind of structure answers only for its own. The placement asks the first provider that knows it.
|
||||||
|
*/
|
||||||
|
@Service(Providers.FIRST)
|
||||||
|
public interface StructureAssembly {
|
||||||
|
/** Whether this provider knows {@code structure}. Validation and the commands ask this. */
|
||||||
|
boolean knows(PackResources pack, ResourceId structure);
|
||||||
|
|
||||||
|
/** How far, in chunks from its start, the structure may reach; empty when this provider does not know it. */
|
||||||
|
OptionalInt reachChunks(PackResources pack, ResourceId structure);
|
||||||
|
|
||||||
|
/** How the pieces are stamped; empty when this provider does not know it. */
|
||||||
|
Optional<StructureStamp> stamp(PackResources pack, ResourceId structure);
|
||||||
|
|
||||||
|
/** Whether the structure can produce pieces at all. */
|
||||||
|
Viability viability(PackResources pack, ResourceId structure);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pieces from {@code origin}, drawing from {@code random}; empty when this provider does not know the structure.
|
||||||
|
* The placement draws its origin, anchor and structure from the same random before this continues on it, so the
|
||||||
|
* draws stay in one order whoever assembles.
|
||||||
|
*/
|
||||||
|
Optional<Assembly> assemble(PackResources pack, ResourceId structure, BlockPosition origin, RNG random);
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework.structure.assembly;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||||
|
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How the pieces of an assembled structure are stamped into the world.
|
||||||
|
*
|
||||||
|
* @param placeMode the place mode each piece is stamped with
|
||||||
|
* @param edits the find-and-replace block edits applied to every piece
|
||||||
|
* @param loot the loot tables the containers of the pieces draw from, blank names left out
|
||||||
|
* @param vanillaSource the platform structure this structure stands in for, blank for a hand-authored one
|
||||||
|
*/
|
||||||
|
public record StructureStamp(ObjectPlaceMode placeMode, List<ObjectReplace> edits, List<String> loot, String vanillaSource) {
|
||||||
|
public StructureStamp {
|
||||||
|
Objects.requireNonNull(placeMode, "placeMode");
|
||||||
|
edits = List.copyOf(edits);
|
||||||
|
loot = List.copyOf(loot);
|
||||||
|
Objects.requireNonNull(vanillaSource, "vanillaSource");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework.structure.assembly;
|
||||||
|
|
||||||
|
/** Whether a structure can produce pieces. */
|
||||||
|
public enum Viability {
|
||||||
|
/** Its pieces cannot be assembled, or its graph has errors. */
|
||||||
|
NOT_VIABLE,
|
||||||
|
/** Assembly completes for the samples tried, but a start or branch may still come up empty. */
|
||||||
|
VIABLE,
|
||||||
|
/** Every start and branch ends in pieces, so a placement of it always produces a structure. */
|
||||||
|
GUARANTEED;
|
||||||
|
|
||||||
|
public boolean isViable() {
|
||||||
|
return this != NOT_VIABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-54
@@ -1,15 +1,8 @@
|
|||||||
package art.arcane.iris.engine.mantle.components;
|
package art.arcane.iris.engine.mantle.components;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
|
||||||
import art.arcane.iris.util.common.data.B;
|
|
||||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
import it.unimi.dsi.fastutil.longs.Long2LongMap;
|
|
||||||
import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public final class StructureCarvingFootprint {
|
public final class StructureCarvingFootprint {
|
||||||
static final int DEFAULT_MAX_CELLS = 1_048_576;
|
static final int DEFAULT_MAX_CELLS = 1_048_576;
|
||||||
@@ -38,14 +31,6 @@ public final class StructureCarvingFootprint {
|
|||||||
sourceMaxY = data.sourceMaxY();
|
sourceMaxY = data.sourceMaxY();
|
||||||
}
|
}
|
||||||
|
|
||||||
static StructureCarvingFootprint from(KList<PlacedStructurePiece> pieces, int padding) {
|
|
||||||
return from(pieces, padding, DEFAULT_MAX_CELLS);
|
|
||||||
}
|
|
||||||
|
|
||||||
static StructureCarvingFootprint from(KList<PlacedStructurePiece> pieces, int padding, int maxCells) {
|
|
||||||
return fromColumns(sink -> emitPieceColumns(pieces, sink), padding, maxCells);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a footprint from any per-column occupancy source. The source reports one contribution per
|
* Builds a footprint from any per-column occupancy source. The source reports one contribution per
|
||||||
* occupied column; overlapping contributions merge into a single column whose vertical extents span
|
* occupied column; overlapping contributions merge into a single column whose vertical extents span
|
||||||
@@ -80,10 +65,10 @@ public final class StructureCarvingFootprint {
|
|||||||
int[] sourceMinY = new int[sourceCount];
|
int[] sourceMinY = new int[sourceCount];
|
||||||
int[] sourceMaxY = new int[sourceCount];
|
int[] sourceMaxY = new int[sourceCount];
|
||||||
int sourceId = 0;
|
int sourceId = 0;
|
||||||
for (Long2LongMap.Entry entry : sources.columns().long2LongEntrySet()) {
|
for (Map.Entry<Long, Long> entry : sources.columns().entrySet()) {
|
||||||
int localX = unpackX(entry.getLongKey()) - bounds.minX();
|
int localX = unpackX(entry.getKey()) - bounds.minX();
|
||||||
int localZ = unpackZ(entry.getLongKey()) - bounds.minZ();
|
int localZ = unpackZ(entry.getKey()) - bounds.minZ();
|
||||||
long heights = entry.getLongValue();
|
long heights = entry.getValue();
|
||||||
sourceX[sourceId] = localX;
|
sourceX[sourceId] = localX;
|
||||||
sourceZ[sourceId] = localZ;
|
sourceZ[sourceId] = localZ;
|
||||||
sourceMinY[sourceId] = unpackMinY(heights);
|
sourceMinY[sourceId] = unpackMinY(heights);
|
||||||
@@ -170,7 +155,7 @@ public final class StructureCarvingFootprint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static SourceCollection collectSources(ColumnSource source) {
|
private static SourceCollection collectSources(ColumnSource source) {
|
||||||
Long2LongOpenHashMap columns = new Long2LongOpenHashMap();
|
Map<Long, Long> columns = new HashMap<>();
|
||||||
MutableBounds bounds = new MutableBounds();
|
MutableBounds bounds = new MutableBounds();
|
||||||
boolean usable = source.emit((worldX, worldZ, minY, maxY) -> {
|
boolean usable = source.emit((worldX, worldZ, minY, maxY) -> {
|
||||||
mergeColumn(columns, worldX, worldZ, minY, maxY);
|
mergeColumn(columns, worldX, worldZ, minY, maxY);
|
||||||
@@ -182,36 +167,6 @@ public final class StructureCarvingFootprint {
|
|||||||
return columns.isEmpty() ? null : new SourceCollection(columns, bounds.freeze());
|
return columns.isEmpty() ? null : new SourceCollection(columns, bounds.freeze());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean emitPieceColumns(KList<PlacedStructurePiece> pieces, ColumnSink sink) {
|
|
||||||
if (pieces == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (PlacedStructurePiece piece : pieces) {
|
|
||||||
if (piece == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
IrisObject object = piece.getObject();
|
|
||||||
ObjectTurn rotation = piece.getRotation();
|
|
||||||
if (object == null || rotation == null || object.getBlocks() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (IrisBlockVector local : object.getBlocks().keys()) {
|
|
||||||
if (local == null || B.isAir(object.getBlocks().get(local))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
IrisBlockVector rotated = rotation.rotate(local.clone());
|
|
||||||
long worldX = (long) piece.getX() + rotated.getBlockX();
|
|
||||||
long worldY = (long) piece.getY() + rotated.getBlockY();
|
|
||||||
long worldZ = (long) piece.getZ() + rotated.getBlockZ();
|
|
||||||
if (!fitsInteger(worldX) || !fitsInteger(worldY) || !fitsInteger(worldZ)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
sink.column((int) worldX, (int) worldZ, (int) worldY, (int) worldY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Bounds paddedBounds(MutableBoundsSnapshot sourceBounds, int padding, int maxCells) {
|
private static Bounds paddedBounds(MutableBoundsSnapshot sourceBounds, int padding, int maxCells) {
|
||||||
long paddedMinX = (long) sourceBounds.minX() - padding;
|
long paddedMinX = (long) sourceBounds.minX() - padding;
|
||||||
long paddedMaxX = (long) sourceBounds.maxX() + padding;
|
long paddedMaxX = (long) sourceBounds.maxX() + padding;
|
||||||
@@ -233,7 +188,7 @@ public final class StructureCarvingFootprint {
|
|||||||
(int) width, (int) depth, cellCount);
|
(int) width, (int) depth, cellCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void mergeColumn(Long2LongOpenHashMap columns, int x, int z, int minY, int maxY) {
|
private static void mergeColumn(Map<Long, Long> columns, int x, int z, int minY, int maxY) {
|
||||||
long key = pack(x, z);
|
long key = pack(x, z);
|
||||||
if (!columns.containsKey(key)) {
|
if (!columns.containsKey(key)) {
|
||||||
columns.put(key, packHeights(minY, maxY));
|
columns.put(key, packHeights(minY, maxY));
|
||||||
@@ -430,7 +385,7 @@ public final class StructureCarvingFootprint {
|
|||||||
int[] nearestSourceIds, int[] sourceMinY, int[] sourceMaxY) {
|
int[] nearestSourceIds, int[] sourceMinY, int[] sourceMaxY) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private record SourceCollection(Long2LongOpenHashMap columns, MutableBoundsSnapshot bounds) {
|
private record SourceCollection(Map<Long, Long> columns, MutableBoundsSnapshot bounds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private record MutableBoundsSnapshot(int minX, int maxX, int minZ, int maxZ) {
|
private record MutableBoundsSnapshot(int minX, int maxX, int minZ, int maxZ) {
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package art.arcane.iris.engine.mantle.components;
|
package art.arcane.iris.engine.mantle.components;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.framework.structure.ColumnHeights;
|
||||||
import art.arcane.iris.spi.PlatformBlockState;
|
import art.arcane.iris.spi.PlatformBlockState;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
|
||||||
|
|
||||||
import java.util.function.IntConsumer;
|
import java.util.function.IntConsumer;
|
||||||
import java.util.function.IntPredicate;
|
import java.util.function.IntPredicate;
|
||||||
@@ -12,7 +12,7 @@ final class StructureFoundationPlanner {
|
|||||||
private StructureFoundationPlanner() {
|
private StructureFoundationPlanner() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void recordBaseCell(Long2IntOpenHashMap columns, int x, int y, int z,
|
static void recordBaseCell(ColumnHeights columns, int x, int y, int z,
|
||||||
PlatformBlockState state, boolean supportNonOccluding) {
|
PlatformBlockState state, boolean supportNonOccluding) {
|
||||||
if (columns == null || state == null
|
if (columns == null || state == null
|
||||||
|| !(supportNonOccluding ? state.isSolid() : state.isOccluding())) {
|
|| !(supportNonOccluding ? state.isSolid() : state.isOccluding())) {
|
||||||
|
|||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
package art.arcane.iris.engine.mantle.components;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.AssembledPiece;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/** The columns an assembled structure occupies, for the carve footprint. */
|
||||||
|
final class StructurePieceColumns {
|
||||||
|
private StructurePieceColumns() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One block of a piece object: where it lies from the object's center, and whether it is air. */
|
||||||
|
record PieceBlock(BlockPosition offset, boolean air) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports a column for every block of every piece that is not air, at the height the block lands, in the
|
||||||
|
* order of the pieces; false when a block lands outside the integer range.
|
||||||
|
*/
|
||||||
|
static boolean emit(List<AssembledPiece> pieces, Function<AssembledPiece, List<PieceBlock>> blocksOf,
|
||||||
|
StructureCarvingFootprint.ColumnSink sink) {
|
||||||
|
if (pieces == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (AssembledPiece piece : pieces) {
|
||||||
|
if (piece == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<PieceBlock> blocks = blocksOf.apply(piece);
|
||||||
|
if (blocks == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (PieceBlock block : blocks) {
|
||||||
|
if (block.air()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BlockPosition rotated = piece.turn().rotate(block.offset());
|
||||||
|
long worldX = (long) piece.x() + rotated.x();
|
||||||
|
long worldY = (long) piece.y() + rotated.y();
|
||||||
|
long worldZ = (long) piece.z() + rotated.z();
|
||||||
|
if (worldX != (int) worldX || worldY != (int) worldY || worldZ != (int) worldZ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
sink.column((int) worldX, (int) worldZ, (int) worldY, (int) worldY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,15 +20,17 @@ package art.arcane.iris.engine.mantle.components;
|
|||||||
|
|
||||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.ColumnHeights;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.AssembledPiece;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.StructureAssembly;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.StructureStamp;
|
||||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||||
import art.arcane.iris.core.IrisSettings;
|
import art.arcane.iris.core.IrisSettings;
|
||||||
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
|
||||||
import art.arcane.volmlib.util.cache.CacheKey;
|
import art.arcane.volmlib.util.cache.CacheKey;
|
||||||
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
||||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
|
||||||
import art.arcane.iris.engine.framework.StructurePlacementScope;
|
import art.arcane.iris.engine.framework.StructurePlacementScope;
|
||||||
import art.arcane.iris.core.modules.PlacementMarkers;
|
import art.arcane.iris.core.modules.PlacementMarkers;
|
||||||
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
||||||
@@ -39,7 +41,6 @@ import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
|||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
|
||||||
import art.arcane.iris.builtin.structure.StructureCarveShape;
|
import art.arcane.iris.builtin.structure.StructureCarveShape;
|
||||||
import art.arcane.iris.builtin.structure.StructurePlacement;
|
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||||
import art.arcane.iris.builtin.structure.StructureStilts;
|
import art.arcane.iris.builtin.structure.StructureStilts;
|
||||||
@@ -61,8 +62,7 @@ import art.arcane.volmlib.util.matter.Matter;
|
|||||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||||
import art.arcane.volmlib.util.matter.MatterStructurePOI;
|
import art.arcane.volmlib.util.matter.MatterStructurePOI;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -112,8 +112,8 @@ public class StructurePlacing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String key = resolved.structureKey();
|
String key = resolved.structureKey();
|
||||||
IrisStructure structure = resolved.structure();
|
StructureStamp stamp = resolved.stamp();
|
||||||
KList<PlacedStructurePiece> pieces = resolvedPiecesOrNull(resolved, cx, cz);
|
KList<AssembledPiece> pieces = resolvedPiecesOrNull(resolved, cx, cz);
|
||||||
if (pieces == null) {
|
if (pieces == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -139,36 +139,36 @@ public class StructurePlacing {
|
|||||||
+ " is not implemented for structure '" + key + "'");
|
+ " is not implemented for structure '" + key + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectPlaceMode mode = structure.getPlaceMode();
|
ObjectPlaceMode mode = stamp.placeMode();
|
||||||
int failedPieces = 0;
|
int failedPieces = 0;
|
||||||
StructureStilts stilt = placement.stilt().orElse(null);
|
StructureStilts stilt = placement.stilt().orElse(null);
|
||||||
Long2IntOpenHashMap foundationColumns = stilt == null
|
ColumnHeights foundationColumns = stilt == null
|
||||||
? null : new Long2IntOpenHashMap();
|
? null : new ColumnHeights(0);
|
||||||
boolean supportNonOccluding = stilt != null && stilt.supportNonOccluding();
|
boolean supportNonOccluding = stilt != null && stilt.supportNonOccluding();
|
||||||
if (placement.isAnchoredUnderground()) {
|
if (placement.isAnchoredUnderground()) {
|
||||||
ObjectPlaceMode undergroundMode = mode.placeMode().has(PlaceTrait.CAVE_ANCHORED)
|
ObjectPlaceMode undergroundMode = mode.placeMode().has(PlaceTrait.CAVE_ANCHORED)
|
||||||
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
|
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
|
||||||
for (PlacedStructurePiece p : pieces) {
|
for (AssembledPiece p : pieces) {
|
||||||
if (placeObject(writer, structure, p, undergroundMode, p.getY(), rng,
|
if (placeObject(writer, key, stamp, p, undergroundMode, p.y(), rng,
|
||||||
foundationColumns, supportNonOccluding) == -1) {
|
foundationColumns, supportNonOccluding) == -1) {
|
||||||
failedPieces++;
|
failedPieces++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
} else if (mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
||||||
for (PlacedStructurePiece p : pieces) {
|
for (AssembledPiece p : pieces) {
|
||||||
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, p.getY(), rng,
|
if (placeObject(writer, key, stamp, p, ObjectPlaceMode.STRUCTURE_PIECE, p.y(), rng,
|
||||||
foundationColumns, supportNonOccluding) == -1) {
|
foundationColumns, supportNonOccluding) == -1) {
|
||||||
failedPieces++;
|
failedPieces++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pieces.size() == 1) {
|
} else if (pieces.size() == 1) {
|
||||||
if (placeObject(writer, structure, pieces.getFirst(), mode, -1, rng,
|
if (placeObject(writer, key, stamp, pieces.getFirst(), mode, -1, rng,
|
||||||
foundationColumns, supportNonOccluding) == -1) {
|
foundationColumns, supportNonOccluding) == -1) {
|
||||||
failedPieces++;
|
failedPieces++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (PlacedStructurePiece p : pieces) {
|
for (AssembledPiece p : pieces) {
|
||||||
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, p.getY(), rng,
|
if (placeObject(writer, key, stamp, p, ObjectPlaceMode.STRUCTURE_PIECE, p.y(), rng,
|
||||||
foundationColumns, supportNonOccluding) == -1) {
|
foundationColumns, supportNonOccluding) == -1) {
|
||||||
failedPieces++;
|
failedPieces++;
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ public class StructurePlacing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placeFoundation(MantleWriter writer, Long2IntOpenHashMap columns,
|
private void placeFoundation(MantleWriter writer, ColumnHeights columns,
|
||||||
StructureStilts settings, RNG rng,
|
StructureStilts settings, RNG rng,
|
||||||
boolean surfaceStructure) {
|
boolean surfaceStructure) {
|
||||||
PaletteSpec palette = settings.palette().orElseThrow(
|
PaletteSpec palette = settings.palette().orElseThrow(
|
||||||
@@ -188,14 +188,13 @@ public class StructurePlacing {
|
|||||||
PaletteSampler picker = engine.getData().getPackResources().blocks().palette(palette, rng.getSeed());
|
PaletteSampler picker = engine.getData().getPackResources().blocks().palette(palette, rng.getSeed());
|
||||||
int mantleOffset = engine.getMinHeight();
|
int mantleOffset = engine.getMinHeight();
|
||||||
int maxDepth = Math.max(1, settings.maxDepth());
|
int maxDepth = Math.max(1, settings.maxDepth());
|
||||||
for (Long2IntMap.Entry column : columns.long2IntEntrySet()) {
|
columns.forEach((column, foundationY) -> {
|
||||||
int worldX = StructureFoundationPlanner.unpackX(column.getLongKey());
|
int worldX = StructureFoundationPlanner.unpackX(column);
|
||||||
int worldZ = StructureFoundationPlanner.unpackZ(column.getLongKey());
|
int worldZ = StructureFoundationPlanner.unpackZ(column);
|
||||||
int foundationY = column.getIntValue();
|
|
||||||
PlatformBlockState foundationState = writer.getDataIfPresent(
|
PlatformBlockState foundationState = writer.getDataIfPresent(
|
||||||
worldX, foundationY, worldZ, PlatformBlockState.class);
|
worldX, foundationY, worldZ, PlatformBlockState.class);
|
||||||
if (foundationState == null || !foundationState.isSolid()) {
|
if (foundationState == null || !foundationState.isSolid()) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
int terrainHeight = engine.getMantle().trueHeight(worldX, worldZ);
|
int terrainHeight = engine.getMantle().trueHeight(worldX, worldZ);
|
||||||
int groundY = StructureFoundationPlanner.findGroundY(
|
int groundY = StructureFoundationPlanner.findGroundY(
|
||||||
@@ -212,12 +211,12 @@ public class StructurePlacing {
|
|||||||
overlay, carved, y, terrainHeight);
|
overlay, carved, y, terrainHeight);
|
||||||
});
|
});
|
||||||
if (groundY == StructureFoundationPlanner.NO_GROUND) {
|
if (groundY == StructureFoundationPlanner.NO_GROUND) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
StructureFoundationPlanner.fillSupportColumn(foundationY, groundY, y -> {
|
StructureFoundationPlanner.fillSupportColumn(foundationY, groundY, y -> {
|
||||||
writeFoundationSupport(writer, picker, worldX, y, worldZ, mantleOffset);
|
writeFoundationSupport(writer, picker, worldX, y, worldZ, mantleOffset);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes the stilt palette's block at the column's mantle height, clearing any carve there. */
|
/** Writes the stilt palette's block at the column's mantle height, clearing any carve there. */
|
||||||
@@ -233,7 +232,7 @@ public class StructurePlacing {
|
|||||||
writer.set(worldX, mantleY, worldZ, support);
|
writer.set(worldX, mantleY, worldZ, support);
|
||||||
}
|
}
|
||||||
|
|
||||||
static KList<PlacedStructurePiece> resolvedPiecesOrNull(
|
static KList<AssembledPiece> resolvedPiecesOrNull(
|
||||||
IrisStructureLocator.ResolvedPlacement resolved,
|
IrisStructureLocator.ResolvedPlacement resolved,
|
||||||
int chunkX,
|
int chunkX,
|
||||||
int chunkZ
|
int chunkZ
|
||||||
@@ -241,7 +240,7 @@ public class StructurePlacing {
|
|||||||
if (resolved == null) {
|
if (resolved == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
KList<PlacedStructurePiece> pieces = resolved.pieces();
|
KList<AssembledPiece> pieces = resolved.pieces();
|
||||||
if (!IrisStructureLocator.requirePlacementOutput(
|
if (!IrisStructureLocator.requirePlacementOutput(
|
||||||
resolved.placement(), resolved.structureKey(), chunkX, chunkZ,
|
resolved.placement(), resolved.structureKey(), chunkX, chunkZ,
|
||||||
pieces != null && !pieces.isEmpty(), "placement application received no assembled pieces")) {
|
pieces != null && !pieces.isEmpty(), "placement application received no assembled pieces")) {
|
||||||
@@ -258,7 +257,7 @@ public class StructurePlacing {
|
|||||||
+ " assembled piece(s)");
|
+ " assembled piece(s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void boreStructure(MantleWriter writer, KList<PlacedStructurePiece> pieces,
|
private void boreStructure(MantleWriter writer, KList<AssembledPiece> pieces,
|
||||||
StructureTerrain terrain) {
|
StructureTerrain terrain) {
|
||||||
int[] bounds = computePieceBounds(pieces);
|
int[] bounds = computePieceBounds(pieces);
|
||||||
if (bounds == null) {
|
if (bounds == null) {
|
||||||
@@ -288,7 +287,7 @@ public class StructurePlacing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forceCarveStructure(MantleWriter writer, KList<PlacedStructurePiece> pieces,
|
private void forceCarveStructure(MantleWriter writer, KList<AssembledPiece> pieces,
|
||||||
StructureTerrain terrain) {
|
StructureTerrain terrain) {
|
||||||
int[] bounds = computePieceBounds(pieces);
|
int[] bounds = computePieceBounds(pieces);
|
||||||
if (bounds == null) {
|
if (bounds == null) {
|
||||||
@@ -310,8 +309,8 @@ public class StructurePlacing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long work = overboreCandidateVolume(bounds, margin, upExtension, floorCut);
|
long work = overboreCandidateVolume(bounds, margin, upExtension, floorCut);
|
||||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(
|
StructureCarvingFootprint footprint = StructureCarvingFootprint.fromColumns(
|
||||||
pieces, margin, Integer.MAX_VALUE);
|
sink -> StructurePieceColumns.emit(pieces, this::blocksOf, sink), margin, Integer.MAX_VALUE);
|
||||||
if (footprint == null) {
|
if (footprint == null) {
|
||||||
throw new IllegalStateException("Structure force-carve footprint is empty or exceeds addressable memory");
|
throw new IllegalStateException("Structure force-carve footprint is empty or exceeds addressable memory");
|
||||||
}
|
}
|
||||||
@@ -419,18 +418,20 @@ public class StructurePlacing {
|
|||||||
int mantleOffset = engine.getMinHeight();
|
int mantleOffset = engine.getMinHeight();
|
||||||
int worldHeight = engine.getHeight();
|
int worldHeight = engine.getHeight();
|
||||||
Map<String, ObjectMarkerBounds> intersectingObjects = new HashMap<>();
|
Map<String, ObjectMarkerBounds> intersectingObjects = new HashMap<>();
|
||||||
for (PlacedStructurePiece piece : resolved.pieces()) {
|
for (AssembledPiece piece : resolved.pieces()) {
|
||||||
for (IrisBlockVector local : piece.getObject().getBlocks().keys()) {
|
IrisObject object = objectOf(piece);
|
||||||
PlatformBlockState structureState = piece.getObject().getBlocks().get(local);
|
for (IrisBlockVector local : object.getBlocks().keys()) {
|
||||||
|
PlatformBlockState structureState = object.getBlocks().get(local);
|
||||||
if (!isOccupiedStructureState(structureState)) {
|
if (!isOccupiedStructureState(structureState)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IrisBlockVector rotated = piece.getRotation().rotate(local.clone());
|
BlockPosition rotated = piece.turn().rotate(
|
||||||
int y = piece.getY() - mantleOffset + rotated.getBlockY();
|
new BlockPosition(local.getBlockX(), local.getBlockY(), local.getBlockZ()));
|
||||||
|
int y = piece.y() - mantleOffset + rotated.y();
|
||||||
if (y >= 0 && y < worldHeight) {
|
if (y >= 0 && y < worldHeight) {
|
||||||
collectIntersectingObjectTreeMarker(
|
collectIntersectingObjectTreeMarker(
|
||||||
writer, piece.getX() + rotated.getBlockX(), y,
|
writer, piece.x() + rotated.x(), y,
|
||||||
piece.getZ() + rotated.getBlockZ(), intersectingObjects);
|
piece.z() + rotated.z(), intersectingObjects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -520,7 +521,29 @@ public class StructurePlacing {
|
|||||||
Math.max(0, horizontalSpan - 1), Math.max(0, verticalSpan - 1), worldHeight);
|
Math.max(0, horizontalSpan - 1), Math.max(0, verticalSpan - 1), worldHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] computePieceBounds(KList<PlacedStructurePiece> pieces) {
|
private List<StructurePieceColumns.PieceBlock> blocksOf(AssembledPiece piece) {
|
||||||
|
IrisObject object = objectOf(piece);
|
||||||
|
if (object == null || object.getBlocks() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<StructurePieceColumns.PieceBlock> blocks = new ArrayList<>();
|
||||||
|
for (IrisBlockVector local : object.getBlocks().keys()) {
|
||||||
|
if (local != null) {
|
||||||
|
blocks.add(new StructurePieceColumns.PieceBlock(
|
||||||
|
new BlockPosition(local.getBlockX(), local.getBlockY(), local.getBlockZ()),
|
||||||
|
B.isAir(object.getBlocks().get(local))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The object of {@code piece}, loaded from the engine's pack. */
|
||||||
|
private IrisObject objectOf(AssembledPiece piece) {
|
||||||
|
String key = engine.getData().getPackResources().keyOf(piece.object());
|
||||||
|
return engine.getData().load(IrisObject.class, key, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] computePieceBounds(KList<AssembledPiece> pieces) {
|
||||||
if (pieces == null || pieces.isEmpty()) {
|
if (pieces == null || pieces.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -530,29 +553,29 @@ public class StructurePlacing {
|
|||||||
int maxX = Integer.MIN_VALUE;
|
int maxX = Integer.MIN_VALUE;
|
||||||
int maxY = Integer.MIN_VALUE;
|
int maxY = Integer.MIN_VALUE;
|
||||||
int maxZ = Integer.MIN_VALUE;
|
int maxZ = Integer.MIN_VALUE;
|
||||||
for (PlacedStructurePiece p : pieces) {
|
for (AssembledPiece p : pieces) {
|
||||||
minX = Math.min(minX, p.getMinX());
|
minX = Math.min(minX, p.minX());
|
||||||
minY = Math.min(minY, p.getMinY());
|
minY = Math.min(minY, p.minY());
|
||||||
minZ = Math.min(minZ, p.getMinZ());
|
minZ = Math.min(minZ, p.minZ());
|
||||||
maxX = Math.max(maxX, p.getMaxX());
|
maxX = Math.max(maxX, p.maxX());
|
||||||
maxY = Math.max(maxY, p.getMaxY());
|
maxY = Math.max(maxY, p.maxY());
|
||||||
maxZ = Math.max(maxZ, p.getMaxZ());
|
maxZ = Math.max(maxZ, p.maxZ());
|
||||||
}
|
}
|
||||||
return new int[]{minX, minY, minZ, maxX, maxY, maxZ};
|
return new int[]{minX, minY, minZ, maxX, maxY, maxZ};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A placement of the piece object {@code objectKey} whose containers draw from the structure's loot tables. */
|
/** A placement of the piece object {@code objectKey} whose containers draw from the stamp's loot tables. */
|
||||||
public static ObjectPlacement lootPlacement(IrisStructure structure, String objectKey) {
|
public static ObjectPlacement lootPlacement(StructureStamp stamp, String objectKey) {
|
||||||
return lootPlacementBuilder(structure, objectKey).build();
|
return lootPlacementBuilder(stamp, objectKey).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ObjectPlacement.Builder lootPlacementBuilder(IrisStructure structure, String objectKey) {
|
private static ObjectPlacement.Builder lootPlacementBuilder(StructureStamp stamp, String objectKey) {
|
||||||
ObjectPlacement.Builder placement = ObjectPlacement.builder().place(List.of(objectKey));
|
ObjectPlacement.Builder placement = ObjectPlacement.builder().place(List.of(objectKey));
|
||||||
if (structure.getLoot() == null) {
|
if (stamp.loot().isEmpty()) {
|
||||||
return placement;
|
return placement;
|
||||||
}
|
}
|
||||||
List<ObjectLoot> loot = new ArrayList<>();
|
List<ObjectLoot> loot = new ArrayList<>();
|
||||||
for (String lootTable : structure.getLoot()) {
|
for (String lootTable : stamp.loot()) {
|
||||||
if (lootTable != null && !lootTable.isBlank()) {
|
if (lootTable != null && !lootTable.isBlank()) {
|
||||||
loot.add(new ObjectLoot(lootTable, 1));
|
loot.add(new ObjectLoot(lootTable, 1));
|
||||||
}
|
}
|
||||||
@@ -560,22 +583,22 @@ public class StructurePlacing {
|
|||||||
return placement.loot(loot);
|
return placement.loot(loot);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int placeObject(MantleWriter writer, IrisStructure structure, PlacedStructurePiece p,
|
private int placeObject(MantleWriter writer, String structureKey, StructureStamp stamp, AssembledPiece p,
|
||||||
ObjectPlaceMode mode, int y, RNG rng, Long2IntOpenHashMap foundationColumns,
|
ObjectPlaceMode mode, int y, RNG rng, ColumnHeights foundationColumns,
|
||||||
boolean supportNonOccluding) {
|
boolean supportNonOccluding) {
|
||||||
IrisObject object = p.getObject();
|
IrisObject object = objectOf(p);
|
||||||
String objectKey = object.getLoadKey();
|
String objectKey = object.getLoadKey();
|
||||||
ObjectPlacement.Builder builder = lootPlacementBuilder(structure, objectKey).mode(mode).rotation(moduleRotation(p.getRotation()));
|
ObjectPlacement.Builder builder = lootPlacementBuilder(stamp, objectKey).mode(mode).rotation(moduleRotation(p.turn()));
|
||||||
if (!structure.getEdit().isEmpty()) {
|
if (!stamp.edits().isEmpty()) {
|
||||||
builder.edit(structure.getEdit());
|
builder.edit(new KList<>(stamp.edits()));
|
||||||
}
|
}
|
||||||
if (!mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
if (!mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
||||||
builder.forcePlace(true);
|
builder.forcePlace(true);
|
||||||
}
|
}
|
||||||
ObjectPlacement config = builder.build();
|
ObjectPlacement config = builder.build();
|
||||||
int placeY = (y == -1) ? -1 : y - engine.getMinHeight();
|
int placeY = (y == -1) ? -1 : y - engine.getMinHeight();
|
||||||
String marker = structurePlacementMarker(structure, p, objectKey);
|
String marker = structurePlacementMarker(structureKey, p, objectKey);
|
||||||
return ModuleObjectPlacement.place(object, p.getX(), placeY, p.getZ(), writer, config, rng, (position, state) -> {
|
return ModuleObjectPlacement.place(object, p.x(), placeY, p.z(), writer, config, rng, (position, state) -> {
|
||||||
StructureFoundationPlanner.recordBaseCell(
|
StructureFoundationPlanner.recordBaseCell(
|
||||||
foundationColumns, position.getX(), position.getY(), position.getZ(), state,
|
foundationColumns, position.getX(), position.getY(), position.getZ(), state,
|
||||||
supportNonOccluding);
|
supportNonOccluding);
|
||||||
@@ -586,8 +609,8 @@ public class StructurePlacing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The placement rotation that turns a placed piece the way {@code turn} does. */
|
/** The placement rotation that turns a placed piece the way {@code turn} does. */
|
||||||
public static ObjectRotation moduleRotation(ObjectTurn turn) {
|
public static ObjectRotation moduleRotation(PieceTurn turn) {
|
||||||
return ObjectRotation.of(turn.xDegrees(), turn.yDegrees(), turn.zDegrees());
|
return ObjectRotation.of(0, turn.yDegrees(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean shouldWriteStructureMarker(PlatformBlockState state) {
|
static boolean shouldWriteStructureMarker(PlatformBlockState state) {
|
||||||
@@ -604,12 +627,11 @@ public class StructurePlacing {
|
|||||||
return hash & Integer.MAX_VALUE;
|
return hash & Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String structurePlacementMarker(IrisStructure structure, PlacedStructurePiece piece, String objectKey) {
|
private static String structurePlacementMarker(String structureKey, AssembledPiece piece, String objectKey) {
|
||||||
String structureKey = structure.getLoadKey();
|
|
||||||
if (structureKey == null || structureKey.isBlank() || objectKey == null || objectKey.isBlank()) {
|
if (structureKey == null || structureKey.isBlank() || objectKey == null || objectKey.isBlank()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int placementId = structurePlacementId(structureKey, objectKey, piece.getX(), piece.getY(), piece.getZ());
|
int placementId = structurePlacementId(structureKey, objectKey, piece.x(), piece.y(), piece.z());
|
||||||
return PlacementMarkers.encodeStructure(objectKey, placementId, structureKey);
|
return PlacementMarkers.encodeStructure(objectKey, placementId, structureKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,9 +662,11 @@ public class StructurePlacing {
|
|||||||
|| terrain.resolvedMode() == StructureTerrainMode.BORE
|
|| terrain.resolvedMode() == StructureTerrainMode.BORE
|
||||||
? Math.max(0, terrain.horizontalPadding()) : 0;
|
? Math.max(0, terrain.horizontalPadding()) : 0;
|
||||||
for (String key : placement.structures()) {
|
for (String key : placement.structures()) {
|
||||||
IrisStructure structure = StructureResources.structure(engine.getData().getPackResources(), key);
|
var pack = engine.getData().getPackResources();
|
||||||
if (structure != null) {
|
var structure = pack.idOf(key);
|
||||||
max = Math.max(max, Math.max(1, structure.getMaxSizeChunks()) * 16 + carvePadding);
|
StructureAssembly provider = IrisStructureLocator.providerOf(engine, structure);
|
||||||
|
if (provider != null) {
|
||||||
|
max = Math.max(max, Math.max(1, provider.reachChunks(pack, structure).orElse(1)) * 16 + carvePadding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-33
@@ -12,11 +12,10 @@ import art.arcane.iris.core.runtime.jigsaw.JigsawStudioSession;
|
|||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariant;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariant;
|
||||||
import art.arcane.iris.core.service.JigsawStudioBlocks;
|
import art.arcane.iris.core.service.JigsawStudioBlocks;
|
||||||
import art.arcane.iris.core.service.JigsawStudioRequest;
|
import art.arcane.iris.core.service.JigsawStudioRequest;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import com.volmit.block.BlockRegistry;
|
import com.volmit.block.BlockRegistry;
|
||||||
@@ -426,7 +425,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
"object '" + variant.objectKey() + "' does not fit workcell '" + workcell.stableId() + "'");
|
"object '" + variant.objectKey() + "' does not fit workcell '" + workcell.stableId() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectTurn rotation = ObjectTurn.of(0, -90.0D * quarterTurns, 0);
|
PieceTurn rotation = PieceTurn.aroundY(-90 * quarterTurns);
|
||||||
List<RenderedBlock> blocks = renderBlocks(resources.blocks(), object, dimensions, quarterTurns, rotation);
|
List<RenderedBlock> blocks = renderBlocks(resources.blocks(), object, dimensions, quarterTurns, rotation);
|
||||||
if (blocks == null) {
|
if (blocks == null) {
|
||||||
return RenderedBay.invalid(
|
return RenderedBay.invalid(
|
||||||
@@ -434,7 +433,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
"object '" + variant.objectKey() + "' contains an invalid or out-of-bounds block");
|
"object '" + variant.objectKey() + "' contains an invalid or out-of-bounds block");
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectorRenderResult connectors = renderConnectors(piece, object, dimensions, quarterTurns, rotation);
|
ConnectorRenderResult connectors = renderConnectors(variant.pieceKey(), piece, object, dimensions, quarterTurns, rotation);
|
||||||
if (!connectors.failure().isEmpty()) {
|
if (!connectors.failure().isEmpty()) {
|
||||||
return RenderedBay.invalid(dimensions, connectors.failure());
|
return RenderedBay.invalid(dimensions, connectors.failure());
|
||||||
}
|
}
|
||||||
@@ -446,7 +445,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
PlaceableObject object,
|
PlaceableObject object,
|
||||||
JigsawStudioCellDimensions dimensions,
|
JigsawStudioCellDimensions dimensions,
|
||||||
int quarterTurns,
|
int quarterTurns,
|
||||||
ObjectTurn rotation
|
PieceTurn rotation
|
||||||
) {
|
) {
|
||||||
BlockPosition center = object.center();
|
BlockPosition center = object.center();
|
||||||
List<ObjectBlock> sourceBlocks = object.geometry().blocks();
|
List<ObjectBlock> sourceBlocks = object.geometry().blocks();
|
||||||
@@ -491,15 +490,16 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ConnectorRenderResult renderConnectors(
|
private ConnectorRenderResult renderConnectors(
|
||||||
|
String pieceKey,
|
||||||
IrisJigsawPiece piece,
|
IrisJigsawPiece piece,
|
||||||
PlaceableObject object,
|
PlaceableObject object,
|
||||||
JigsawStudioCellDimensions dimensions,
|
JigsawStudioCellDimensions dimensions,
|
||||||
int quarterTurns,
|
int quarterTurns,
|
||||||
ObjectTurn rotation
|
PieceTurn rotation
|
||||||
) {
|
) {
|
||||||
KList<IrisJigsawConnector> sourceConnectors = piece.getConnectors();
|
List<IrisJigsawConnector> sourceConnectors = piece.getConnectors();
|
||||||
if (sourceConnectors == null) {
|
if (sourceConnectors == null) {
|
||||||
return ConnectorRenderResult.invalid("piece '" + piece.getLoadKey() + "' has no connector list");
|
return ConnectorRenderResult.invalid("piece '" + pieceKey + "' has no connector list");
|
||||||
}
|
}
|
||||||
List<RenderedConnector> connectors = new ArrayList<>(sourceConnectors.size());
|
List<RenderedConnector> connectors = new ArrayList<>(sourceConnectors.size());
|
||||||
for (int index = 0; index < sourceConnectors.size(); index++) {
|
for (int index = 0; index < sourceConnectors.size(); index++) {
|
||||||
@@ -507,29 +507,29 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
if (!validConnectorMetadata(source)) {
|
if (!validConnectorMetadata(source)) {
|
||||||
return ConnectorRenderResult.invalid("connector " + index + " has incomplete metadata");
|
return ConnectorRenderResult.invalid("connector " + index + " has incomplete metadata");
|
||||||
}
|
}
|
||||||
IrisPosition sourcePosition = source.getPosition();
|
BlockPosition sourcePosition = source.getPosition();
|
||||||
if (!inside(
|
if (!inside(
|
||||||
sourcePosition.getX(),
|
sourcePosition.x(),
|
||||||
sourcePosition.getY(),
|
sourcePosition.y(),
|
||||||
sourcePosition.getZ(),
|
sourcePosition.z(),
|
||||||
object.width(),
|
object.width(),
|
||||||
object.height(),
|
object.height(),
|
||||||
object.depth())) {
|
object.depth())) {
|
||||||
return ConnectorRenderResult.invalid("connector " + index + " is outside its object bounds");
|
return ConnectorRenderResult.invalid("connector " + index + " is outside its object bounds");
|
||||||
}
|
}
|
||||||
RotatedPosition position = rotatePosition(
|
RotatedPosition position = rotatePosition(
|
||||||
sourcePosition.getX(),
|
sourcePosition.x(),
|
||||||
sourcePosition.getY(),
|
sourcePosition.y(),
|
||||||
sourcePosition.getZ(),
|
sourcePosition.z(),
|
||||||
object.width(),
|
object.width(),
|
||||||
object.depth(),
|
object.depth(),
|
||||||
quarterTurns);
|
quarterTurns);
|
||||||
IrisDirection front = quarterTurns == 0
|
JigsawDirection front = quarterTurns == 0
|
||||||
? source.getDirection()
|
? source.getDirection()
|
||||||
: rotation.rotate(source.getDirection());
|
: source.getDirection().turnedBy(rotation.quarterTurns());
|
||||||
IrisDirection top = quarterTurns == 0
|
JigsawDirection top = quarterTurns == 0
|
||||||
? source.getTop()
|
? source.getTop()
|
||||||
: rotation.rotate(source.getTop());
|
: source.getTop().turnedBy(rotation.quarterTurns());
|
||||||
String orientation;
|
String orientation;
|
||||||
try {
|
try {
|
||||||
orientation = orientation(front, top);
|
orientation = orientation(front, top);
|
||||||
@@ -543,7 +543,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
+ source.getFinalState() + "' cannot be parsed and rotated");
|
+ source.getFinalState() + "' cannot be parsed and rotated");
|
||||||
}
|
}
|
||||||
IrisJigsawConnector connector = copyConnector(source)
|
IrisJigsawConnector connector = copyConnector(source)
|
||||||
.setPosition(new IrisPosition(position.x(), position.y(), position.z()))
|
.setPosition(new BlockPosition(position.x(), position.y(), position.z()))
|
||||||
.setDirection(front)
|
.setDirection(front)
|
||||||
.setTop(top)
|
.setTop(top)
|
||||||
.setFinalState(finalState);
|
.setFinalState(finalState);
|
||||||
@@ -562,7 +562,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
return ConnectorRenderResult.valid(connectors);
|
return ConnectorRenderResult.valid(connectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String rotatedFinalState(String finalState, ObjectTurn rotation, int quarterTurns) {
|
private String rotatedFinalState(String finalState, PieceTurn rotation, int quarterTurns) {
|
||||||
BlockRegistry registry = pack.resources().blocks();
|
BlockRegistry registry = pack.resources().blocks();
|
||||||
BlockState state = registry.find(finalState).orElse(null);
|
BlockState state = registry.find(finalState).orElse(null);
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
@@ -712,16 +712,16 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static String orientation(IrisDirection front, IrisDirection top) {
|
static String orientation(JigsawDirection front, JigsawDirection top) {
|
||||||
IrisDirection activeFront = Objects.requireNonNull(front, "Jigsaw connector front");
|
JigsawDirection activeFront = Objects.requireNonNull(front, "Jigsaw connector front");
|
||||||
IrisDirection activeTop = Objects.requireNonNull(top, "Jigsaw connector top");
|
JigsawDirection activeTop = Objects.requireNonNull(top, "Jigsaw connector top");
|
||||||
if (activeFront == IrisDirection.UP_POSITIVE_Y || activeFront == IrisDirection.DOWN_NEGATIVE_Y) {
|
if (activeFront == JigsawDirection.UP_POSITIVE_Y || activeFront == JigsawDirection.DOWN_NEGATIVE_Y) {
|
||||||
if (activeTop.isVertical()) {
|
if (activeTop.isVertical()) {
|
||||||
throw new IllegalArgumentException("Vertical jigsaw fronts require a horizontal top direction");
|
throw new IllegalArgumentException("Vertical jigsaw fronts require a horizontal top direction");
|
||||||
}
|
}
|
||||||
return directionName(activeFront) + "_" + directionName(activeTop);
|
return directionName(activeFront) + "_" + directionName(activeTop);
|
||||||
}
|
}
|
||||||
if (activeTop != IrisDirection.UP_POSITIVE_Y) {
|
if (activeTop != JigsawDirection.UP_POSITIVE_Y) {
|
||||||
throw new IllegalArgumentException("Horizontal jigsaw fronts require an upward top direction");
|
throw new IllegalArgumentException("Horizontal jigsaw fronts require an upward top direction");
|
||||||
}
|
}
|
||||||
return directionName(activeFront) + "_up";
|
return directionName(activeFront) + "_up";
|
||||||
@@ -763,10 +763,10 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
|
|
||||||
private static IrisJigsawConnector copyConnector(IrisJigsawConnector source) {
|
private static IrisJigsawConnector copyConnector(IrisJigsawConnector source) {
|
||||||
return new IrisJigsawConnector()
|
return new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition(
|
.setPosition(new BlockPosition(
|
||||||
source.getPosition().getX(),
|
source.getPosition().x(),
|
||||||
source.getPosition().getY(),
|
source.getPosition().y(),
|
||||||
source.getPosition().getZ()))
|
source.getPosition().z()))
|
||||||
.setDirection(source.getDirection())
|
.setDirection(source.getDirection())
|
||||||
.setTop(source.getTop())
|
.setTop(source.getTop())
|
||||||
.setPool(source.getPool())
|
.setPool(source.getPool())
|
||||||
@@ -779,7 +779,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
.setPlacementPriority(source.getPlacementPriority());
|
.setPlacementPriority(source.getPlacementPriority());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String directionName(IrisDirection direction) {
|
private static String directionName(JigsawDirection direction) {
|
||||||
return switch (direction) {
|
return switch (direction) {
|
||||||
case UP_POSITIVE_Y -> "up";
|
case UP_POSITIVE_Y -> "up";
|
||||||
case DOWN_NEGATIVE_Y -> "down";
|
case DOWN_NEGATIVE_Y -> "down";
|
||||||
@@ -884,7 +884,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
|||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
interface FinalStateRenderer {
|
interface FinalStateRenderer {
|
||||||
String render(String finalState, ObjectTurn rotation, int quarterTurns);
|
String render(String finalState, PieceTurn rotation, int quarterTurns);
|
||||||
}
|
}
|
||||||
|
|
||||||
record RotatedPosition(int x, int y, int z) {
|
record RotatedPosition(int x, int y, int z) {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public final class BuiltInPack {
|
|||||||
LoadedPack pack = LoadedPack.load(packFolder, ModuleHost.of(modules)
|
LoadedPack pack = LoadedPack.load(packFolder, ModuleHost.of(modules)
|
||||||
.exposing(IrisModuleHost.EXPOSED_PACKAGES.toArray(String[]::new))
|
.exposing(IrisModuleHost.EXPOSED_PACKAGES.toArray(String[]::new))
|
||||||
.reservingFields(ModuleTargets.reservedFields())
|
.reservingFields(ModuleTargets.reservedFields())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE)
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES)
|
||||||
.copyingJarsTo(folder.newFolder().toPath()));
|
.copyingJarsTo(folder.newFolder().toPath()));
|
||||||
PackModuleSet moduleSet = mock(PackModuleSet.class);
|
PackModuleSet moduleSet = mock(PackModuleSet.class);
|
||||||
when(moduleSet.pack()).thenReturn(pack);
|
when(moduleSet.pack()).thenReturn(pack);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class CarveSettingsDecodingTest {
|
|||||||
packFolder = Path.of(CarveSettingsDecodingTest.class.getResource(PACK).toURI());
|
packFolder = Path.of(CarveSettingsDecodingTest.class.getResource(PACK).toURI());
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.reservingFields(ModuleTargets.reservedFields())
|
.reservingFields(ModuleTargets.reservedFields())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class DecorantSettingsDecodingTest {
|
|||||||
Path snippets = Files.createDirectories(packFolder.resolve("snippet/iris/decorant/decorator"));
|
Path snippets = Files.createDirectories(packFolder.resolve("snippet/iris/decorant/decorator"));
|
||||||
Files.writeString(snippets.resolve("bush.json"), "{\"chance\": 0.2, \"palette\": [{\"block\": \"minecraft:fern\"}]}");
|
Files.writeString(snippets.resolve("bush.json"), "{\"chance\": 0.2, \"palette\": [{\"block\": \"minecraft:fern\"}]}");
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class DepositSettingsDecodingTest {
|
|||||||
Path snippets = Files.createDirectories(packFolder.resolve("snippet/iris/deposit/deposit"));
|
Path snippets = Files.createDirectories(packFolder.resolve("snippet/iris/deposit/deposit"));
|
||||||
Files.writeString(snippets.resolve("diamonds.json"), "{\"maxHeight\": 16, \"palette\": [{\"block\": \"minecraft:diamond_ore\"}]}");
|
Files.writeString(snippets.resolve("diamonds.json"), "{\"maxHeight\": 16, \"palette\": [{\"block\": \"minecraft:diamond_ore\"}]}");
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class FloatingSettingsDecodingTest {
|
|||||||
packFolder = Path.of(FloatingSettingsDecodingTest.class.getResource(PACK).toURI());
|
packFolder = Path.of(FloatingSettingsDecodingTest.class.getResource(PACK).toURI());
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.reservingFields(ModuleTargets.reservedFields())
|
.reservingFields(ModuleTargets.reservedFields())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class LootAndSpawnPackDecodingTest {
|
|||||||
packFolder = Path.of(LootAndSpawnPackDecodingTest.class.getResource(PACK).toURI());
|
packFolder = Path.of(LootAndSpawnPackDecodingTest.class.getResource(PACK).toURI());
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.reservingFields(ModuleTargets.reservedFields())
|
.reservingFields(ModuleTargets.reservedFields())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import com.volmit.host.LoadedPack;
|
|||||||
import com.volmit.host.ModuleRegistry;
|
import com.volmit.host.ModuleRegistry;
|
||||||
import com.volmit.host.ModuleSetups;
|
import com.volmit.host.ModuleSetups;
|
||||||
import com.volmit.host.StageGraphBuilder;
|
import com.volmit.host.StageGraphBuilder;
|
||||||
|
import com.volmit.geometry.BlockBox;
|
||||||
|
import com.volmit.object.PackObjects;
|
||||||
import com.volmit.resource.ResourceId;
|
import com.volmit.resource.ResourceId;
|
||||||
import com.volmit.resource.ResourceKind;
|
import com.volmit.resource.ResourceKind;
|
||||||
|
|
||||||
@@ -46,6 +48,7 @@ public final class ModuleResourceFixture {
|
|||||||
public static synchronized ModuleResourceFixture serve(IrisData data) {
|
public static synchronized ModuleResourceFixture serve(IrisData data) {
|
||||||
IrisPackResources resources = mock(IrisPackResources.class);
|
IrisPackResources resources = mock(IrisPackResources.class);
|
||||||
when(data.getPackResources()).thenReturn(resources);
|
when(data.getPackResources()).thenReturn(resources);
|
||||||
|
when(resources.objects()).thenReturn(mock(PackObjects.class));
|
||||||
when(resources.idOf(anyString())).thenAnswer(invocation -> idOf(invocation.getArgument(0)));
|
when(resources.idOf(anyString())).thenAnswer(invocation -> idOf(invocation.getArgument(0)));
|
||||||
when(resources.keyOf(any(ResourceId.class))).thenAnswer(invocation -> keyOf(invocation.getArgument(0)));
|
when(resources.keyOf(any(ResourceId.class))).thenAnswer(invocation -> keyOf(invocation.getArgument(0)));
|
||||||
when(resources.keyOf(any(ResourceKind.class), any(ResourceId.class))).thenAnswer(invocation -> keyOf(invocation.getArgument(1)));
|
when(resources.keyOf(any(ResourceKind.class), any(ResourceId.class))).thenAnswer(invocation -> keyOf(invocation.getArgument(1)));
|
||||||
@@ -108,6 +111,12 @@ public final class ModuleResourceFixture {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Serves a pack object {@code key} declared {@code width} by {@code height} by {@code depth}. */
|
||||||
|
public ModuleResourceFixture object(String key, int width, int height, int depth) {
|
||||||
|
when(resources.objects().sizeOf(idOf(key))).thenReturn(Optional.of(new BlockBox(0, 0, 0, width, height, depth)));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
private static ResourceId idOf(String key) {
|
private static ResourceId idOf(String key) {
|
||||||
return new ResourceId(NAMESPACE, key.toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9_./-]", "_"));
|
return new ResourceId(NAMESPACE, key.toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9_./-]", "_"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public class ModuleSettingsDecoderTest {
|
|||||||
public void loadPack() throws IOException {
|
public void loadPack() throws IOException {
|
||||||
packFolder = folder.newFolder("pack").toPath();
|
packFolder = folder.newFolder("pack").toPath();
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(List.of(new MossModule()))
|
pack = LoadedPack.load(packFolder, ModuleHost.of(List.of(new MossModule()))
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class OreSettingsDecodingTest {
|
|||||||
packFolder = Path.of(OreSettingsDecodingTest.class.getResource(PACK).toURI());
|
packFolder = Path.of(OreSettingsDecodingTest.class.getResource(PACK).toURI());
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.reservingFields(ModuleTargets.reservedFields())
|
.reservingFields(ModuleTargets.reservedFields())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class PackBeforeThePortDecodingTest {
|
|||||||
packFolder = Path.of(PackBeforeThePortDecodingTest.class.getResource(PACK).toURI());
|
packFolder = Path.of(PackBeforeThePortDecodingTest.class.getResource(PACK).toURI());
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.reservingFields(ModuleTargets.reservedFields())
|
.reservingFields(ModuleTargets.reservedFields())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -126,7 +126,7 @@ public class StructurePlacementSettingsDecodingTest {
|
|||||||
public void loadBuiltIns() throws IOException {
|
public void loadBuiltIns() throws IOException {
|
||||||
Path packFolder = folder.newFolder("pack").toPath();
|
Path packFolder = folder.newFolder("pack").toPath();
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class StructureSettingsDecodingTest {
|
|||||||
public void loadBuiltIns() throws IOException {
|
public void loadBuiltIns() throws IOException {
|
||||||
Path packFolder = folder.newFolder("pack").toPath();
|
Path packFolder = folder.newFolder("pack").toPath();
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class TerrainSettingsDecodingTest {
|
|||||||
packFolder = Path.of(TerrainSettingsDecodingTest.class.getResource(PACK).toURI());
|
packFolder = Path.of(TerrainSettingsDecodingTest.class.getResource(PACK).toURI());
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.reservingFields(ModuleTargets.reservedFields())
|
.reservingFields(ModuleTargets.reservedFields())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ public class VanillaFeaturesSettingsDecodingTest {
|
|||||||
public void loadBuiltIns() throws IOException {
|
public void loadBuiltIns() throws IOException {
|
||||||
Path packFolder = folder.newFolder("pack").toPath();
|
Path packFolder = folder.newFolder("pack").toPath();
|
||||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,13 @@ public class PackValidatorStructureGraphTest {
|
|||||||
write(pack, "structures/regional.json", "{}");
|
write(pack, "structures/regional.json", "{}");
|
||||||
write(pack, "structures/library.json", "{}");
|
write(pack, "structures/library.json", "{}");
|
||||||
|
|
||||||
assertEquals(Set.of("active", "regional"), StructureValidator.placedStructureKeys(pack));
|
art.arcane.iris.core.loader.IrisData data = art.arcane.iris.core.loader.IrisData.openValidation(pack);
|
||||||
|
try {
|
||||||
|
assertEquals(Set.of("active", "regional"), StructureValidator.placedStructureKeys(
|
||||||
|
art.arcane.iris.core.modules.IrisValidationContext.forPack(data)));
|
||||||
|
} finally {
|
||||||
|
data.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -889,7 +889,7 @@ public class SchemaBuilderParityTest {
|
|||||||
try (LoadedPack pack = LoadedPack.load(Files.createDirectory(root.resolve("pack")),
|
try (LoadedPack pack = LoadedPack.load(Files.createDirectory(root.resolve("pack")),
|
||||||
ModuleHost.of(modules)
|
ModuleHost.of(modules)
|
||||||
.exposing(IrisModuleHost.EXPOSED_PACKAGES.toArray(String[]::new))
|
.exposing(IrisModuleHost.EXPOSED_PACKAGES.toArray(String[]::new))
|
||||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE)
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES)
|
||||||
.copyingJarsTo(Files.createDirectory(root.resolve("copies"))))) {
|
.copyingJarsTo(Files.createDirectory(root.resolve("copies"))))) {
|
||||||
return pack.schema();
|
return pack.schema();
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -1,6 +1,6 @@
|
|||||||
package art.arcane.iris.core.runtime.jigsaw;
|
package art.arcane.iris.core.runtime.jigsaw;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
@@ -86,17 +86,17 @@ public class JigsawPlanarTopologyTest {
|
|||||||
new JigsawStudioPieceRules(0, 30, 0, 0, false),
|
new JigsawStudioPieceRules(0, 30, 0, 0, false),
|
||||||
List.of());
|
List.of());
|
||||||
JigsawStudioCellDimensions sourceDimensions = new JigsawStudioCellDimensions(3, 3, 5);
|
JigsawStudioCellDimensions sourceDimensions = new JigsawStudioCellDimensions(3, 3, 5);
|
||||||
IrisPosition source = new IrisPosition(2, 1, 1);
|
BlockPosition source = new BlockPosition(2, 1, 1);
|
||||||
|
|
||||||
IrisPosition canonical = east.sourceToCanonicalPosition(source, sourceDimensions);
|
BlockPosition canonical = east.sourceToCanonicalPosition(source, sourceDimensions);
|
||||||
IrisPosition restored = east.canonicalToSourcePosition(canonical, sourceDimensions);
|
BlockPosition restored = east.canonicalToSourcePosition(canonical, sourceDimensions);
|
||||||
|
|
||||||
assertEquals(new JigsawStudioCellDimensions(5, 3, 3), east.canonicalDimensions(sourceDimensions));
|
assertEquals(new JigsawStudioCellDimensions(5, 3, 3), east.canonicalDimensions(sourceDimensions));
|
||||||
assertEquals(1, canonical.getX());
|
assertEquals(1, canonical.x());
|
||||||
assertEquals(1, canonical.getY());
|
assertEquals(1, canonical.y());
|
||||||
assertEquals(0, canonical.getZ());
|
assertEquals(0, canonical.z());
|
||||||
assertEquals(source.getX(), restored.getX());
|
assertEquals(source.x(), restored.x());
|
||||||
assertEquals(source.getY(), restored.getY());
|
assertEquals(source.y(), restored.y());
|
||||||
assertEquals(source.getZ(), restored.getZ());
|
assertEquals(source.z(), restored.z());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+11
-11
@@ -1,10 +1,10 @@
|
|||||||
package art.arcane.iris.core.runtime.jigsaw;
|
package art.arcane.iris.core.runtime.jigsaw;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import art.arcane.iris.spi.PlatformBlockState;
|
import art.arcane.iris.spi.PlatformBlockState;
|
||||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
@@ -70,8 +70,8 @@ public class JigsawStudioGraphEditorResizeTest {
|
|||||||
JsonArray connectors = readJson(packRoot.resolve(
|
JsonArray connectors = readJson(packRoot.resolve(
|
||||||
"jigsaw-pieces/resize/atomic/variants/corner/variant-2.json"))
|
"jigsaw-pieces/resize/atomic/variants/corner/variant-2.json"))
|
||||||
.getAsJsonArray("connectors");
|
.getAsJsonArray("connectors");
|
||||||
assertEquals(new IrisPosition(3, 2, 0), connectorPosition(connectors, "NORTH_NEGATIVE_Z"));
|
assertEquals(new BlockPosition(3, 2, 0), connectorPosition(connectors, "NORTH_NEGATIVE_Z"));
|
||||||
assertEquals(new IrisPosition(6, 2, 4), connectorPosition(connectors, "EAST_POSITIVE_X"));
|
assertEquals(new BlockPosition(6, 2, 4), connectorPosition(connectors, "EAST_POSITIVE_X"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -124,7 +124,7 @@ public class JigsawStudioGraphEditorResizeTest {
|
|||||||
PlatformBlockState stone = state("minecraft:stone", false);
|
PlatformBlockState stone = state("minecraft:stone", false);
|
||||||
source.setUnsigned(6, 1, 2, explicitAir);
|
source.setUnsigned(6, 1, 2, explicitAir);
|
||||||
source.setUnsigned(4, 1, 1, stone);
|
source.setUnsigned(4, 1, 1, stone);
|
||||||
IrisJigsawPiece piece = endPiece(IrisDirection.EAST_POSITIVE_X, new IrisPosition(6, 1, 2));
|
IrisJigsawPiece piece = endPiece(JigsawDirection.EAST_POSITIVE_X, new BlockPosition(6, 1, 2));
|
||||||
|
|
||||||
JigsawStudioGraphEditor.PlanarPieceObjectResize result =
|
JigsawStudioGraphEditor.PlanarPieceObjectResize result =
|
||||||
JigsawStudioGraphEditor.resizePlanarPieceObject(
|
JigsawStudioGraphEditor.resizePlanarPieceObject(
|
||||||
@@ -139,7 +139,7 @@ public class JigsawStudioGraphEditorResizeTest {
|
|||||||
assertEquals(3, resized.getH());
|
assertEquals(3, resized.getH());
|
||||||
assertEquals(9, resized.getD());
|
assertEquals(9, resized.getD());
|
||||||
assertEquals(1, result.relocatedConnectors());
|
assertEquals(1, result.relocatedConnectors());
|
||||||
assertEquals(new IrisPosition(10, 1, 4), piece.getConnectors().getFirst().getPosition());
|
assertEquals(new BlockPosition(10, 1, 4), piece.getConnectors().getFirst().getPosition());
|
||||||
assertSame(explicitAir, blockAt(resized, 10, 1, 4));
|
assertSame(explicitAir, blockAt(resized, 10, 1, 4));
|
||||||
assertFalse(resized.getBlocks().containsKey(resized.getSigned(10, 1, 2)));
|
assertFalse(resized.getBlocks().containsKey(resized.getSigned(10, 1, 2)));
|
||||||
assertSame(stone, blockAt(resized, 8, 1, 1));
|
assertSame(stone, blockAt(resized, 8, 1, 1));
|
||||||
@@ -173,8 +173,8 @@ public class JigsawStudioGraphEditorResizeTest {
|
|||||||
PlatformBlockState collision = state("minecraft:stone", false);
|
PlatformBlockState collision = state("minecraft:stone", false);
|
||||||
source.setUnsigned(2, 1, 0, underlay);
|
source.setUnsigned(2, 1, 0, underlay);
|
||||||
source.setUnsigned(3, 1, 0, collision);
|
source.setUnsigned(3, 1, 0, collision);
|
||||||
IrisPosition originalPosition = new IrisPosition(2, 1, 0);
|
BlockPosition originalPosition = new BlockPosition(2, 1, 0);
|
||||||
IrisJigsawPiece piece = endPiece(IrisDirection.NORTH_NEGATIVE_Z, originalPosition.copy());
|
IrisJigsawPiece piece = endPiece(JigsawDirection.NORTH_NEGATIVE_Z, originalPosition);
|
||||||
|
|
||||||
IOException failure = assertThrows(
|
IOException failure = assertThrows(
|
||||||
IOException.class,
|
IOException.class,
|
||||||
@@ -202,7 +202,7 @@ public class JigsawStudioGraphEditorResizeTest {
|
|||||||
return packRoot;
|
return packRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisJigsawPiece endPiece(IrisDirection direction, IrisPosition position) {
|
private static IrisJigsawPiece endPiece(JigsawDirection direction, BlockPosition position) {
|
||||||
IrisJigsawPiece piece = new IrisJigsawPiece().setObject("resize/end");
|
IrisJigsawPiece piece = new IrisJigsawPiece().setObject("resize/end");
|
||||||
piece.getConnectors().add(new IrisJigsawConnector()
|
piece.getConnectors().add(new IrisJigsawConnector()
|
||||||
.setDirection(direction)
|
.setDirection(direction)
|
||||||
@@ -245,14 +245,14 @@ public class JigsawStudioGraphEditorResizeTest {
|
|||||||
throw new AssertionError("Missing planar workcell " + archetype);
|
throw new AssertionError("Missing planar workcell " + archetype);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisPosition connectorPosition(JsonArray connectors, String direction) {
|
private static BlockPosition connectorPosition(JsonArray connectors, String direction) {
|
||||||
for (int index = 0; index < connectors.size(); index++) {
|
for (int index = 0; index < connectors.size(); index++) {
|
||||||
JsonObject connector = connectors.get(index).getAsJsonObject();
|
JsonObject connector = connectors.get(index).getAsJsonObject();
|
||||||
if (!direction.equals(connector.get("direction").getAsString())) {
|
if (!direction.equals(connector.get("direction").getAsString())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
JsonObject position = connector.getAsJsonObject("position");
|
JsonObject position = connector.getAsJsonObject("position");
|
||||||
return new IrisPosition(
|
return new BlockPosition(
|
||||||
position.get("x").getAsInt(),
|
position.get("x").getAsInt(),
|
||||||
position.get("y").getAsInt(),
|
position.get("y").getAsInt(),
|
||||||
position.get("z").getAsInt());
|
position.get("z").getAsInt());
|
||||||
|
|||||||
+32
-35
@@ -2,13 +2,13 @@ package art.arcane.iris.core.runtime.jigsaw;
|
|||||||
|
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.core.loader.ResourceLoader;
|
|
||||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureBackend;
|
import art.arcane.iris.core.structure.authoring.StructureBackend;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureKey;
|
import art.arcane.iris.core.structure.authoring.StructureKey;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureOwnershipManifest;
|
import art.arcane.iris.core.structure.authoring.StructureOwnershipManifest;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureSource;
|
import art.arcane.iris.core.structure.authoring.StructureSource;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
|
import art.arcane.iris.core.service.StudioToolPacks;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
@@ -17,7 +17,6 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceRules;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcell;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcell;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@@ -44,8 +43,8 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
@Test
|
@Test
|
||||||
public void horizontalConnectorsMapToPlanarTopology() {
|
public void horizontalConnectorsMapToPlanarTopology() {
|
||||||
IrisJigsawPiece corner = new IrisJigsawPiece().setConnectors(new KList<>());
|
IrisJigsawPiece corner = new IrisJigsawPiece().setConnectors(new KList<>());
|
||||||
corner.getConnectors().add(connector(IrisDirection.NORTH_NEGATIVE_Z));
|
corner.getConnectors().add(connector(JigsawDirection.NORTH_NEGATIVE_Z));
|
||||||
corner.getConnectors().add(connector(IrisDirection.EAST_POSITIVE_X));
|
corner.getConnectors().add(connector(JigsawDirection.EAST_POSITIVE_X));
|
||||||
|
|
||||||
assertEquals(JigsawPlanarTopology.NORTH_EAST_CORNER,
|
assertEquals(JigsawPlanarTopology.NORTH_EAST_CORNER,
|
||||||
JigsawStudioGraphMapper.topologyOf(corner));
|
JigsawStudioGraphMapper.topologyOf(corner));
|
||||||
@@ -54,8 +53,8 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
@Test
|
@Test
|
||||||
public void verticalConnectorsDoNotChangePlanarMask() {
|
public void verticalConnectorsDoNotChangePlanarMask() {
|
||||||
IrisJigsawPiece end = new IrisJigsawPiece().setConnectors(new KList<>());
|
IrisJigsawPiece end = new IrisJigsawPiece().setConnectors(new KList<>());
|
||||||
end.getConnectors().add(connector(IrisDirection.WEST_NEGATIVE_X));
|
end.getConnectors().add(connector(JigsawDirection.WEST_NEGATIVE_X));
|
||||||
end.getConnectors().add(connector(IrisDirection.UP_POSITIVE_Y));
|
end.getConnectors().add(connector(JigsawDirection.UP_POSITIVE_Y));
|
||||||
|
|
||||||
assertEquals(JigsawPlanarTopology.WEST_END,
|
assertEquals(JigsawPlanarTopology.WEST_END,
|
||||||
JigsawStudioGraphMapper.topologyOf(end));
|
JigsawStudioGraphMapper.topologyOf(end));
|
||||||
@@ -72,7 +71,7 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
start.getPieces().add(new IrisJigsawPieceEntry("village/end", 7));
|
start.getPieces().add(new IrisJigsawPieceEntry("village/end", 7));
|
||||||
start.getPieces().add(new IrisJigsawPieceEntry("village/east", 5));
|
start.getPieces().add(new IrisJigsawPieceEntry("village/east", 5));
|
||||||
resources.resource(StructureResources.POOLS, "village/start", start);
|
resources.resource(StructureResources.POOLS, "village/start", start);
|
||||||
IrisJigsawPiece endPiece = planarPiece("village/end", IrisDirection.NORTH_NEGATIVE_Z)
|
IrisJigsawPiece endPiece = planarPiece("village/end", JigsawDirection.NORTH_NEGATIVE_Z)
|
||||||
.setRules(new IrisJigsawPieceRules()
|
.setRules(new IrisJigsawPieceRules()
|
||||||
.setMinimumDepth(1)
|
.setMinimumDepth(1)
|
||||||
.setMaximumDepth(4)
|
.setMaximumDepth(4)
|
||||||
@@ -82,13 +81,12 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
endPiece.getThemes().add("spruce");
|
endPiece.getThemes().add("spruce");
|
||||||
resources.resource(StructureResources.PIECES, "village/end", endPiece);
|
resources.resource(StructureResources.PIECES, "village/end", endPiece);
|
||||||
resources.resource(StructureResources.PIECES, "village/east", planarPiece(
|
resources.resource(StructureResources.PIECES, "village/east", planarPiece(
|
||||||
"village/east", IrisDirection.EAST_POSITIVE_X));
|
"village/east", JigsawDirection.EAST_POSITIVE_X));
|
||||||
IrisStructure structure = new IrisStructure()
|
IrisStructure structure = new IrisStructure()
|
||||||
.setStartPool("village/start")
|
.setStartPool("village/start")
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
||||||
|
|
||||||
JigsawStudioVariantCatalog catalog = JigsawStudioGraphMapper.catalog(
|
JigsawStudioVariantCatalog catalog = planarCatalog(data, Path.of("pack"), "village/demo", structure);
|
||||||
data, structure, JigsawStudioMode.PLANAR_JIGSAW);
|
|
||||||
JigsawStudioVariant end = catalog.find("village/end").orElseThrow();
|
JigsawStudioVariant end = catalog.find("village/end").orElseThrow();
|
||||||
JigsawStudioVariant east = catalog.find("village/east").orElseThrow();
|
JigsawStudioVariant east = catalog.find("village/east").orElseThrow();
|
||||||
|
|
||||||
@@ -110,14 +108,13 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
when(data.getDataFolder()).thenReturn(root.toFile());
|
when(data.getDataFolder()).thenReturn(root.toFile());
|
||||||
ModuleResourceFixture resources = ModuleResourceFixture.serve(data);
|
ModuleResourceFixture resources = ModuleResourceFixture.serve(data);
|
||||||
resources.resource(StructureResources.PIECES, "village/orphan", planarPiece(
|
resources.resource(StructureResources.PIECES, "village/orphan", planarPiece(
|
||||||
"village/orphan", IrisDirection.NORTH_NEGATIVE_Z));
|
"village/orphan", JigsawDirection.NORTH_NEGATIVE_Z));
|
||||||
resources.resource(StructureResources.PIECES, "village/incomplete", planarPiece(
|
resources.resource(StructureResources.PIECES, "village/incomplete", planarPiece(
|
||||||
"village/incomplete", IrisDirection.EAST_POSITIVE_X));
|
"village/incomplete", JigsawDirection.EAST_POSITIVE_X));
|
||||||
|
|
||||||
IrisStructure structure = new IrisStructure()
|
IrisStructure structure = new IrisStructure()
|
||||||
.setStartPool("village/start")
|
.setStartPool("village/start")
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
||||||
structure.setLoadKey("village/demo");
|
|
||||||
StructureKey key = new StructureKey("iris", "village/demo");
|
StructureKey key = new StructureKey("iris", "village/demo");
|
||||||
String hash = "0".repeat(64);
|
String hash = "0".repeat(64);
|
||||||
StructureOwnershipManifest manifest = new StructureOwnershipManifest(
|
StructureOwnershipManifest manifest = new StructureOwnershipManifest(
|
||||||
@@ -135,8 +132,7 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
Files.createDirectories(manifestPath.getParent());
|
Files.createDirectories(manifestPath.getParent());
|
||||||
Files.write(manifestPath, manifest.toJson());
|
Files.write(manifestPath, manifest.toJson());
|
||||||
|
|
||||||
JigsawStudioVariantCatalog catalog = JigsawStudioGraphMapper.catalog(
|
JigsawStudioVariantCatalog catalog = planarCatalog(data, root, "village/demo", structure);
|
||||||
data, structure, JigsawStudioMode.PLANAR_JIGSAW);
|
|
||||||
JigsawStudioVariant orphan = catalog.find("village/orphan").orElseThrow();
|
JigsawStudioVariant orphan = catalog.find("village/orphan").orElseThrow();
|
||||||
JigsawStudioVariant incomplete = catalog.find("village/incomplete").orElseThrow();
|
JigsawStudioVariant incomplete = catalog.find("village/incomplete").orElseThrow();
|
||||||
|
|
||||||
@@ -155,12 +151,11 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
when(data.getDataFolder()).thenReturn(root.toFile());
|
when(data.getDataFolder()).thenReturn(root.toFile());
|
||||||
ModuleResourceFixture resources = ModuleResourceFixture.serve(data);
|
ModuleResourceFixture resources = ModuleResourceFixture.serve(data);
|
||||||
resources.resource(StructureResources.PIECES, "village/managed", planarPiece(
|
resources.resource(StructureResources.PIECES, "village/managed", planarPiece(
|
||||||
"village/managed", IrisDirection.NORTH_NEGATIVE_Z));
|
"village/managed", JigsawDirection.NORTH_NEGATIVE_Z));
|
||||||
|
|
||||||
IrisStructure structure = new IrisStructure()
|
IrisStructure structure = new IrisStructure()
|
||||||
.setStartPool("village/start")
|
.setStartPool("village/start")
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
||||||
structure.setLoadKey("village/managed");
|
|
||||||
StructureKey key = new StructureKey("iris", "village/managed");
|
StructureKey key = new StructureKey("iris", "village/managed");
|
||||||
String hash = "0".repeat(64);
|
String hash = "0".repeat(64);
|
||||||
String sourcePath = "data/example/worldgen/template_pool/village/start.json";
|
String sourcePath = "data/example/worldgen/template_pool/village/start.json";
|
||||||
@@ -188,10 +183,7 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
Files.createDirectories(manifestPath.getParent());
|
Files.createDirectories(manifestPath.getParent());
|
||||||
Files.write(manifestPath, manifest.toJson());
|
Files.write(manifestPath, manifest.toJson());
|
||||||
|
|
||||||
JigsawStudioVariantCatalog catalog = JigsawStudioGraphMapper.catalog(
|
JigsawStudioVariantCatalog catalog = planarCatalog(data, root, "village/managed", structure);
|
||||||
data,
|
|
||||||
structure,
|
|
||||||
JigsawStudioMode.PLANAR_JIGSAW);
|
|
||||||
JigsawStudioVariant managed = catalog.find("village/managed").orElseThrow();
|
JigsawStudioVariant managed = catalog.find("village/managed").orElseThrow();
|
||||||
|
|
||||||
assertFalse(managed.owned());
|
assertFalse(managed.owned());
|
||||||
@@ -203,9 +195,7 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void spatialLayoutExpandsToFitLargestReachableObject() {
|
public void spatialLayoutExpandsToFitLargestReachableObject() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
ResourceLoader<IrisObject> objectLoader = mock(ResourceLoader.class);
|
ModuleResourceFixture.serve(data).object("stronghold/tall-room", 24, 32, 20);
|
||||||
when(data.getObjectLoader()).thenReturn(objectLoader);
|
|
||||||
when(objectLoader.load("stronghold/tall-room")).thenReturn(new IrisObject(24, 32, 20));
|
|
||||||
JigsawStudioVariant variant = new JigsawStudioVariant(
|
JigsawStudioVariant variant = new JigsawStudioVariant(
|
||||||
"stronghold/tall-room",
|
"stronghold/tall-room",
|
||||||
"stronghold/tall-room",
|
"stronghold/tall-room",
|
||||||
@@ -220,7 +210,7 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
List.of());
|
List.of());
|
||||||
|
|
||||||
JigsawStudioCellDimensions dimensions = JigsawStudioGraphMapper.expandSpatialDimensions(
|
JigsawStudioCellDimensions dimensions = JigsawStudioGraphMapper.expandSpatialDimensions(
|
||||||
data,
|
new JigsawStudioGraphMapper.Source(data.getPackResources(), Path.of("pack"), "stronghold"),
|
||||||
new JigsawStudioVariantCatalog(List.of(variant)),
|
new JigsawStudioVariantCatalog(List.of(variant)),
|
||||||
new JigsawStudioCellDimensions(16, 16, 16));
|
new JigsawStudioCellDimensions(16, 16, 16));
|
||||||
|
|
||||||
@@ -231,16 +221,14 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void mapsAuthorLabelsAndCanonicalPerVariantDimensionsIndependently() {
|
public void mapsAuthorLabelsAndCanonicalPerVariantDimensionsIndependently() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
ResourceLoader<IrisObject> objectLoader = mock(ResourceLoader.class);
|
|
||||||
ModuleResourceFixture resources = ModuleResourceFixture.serve(data);
|
ModuleResourceFixture resources = ModuleResourceFixture.serve(data);
|
||||||
when(data.getObjectLoader()).thenReturn(objectLoader);
|
|
||||||
IrisJigsawPool start = new IrisJigsawPool().setPieces(new KList<>());
|
IrisJigsawPool start = new IrisJigsawPool().setPieces(new KList<>());
|
||||||
start.getPieces().add(new IrisJigsawPieceEntry("village/east-gate", 1));
|
start.getPieces().add(new IrisJigsawPieceEntry("village/east-gate", 1));
|
||||||
resources.resource(StructureResources.POOLS, "village/start", start);
|
resources.resource(StructureResources.POOLS, "village/start", start);
|
||||||
IrisJigsawPiece gate = planarPiece("village/east-gate", IrisDirection.EAST_POSITIVE_X)
|
IrisJigsawPiece gate = planarPiece("village/east-gate", JigsawDirection.EAST_POSITIVE_X)
|
||||||
.setDisplayName("East Gatehouse");
|
.setDisplayName("East Gatehouse");
|
||||||
resources.resource(StructureResources.PIECES, "village/east-gate", gate);
|
resources.resource(StructureResources.PIECES, "village/east-gate", gate);
|
||||||
when(objectLoader.load("village/east-gate")).thenReturn(new IrisObject(7, 3, 5));
|
resources.object("village/east-gate", 7, 3, 5);
|
||||||
IrisStructure structure = new IrisStructure()
|
IrisStructure structure = new IrisStructure()
|
||||||
.setStartPool("village/start")
|
.setStartPool("village/start")
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
||||||
@@ -255,7 +243,7 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
true));
|
true));
|
||||||
}
|
}
|
||||||
|
|
||||||
JigsawStudioLayout layout = JigsawStudioGraphMapper.map(data, structure);
|
JigsawStudioLayout layout = map(data, structure);
|
||||||
JigsawStudioBay workcell = layout.get(JigsawPlanarArchetype.END.stableId());
|
JigsawStudioBay workcell = layout.get(JigsawPlanarArchetype.END.stableId());
|
||||||
JigsawStudioVariant variant = layout.variantCatalog().find("village/east-gate").orElseThrow();
|
JigsawStudioVariant variant = layout.variantCatalog().find("village/east-gate").orElseThrow();
|
||||||
|
|
||||||
@@ -276,7 +264,7 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
.setMode(IrisJigsawMode.SPATIAL_JIGSAW)
|
.setMode(IrisJigsawMode.SPATIAL_JIGSAW)
|
||||||
.setSpatialWorkcellDisplayName("Stronghold Rooms");
|
.setSpatialWorkcellDisplayName("Stronghold Rooms");
|
||||||
|
|
||||||
JigsawStudioBay workcell = JigsawStudioGraphMapper.map(data, structure)
|
JigsawStudioBay workcell = map(data, structure)
|
||||||
.get(JigsawStudioLayout.SPATIAL_WORKCELL_ID);
|
.get(JigsawStudioLayout.SPATIAL_WORKCELL_ID);
|
||||||
|
|
||||||
assertEquals("Spatial", workcell.canonicalDisplayName());
|
assertEquals("Spatial", workcell.canonicalDisplayName());
|
||||||
@@ -302,7 +290,7 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
archetype != IrisJigsawWorkcellArchetype.TEE));
|
archetype != IrisJigsawWorkcellArchetype.TEE));
|
||||||
}
|
}
|
||||||
|
|
||||||
JigsawStudioLayout layout = JigsawStudioGraphMapper.map(data, structure);
|
JigsawStudioLayout layout = map(data, structure);
|
||||||
|
|
||||||
assertEquals(new JigsawStudioCellDimensions(11, 9, 13),
|
assertEquals(new JigsawStudioCellDimensions(11, 9, 13),
|
||||||
layout.get("workcell/corner").bounds().dimensions());
|
layout.get("workcell/corner").bounds().dimensions());
|
||||||
@@ -312,7 +300,16 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
assertTrue(layout.variants(layout.get("workcell/tee")).isEmpty());
|
assertTrue(layout.variants(layout.get("workcell/tee")).isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisJigsawPiece planarPiece(String objectKey, IrisDirection direction) {
|
private static JigsawStudioVariantCatalog planarCatalog(IrisData data, Path root, String structureKey, IrisStructure structure) {
|
||||||
|
return JigsawStudioGraphMapper.catalog(StudioToolPacks.toolPack(data.getPackResources()), root, structureKey,
|
||||||
|
structure, JigsawStudioMode.PLANAR_JIGSAW);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JigsawStudioLayout map(IrisData data, IrisStructure structure) {
|
||||||
|
return JigsawStudioGraphMapper.map(StudioToolPacks.toolPack(data.getPackResources()), Path.of("pack"), "structure", structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IrisJigsawPiece planarPiece(String objectKey, JigsawDirection direction) {
|
||||||
IrisJigsawPiece piece = new IrisJigsawPiece()
|
IrisJigsawPiece piece = new IrisJigsawPiece()
|
||||||
.setObject(objectKey)
|
.setObject(objectKey)
|
||||||
.setConnectors(new KList<>());
|
.setConnectors(new KList<>());
|
||||||
@@ -320,7 +317,7 @@ public class JigsawStudioGraphMapperTest {
|
|||||||
return piece;
|
return piece;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisJigsawConnector connector(IrisDirection direction) {
|
private static IrisJigsawConnector connector(JigsawDirection direction) {
|
||||||
return new IrisJigsawConnector().setDirection(direction);
|
return new IrisJigsawConnector().setDirection(direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -8,7 +8,7 @@ import art.arcane.iris.engine.framework.structure.StructureAssemblyStatus;
|
|||||||
import art.arcane.iris.engine.framework.structure.StructureGraphCompilation;
|
import art.arcane.iris.engine.framework.structure.StructureGraphCompilation;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResourceBundleGraphCompiler;
|
import art.arcane.iris.engine.framework.structure.StructureResourceBundleGraphCompiler;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
@@ -200,7 +200,7 @@ public class JigsawStudioProjectCreatorTest {
|
|||||||
for (long seed : List.of(0L, 1337L)) {
|
for (long seed : List.of(0L, 1337L)) {
|
||||||
StructureAssemblyResult result = StructureAssembler.forCompilation(
|
StructureAssemblyResult result = StructureAssembler.forCompilation(
|
||||||
compilation,
|
compilation,
|
||||||
new IrisPosition(0, 64, 0)).assemble(new RNG(seed));
|
new BlockPosition(0, 64, 0)).assemble(new RNG(seed));
|
||||||
|
|
||||||
assertEquals(result.detail(), StructureAssemblyStatus.COMPLETE, result.status());
|
assertEquals(result.detail(), StructureAssemblyStatus.COMPLETE, result.status());
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,7 @@ public class JigsawStudioProjectCreatorTest {
|
|||||||
JigsawStudioProjectCreator.bundle(options)).getFirst();
|
JigsawStudioProjectCreator.bundle(options)).getFirst();
|
||||||
StructureAssemblyResult preview = StructureAssembler.forCompilation(
|
StructureAssemblyResult preview = StructureAssembler.forCompilation(
|
||||||
compilation,
|
compilation,
|
||||||
new IrisPosition(0, 0, 0)).assemble(new RNG(1337L));
|
new BlockPosition(0, 0, 0)).assemble(new RNG(1337L));
|
||||||
assertEquals(preview.detail(), StructureAssemblyStatus.COMPLETE, preview.status());
|
assertEquals(preview.detail(), StructureAssemblyStatus.COMPLETE, preview.status());
|
||||||
assertTrue(preview.pieces().size() > 1);
|
assertTrue(preview.pieces().size() > 1);
|
||||||
assertTrue(preview.pieces().size() <= 96);
|
assertTrue(preview.pieces().size() <= 96);
|
||||||
@@ -328,7 +328,7 @@ public class JigsawStudioProjectCreatorTest {
|
|||||||
temporaryDirectory,
|
temporaryDirectory,
|
||||||
"settlement/test",
|
"settlement/test",
|
||||||
"settlement/test/side",
|
"settlement/test/side",
|
||||||
new IrisPosition(8, 8, 0),
|
new BlockPosition(8, 8, 0),
|
||||||
"village/road").successful());
|
"village/road").successful());
|
||||||
JsonObject channeledPiece = JsonParser.parseString(Files.readString(
|
JsonObject channeledPiece = JsonParser.parseString(Files.readString(
|
||||||
temporaryDirectory.resolve("jigsaw-pieces/settlement/test/side.json"),
|
temporaryDirectory.resolve("jigsaw-pieces/settlement/test/side.json"),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
import com.volmit.block.BlockRegistry;
|
import com.volmit.block.BlockRegistry;
|
||||||
import com.volmit.block.BlockState;
|
import com.volmit.block.BlockState;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -18,7 +18,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class JigsawStudioBlocksTest {
|
public class JigsawStudioBlocksTest {
|
||||||
private static final ObjectTurn QUARTER_TURN = ObjectTurn.of(0, 90.0D, 0);
|
private static final PieceTurn QUARTER_TURN = PieceTurn.aroundY(90);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void aBlockTheRegistryCannotTurnComesBackAsNothingNotAsAir() {
|
public void aBlockTheRegistryCannotTurnComesBackAsNothingNotAsAir() {
|
||||||
@@ -43,7 +43,7 @@ public class JigsawStudioBlocksTest {
|
|||||||
BlockRegistry registry = mock(BlockRegistry.class);
|
BlockRegistry registry = mock(BlockRegistry.class);
|
||||||
BlockState stairs = BlockState.parse("minecraft:oak_stairs[facing=east]");
|
BlockState stairs = BlockState.parse("minecraft:oak_stairs[facing=east]");
|
||||||
|
|
||||||
assertSame(stairs, JigsawStudioBlocks.rotated(registry, stairs, ObjectTurn.of(0, 0, 0)));
|
assertSame(stairs, JigsawStudioBlocks.rotated(registry, stairs, PieceTurn.NONE));
|
||||||
verifyNoInteractions(registry);
|
verifyNoInteractions(registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioBay;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioBay;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
||||||
@@ -299,7 +298,7 @@ public class JigsawStudioLifecycleTest {
|
|||||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||||
new JigsawStudioCellDimensions(16, 16, 16),
|
new JigsawStudioCellDimensions(16, 16, 16),
|
||||||
mock(IrisData.class),
|
StudioToolPacks.toolPack(),
|
||||||
JigsawStudioLayout.create(
|
JigsawStudioLayout.create(
|
||||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||||
new JigsawStudioCellDimensions(16, 16, 16),
|
new JigsawStudioCellDimensions(16, 16, 16),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -14,18 +14,18 @@ import static org.junit.Assert.assertThrows;
|
|||||||
public class JigsawStudioMarkerParserTest {
|
public class JigsawStudioMarkerParserTest {
|
||||||
@Test
|
@Test
|
||||||
public void mapsEveryJigsawOrientation() {
|
public void mapsEveryJigsawOrientation() {
|
||||||
assertDirections("down_east", IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.EAST_POSITIVE_X);
|
assertDirections("down_east", JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.EAST_POSITIVE_X);
|
||||||
assertDirections("down_north", IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.NORTH_NEGATIVE_Z);
|
assertDirections("down_north", JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
assertDirections("down_south", IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.SOUTH_POSITIVE_Z);
|
assertDirections("down_south", JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
assertDirections("down_west", IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.WEST_NEGATIVE_X);
|
assertDirections("down_west", JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.WEST_NEGATIVE_X);
|
||||||
assertDirections("up_east", IrisDirection.UP_POSITIVE_Y, IrisDirection.EAST_POSITIVE_X);
|
assertDirections("up_east", JigsawDirection.UP_POSITIVE_Y, JigsawDirection.EAST_POSITIVE_X);
|
||||||
assertDirections("up_north", IrisDirection.UP_POSITIVE_Y, IrisDirection.NORTH_NEGATIVE_Z);
|
assertDirections("up_north", JigsawDirection.UP_POSITIVE_Y, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
assertDirections("up_south", IrisDirection.UP_POSITIVE_Y, IrisDirection.SOUTH_POSITIVE_Z);
|
assertDirections("up_south", JigsawDirection.UP_POSITIVE_Y, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
assertDirections("up_west", IrisDirection.UP_POSITIVE_Y, IrisDirection.WEST_NEGATIVE_X);
|
assertDirections("up_west", JigsawDirection.UP_POSITIVE_Y, JigsawDirection.WEST_NEGATIVE_X);
|
||||||
assertDirections("west_up", IrisDirection.WEST_NEGATIVE_X, IrisDirection.UP_POSITIVE_Y);
|
assertDirections("west_up", JigsawDirection.WEST_NEGATIVE_X, JigsawDirection.UP_POSITIVE_Y);
|
||||||
assertDirections("east_up", IrisDirection.EAST_POSITIVE_X, IrisDirection.UP_POSITIVE_Y);
|
assertDirections("east_up", JigsawDirection.EAST_POSITIVE_X, JigsawDirection.UP_POSITIVE_Y);
|
||||||
assertDirections("north_up", IrisDirection.NORTH_NEGATIVE_Z, IrisDirection.UP_POSITIVE_Y);
|
assertDirections("north_up", JigsawDirection.NORTH_NEGATIVE_Z, JigsawDirection.UP_POSITIVE_Y);
|
||||||
assertDirections("south_up", IrisDirection.SOUTH_POSITIVE_Z, IrisDirection.UP_POSITIVE_Y);
|
assertDirections("south_up", JigsawDirection.SOUTH_POSITIVE_Z, JigsawDirection.UP_POSITIVE_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -43,11 +43,11 @@ public class JigsawStudioMarkerParserTest {
|
|||||||
IrisJigsawConnector connector = JigsawStudioMarkerParser.parse(
|
IrisJigsawConnector connector = JigsawStudioMarkerParser.parse(
|
||||||
nbt, "north_up", 3, 5, 7);
|
nbt, "north_up", 3, 5, 7);
|
||||||
|
|
||||||
assertEquals(3, connector.getPosition().getX());
|
assertEquals(3, connector.getPosition().x());
|
||||||
assertEquals(5, connector.getPosition().getY());
|
assertEquals(5, connector.getPosition().y());
|
||||||
assertEquals(7, connector.getPosition().getZ());
|
assertEquals(7, connector.getPosition().z());
|
||||||
assertEquals(IrisDirection.NORTH_NEGATIVE_Z, connector.getDirection());
|
assertEquals(JigsawDirection.NORTH_NEGATIVE_Z, connector.getDirection());
|
||||||
assertEquals(IrisDirection.UP_POSITIVE_Y, connector.getTop());
|
assertEquals(JigsawDirection.UP_POSITIVE_Y, connector.getTop());
|
||||||
assertEquals("fort/pool", connector.getPool());
|
assertEquals("fort/pool", connector.getPool());
|
||||||
assertEquals("iris:door", connector.getName());
|
assertEquals("iris:door", connector.getName());
|
||||||
assertEquals("iris:door", connector.getTargetName());
|
assertEquals("iris:door", connector.getTargetName());
|
||||||
@@ -98,8 +98,8 @@ public class JigsawStudioMarkerParserTest {
|
|||||||
|
|
||||||
private static void assertDirections(
|
private static void assertDirections(
|
||||||
String orientation,
|
String orientation,
|
||||||
IrisDirection expectedFront,
|
JigsawDirection expectedFront,
|
||||||
IrisDirection expectedTop
|
JigsawDirection expectedTop
|
||||||
) {
|
) {
|
||||||
JigsawStudioMarkerParser.Directions directions = JigsawStudioMarkerParser.directions(orientation);
|
JigsawStudioMarkerParser.Directions directions = JigsawStudioMarkerParser.directions(orientation);
|
||||||
assertEquals(expectedFront, directions.front());
|
assertEquals(expectedFront, directions.front());
|
||||||
|
|||||||
+25
-8
@@ -5,15 +5,20 @@ import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMode;
|
|||||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
import art.arcane.iris.spi.PlatformBlockState;
|
import art.arcane.iris.spi.PlatformBlockState;
|
||||||
import com.volmit.ModuleLog;
|
import com.volmit.ModuleLog;
|
||||||
import com.volmit.block.BlockRegistry;
|
import com.volmit.block.BlockRegistry;
|
||||||
|
import com.volmit.object.PackObjects;
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
|
import com.volmit.resource.ResourceId;
|
||||||
import com.volmit.tooling.world.ToolWorld;
|
import com.volmit.tooling.world.ToolWorld;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -35,9 +40,9 @@ public class JigsawStudioPreviewRendererTest {
|
|||||||
when(stone.key()).thenReturn("minecraft:stone");
|
when(stone.key()).thenReturn("minecraft:stone");
|
||||||
IrisObject object = new IrisObject(3, 3, 3);
|
IrisObject object = new IrisObject(3, 3, 3);
|
||||||
object.setUnsigned(2, 1, 0, stone);
|
object.setUnsigned(2, 1, 0, stone);
|
||||||
PlacedStructurePiece piece = piece(object, 100, 70, -40, ObjectTurn.of(0, 0, 0));
|
PlacedStructurePiece piece = piece(object, 100, 70, -40, PieceTurn.NONE);
|
||||||
|
|
||||||
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(List.of(piece), registry);
|
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(List.of(piece), packOf(object));
|
||||||
|
|
||||||
assertEquals(1, plan.blocks().size());
|
assertEquals(1, plan.blocks().size());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@@ -60,7 +65,7 @@ public class JigsawStudioPreviewRendererTest {
|
|||||||
object.setUnsigned(0, 0, 0, structureVoid);
|
object.setUnsigned(0, 0, 0, structureVoid);
|
||||||
|
|
||||||
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(List.of(
|
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(List.of(
|
||||||
piece(object, 0, 65, 0, ObjectTurn.of(0, 0, 0))), registry);
|
piece(object, 0, 65, 0, PieceTurn.NONE)), packOf(object));
|
||||||
|
|
||||||
assertTrue(plan.blocks().isEmpty());
|
assertTrue(plan.blocks().isEmpty());
|
||||||
assertFalse(plan.bounds().isEmpty());
|
assertFalse(plan.bounds().isEmpty());
|
||||||
@@ -68,7 +73,7 @@ public class JigsawStudioPreviewRendererTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyAssemblyProducesAnEmptyPlan() throws Exception {
|
public void emptyAssemblyProducesAnEmptyPlan() throws Exception {
|
||||||
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(List.of(), registry);
|
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(List.of(), packOf(new IrisObject(1, 1, 1)));
|
||||||
|
|
||||||
assertTrue(plan.blocks().isEmpty());
|
assertTrue(plan.blocks().isEmpty());
|
||||||
assertTrue(plan.bounds().isEmpty());
|
assertTrue(plan.bounds().isEmpty());
|
||||||
@@ -81,7 +86,7 @@ public class JigsawStudioPreviewRendererTest {
|
|||||||
10,
|
10,
|
||||||
10,
|
10,
|
||||||
10,
|
10,
|
||||||
ObjectTurn.of(0, 0, 0));
|
PieceTurn.NONE);
|
||||||
|
|
||||||
PlacedStructurePiece planar = JigsawStudioService.alignPreviewPieces(
|
PlacedStructurePiece planar = JigsawStudioService.alignPreviewPieces(
|
||||||
List.of(source),
|
List.of(source),
|
||||||
@@ -134,19 +139,31 @@ public class JigsawStudioPreviewRendererTest {
|
|||||||
verifyNoInteractions(world);
|
verifyNoInteractions(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A pack whose only object, {@code preview}, is {@code object}, and whose blocks are {@link #registry}. */
|
||||||
|
private PackResources packOf(IrisObject object) {
|
||||||
|
PackResources pack = mock(PackResources.class);
|
||||||
|
PackObjects objects = mock(PackObjects.class);
|
||||||
|
when(pack.idOf("preview")).thenReturn(ResourceId.parse("test:preview"));
|
||||||
|
when(pack.objects()).thenReturn(objects);
|
||||||
|
when(objects.object(ResourceId.parse("test:preview"))).thenReturn(Optional.of(object));
|
||||||
|
when(pack.blocks()).thenReturn(registry);
|
||||||
|
return pack;
|
||||||
|
}
|
||||||
|
|
||||||
private static PlacedStructurePiece piece(
|
private static PlacedStructurePiece piece(
|
||||||
IrisObject object,
|
IrisObject object,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int z,
|
int z,
|
||||||
ObjectTurn rotation
|
PieceTurn rotation
|
||||||
) {
|
) {
|
||||||
int minimumX = x - object.getW() / 2;
|
int minimumX = x - object.getW() / 2;
|
||||||
int minimumY = y - object.getH() / 2;
|
int minimumY = y - object.getH() / 2;
|
||||||
int minimumZ = z - object.getD() / 2;
|
int minimumZ = z - object.getD() / 2;
|
||||||
return new PlacedStructurePiece(
|
return new PlacedStructurePiece(
|
||||||
new IrisJigsawPiece().setObject("preview"),
|
new IrisJigsawPiece().setObject("preview"),
|
||||||
object,
|
"preview",
|
||||||
|
new ObjectFrame(object.getW(), object.getH(), object.getD()),
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
z,
|
z,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import com.volmit.tooling.ToolPack;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioLayout;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioLayout;
|
||||||
@@ -38,7 +38,7 @@ public class JigsawStudioRegistryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void storesRequestAndSessionByNormalizedPackKey() {
|
public void storesRequestAndSessionByNormalizedPackKey() {
|
||||||
IrisData source = mock(IrisData.class);
|
ToolPack source = StudioToolPacks.toolPack();
|
||||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(11, 7, 11);
|
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(11, 7, 11);
|
||||||
JigsawStudioRequest request = registry.activate(
|
JigsawStudioRequest request = registry.activate(
|
||||||
"OverWorld",
|
"OverWorld",
|
||||||
@@ -61,7 +61,7 @@ public class JigsawStudioRegistryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void replacementGetsANewRequestScopedSession() {
|
public void replacementGetsANewRequestScopedSession() {
|
||||||
IrisData source = mock(IrisData.class);
|
ToolPack source = StudioToolPacks.toolPack();
|
||||||
JigsawStudioRequest first = registry.activate(
|
JigsawStudioRequest first = registry.activate(
|
||||||
"overworld",
|
"overworld",
|
||||||
"village",
|
"village",
|
||||||
@@ -90,7 +90,7 @@ public class JigsawStudioRegistryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void staleRequestCannotDeactivateItsReplacement() {
|
public void staleRequestCannotDeactivateItsReplacement() {
|
||||||
IrisData source = mock(IrisData.class);
|
ToolPack source = StudioToolPacks.toolPack();
|
||||||
JigsawStudioRequest first = registry.activate(
|
JigsawStudioRequest first = registry.activate(
|
||||||
"overworld",
|
"overworld",
|
||||||
"village",
|
"village",
|
||||||
@@ -116,7 +116,7 @@ public class JigsawStudioRegistryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void acceptsExistingGraphLayoutAsCleanInitialState() {
|
public void acceptsExistingGraphLayoutAsCleanInitialState() {
|
||||||
IrisData source = mock(IrisData.class);
|
ToolPack source = StudioToolPacks.toolPack();
|
||||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(9, 6, 9);
|
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(9, 6, 9);
|
||||||
JigsawStudioVariant variant = new JigsawStudioVariant(
|
JigsawStudioVariant variant = new JigsawStudioVariant(
|
||||||
"stronghold/hall",
|
"stronghold/hall",
|
||||||
@@ -154,7 +154,7 @@ public class JigsawStudioRegistryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void stagedSamePackReplacementKeepsPriorActivationUntilCommit() {
|
public void stagedSamePackReplacementKeepsPriorActivationUntilCommit() {
|
||||||
IrisData source = mock(IrisData.class);
|
ToolPack source = StudioToolPacks.toolPack();
|
||||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||||
JigsawStudioLayout oldLayout = JigsawStudioLayout.create(
|
JigsawStudioLayout oldLayout = JigsawStudioLayout.create(
|
||||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||||
@@ -199,7 +199,7 @@ public class JigsawStudioRegistryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void failedSamePackReplacementRollsBackWithoutReplacingPriorSession() {
|
public void failedSamePackReplacementRollsBackWithoutReplacingPriorSession() {
|
||||||
IrisData source = mock(IrisData.class);
|
ToolPack source = StudioToolPacks.toolPack();
|
||||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||||
JigsawStudioLayout layout = JigsawStudioLayout.create(
|
JigsawStudioLayout layout = JigsawStudioLayout.create(
|
||||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||||
|
|||||||
+5
-5
@@ -11,11 +11,11 @@ import art.arcane.iris.core.structure.authoring.StructureTransactionWriter;
|
|||||||
import art.arcane.iris.core.structure.authoring.StructureWriteMode;
|
import art.arcane.iris.core.structure.authoring.StructureWriteMode;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureWriteOptions;
|
import art.arcane.iris.core.structure.authoring.StructureWriteOptions;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureWriteResult;
|
import art.arcane.iris.core.structure.authoring.StructureWriteResult;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
@@ -275,9 +275,9 @@ public class JigsawStudioResourceBundleAssemblerTest {
|
|||||||
|
|
||||||
private static IrisJigsawConnector connector() {
|
private static IrisJigsawConnector connector() {
|
||||||
return new IrisJigsawConnector()
|
return new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition(0, 0, 0))
|
.setPosition(new BlockPosition(0, 0, 0))
|
||||||
.setDirection(IrisDirection.NORTH_NEGATIVE_Z)
|
.setDirection(JigsawDirection.NORTH_NEGATIVE_Z)
|
||||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||||
.setPool("fort/start")
|
.setPool("fort/start")
|
||||||
.setName("iris:door")
|
.setName("iris:door")
|
||||||
.setTargetName("iris:door")
|
.setTargetName("iris:door")
|
||||||
|
|||||||
+71
-71
@@ -1,6 +1,5 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarArchetype;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarArchetype;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarTopology;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarTopology;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioBay;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioBay;
|
||||||
@@ -17,12 +16,12 @@ import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariant;
|
|||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariantCatalog;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariantCatalog;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioWorkcellSpec;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioWorkcellSpec;
|
||||||
import art.arcane.iris.core.structure.authoring.StructureWriteResult;
|
import art.arcane.iris.core.structure.authoring.StructureWriteResult;
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import art.arcane.iris.engine.platform.studio.generators.JigsawStudioGenerator;
|
import art.arcane.iris.engine.platform.studio.generators.JigsawStudioGenerator;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.collection.KMap;
|
import art.arcane.volmlib.util.collection.KMap;
|
||||||
@@ -432,7 +431,7 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
JigsawStudioMode.PLANAR_JIGSAW,
|
JigsawStudioMode.PLANAR_JIGSAW,
|
||||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||||
dimensions,
|
dimensions,
|
||||||
mock(IrisData.class),
|
StudioToolPacks.toolPack(),
|
||||||
initialLayout);
|
initialLayout);
|
||||||
JigsawStudioSession session = service.registry().getSession(request.requestId());
|
JigsawStudioSession session = service.registry().getSession(request.requestId());
|
||||||
JigsawStudioBay initialEnd = initialLayout.get("workcell/end");
|
JigsawStudioBay initialEnd = initialLayout.get("workcell/end");
|
||||||
@@ -505,7 +504,7 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
JigsawStudioMode.PLANAR_JIGSAW,
|
JigsawStudioMode.PLANAR_JIGSAW,
|
||||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||||
dimensions,
|
dimensions,
|
||||||
mock(IrisData.class),
|
StudioToolPacks.toolPack(),
|
||||||
layout,
|
layout,
|
||||||
OWNER);
|
OWNER);
|
||||||
service.registry().finishOpen(OWNER);
|
service.registry().finishOpen(OWNER);
|
||||||
@@ -601,8 +600,8 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
JigsawStudioMode.PLANAR_JIGSAW,
|
JigsawStudioMode.PLANAR_JIGSAW,
|
||||||
dimensions,
|
dimensions,
|
||||||
JigsawStudioVariantCatalog.empty());
|
JigsawStudioVariantCatalog.empty());
|
||||||
IrisJigsawConnector eastSource = connector().setDirection(IrisDirection.EAST_POSITIVE_X);
|
IrisJigsawConnector eastSource = connector().setDirection(JigsawDirection.EAST_POSITIVE_X);
|
||||||
IrisJigsawConnector southDisplayed = connector().setDirection(IrisDirection.SOUTH_POSITIVE_Z);
|
IrisJigsawConnector southDisplayed = connector().setDirection(JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
|
|
||||||
JigsawStudioService.requireWorkcellTopology(
|
JigsawStudioService.requireWorkcellTopology(
|
||||||
layout.get("workcell/end"),
|
layout.get("workcell/end"),
|
||||||
@@ -637,15 +636,15 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
List<JigsawStudioService.ChunkCaptureArea> areas = JigsawStudioService.chunkIntersections(bounds);
|
List<JigsawStudioService.ChunkCaptureArea> areas = JigsawStudioService.chunkIntersections(bounds);
|
||||||
BlockState sourceState = BlockState.parse("minecraft:observer[facing=north]");
|
BlockState sourceState = BlockState.parse("minecraft:observer[facing=north]");
|
||||||
for (int quarterTurns = 1; quarterTurns <= 3; quarterTurns++) {
|
for (int quarterTurns = 1; quarterTurns <= 3; quarterTurns++) {
|
||||||
ObjectTurn displayRotation = ObjectTurn.of(0, -90.0D * quarterTurns, 0);
|
PieceTurn displayRotation = PieceTurn.aroundY(-90 * quarterTurns);
|
||||||
BlockState displayedState = FakeBlockRegistry.rotated(sourceState, displayRotation.blockTurn());
|
BlockState displayedState = FakeBlockRegistry.rotated(sourceState, displayRotation.blockTurn());
|
||||||
IrisDirection displayedDirection = displayRotation.rotate(IrisDirection.NORTH_NEGATIVE_Z);
|
JigsawDirection displayedDirection = JigsawDirection.NORTH_NEGATIVE_Z.turnedBy(displayRotation.quarterTurns());
|
||||||
JigsawStudioService.CapturedConnector connector = new JigsawStudioService.CapturedConnector(
|
JigsawStudioService.CapturedConnector connector = new JigsawStudioService.CapturedConnector(
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
displayedDirection,
|
displayedDirection,
|
||||||
IrisDirection.UP_POSITIVE_Y,
|
JigsawDirection.UP_POSITIVE_Y,
|
||||||
"test/pool",
|
"test/pool",
|
||||||
"door",
|
"door",
|
||||||
"door",
|
"door",
|
||||||
@@ -721,26 +720,26 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
@Test
|
@Test
|
||||||
public void noOpTeeAndCrossCapturePreservesCreatorOrderForSeededAssembly() throws IOException {
|
public void noOpTeeAndCrossCapturePreservesCreatorOrderForSeededAssembly() throws IOException {
|
||||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||||
List<List<IrisDirection>> authoredOrders = List.of(
|
List<List<JigsawDirection>> authoredOrders = List.of(
|
||||||
List.of(
|
List.of(
|
||||||
IrisDirection.NORTH_NEGATIVE_Z,
|
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
IrisDirection.EAST_POSITIVE_X,
|
JigsawDirection.EAST_POSITIVE_X,
|
||||||
IrisDirection.WEST_NEGATIVE_X),
|
JigsawDirection.WEST_NEGATIVE_X),
|
||||||
List.of(
|
List.of(
|
||||||
IrisDirection.NORTH_NEGATIVE_Z,
|
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
IrisDirection.EAST_POSITIVE_X,
|
JigsawDirection.EAST_POSITIVE_X,
|
||||||
IrisDirection.SOUTH_POSITIVE_Z,
|
JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
IrisDirection.WEST_NEGATIVE_X));
|
JigsawDirection.WEST_NEGATIVE_X));
|
||||||
List<List<IrisDirection>> captureOrders = List.of(
|
List<List<JigsawDirection>> captureOrders = List.of(
|
||||||
List.of(
|
List.of(
|
||||||
IrisDirection.WEST_NEGATIVE_X,
|
JigsawDirection.WEST_NEGATIVE_X,
|
||||||
IrisDirection.NORTH_NEGATIVE_Z,
|
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
IrisDirection.EAST_POSITIVE_X),
|
JigsawDirection.EAST_POSITIVE_X),
|
||||||
List.of(
|
List.of(
|
||||||
IrisDirection.WEST_NEGATIVE_X,
|
JigsawDirection.WEST_NEGATIVE_X,
|
||||||
IrisDirection.NORTH_NEGATIVE_Z,
|
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
IrisDirection.SOUTH_POSITIVE_Z,
|
JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
IrisDirection.EAST_POSITIVE_X));
|
JigsawDirection.EAST_POSITIVE_X));
|
||||||
|
|
||||||
for (int index = 0; index < authoredOrders.size(); index++) {
|
for (int index = 0; index < authoredOrders.size(); index++) {
|
||||||
IrisJigsawPiece source = pieceWithPlanarConnectors(dimensions, authoredOrders.get(index));
|
IrisJigsawPiece source = pieceWithPlanarConnectors(dimensions, authoredOrders.get(index));
|
||||||
@@ -758,11 +757,11 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
public void connectorMetadataEditsAtTheSamePositionKeepAuthoredOrder() throws IOException {
|
public void connectorMetadataEditsAtTheSamePositionKeepAuthoredOrder() throws IOException {
|
||||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||||
IrisJigsawPiece source = pieceWithPlanarConnectors(dimensions, List.of(
|
IrisJigsawPiece source = pieceWithPlanarConnectors(dimensions, List.of(
|
||||||
IrisDirection.NORTH_NEGATIVE_Z,
|
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
IrisDirection.EAST_POSITIVE_X));
|
JigsawDirection.EAST_POSITIVE_X));
|
||||||
IrisJigsawConnector capturedNorth = planarConnector(
|
IrisJigsawConnector capturedNorth = planarConnector(
|
||||||
dimensions,
|
dimensions,
|
||||||
IrisDirection.NORTH_NEGATIVE_Z)
|
JigsawDirection.NORTH_NEGATIVE_Z)
|
||||||
.setPool("changed/pool")
|
.setPool("changed/pool")
|
||||||
.setName("changed:name")
|
.setName("changed:name")
|
||||||
.setTargetName("changed:target")
|
.setTargetName("changed:target")
|
||||||
@@ -773,7 +772,7 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
.setPlacementPriority(-4);
|
.setPlacementPriority(-4);
|
||||||
IrisJigsawConnector capturedEast = planarConnector(
|
IrisJigsawConnector capturedEast = planarConnector(
|
||||||
dimensions,
|
dimensions,
|
||||||
IrisDirection.EAST_POSITIVE_X);
|
JigsawDirection.EAST_POSITIVE_X);
|
||||||
|
|
||||||
List<IrisJigsawConnector> ordered = JigsawStudioService.preserveCapturedConnectorOrder(
|
List<IrisJigsawConnector> ordered = JigsawStudioService.preserveCapturedConnectorOrder(
|
||||||
source,
|
source,
|
||||||
@@ -789,23 +788,23 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
public void removedConnectorsDisappearWithoutReorderingSurvivors() throws IOException {
|
public void removedConnectorsDisappearWithoutReorderingSurvivors() throws IOException {
|
||||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||||
IrisJigsawPiece source = pieceWithPlanarConnectors(dimensions, List.of(
|
IrisJigsawPiece source = pieceWithPlanarConnectors(dimensions, List.of(
|
||||||
IrisDirection.NORTH_NEGATIVE_Z,
|
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
IrisDirection.EAST_POSITIVE_X,
|
JigsawDirection.EAST_POSITIVE_X,
|
||||||
IrisDirection.WEST_NEGATIVE_X));
|
JigsawDirection.WEST_NEGATIVE_X));
|
||||||
IrisJigsawConnector capturedWest = planarConnector(
|
IrisJigsawConnector capturedWest = planarConnector(
|
||||||
dimensions,
|
dimensions,
|
||||||
IrisDirection.WEST_NEGATIVE_X);
|
JigsawDirection.WEST_NEGATIVE_X);
|
||||||
IrisJigsawConnector capturedNorth = planarConnector(
|
IrisJigsawConnector capturedNorth = planarConnector(
|
||||||
dimensions,
|
dimensions,
|
||||||
IrisDirection.NORTH_NEGATIVE_Z);
|
JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
|
|
||||||
List<IrisJigsawConnector> ordered = JigsawStudioService.preserveCapturedConnectorOrder(
|
List<IrisJigsawConnector> ordered = JigsawStudioService.preserveCapturedConnectorOrder(
|
||||||
source,
|
source,
|
||||||
List.of(capturedWest, capturedNorth));
|
List.of(capturedWest, capturedNorth));
|
||||||
|
|
||||||
assertEquals(List.of(
|
assertEquals(List.of(
|
||||||
IrisDirection.NORTH_NEGATIVE_Z,
|
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
IrisDirection.WEST_NEGATIVE_X), connectorDirections(ordered));
|
JigsawDirection.WEST_NEGATIVE_X), connectorDirections(ordered));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -813,10 +812,10 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||||
IrisJigsawPiece source = pieceWithPlanarConnectors(
|
IrisJigsawPiece source = pieceWithPlanarConnectors(
|
||||||
dimensions,
|
dimensions,
|
||||||
List.of(IrisDirection.NORTH_NEGATIVE_Z));
|
List.of(JigsawDirection.NORTH_NEGATIVE_Z));
|
||||||
IrisJigsawConnector capturedNorth = planarConnector(
|
IrisJigsawConnector capturedNorth = planarConnector(
|
||||||
dimensions,
|
dimensions,
|
||||||
IrisDirection.NORTH_NEGATIVE_Z);
|
JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
IrisJigsawConnector highY = connectorAt(2, 5, 9);
|
IrisJigsawConnector highY = connectorAt(2, 5, 9);
|
||||||
IrisJigsawConnector highZ = connectorAt(2, 3, 10);
|
IrisJigsawConnector highZ = connectorAt(2, 3, 10);
|
||||||
IrisJigsawConnector lowZ = connectorAt(2, 3, 4);
|
IrisJigsawConnector lowZ = connectorAt(2, 3, 4);
|
||||||
@@ -835,7 +834,7 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
public void duplicateSourceOrCapturedConnectorPositionsAreRejected() {
|
public void duplicateSourceOrCapturedConnectorPositionsAreRejected() {
|
||||||
IrisJigsawConnector first = connectorAt(1, 2, 3);
|
IrisJigsawConnector first = connectorAt(1, 2, 3);
|
||||||
IrisJigsawConnector second = connectorAt(1, 2, 3)
|
IrisJigsawConnector second = connectorAt(1, 2, 3)
|
||||||
.setDirection(IrisDirection.SOUTH_POSITIVE_Z);
|
.setDirection(JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
IrisJigsawPiece duplicateSource = new IrisJigsawPiece().setConnectors(new KList<>());
|
IrisJigsawPiece duplicateSource = new IrisJigsawPiece().setConnectors(new KList<>());
|
||||||
duplicateSource.getConnectors().add(first);
|
duplicateSource.getConnectors().add(first);
|
||||||
duplicateSource.getConnectors().add(second);
|
duplicateSource.getConnectors().add(second);
|
||||||
@@ -858,16 +857,16 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
new JigsawStudioCellDimensions(5, 1, 3));
|
new JigsawStudioCellDimensions(5, 1, 3));
|
||||||
List<JigsawStudioService.ChunkCaptureArea> areas = JigsawStudioService.chunkIntersections(bounds);
|
List<JigsawStudioService.ChunkCaptureArea> areas = JigsawStudioService.chunkIntersections(bounds);
|
||||||
IrisJigsawConnector sourceFirst = connectorAt(0, 0, 1)
|
IrisJigsawConnector sourceFirst = connectorAt(0, 0, 1)
|
||||||
.setDirection(IrisDirection.NORTH_NEGATIVE_Z);
|
.setDirection(JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
IrisJigsawConnector sourceSecond = connectorAt(2, 0, 2)
|
IrisJigsawConnector sourceSecond = connectorAt(2, 0, 2)
|
||||||
.setDirection(IrisDirection.EAST_POSITIVE_X);
|
.setDirection(JigsawDirection.EAST_POSITIVE_X);
|
||||||
IrisJigsawPiece source = new IrisJigsawPiece().setConnectors(new KList<>());
|
IrisJigsawPiece source = new IrisJigsawPiece().setConnectors(new KList<>());
|
||||||
source.getConnectors().add(sourceFirst);
|
source.getConnectors().add(sourceFirst);
|
||||||
source.getConnectors().add(sourceSecond);
|
source.getConnectors().add(sourceSecond);
|
||||||
BlockState sourceState = BlockState.parse("minecraft:observer[facing=north]");
|
BlockState sourceState = BlockState.parse("minecraft:observer[facing=north]");
|
||||||
|
|
||||||
for (int quarterTurns = 1; quarterTurns <= 3; quarterTurns++) {
|
for (int quarterTurns = 1; quarterTurns <= 3; quarterTurns++) {
|
||||||
ObjectTurn displayRotation = ObjectTurn.of(0, -90.0D * quarterTurns, 0);
|
PieceTurn displayRotation = PieceTurn.aroundY(-90 * quarterTurns);
|
||||||
BlockState displayedState = FakeBlockRegistry.rotated(sourceState, displayRotation.blockTurn());
|
BlockState displayedState = FakeBlockRegistry.rotated(sourceState, displayRotation.blockTurn());
|
||||||
JigsawStudioService.CapturedConnector displayedFirst = displayedConnector(
|
JigsawStudioService.CapturedConnector displayedFirst = displayedConnector(
|
||||||
sourceFirst,
|
sourceFirst,
|
||||||
@@ -1248,7 +1247,8 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
mode,
|
mode,
|
||||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||||
dimensions,
|
dimensions,
|
||||||
mock(IrisData.class),
|
mock(com.volmit.tooling.ToolPack.class),
|
||||||
|
java.nio.file.Path.of("pack"),
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1274,9 +1274,9 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
|
|
||||||
private static IrisJigsawConnector connector() {
|
private static IrisJigsawConnector connector() {
|
||||||
return new IrisJigsawConnector()
|
return new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition(0, 0, 0))
|
.setPosition(new BlockPosition(0, 0, 0))
|
||||||
.setDirection(IrisDirection.NORTH_NEGATIVE_Z)
|
.setDirection(JigsawDirection.NORTH_NEGATIVE_Z)
|
||||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||||
.setPool("fort/start")
|
.setPool("fort/start")
|
||||||
.setName("iris:door")
|
.setName("iris:door")
|
||||||
.setTargetName("iris:door")
|
.setTargetName("iris:door")
|
||||||
@@ -1285,14 +1285,14 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static IrisJigsawConnector connectorAt(int x, int y, int z) {
|
private static IrisJigsawConnector connectorAt(int x, int y, int z) {
|
||||||
return connector().setPosition(new IrisPosition(x, y, z));
|
return connector().setPosition(new BlockPosition(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisJigsawConnector planarConnector(
|
private static IrisJigsawConnector planarConnector(
|
||||||
JigsawStudioCellDimensions dimensions,
|
JigsawStudioCellDimensions dimensions,
|
||||||
IrisDirection direction
|
JigsawDirection direction
|
||||||
) {
|
) {
|
||||||
IrisPosition size = new IrisPosition(
|
BlockPosition size = new BlockPosition(
|
||||||
dimensions.width(),
|
dimensions.width(),
|
||||||
dimensions.height(),
|
dimensions.height(),
|
||||||
dimensions.depth());
|
dimensions.depth());
|
||||||
@@ -1303,10 +1303,10 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
|
|
||||||
private static List<IrisJigsawConnector> planarConnectors(
|
private static List<IrisJigsawConnector> planarConnectors(
|
||||||
JigsawStudioCellDimensions dimensions,
|
JigsawStudioCellDimensions dimensions,
|
||||||
List<IrisDirection> directions
|
List<JigsawDirection> directions
|
||||||
) {
|
) {
|
||||||
List<IrisJigsawConnector> connectors = new ArrayList<>(directions.size());
|
List<IrisJigsawConnector> connectors = new ArrayList<>(directions.size());
|
||||||
for (IrisDirection direction : directions) {
|
for (JigsawDirection direction : directions) {
|
||||||
connectors.add(planarConnector(dimensions, direction));
|
connectors.add(planarConnector(dimensions, direction));
|
||||||
}
|
}
|
||||||
return connectors;
|
return connectors;
|
||||||
@@ -1314,15 +1314,15 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
|
|
||||||
private static IrisJigsawPiece pieceWithPlanarConnectors(
|
private static IrisJigsawPiece pieceWithPlanarConnectors(
|
||||||
JigsawStudioCellDimensions dimensions,
|
JigsawStudioCellDimensions dimensions,
|
||||||
List<IrisDirection> directions
|
List<JigsawDirection> directions
|
||||||
) {
|
) {
|
||||||
IrisJigsawPiece piece = new IrisJigsawPiece().setConnectors(new KList<>());
|
IrisJigsawPiece piece = new IrisJigsawPiece().setConnectors(new KList<>());
|
||||||
piece.getConnectors().addAll(planarConnectors(dimensions, directions));
|
piece.getConnectors().addAll(planarConnectors(dimensions, directions));
|
||||||
return piece;
|
return piece;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<IrisDirection> connectorDirections(List<IrisJigsawConnector> connectors) {
|
private static List<JigsawDirection> connectorDirections(List<IrisJigsawConnector> connectors) {
|
||||||
List<IrisDirection> directions = new ArrayList<>(connectors.size());
|
List<JigsawDirection> directions = new ArrayList<>(connectors.size());
|
||||||
for (IrisJigsawConnector connector : connectors) {
|
for (IrisJigsawConnector connector : connectors) {
|
||||||
directions.add(connector.getDirection());
|
directions.add(connector.getDirection());
|
||||||
}
|
}
|
||||||
@@ -1333,19 +1333,19 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
IrisJigsawConnector source,
|
IrisJigsawConnector source,
|
||||||
JigsawStudioCellDimensions displayDimensions,
|
JigsawStudioCellDimensions displayDimensions,
|
||||||
int displayRotationQuarterTurns,
|
int displayRotationQuarterTurns,
|
||||||
ObjectTurn displayRotation,
|
PieceTurn displayRotation,
|
||||||
String finalState
|
String finalState
|
||||||
) {
|
) {
|
||||||
IrisPosition displayedPosition = displayedPosition(
|
BlockPosition displayedPosition = displayedPosition(
|
||||||
source.getPosition(),
|
source.getPosition(),
|
||||||
displayDimensions,
|
displayDimensions,
|
||||||
displayRotationQuarterTurns);
|
displayRotationQuarterTurns);
|
||||||
return new JigsawStudioService.CapturedConnector(
|
return new JigsawStudioService.CapturedConnector(
|
||||||
displayedPosition.getX(),
|
displayedPosition.x(),
|
||||||
displayedPosition.getY(),
|
displayedPosition.y(),
|
||||||
displayedPosition.getZ(),
|
displayedPosition.z(),
|
||||||
displayRotation.rotate(source.getDirection()),
|
source.getDirection().turnedBy(displayRotation.quarterTurns()),
|
||||||
displayRotation.rotate(source.getTop()),
|
source.getTop().turnedBy(displayRotation.quarterTurns()),
|
||||||
source.getPool(),
|
source.getPool(),
|
||||||
source.getName(),
|
source.getName(),
|
||||||
source.getTargetName(),
|
source.getTargetName(),
|
||||||
@@ -1356,8 +1356,8 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
source.getPlacementPriority());
|
source.getPlacementPriority());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisPosition displayedPosition(
|
private static BlockPosition displayedPosition(
|
||||||
IrisPosition source,
|
BlockPosition source,
|
||||||
JigsawStudioCellDimensions displayDimensions,
|
JigsawStudioCellDimensions displayDimensions,
|
||||||
int displayRotationQuarterTurns
|
int displayRotationQuarterTurns
|
||||||
) {
|
) {
|
||||||
@@ -1370,12 +1370,12 @@ public class JigsawStudioServiceCaptureTest {
|
|||||||
: displayDimensions.width();
|
: displayDimensions.width();
|
||||||
return switch (quarterTurns) {
|
return switch (quarterTurns) {
|
||||||
case 0 -> source;
|
case 0 -> source;
|
||||||
case 1 -> new IrisPosition(sourceDepth - 1 - source.getZ(), source.getY(), source.getX());
|
case 1 -> new BlockPosition(sourceDepth - 1 - source.z(), source.y(), source.x());
|
||||||
case 2 -> new IrisPosition(
|
case 2 -> new BlockPosition(
|
||||||
sourceWidth - 1 - source.getX(),
|
sourceWidth - 1 - source.x(),
|
||||||
source.getY(),
|
source.y(),
|
||||||
sourceDepth - 1 - source.getZ());
|
sourceDepth - 1 - source.z());
|
||||||
case 3 -> new IrisPosition(source.getZ(), source.getY(), sourceWidth - 1 - source.getX());
|
case 3 -> new BlockPosition(source.z(), source.y(), sourceWidth - 1 - source.x());
|
||||||
default -> throw new IllegalStateException("Unreachable Jigsaw Studio test rotation");
|
default -> throw new IllegalStateException("Unreachable Jigsaw Studio test rotation");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarTopology;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawPlanarTopology;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioBay;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioBay;
|
||||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
||||||
@@ -81,7 +80,7 @@ public class JigsawStudioWorldListenerTest {
|
|||||||
JigsawStudioMode.PLANAR_JIGSAW,
|
JigsawStudioMode.PLANAR_JIGSAW,
|
||||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||||
dimensions,
|
dimensions,
|
||||||
mock(IrisData.class),
|
StudioToolPacks.toolPack(),
|
||||||
layout,
|
layout,
|
||||||
OWNER);
|
OWNER);
|
||||||
service.registry().finishOpen(OWNER);
|
service.registry().finishOpen(OWNER);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package art.arcane.iris.core.service;
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.project.IrisProject;
|
import art.arcane.iris.core.project.IrisProject;
|
||||||
import art.arcane.iris.core.runtime.StudioOpenCoordinator;
|
import art.arcane.iris.core.runtime.StudioOpenCoordinator;
|
||||||
import art.arcane.iris.core.runtime.StudioSlotOccupant;
|
import art.arcane.iris.core.runtime.StudioSlotOccupant;
|
||||||
@@ -177,7 +176,7 @@ public class StudioSVCJigsawProtectionTest {
|
|||||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||||
dimensions,
|
dimensions,
|
||||||
mock(IrisData.class),
|
StudioToolPacks.toolPack(),
|
||||||
JigsawStudioLayout.create(
|
JigsawStudioLayout.create(
|
||||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||||
dimensions,
|
dimensions,
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package art.arcane.iris.core.service;
|
||||||
|
|
||||||
|
import com.volmit.resource.PackResources;
|
||||||
|
import com.volmit.tooling.PackEdit;
|
||||||
|
import com.volmit.tooling.ToolPack;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/** A pack of tool tests that runs every edit on the folder {@code pack}. */
|
||||||
|
public final class StudioToolPacks {
|
||||||
|
private static final Path PACK_FOLDER = Path.of("pack");
|
||||||
|
|
||||||
|
private StudioToolPacks() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ToolPack toolPack(PackResources resources) {
|
||||||
|
ToolPack pack = toolPack();
|
||||||
|
when(pack.resources()).thenReturn(resources);
|
||||||
|
return pack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static ToolPack toolPack() {
|
||||||
|
ToolPack pack = mock(ToolPack.class);
|
||||||
|
try {
|
||||||
|
when(pack.edit(any(PackEdit.class))).thenAnswer(invocation -> ((PackEdit<Object>) invocation.getArgument(0)).apply(PACK_FOLDER));
|
||||||
|
} catch (java.io.IOException impossible) {
|
||||||
|
throw new IllegalStateException(impossible);
|
||||||
|
}
|
||||||
|
return pack;
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-14
@@ -12,9 +12,10 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.core.structure.export.ObjectContents;
|
||||||
|
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.spi.PlatformBlockState;
|
import com.volmit.block.BlockState;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.nbt.io.NBTUtil;
|
import art.arcane.volmlib.util.nbt.io.NBTUtil;
|
||||||
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
||||||
@@ -35,8 +36,6 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
public class VillageImporterConnectorRoundTripTest {
|
public class VillageImporterConnectorRoundTripTest {
|
||||||
private static final String FINAL_STATE =
|
private static final String FINAL_STATE =
|
||||||
@@ -77,7 +76,8 @@ public class VillageImporterConnectorRoundTripTest {
|
|||||||
VanillaJigsawExportSource source = VanillaJigsawExportSource.forStructure(
|
VanillaJigsawExportSource source = VanillaJigsawExportSource.forStructure(
|
||||||
"metadata",
|
"metadata",
|
||||||
graph.structure,
|
graph.structure,
|
||||||
graph
|
graph,
|
||||||
|
graph.objects::get
|
||||||
);
|
);
|
||||||
VanillaJigsawExportResult result = new VanillaJigsawDatapackExporter().export(
|
VanillaJigsawExportResult result = new VanillaJigsawDatapackExporter().export(
|
||||||
VanillaJigsawExportRequest.builder(source, output)
|
VanillaJigsawExportRequest.builder(source, output)
|
||||||
@@ -98,11 +98,8 @@ public class VillageImporterConnectorRoundTripTest {
|
|||||||
|
|
||||||
private static TestGraph graph(IrisJigsawPiece piece, IrisJigsawConnector connector) {
|
private static TestGraph graph(IrisJigsawPiece piece, IrisJigsawConnector connector) {
|
||||||
TestGraph graph = new TestGraph();
|
TestGraph graph = new TestGraph();
|
||||||
IrisObject object = new IrisObject(3, 3, 3);
|
graph.objects.put("objects/start", ObjectContents.plain(3, 3, 3,
|
||||||
PlatformBlockState finalState = mock(PlatformBlockState.class);
|
Map.of(new BlockPosition(1, 1, 0), BlockState.parse(connector.getFinalState())), Map.of()));
|
||||||
when(finalState.key()).thenReturn(connector.getFinalState());
|
|
||||||
object.setUnsigned(1, 1, 0, finalState);
|
|
||||||
graph.objects.put("objects/start", object);
|
|
||||||
graph.pieces.put("pieces/start", piece);
|
graph.pieces.put("pieces/start", piece);
|
||||||
graph.pools.put("pools/start", new IrisJigsawPool().setPieces(new KList<>(
|
graph.pools.put("pools/start", new IrisJigsawPool().setPieces(new KList<>(
|
||||||
new IrisJigsawPieceEntry("pieces/start", 1)
|
new IrisJigsawPieceEntry("pieces/start", 1)
|
||||||
@@ -117,14 +114,13 @@ public class VillageImporterConnectorRoundTripTest {
|
|||||||
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH)
|
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH)
|
||||||
.setCompatibility(IrisJigsawCompatibility.VANILLA_PORTABLE)
|
.setCompatibility(IrisJigsawCompatibility.VANILLA_PORTABLE)
|
||||||
.setPlaceMode(ObjectPlaceMode.STRUCTURE_PIECE);
|
.setPlaceMode(ObjectPlaceMode.STRUCTURE_PIECE);
|
||||||
graph.structure.setLoadKey("metadata");
|
|
||||||
return graph;
|
return graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class TestGraph implements StructureGraphResolver {
|
private static final class TestGraph implements StructureGraphResolver {
|
||||||
private final Map<String, IrisJigsawPool> pools = new LinkedHashMap<>();
|
private final Map<String, IrisJigsawPool> pools = new LinkedHashMap<>();
|
||||||
private final Map<String, IrisJigsawPiece> pieces = new LinkedHashMap<>();
|
private final Map<String, IrisJigsawPiece> pieces = new LinkedHashMap<>();
|
||||||
private final Map<String, IrisObject> objects = new LinkedHashMap<>();
|
private final Map<String, ObjectContents> objects = new LinkedHashMap<>();
|
||||||
private IrisStructure structure;
|
private IrisStructure structure;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -138,8 +134,9 @@ public class VillageImporterConnectorRoundTripTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisObject loadObject(String key) {
|
public ObjectFrame loadObject(String key) {
|
||||||
return objects.get(key);
|
ObjectContents contents = objects.get(key);
|
||||||
|
return contents == null ? null : new ObjectFrame(contents.width(), contents.height(), contents.depth());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+29
-60
@@ -3,7 +3,12 @@ package art.arcane.iris.core.structure.export;
|
|||||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureGraphResolver;
|
import art.arcane.iris.engine.framework.structure.StructureGraphResolver;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
|
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||||
|
import com.volmit.block.BlockState;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
|
import com.volmit.object.BlockEntityData;
|
||||||
|
import com.volmit.resource.ResourceId;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawCompatibility;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawCompatibility;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
@@ -12,22 +17,13 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceRules;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceRules;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.prefab.TileData;
|
|
||||||
import art.arcane.iris.spi.IrisPlatform;
|
|
||||||
import art.arcane.iris.spi.IrisPlatforms;
|
|
||||||
import art.arcane.iris.spi.PlatformBlockState;
|
|
||||||
import art.arcane.iris.spi.PlatformRegistries;
|
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.nbt.io.NBTUtil;
|
import art.arcane.volmlib.util.nbt.io.NBTUtil;
|
||||||
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
||||||
import art.arcane.volmlib.util.nbt.tag.ListTag;
|
import art.arcane.volmlib.util.nbt.tag.ListTag;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
@@ -48,32 +44,14 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
public class VanillaJigsawDatapackExporterTest {
|
public class VanillaJigsawDatapackExporterTest {
|
||||||
private static PlatformBlockState stone;
|
private static final BlockState STONE = new BlockState("minecraft:stone");
|
||||||
|
private static final BlockState AIR = new BlockState("minecraft:air");
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void bindPlatform() {
|
|
||||||
IrisPlatforms.unbind();
|
|
||||||
stone = blockState("minecraft:stone");
|
|
||||||
PlatformRegistries registries = mock(PlatformRegistries.class);
|
|
||||||
when(registries.block(anyString())).thenReturn(stone);
|
|
||||||
IrisPlatform platform = mock(IrisPlatform.class);
|
|
||||||
when(platform.registries()).thenReturn(registries);
|
|
||||||
IrisPlatforms.bind(platform);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void unbindPlatform() {
|
|
||||||
IrisPlatforms.unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void exportsComplete26_2DirectoryAndConnectorTemplate() throws Exception {
|
public void exportsComplete26_2DirectoryAndConnectorTemplate() throws Exception {
|
||||||
TestGraph graph = connectorGraph();
|
TestGraph graph = connectorGraph();
|
||||||
@@ -166,22 +144,21 @@ public class VanillaJigsawDatapackExporterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void preservesExplicitAirAndStructureVoidConnectorFinalStates() throws Exception {
|
public void preservesExplicitAirAndStructureVoidConnectorFinalStates() throws Exception {
|
||||||
TestGraph graph = terminalGraph();
|
TestGraph graph = terminalGraph();
|
||||||
PlatformBlockState air = blockState("minecraft:air");
|
graph.objects.put("objects/start", ObjectContents.plain(3, 3, 3,
|
||||||
IrisObject object = graph.objects.get("objects/start");
|
Map.of(new BlockPosition(1, 1, 1), STONE, new BlockPosition(0, 1, 1), AIR), Map.of()));
|
||||||
object.setUnsigned(0, 1, 1, air);
|
|
||||||
IrisJigsawPiece piece = graph.pieces.get("pieces/start");
|
IrisJigsawPiece piece = graph.pieces.get("pieces/start");
|
||||||
piece.getConnectors().add(new IrisJigsawConnector()
|
piece.getConnectors().add(new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition(0, 1, 1))
|
.setPosition(new BlockPosition(0, 1, 1))
|
||||||
.setDirection(IrisDirection.WEST_NEGATIVE_X)
|
.setDirection(JigsawDirection.WEST_NEGATIVE_X)
|
||||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||||
.setPool("pools/terminal")
|
.setPool("pools/terminal")
|
||||||
.setName("studio:air")
|
.setName("studio:air")
|
||||||
.setTargetName("studio:door")
|
.setTargetName("studio:door")
|
||||||
.setFinalState("minecraft:air"));
|
.setFinalState("minecraft:air"));
|
||||||
piece.getConnectors().add(new IrisJigsawConnector()
|
piece.getConnectors().add(new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition(2, 1, 1))
|
.setPosition(new BlockPosition(2, 1, 1))
|
||||||
.setDirection(IrisDirection.EAST_POSITIVE_X)
|
.setDirection(JigsawDirection.EAST_POSITIVE_X)
|
||||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||||
.setPool("pools/terminal")
|
.setPool("pools/terminal")
|
||||||
.setName("studio:void")
|
.setName("studio:void")
|
||||||
.setTargetName("studio:door")
|
.setTargetName("studio:door")
|
||||||
@@ -211,7 +188,8 @@ public class VanillaJigsawDatapackExporterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void rejectsTilePayloadWithoutPublishingPartialOutput() {
|
public void rejectsTilePayloadWithoutPublishingPartialOutput() {
|
||||||
TestGraph graph = terminalGraph();
|
TestGraph graph = terminalGraph();
|
||||||
graph.objects.get("objects/start").setUnsignedTile(0, 0, 0, mock(TileData.class));
|
graph.objects.put("objects/start", ObjectContents.plain(3, 3, 3, Map.of(new BlockPosition(1, 1, 1), STONE),
|
||||||
|
Map.of(new BlockPosition(0, 0, 0), new BlockEntityData(ResourceId.parse("test:tile"), 0, new byte[0]))));
|
||||||
Path output = temporaryFolder.getRoot().toPath().resolve("rejected-pack");
|
Path output = temporaryFolder.getRoot().toPath().resolve("rejected-pack");
|
||||||
|
|
||||||
VanillaJigsawExportResult result = new VanillaJigsawDatapackExporter().export(
|
VanillaJigsawExportResult result = new VanillaJigsawDatapackExporter().export(
|
||||||
@@ -310,18 +288,18 @@ public class VanillaJigsawDatapackExporterTest {
|
|||||||
VanillaJigsawExportSource source = VanillaJigsawExportSource.forStructure(
|
VanillaJigsawExportSource source = VanillaJigsawExportSource.forStructure(
|
||||||
"test_structure",
|
"test_structure",
|
||||||
graph.structure,
|
graph.structure,
|
||||||
graph);
|
graph,
|
||||||
|
graph.objects::get);
|
||||||
return VanillaJigsawExportRequest.builder(source, output);
|
return VanillaJigsawExportRequest.builder(source, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TestGraph connectorGraph() {
|
private static TestGraph connectorGraph() {
|
||||||
TestGraph graph = new TestGraph();
|
TestGraph graph = new TestGraph();
|
||||||
IrisObject object = new IrisObject(3, 3, 3);
|
ObjectContents object = ObjectContents.plain(3, 3, 3, Map.of(new BlockPosition(1, 1, 0), STONE), Map.of());
|
||||||
object.setUnsigned(1, 1, 0, stone);
|
|
||||||
IrisJigsawConnector connector = new IrisJigsawConnector()
|
IrisJigsawConnector connector = new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition(1, 1, 0))
|
.setPosition(new BlockPosition(1, 1, 0))
|
||||||
.setDirection(IrisDirection.NORTH_NEGATIVE_Z)
|
.setDirection(JigsawDirection.NORTH_NEGATIVE_Z)
|
||||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||||
.setPool("pools/terminal")
|
.setPool("pools/terminal")
|
||||||
.setName("studio:source")
|
.setName("studio:source")
|
||||||
.setTargetName("studio:door")
|
.setTargetName("studio:door")
|
||||||
@@ -338,9 +316,7 @@ public class VanillaJigsawDatapackExporterTest {
|
|||||||
|
|
||||||
private static TestGraph terminalGraph() {
|
private static TestGraph terminalGraph() {
|
||||||
TestGraph graph = new TestGraph();
|
TestGraph graph = new TestGraph();
|
||||||
IrisObject object = new IrisObject(3, 3, 3);
|
graph.objects.put("objects/start", ObjectContents.plain(3, 3, 3, Map.of(new BlockPosition(1, 1, 1), STONE), Map.of()));
|
||||||
object.setUnsigned(1, 1, 1, stone);
|
|
||||||
graph.objects.put("objects/start", object);
|
|
||||||
graph.pieces.put("pieces/start", piece("objects/start"));
|
graph.pieces.put("pieces/start", piece("objects/start"));
|
||||||
graph.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
graph.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
graph.structure = structure("pools/start");
|
graph.structure = structure("pools/start");
|
||||||
@@ -349,7 +325,6 @@ public class VanillaJigsawDatapackExporterTest {
|
|||||||
|
|
||||||
private static IrisStructure structure(String startPool) {
|
private static IrisStructure structure(String startPool) {
|
||||||
IrisStructure structure = new IrisStructure();
|
IrisStructure structure = new IrisStructure();
|
||||||
structure.setLoadKey("test_structure");
|
|
||||||
structure.setStartPool(startPool);
|
structure.setStartPool(startPool);
|
||||||
structure.setMaxDepth(4);
|
structure.setMaxDepth(4);
|
||||||
structure.setMaxSizeChunks(4);
|
structure.setMaxSizeChunks(4);
|
||||||
@@ -377,13 +352,6 @@ public class VanillaJigsawDatapackExporterTest {
|
|||||||
return new IrisJigsawPieceEntry().setEmpty(true).setWeight(weight);
|
return new IrisJigsawPieceEntry().setEmpty(true).setWeight(weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PlatformBlockState blockState(String key) {
|
|
||||||
PlatformBlockState state = mock(PlatformBlockState.class);
|
|
||||||
when(state.key()).thenReturn(key);
|
|
||||||
when(state.namespace()).thenReturn(key.substring(0, key.indexOf(':')));
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static JsonObject json(Path path) throws IOException {
|
private static JsonObject json(Path path) throws IOException {
|
||||||
return JsonParser.parseString(Files.readString(path, StandardCharsets.UTF_8)).getAsJsonObject();
|
return JsonParser.parseString(Files.readString(path, StandardCharsets.UTF_8)).getAsJsonObject();
|
||||||
}
|
}
|
||||||
@@ -398,7 +366,7 @@ public class VanillaJigsawDatapackExporterTest {
|
|||||||
private static final class TestGraph implements StructureGraphResolver {
|
private static final class TestGraph implements StructureGraphResolver {
|
||||||
private final Map<String, IrisJigsawPool> pools = new LinkedHashMap<>();
|
private final Map<String, IrisJigsawPool> pools = new LinkedHashMap<>();
|
||||||
private final Map<String, IrisJigsawPiece> pieces = new LinkedHashMap<>();
|
private final Map<String, IrisJigsawPiece> pieces = new LinkedHashMap<>();
|
||||||
private final Map<String, IrisObject> objects = new LinkedHashMap<>();
|
private final Map<String, ObjectContents> objects = new LinkedHashMap<>();
|
||||||
private IrisStructure structure;
|
private IrisStructure structure;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -412,8 +380,9 @@ public class VanillaJigsawDatapackExporterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisObject loadObject(String key) {
|
public ObjectFrame loadObject(String key) {
|
||||||
return objects.get(key);
|
ObjectContents contents = objects.get(key);
|
||||||
|
return contents == null ? null : new ObjectFrame(contents.width(), contents.height(), contents.depth());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+11
-11
@@ -17,11 +17,11 @@ import art.arcane.iris.core.structure.authoring.StructureTransactionWriter;
|
|||||||
import art.arcane.iris.core.structure.conversion.IrisStructureAdoptionInputKind;
|
import art.arcane.iris.core.structure.conversion.IrisStructureAdoptionInputKind;
|
||||||
import art.arcane.iris.core.structure.conversion.IrisStructureAdoptionStrategy;
|
import art.arcane.iris.core.structure.conversion.IrisStructureAdoptionStrategy;
|
||||||
import art.arcane.iris.core.structure.export.VanillaJigsawExportFormat;
|
import art.arcane.iris.core.structure.export.VanillaJigsawExportFormat;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import com.volmit.resource.ResourceId;
|
import com.volmit.resource.ResourceId;
|
||||||
import com.volmit.tooling.Argument;
|
import com.volmit.tooling.Argument;
|
||||||
import com.volmit.tooling.Command;
|
import com.volmit.tooling.Command;
|
||||||
@@ -270,8 +270,8 @@ public class JigsawCommandsContractTest {
|
|||||||
public void pieceAddUsesCanonicalAxesForRotatedRectangularPlanarWorkcells() {
|
public void pieceAddUsesCanonicalAxesForRotatedRectangularPlanarWorkcells() {
|
||||||
JigsawStudioLayout layout = nonuniformPlanarLayout();
|
JigsawStudioLayout layout = nonuniformPlanarLayout();
|
||||||
IrisJigsawPiece eastEnd = new IrisJigsawPiece();
|
IrisJigsawPiece eastEnd = new IrisJigsawPiece();
|
||||||
eastEnd.getConnectors().add(new IrisJigsawConnector().setDirection(IrisDirection.EAST_POSITIVE_X));
|
eastEnd.getConnectors().add(new IrisJigsawConnector().setDirection(JigsawDirection.EAST_POSITIVE_X));
|
||||||
IrisObject exactObject = new IrisObject(7, 5, 13);
|
ObjectFrame exactObject = new ObjectFrame(7, 5, 13);
|
||||||
|
|
||||||
GraphMutations.PieceWorkcellResolution exact = GraphMutations.resolvePieceWorkcell(
|
GraphMutations.PieceWorkcellResolution exact = GraphMutations.resolvePieceWorkcell(
|
||||||
layout,
|
layout,
|
||||||
@@ -280,13 +280,13 @@ public class JigsawCommandsContractTest {
|
|||||||
GraphMutations.PieceWorkcellResolution oversized = GraphMutations.resolvePieceWorkcell(
|
GraphMutations.PieceWorkcellResolution oversized = GraphMutations.resolvePieceWorkcell(
|
||||||
layout,
|
layout,
|
||||||
eastEnd,
|
eastEnd,
|
||||||
new IrisObject(8, 5, 13));
|
new ObjectFrame(8, 5, 13));
|
||||||
|
|
||||||
assertEquals(JigsawPlanarArchetype.END.stableId(), exact.workcell().stableId());
|
assertEquals(JigsawPlanarArchetype.END.stableId(), exact.workcell().stableId());
|
||||||
assertEquals(new IrisPosition(13, 5, 7), exact.requiredDimensions());
|
assertEquals(new BlockPosition(13, 5, 7), exact.requiredDimensions());
|
||||||
assertEquals(new JigsawStudioCellDimensions(13, 5, 7), exact.workcell().capacity());
|
assertEquals(new JigsawStudioCellDimensions(13, 5, 7), exact.workcell().capacity());
|
||||||
assertTrue(exact.fits());
|
assertTrue(exact.fits());
|
||||||
assertTrue(exactObject.getD() > exact.workcell().capacity().depth());
|
assertTrue(exactObject.depth() > exact.workcell().capacity().depth());
|
||||||
assertFalse(oversized.fits());
|
assertFalse(oversized.fits());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,15 +299,15 @@ public class JigsawCommandsContractTest {
|
|||||||
JigsawStudioVariantCatalog.empty());
|
JigsawStudioVariantCatalog.empty());
|
||||||
IrisJigsawPiece spatialPiece = new IrisJigsawPiece();
|
IrisJigsawPiece spatialPiece = new IrisJigsawPiece();
|
||||||
spatialPiece.getConnectors().add(
|
spatialPiece.getConnectors().add(
|
||||||
new IrisJigsawConnector().setDirection(IrisDirection.EAST_POSITIVE_X));
|
new IrisJigsawConnector().setDirection(JigsawDirection.EAST_POSITIVE_X));
|
||||||
|
|
||||||
GraphMutations.PieceWorkcellResolution resolution = GraphMutations.resolvePieceWorkcell(
|
GraphMutations.PieceWorkcellResolution resolution = GraphMutations.resolvePieceWorkcell(
|
||||||
layout,
|
layout,
|
||||||
spatialPiece,
|
spatialPiece,
|
||||||
new IrisObject(7, 5, 13));
|
new ObjectFrame(7, 5, 13));
|
||||||
|
|
||||||
assertEquals(JigsawStudioLayout.SPATIAL_WORKCELL_ID, resolution.workcell().stableId());
|
assertEquals(JigsawStudioLayout.SPATIAL_WORKCELL_ID, resolution.workcell().stableId());
|
||||||
assertEquals(new IrisPosition(7, 5, 13), resolution.requiredDimensions());
|
assertEquals(new BlockPosition(7, 5, 13), resolution.requiredDimensions());
|
||||||
assertEquals(capacity, resolution.workcell().capacity());
|
assertEquals(capacity, resolution.workcell().capacity());
|
||||||
assertTrue(resolution.fits());
|
assertTrue(resolution.fits());
|
||||||
}
|
}
|
||||||
|
|||||||
+59
-65
@@ -24,17 +24,18 @@ import com.google.gson.Gson;
|
|||||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||||
|
import art.arcane.iris.core.modules.StructureModelModule;
|
||||||
|
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureGraphCatalog;
|
import art.arcane.iris.engine.framework.structure.StructureGraphCatalog;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
import art.arcane.iris.builtin.structure.NativeStructureSource;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
||||||
@@ -46,7 +47,12 @@ import art.arcane.volmlib.util.math.RNG;
|
|||||||
import com.volmit.host.ModuleLogs;
|
import com.volmit.host.ModuleLogs;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.AssembledPiece;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
|
import art.arcane.iris.engine.framework.structure.assembly.StructureStamp;
|
||||||
|
import com.volmit.resource.ResourceId;
|
||||||
import art.arcane.iris.engine.object.TestSettings;
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
|
||||||
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placement;
|
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.placement;
|
||||||
@@ -118,8 +124,8 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void locatableIndexIncludesAliasesAndSeparatesEditableFromNativePlacements() {
|
public void locatableIndexIncludesAliasesAndSeparatesEditableFromNativePlacements() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||||
IrisStructure structure = new IrisStructure();
|
IrisStructure structure = new IrisStructure();
|
||||||
structure.setLoadKey("test:city");
|
|
||||||
structure.setVanillaSource("source:city");
|
structure.setVanillaSource("source:city");
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city_definition", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city_definition", structure);
|
||||||
|
|
||||||
@@ -141,9 +147,9 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
when(dimension.getAllRegions(engine)).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>());
|
||||||
|
|
||||||
assertEquals(Set.of("test:city_definition", "test:city", "source:city", "source:native_city"),
|
assertEquals(Set.of("test:city_definition", "source:city", "source:native_city"),
|
||||||
IrisStructureLocator.locatableKeys(engine));
|
IrisStructureLocator.locatableKeys(engine));
|
||||||
assertEquals(Set.of("test:city_definition", "test:city", "source:city"),
|
assertEquals(Set.of("test:city_definition", "source:city"),
|
||||||
IrisStructureLocator.locatableEditableKeys(engine));
|
IrisStructureLocator.locatableEditableKeys(engine));
|
||||||
assertEquals(Set.of("source:native_city"), IrisStructureLocator.locatableNativeKeys(engine));
|
assertEquals(Set.of("source:native_city"), IrisStructureLocator.locatableNativeKeys(engine));
|
||||||
assertTrue(IrisStructureLocator.hasLocatableEditablePlacement(engine, "SOURCE:CITY"));
|
assertTrue(IrisStructureLocator.hasLocatableEditablePlacement(engine, "SOURCE:CITY"));
|
||||||
@@ -160,6 +166,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void nativeStructureReplacementSuppressesOnlyItsRegisteredSource() {
|
public void nativeStructureReplacementSuppressesOnlyItsRegisteredSource() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
@@ -189,8 +196,8 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void vanillaSourceRequiresExplicitDimensionSuppression() {
|
public void vanillaSourceRequiresExplicitDimensionSuppression() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||||
IrisStructure structure = new IrisStructure();
|
IrisStructure structure = new IrisStructure();
|
||||||
structure.setLoadKey("test:city");
|
|
||||||
structure.setVanillaSource("minecraft:ancient_city");
|
structure.setVanillaSource("minecraft:ancient_city");
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||||
registerSinglePieceGraph(data, structure, "test:city");
|
registerSinglePieceGraph(data, structure, "test:city");
|
||||||
@@ -220,8 +227,8 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void regionReplacementFailsInsteadOfFallingBackToNative() {
|
public void regionReplacementFailsInsteadOfFallingBackToNative() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||||
IrisStructure structure = new IrisStructure();
|
IrisStructure structure = new IrisStructure();
|
||||||
structure.setLoadKey("test:city");
|
|
||||||
structure.setVanillaSource("minecraft:ancient_city");
|
structure.setVanillaSource("minecraft:ancient_city");
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||||
registerSinglePieceGraph(data, structure, "test:city");
|
registerSinglePieceGraph(data, structure, "test:city");
|
||||||
@@ -250,21 +257,21 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void geometryFailureFailsInsteadOfFallingBackToNative() {
|
public void geometryFailureFailsInsteadOfFallingBackToNative() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||||
IrisStructure structure = new IrisStructure()
|
IrisStructure structure = new IrisStructure()
|
||||||
.setStartPool("test:start")
|
.setStartPool("test:start")
|
||||||
.setMaxDepth(1)
|
.setMaxDepth(1)
|
||||||
.setMaxSizeChunks(1)
|
.setMaxSizeChunks(1)
|
||||||
.setVanillaSource("minecraft:ancient_city");
|
.setVanillaSource("minecraft:ancient_city");
|
||||||
structure.setLoadKey("test:city");
|
|
||||||
IrisJigsawConnector source = new IrisJigsawConnector()
|
IrisJigsawConnector source = new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition(0, 0, 0))
|
.setPosition(new BlockPosition(0, 0, 0))
|
||||||
.setDirection(IrisDirection.EAST_POSITIVE_X)
|
.setDirection(JigsawDirection.EAST_POSITIVE_X)
|
||||||
.setPool("test:target")
|
.setPool("test:target")
|
||||||
.setName("source")
|
.setName("source")
|
||||||
.setTargetName("door");
|
.setTargetName("door");
|
||||||
IrisJigsawConnector target = new IrisJigsawConnector()
|
IrisJigsawConnector target = new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition(50, 0, 0))
|
.setPosition(new BlockPosition(50, 0, 0))
|
||||||
.setDirection(IrisDirection.WEST_NEGATIVE_X)
|
.setDirection(JigsawDirection.WEST_NEGATIVE_X)
|
||||||
.setPool("test:target")
|
.setPool("test:target")
|
||||||
.setName("door")
|
.setName("door")
|
||||||
.setTargetName("unused");
|
.setTargetName("unused");
|
||||||
@@ -276,22 +283,13 @@ public class IrisStructureLocatorContractTest {
|
|||||||
startPool.getPieces().add(new IrisJigsawPieceEntry("test:start-piece", 1));
|
startPool.getPieces().add(new IrisJigsawPieceEntry("test:start-piece", 1));
|
||||||
IrisJigsawPool targetPool = new IrisJigsawPool();
|
IrisJigsawPool targetPool = new IrisJigsawPool();
|
||||||
targetPool.getPieces().add(new IrisJigsawPieceEntry("test:target-piece", 1));
|
targetPool.getPieces().add(new IrisJigsawPieceEntry("test:target-piece", 1));
|
||||||
IrisObject startObject = mock(IrisObject.class);
|
ModuleResourceFixture.of(data).object("test:start-object", 1, 1, 1).object("test:target-object", 100, 1, 1);
|
||||||
IrisObject targetObject = mock(IrisObject.class);
|
|
||||||
when(startObject.getW()).thenReturn(1);
|
|
||||||
when(startObject.getH()).thenReturn(1);
|
|
||||||
when(startObject.getD()).thenReturn(1);
|
|
||||||
when(targetObject.getW()).thenReturn(100);
|
|
||||||
when(targetObject.getH()).thenReturn(1);
|
|
||||||
when(targetObject.getD()).thenReturn(1);
|
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, "test:start", startPool);
|
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, "test:start", startPool);
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, "test:target", targetPool);
|
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, "test:target", targetPool);
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, "test:start-piece", startPiece);
|
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, "test:start-piece", startPiece);
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, "test:target-piece", targetPiece);
|
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, "test:target-piece", targetPiece);
|
||||||
when(data.load(IrisObject.class, "test:start-object", false)).thenReturn(startObject);
|
assertFalse(StructureGraphCatalog.compile(data.getPackResources(), "test:city", structure, ModuleLogs.discarding()).isAssemblyViable());
|
||||||
when(data.load(IrisObject.class, "test:target-object", false)).thenReturn(targetObject);
|
|
||||||
assertFalse(StructureGraphCatalog.compile(data, structure, ModuleLogs.discarding()).isAssemblyViable());
|
|
||||||
|
|
||||||
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
withAdded(placement, "structures", "test:city");
|
withAdded(placement, "structures", "test:city");
|
||||||
@@ -312,8 +310,8 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void missingVanillaSourceFailsInsteadOfFallingBackToNative() {
|
public void missingVanillaSourceFailsInsteadOfFallingBackToNative() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||||
IrisStructure structure = new IrisStructure();
|
IrisStructure structure = new IrisStructure();
|
||||||
structure.setLoadKey("test:city");
|
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||||
registerSinglePieceGraph(data, structure, "test:city");
|
registerSinglePieceGraph(data, structure, "test:city");
|
||||||
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
@@ -335,6 +333,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void missingNonReplacementStructureFailsInsteadOfBeingSkipped() {
|
public void missingNonReplacementStructureFailsInsteadOfBeingSkipped() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||||
ModuleResourceFixture.serve(data);
|
ModuleResourceFixture.serve(data);
|
||||||
StructurePlacement placement = new StructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
withAdded(placement, "structures", "test:missing");
|
withAdded(placement, "structures", "test:missing");
|
||||||
@@ -512,6 +511,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void placementIndexIsKeptPerWorld() {
|
public void placementIndexIsKeptPerWorld() {
|
||||||
IrisData sharedData = mock(IrisData.class);
|
IrisData sharedData = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture.serveModules(sharedData, new StructureModelModule(), new StructureModule());
|
||||||
Engine firstEngine = emptyEngine(sharedData);
|
Engine firstEngine = emptyEngine(sharedData);
|
||||||
Engine secondEngine = emptyEngine(sharedData);
|
Engine secondEngine = emptyEngine(sharedData);
|
||||||
Set<String> firstIndex = IrisStructureLocator.placedKeys(firstEngine);
|
Set<String> firstIndex = IrisStructureLocator.placedKeys(firstEngine);
|
||||||
@@ -524,15 +524,15 @@ public class IrisStructureLocatorContractTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void assembledBoundsMustFitVerticallyAndHorizontally() {
|
public void assembledBoundsMustFitVerticallyAndHorizontally() {
|
||||||
KList<PlacedStructurePiece> fitting = new KList<>();
|
KList<AssembledPiece> fitting = new KList<>();
|
||||||
fitting.add(piece(-4, 1, -4, 4, 20, 4));
|
fitting.add(piece(-4, 1, -4, 4, 20, 4));
|
||||||
assertTrue(IrisStructureLocator.fitsWorldBounds(fitting, 0, 20, 0, 0, 4));
|
assertTrue(IrisStructureLocator.fitsWorldBounds(fitting, 0, 20, 0, 0, 4));
|
||||||
|
|
||||||
KList<PlacedStructurePiece> belowWorld = new KList<>();
|
KList<AssembledPiece> belowWorld = new KList<>();
|
||||||
belowWorld.add(piece(-4, -1, -4, 4, 20, 4));
|
belowWorld.add(piece(-4, -1, -4, 4, 20, 4));
|
||||||
assertFalse(IrisStructureLocator.fitsWorldBounds(belowWorld, 0, 20, 0, 0, 4));
|
assertFalse(IrisStructureLocator.fitsWorldBounds(belowWorld, 0, 20, 0, 0, 4));
|
||||||
|
|
||||||
KList<PlacedStructurePiece> outsideRadius = new KList<>();
|
KList<AssembledPiece> outsideRadius = new KList<>();
|
||||||
outsideRadius.add(piece(-4, 1, -4, 5, 20, 4));
|
outsideRadius.add(piece(-4, 1, -4, 5, 20, 4));
|
||||||
assertFalse(IrisStructureLocator.fitsWorldBounds(outsideRadius, 0, 20, 0, 0, 4));
|
assertFalse(IrisStructureLocator.fitsWorldBounds(outsideRadius, 0, 20, 0, 0, 4));
|
||||||
}
|
}
|
||||||
@@ -556,9 +556,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
String selectedKey = IrisStructureLocator.selectStructureKey(placement, selectsLast);
|
String selectedKey = IrisStructureLocator.selectStructureKey(placement, selectsLast);
|
||||||
assertEquals("test:second", selectedKey);
|
assertEquals("test:second", selectedKey);
|
||||||
|
|
||||||
IrisStructure selected = new IrisStructure();
|
StructureStamp selected = new StructureStamp(ObjectPlaceMode.STRUCTURE_PIECE, List.of(), List.of(), "minecraft:second");
|
||||||
selected.setLoadKey("test:second");
|
|
||||||
selected.setVanillaSource("minecraft:second");
|
|
||||||
IrisStructureLocator.ResolvedPlacement resolved = new IrisStructureLocator.ResolvedPlacement(
|
IrisStructureLocator.ResolvedPlacement resolved = new IrisStructureLocator.ResolvedPlacement(
|
||||||
placement, selectedKey, selected, new KList<>(), selectsLast, 0, 64, 0, false);
|
placement, selectedKey, selected, new KList<>(), selectsLast, 0, 64, 0, false);
|
||||||
assertFalse(IrisStructureLocator.matchesResolved(resolved, "test:first"));
|
assertFalse(IrisStructureLocator.matchesResolved(resolved, "test:first"));
|
||||||
@@ -573,40 +571,40 @@ public class IrisStructureLocatorContractTest {
|
|||||||
TestSettings.with(placement, "minHeight", -10);
|
TestSettings.with(placement, "minHeight", -10);
|
||||||
TestSettings.with(placement, "maxHeight", 10);
|
TestSettings.with(placement, "maxHeight", 10);
|
||||||
|
|
||||||
KList<PlacedStructurePiece> movable = new KList<>();
|
KList<AssembledPiece> movable = new KList<>();
|
||||||
movable.add(piece(-4, -10, -4, 4, 5, 4));
|
movable.add(piece(-4, -10, -4, 4, 5, 4));
|
||||||
assertEquals(Integer.valueOf(10), IrisStructureLocator.resolveVerticalShift(movable, placement, -10, 0, 319));
|
assertEquals(Integer.valueOf(10), IrisStructureLocator.resolveVerticalShift(movable, placement, -10, 0, 319));
|
||||||
|
|
||||||
KList<PlacedStructurePiece> tooTall = new KList<>();
|
KList<AssembledPiece> tooTall = new KList<>();
|
||||||
tooTall.add(piece(-4, -100, -4, 4, 400, 4));
|
tooTall.add(piece(-4, -100, -4, 4, 400, 4));
|
||||||
assertNull(IrisStructureLocator.resolveVerticalShift(tooTall, placement, 0, 0, 319));
|
assertNull(IrisStructureLocator.resolveVerticalShift(tooTall, placement, 0, 0, 319));
|
||||||
|
|
||||||
TestSettings.with(placement, "underground", false);
|
TestSettings.with(placement, "underground", false);
|
||||||
KList<PlacedStructurePiece> clippedSurface = new KList<>();
|
KList<AssembledPiece> clippedSurface = new KList<>();
|
||||||
clippedSurface.add(piece(-4, 300, -4, 4, 330, 4));
|
clippedSurface.add(piece(-4, 300, -4, 4, 330, 4));
|
||||||
assertNull(IrisStructureLocator.resolveVerticalShift(clippedSurface, placement, 300, -64, 319));
|
assertNull(IrisStructureLocator.resolveVerticalShift(clippedSurface, placement, 300, -64, 319));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void caveAssemblyBoundsAlignToTheRequestedAnchorFace() {
|
public void caveAssemblyBoundsAlignToTheRequestedAnchorFace() {
|
||||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
KList<AssembledPiece> pieces = new KList<>();
|
||||||
pieces.add(piece(-2, 10, -2, 2, 14, 2));
|
pieces.add(piece(-2, 10, -2, 2, 14, 2));
|
||||||
StructurePlacement placement = new StructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
|
|
||||||
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_FLOOR);
|
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_FLOOR);
|
||||||
KList<PlacedStructurePiece> floor = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
KList<AssembledPiece> floor = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||||
assertEquals(40, floor.getFirst().getMinY());
|
assertEquals(40, floor.getFirst().minY());
|
||||||
assertEquals(44, floor.getFirst().getMaxY());
|
assertEquals(44, floor.getFirst().maxY());
|
||||||
|
|
||||||
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_CEILING);
|
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_CEILING);
|
||||||
KList<PlacedStructurePiece> ceiling = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
KList<AssembledPiece> ceiling = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||||
assertEquals(36, ceiling.getFirst().getMinY());
|
assertEquals(36, ceiling.getFirst().minY());
|
||||||
assertEquals(40, ceiling.getFirst().getMaxY());
|
assertEquals(40, ceiling.getFirst().maxY());
|
||||||
|
|
||||||
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_CENTER);
|
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_CENTER);
|
||||||
KList<PlacedStructurePiece> center = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
KList<AssembledPiece> center = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||||
assertEquals(38, center.getFirst().getMinY());
|
assertEquals(38, center.getFirst().minY());
|
||||||
assertEquals(42, center.getFirst().getMaxY());
|
assertEquals(42, center.getFirst().maxY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -637,7 +635,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
TestSettings.with(placement, "underground", true);
|
TestSettings.with(placement, "underground", true);
|
||||||
TestSettings.with(placement, "minHeight", -64);
|
TestSettings.with(placement, "minHeight", -64);
|
||||||
TestSettings.with(placement, "maxHeight", 100);
|
TestSettings.with(placement, "maxHeight", 100);
|
||||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
KList<AssembledPiece> pieces = new KList<>();
|
||||||
pieces.add(piece(0, 60, 0, 1, 80, 0));
|
pieces.add(piece(0, 60, 0, 1, 80, 0));
|
||||||
|
|
||||||
assertEquals(Integer.valueOf(-5), IrisStructureLocator.resolveUndergroundBurialShift(
|
assertEquals(Integer.valueOf(-5), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||||
@@ -660,7 +658,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
TestSettings.with(placement, "minHeight", -64);
|
TestSettings.with(placement, "minHeight", -64);
|
||||||
TestSettings.with(placement, "maxHeight", 100);
|
TestSettings.with(placement, "maxHeight", 100);
|
||||||
TestSettings.with(placement, "terrain", forceCarve("\"horizontalPadding\":2,\"ceilingPadding\":20,\"shape\":\"ERODED\""));
|
TestSettings.with(placement, "terrain", forceCarve("\"horizontalPadding\":2,\"ceilingPadding\":20,\"shape\":\"ERODED\""));
|
||||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
KList<AssembledPiece> pieces = new KList<>();
|
||||||
pieces.add(piece(0, 60, 0, 1, 80, 1));
|
pieces.add(piece(0, 60, 0, 1, 80, 1));
|
||||||
|
|
||||||
assertEquals(Integer.valueOf(-14), IrisStructureLocator.resolveUndergroundBurialShift(
|
assertEquals(Integer.valueOf(-14), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||||
@@ -686,7 +684,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
|
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
|
||||||
StructurePlacement placement = placement("underground", true, "minHeight", -64, "maxHeight", 100, "terrain", forceCarve("\"shape\":\"ROUNDED\",\"horizontalPadding\":0,\"ceilingPadding\":0"));
|
StructurePlacement placement = placement("underground", true, "minHeight", -64, "maxHeight", 100, "terrain", forceCarve("\"shape\":\"ROUNDED\",\"horizontalPadding\":0,\"ceilingPadding\":0"));
|
||||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
KList<AssembledPiece> pieces = new KList<>();
|
||||||
pieces.add(piece(4, 60, 7, 4, 80, 7));
|
pieces.add(piece(4, 60, 7, 4, 80, 7));
|
||||||
|
|
||||||
assertEquals(Integer.valueOf(0), IrisStructureLocator.resolveUndergroundBurialShift(
|
assertEquals(Integer.valueOf(0), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||||
@@ -697,23 +695,19 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void exactYOnlyCoversPlacementPathsWithResolvedAbsoluteAnchors() {
|
public void exactYOnlyCoversPlacementPathsWithResolvedAbsoluteAnchors() {
|
||||||
StructurePlacement placement = new StructurePlacement();
|
StructurePlacement placement = new StructurePlacement();
|
||||||
IrisStructure structure = new IrisStructure();
|
KList<AssembledPiece> onePiece = new KList<>();
|
||||||
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
|
||||||
KList<PlacedStructurePiece> onePiece = new KList<>();
|
|
||||||
onePiece.add(piece(-4, 1, -4, 4, 20, 4));
|
onePiece.add(piece(-4, 1, -4, 4, 20, 4));
|
||||||
assertFalse(IrisStructureLocator.hasExactY(placement, structure, onePiece));
|
assertFalse(IrisStructureLocator.hasExactY(placement, stamp(ObjectPlaceMode.CENTER_HEIGHT), onePiece));
|
||||||
|
|
||||||
structure.setPlaceMode(ObjectPlaceMode.STRUCTURE_PIECE);
|
assertTrue(IrisStructureLocator.hasExactY(placement, stamp(ObjectPlaceMode.STRUCTURE_PIECE), onePiece));
|
||||||
assertTrue(IrisStructureLocator.hasExactY(placement, structure, onePiece));
|
|
||||||
|
|
||||||
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
|
||||||
TestSettings.with(placement, "underground", true);
|
TestSettings.with(placement, "underground", true);
|
||||||
assertTrue(IrisStructureLocator.hasExactY(placement, structure, onePiece));
|
assertTrue(IrisStructureLocator.hasExactY(placement, stamp(ObjectPlaceMode.CENTER_HEIGHT), onePiece));
|
||||||
|
|
||||||
TestSettings.with(placement, "underground", false);
|
TestSettings.with(placement, "underground", false);
|
||||||
KList<PlacedStructurePiece> multiplePieces = new KList<>(onePiece);
|
KList<AssembledPiece> multiplePieces = new KList<>(onePiece);
|
||||||
multiplePieces.add(piece(5, 1, -4, 12, 20, 4));
|
multiplePieces.add(piece(5, 1, -4, 12, 20, 4));
|
||||||
assertTrue(IrisStructureLocator.hasExactY(placement, structure, multiplePieces));
|
assertTrue(IrisStructureLocator.hasExactY(placement, stamp(ObjectPlaceMode.CENTER_HEIGHT), multiplePieces));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -778,8 +772,12 @@ public class IrisStructureLocatorContractTest {
|
|||||||
return dx * dx + dz * dz;
|
return dx * dx + dz * dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlacedStructurePiece piece(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
private AssembledPiece piece(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||||
return new PlacedStructurePiece(null, null, 0, 0, 0, null, minX, minY, minZ, maxX, maxY, maxZ);
|
return new AssembledPiece(new ResourceId("test", "piece"), 0, 0, 0, PieceTurn.NONE, minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
private StructureStamp stamp(ObjectPlaceMode placeMode) {
|
||||||
|
return new StructureStamp(placeMode, List.of(), List.of(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Engine emptyEngine(IrisData data) {
|
private Engine emptyEngine(IrisData data) {
|
||||||
@@ -797,8 +795,8 @@ public class IrisStructureLocatorContractTest {
|
|||||||
private Engine densityEngine(double density, boolean underground, int worldMin, int worldHeight,
|
private Engine densityEngine(double density, boolean underground, int worldMin, int worldHeight,
|
||||||
int placementMin, int placementMax) {
|
int placementMin, int placementMax) {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||||
IrisStructure structure = new IrisStructure();
|
IrisStructure structure = new IrisStructure();
|
||||||
structure.setLoadKey("test:density");
|
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:density", structure);
|
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:density", structure);
|
||||||
registerSinglePieceGraph(data, structure, "test:density");
|
registerSinglePieceGraph(data, structure, "test:density");
|
||||||
|
|
||||||
@@ -836,13 +834,9 @@ public class IrisStructureLocatorContractTest {
|
|||||||
pool.getPieces().add(new IrisJigsawPieceEntry().setPiece(pieceKey).setWeight(1));
|
pool.getPieces().add(new IrisJigsawPieceEntry().setPiece(pieceKey).setWeight(1));
|
||||||
IrisJigsawPiece piece = new IrisJigsawPiece();
|
IrisJigsawPiece piece = new IrisJigsawPiece();
|
||||||
piece.setObject(objectKey);
|
piece.setObject(objectKey);
|
||||||
IrisObject object = mock(IrisObject.class);
|
ModuleResourceFixture.of(data).object(objectKey, 1, 1, 1);
|
||||||
when(object.getW()).thenReturn(1);
|
|
||||||
when(object.getH()).thenReturn(1);
|
|
||||||
when(object.getD()).thenReturn(1);
|
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, poolKey, pool);
|
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, poolKey, pool);
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, pieceKey, piece);
|
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, pieceKey, piece);
|
||||||
when(data.load(IrisObject.class, objectKey, false)).thenReturn(object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertReplacementFailure(Runnable operation, String expectedMessage) {
|
private void assertReplacementFailure(Runnable operation, String expectedMessage) {
|
||||||
|
|||||||
@@ -18,12 +18,11 @@
|
|||||||
|
|
||||||
package art.arcane.iris.engine.framework;
|
package art.arcane.iris.engine.framework;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.MapStructureResolver;
|
||||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureAssemblyStatus;
|
import art.arcane.iris.engine.framework.structure.StructureAssemblyStatus;
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
|
||||||
@@ -32,8 +31,6 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceRules;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceRules;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import art.arcane.iris.spi.IrisPlatform;
|
import art.arcane.iris.spi.IrisPlatform;
|
||||||
@@ -41,7 +38,7 @@ import art.arcane.iris.spi.IrisPlatforms;
|
|||||||
import art.arcane.iris.spi.PlatformBlockState;
|
import art.arcane.iris.spi.PlatformBlockState;
|
||||||
import art.arcane.iris.spi.PlatformRegistries;
|
import art.arcane.iris.spi.PlatformRegistries;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import com.volmit.host.ModuleLogs;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -77,16 +74,16 @@ public class StructureAssemblerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void attachedNonRotatablePieceKeepsItsAuthoredFacing() {
|
public void attachedNonRotatablePieceKeepsItsAuthoredFacing() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawConnector startConnector = connector(IrisDirection.EAST_POSITIVE_X, "target", "start", "door");
|
IrisJigsawConnector startConnector = connector(JigsawDirection.EAST_POSITIVE_X, "target", "start", "door");
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false, startConnector);
|
IrisJigsawPiece startPiece = piece("start-object", false, startConnector);
|
||||||
IrisJigsawConnector candidateConnector = connector(IrisDirection.NORTH_NEGATIVE_Z, "", "door", "");
|
IrisJigsawConnector candidateConnector = connector(JigsawDirection.NORTH_NEGATIVE_Z, "", "door", "");
|
||||||
IrisJigsawPiece candidatePiece = piece("candidate-object", false, candidateConnector);
|
IrisJigsawPiece candidatePiece = piece("candidate-object", false, candidateConnector);
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("target", pool("", "candidate-piece"));
|
fixture.pool("target", pool("", "candidate-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("candidate-piece", candidatePiece);
|
fixture.piece("candidate-piece", candidatePiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("candidate-object", new IrisObject(1, 1, 1));
|
fixture.object("candidate-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
StructureAssemblyResult fixed = fixture.assembler(
|
StructureAssemblyResult fixed = fixture.assembler(
|
||||||
structure("start", 1), 0, 0, 0).assemble(new RNG(11L));
|
structure("start", 1), 0, 0, 0).assemble(new RNG(11L));
|
||||||
@@ -105,20 +102,20 @@ public class StructureAssemblerTest {
|
|||||||
public void fallbackCandidatesAreTriedAfterPrimaryCandidatesFail() {
|
public void fallbackCandidatesAreTriedAfterPrimaryCandidatesFail() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
||||||
IrisJigsawPiece incompatiblePiece = piece("incompatible-object", false,
|
IrisJigsawPiece incompatiblePiece = piece("incompatible-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||||
IrisJigsawPiece fallbackPiece = piece("fallback-object", false,
|
IrisJigsawPiece fallbackPiece = piece("fallback-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("branch", pool("fallback", "incompatible-piece"));
|
fixture.pool("branch", pool("fallback", "incompatible-piece"));
|
||||||
fixture.pool("fallback", pool("", "fallback-piece"));
|
fixture.pool("fallback", pool("", "fallback-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("incompatible-piece", incompatiblePiece);
|
fixture.piece("incompatible-piece", incompatiblePiece);
|
||||||
fixture.piece("fallback-piece", fallbackPiece);
|
fixture.piece("fallback-piece", fallbackPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("incompatible-object", new IrisObject(1, 1, 1));
|
fixture.object("incompatible-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("fallback-object", new IrisObject(1, 1, 1));
|
fixture.object("fallback-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
List<PlacedStructurePiece> placed = completedPieces(
|
List<PlacedStructurePiece> placed = completedPieces(
|
||||||
fixture.assembler(structure("start", 2), 0, 0, 0), new RNG(29L));
|
fixture.assembler(structure("start", 2), 0, 0, 0), new RNG(29L));
|
||||||
@@ -139,21 +136,21 @@ public class StructureAssemblerTest {
|
|||||||
public void branchTerminationPolicyEndsOnlyAnUnmatchedOptionalBranch() {
|
public void branchTerminationPolicyEndsOnlyAnUnmatchedOptionalBranch() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "target", "start", "door"),
|
connector(JigsawDirection.EAST_POSITIVE_X, "target", "start", "door"),
|
||||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "sibling", "start", "hall"));
|
connector(JigsawDirection.SOUTH_POSITIVE_Z, "sibling", "start", "hall"));
|
||||||
IrisJigsawPiece incompatiblePiece = piece("incompatible-object", false,
|
IrisJigsawPiece incompatiblePiece = piece("incompatible-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||||
IrisJigsawPiece siblingPiece = piece("sibling-object", false,
|
IrisJigsawPiece siblingPiece = piece("sibling-object", false,
|
||||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "", "hall", ""));
|
connector(JigsawDirection.NORTH_NEGATIVE_Z, "", "hall", ""));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("target", pool("", "incompatible-piece"));
|
fixture.pool("target", pool("", "incompatible-piece"));
|
||||||
fixture.pool("sibling", pool("", "sibling-piece"));
|
fixture.pool("sibling", pool("", "sibling-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("incompatible-piece", incompatiblePiece);
|
fixture.piece("incompatible-piece", incompatiblePiece);
|
||||||
fixture.piece("sibling-piece", siblingPiece);
|
fixture.piece("sibling-piece", siblingPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("incompatible-object", new IrisObject(1, 1, 1));
|
fixture.object("incompatible-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("sibling-object", new IrisObject(1, 1, 1));
|
fixture.object("sibling-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
StructureAssemblyResult strict = fixture.assembler(
|
StructureAssemblyResult strict = fixture.assembler(
|
||||||
structure("start", 2), 0, 0, 0).assemble(new RNG(17L));
|
structure("start", 2), 0, 0, 0).assemble(new RNG(17L));
|
||||||
@@ -173,17 +170,17 @@ public class StructureAssemblerTest {
|
|||||||
public void requiredFallbackOverridesBranchTerminationPolicy() {
|
public void requiredFallbackOverridesBranchTerminationPolicy() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "target", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "target", "start", "door"));
|
||||||
IrisJigsawPiece capPiece = piece("cap-object", false,
|
IrisJigsawPiece capPiece = piece("cap-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", "unused"));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", "unused"));
|
||||||
capPiece.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
capPiece.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("target", pool("caps"));
|
fixture.pool("target", pool("caps"));
|
||||||
fixture.pool("caps", pool("", "cap-piece"));
|
fixture.pool("caps", pool("", "cap-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("cap-piece", capPiece);
|
fixture.piece("cap-piece", capPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("cap-object", new IrisObject(64, 1, 1));
|
fixture.object("cap-object", new ObjectFrame(64, 1, 1));
|
||||||
IrisStructure structure = structure("start", 2)
|
IrisStructure structure = structure("start", 2)
|
||||||
.setMaxSizeChunks(1)
|
.setMaxSizeChunks(1)
|
||||||
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
||||||
@@ -203,9 +200,9 @@ public class StructureAssemblerTest {
|
|||||||
public void explicitEmptyAndEmptyPrimaryPoolsCutOffDirectFallback() {
|
public void explicitEmptyAndEmptyPrimaryPoolsCutOffDirectFallback() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "target", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "target", "start", "door"));
|
||||||
IrisJigsawPiece fallbackPiece = piece("fallback-object", false,
|
IrisJigsawPiece fallbackPiece = piece("fallback-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
IrisJigsawPool explicitEmpty = pool("fallback");
|
IrisJigsawPool explicitEmpty = pool("fallback");
|
||||||
explicitEmpty.getPieces().add(new IrisJigsawPieceEntry().setEmpty(true).setWeight(1));
|
explicitEmpty.getPieces().add(new IrisJigsawPieceEntry().setEmpty(true).setWeight(1));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
@@ -213,8 +210,8 @@ public class StructureAssemblerTest {
|
|||||||
fixture.pool("fallback", pool("", "fallback-piece"));
|
fixture.pool("fallback", pool("", "fallback-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("fallback-piece", fallbackPiece);
|
fixture.piece("fallback-piece", fallbackPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("fallback-object", new IrisObject(1, 1, 1));
|
fixture.object("fallback-object", new ObjectFrame(1, 1, 1));
|
||||||
IrisStructure structure = structure("start", 2)
|
IrisStructure structure = structure("start", 2)
|
||||||
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
||||||
|
|
||||||
@@ -233,25 +230,25 @@ public class StructureAssemblerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void alignedRuntimeConnectorsPreserveTopOrientation() {
|
public void alignedRuntimeConnectorsPreserveTopOrientation() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawConnector source = connector(IrisDirection.EAST_POSITIVE_X, "target", "start", "door")
|
IrisJigsawConnector source = connector(JigsawDirection.EAST_POSITIVE_X, "target", "start", "door")
|
||||||
.setJoint(JigsawJoint.ALIGNED)
|
.setJoint(JigsawJoint.ALIGNED)
|
||||||
.setTop(IrisDirection.UP_POSITIVE_Y);
|
.setTop(JigsawDirection.UP_POSITIVE_Y);
|
||||||
IrisJigsawConnector target = connector(IrisDirection.WEST_NEGATIVE_X, "target", "door", "unused")
|
IrisJigsawConnector target = connector(JigsawDirection.WEST_NEGATIVE_X, "target", "door", "unused")
|
||||||
.setTop(IrisDirection.DOWN_NEGATIVE_Y);
|
.setTop(JigsawDirection.DOWN_NEGATIVE_Y);
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false, source);
|
IrisJigsawPiece startPiece = piece("start-object", false, source);
|
||||||
IrisJigsawPiece targetPiece = piece("target-object", false, target);
|
IrisJigsawPiece targetPiece = piece("target-object", false, target);
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("target", pool("", "target-piece"));
|
fixture.pool("target", pool("", "target-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("target-piece", targetPiece);
|
fixture.piece("target-piece", targetPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("target-object", new IrisObject(1, 1, 1));
|
fixture.object("target-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
assertEquals(StructureAssemblyStatus.FAILED_UNCAPPED,
|
assertEquals(StructureAssemblyStatus.FAILED_UNCAPPED,
|
||||||
fixture.assembler(structure("start", 1), 0, 0, 0)
|
fixture.assembler(structure("start", 1), 0, 0, 0)
|
||||||
.assemble(new RNG(13L)).status());
|
.assemble(new RNG(13L)).status());
|
||||||
|
|
||||||
target.setTop(IrisDirection.UP_POSITIVE_Y);
|
target.setTop(JigsawDirection.UP_POSITIVE_Y);
|
||||||
List<PlacedStructurePiece> placed = completedPieces(
|
List<PlacedStructurePiece> placed = completedPieces(
|
||||||
fixture.assembler(structure("start", 1), 0, 0, 0), new RNG(13L));
|
fixture.assembler(structure("start", 1), 0, 0, 0), new RNG(13L));
|
||||||
assertEquals(2, placed.size());
|
assertEquals(2, placed.size());
|
||||||
@@ -261,31 +258,31 @@ public class StructureAssemblerTest {
|
|||||||
public void planarCanonicalSocketsPlaceEveryNeighborOnTheExactCellGrid() {
|
public void planarCanonicalSocketsPlaceEveryNeighborOnTheExactCellGrid() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawConnector northSource = connector(
|
IrisJigsawConnector northSource = connector(
|
||||||
IrisDirection.NORTH_NEGATIVE_Z, "north", "start", "door")
|
JigsawDirection.NORTH_NEGATIVE_Z, "north", "start", "door")
|
||||||
.setPosition(new IrisPosition(8, 4, 0));
|
.setPosition(new BlockPosition(8, 4, 0));
|
||||||
IrisJigsawConnector eastSource = connector(
|
IrisJigsawConnector eastSource = connector(
|
||||||
IrisDirection.EAST_POSITIVE_X, "east", "start", "door")
|
JigsawDirection.EAST_POSITIVE_X, "east", "start", "door")
|
||||||
.setPosition(new IrisPosition(15, 4, 8));
|
.setPosition(new BlockPosition(15, 4, 8));
|
||||||
IrisJigsawConnector southSource = connector(
|
IrisJigsawConnector southSource = connector(
|
||||||
IrisDirection.SOUTH_POSITIVE_Z, "south", "start", "door")
|
JigsawDirection.SOUTH_POSITIVE_Z, "south", "start", "door")
|
||||||
.setPosition(new IrisPosition(8, 4, 15));
|
.setPosition(new BlockPosition(8, 4, 15));
|
||||||
IrisJigsawConnector westSource = connector(
|
IrisJigsawConnector westSource = connector(
|
||||||
IrisDirection.WEST_NEGATIVE_X, "west", "start", "door")
|
JigsawDirection.WEST_NEGATIVE_X, "west", "start", "door")
|
||||||
.setPosition(new IrisPosition(0, 4, 8));
|
.setPosition(new BlockPosition(0, 4, 8));
|
||||||
IrisJigsawPiece startPiece = piece(
|
IrisJigsawPiece startPiece = piece(
|
||||||
"start-object", false, northSource, eastSource, southSource, westSource);
|
"start-object", false, northSource, eastSource, southSource, westSource);
|
||||||
IrisJigsawPiece northPiece = piece("north-object", false,
|
IrisJigsawPiece northPiece = piece("north-object", false,
|
||||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "", "door", "")
|
connector(JigsawDirection.SOUTH_POSITIVE_Z, "", "door", "")
|
||||||
.setPosition(new IrisPosition(8, 4, 15)));
|
.setPosition(new BlockPosition(8, 4, 15)));
|
||||||
IrisJigsawPiece eastPiece = piece("east-object", false,
|
IrisJigsawPiece eastPiece = piece("east-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", "")
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", "")
|
||||||
.setPosition(new IrisPosition(0, 4, 8)));
|
.setPosition(new BlockPosition(0, 4, 8)));
|
||||||
IrisJigsawPiece southPiece = piece("south-object", false,
|
IrisJigsawPiece southPiece = piece("south-object", false,
|
||||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "", "door", "")
|
connector(JigsawDirection.NORTH_NEGATIVE_Z, "", "door", "")
|
||||||
.setPosition(new IrisPosition(8, 4, 0)));
|
.setPosition(new BlockPosition(8, 4, 0)));
|
||||||
IrisJigsawPiece westPiece = piece("west-object", false,
|
IrisJigsawPiece westPiece = piece("west-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "", "door", "")
|
connector(JigsawDirection.EAST_POSITIVE_X, "", "door", "")
|
||||||
.setPosition(new IrisPosition(15, 4, 8)));
|
.setPosition(new BlockPosition(15, 4, 8)));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("north", pool("", "north-piece"));
|
fixture.pool("north", pool("", "north-piece"));
|
||||||
fixture.pool("east", pool("", "east-piece"));
|
fixture.pool("east", pool("", "east-piece"));
|
||||||
@@ -296,14 +293,14 @@ public class StructureAssemblerTest {
|
|||||||
fixture.piece("east-piece", eastPiece);
|
fixture.piece("east-piece", eastPiece);
|
||||||
fixture.piece("south-piece", southPiece);
|
fixture.piece("south-piece", southPiece);
|
||||||
fixture.piece("west-piece", westPiece);
|
fixture.piece("west-piece", westPiece);
|
||||||
fixture.object("start-object", new IrisObject(16, 8, 16));
|
fixture.object("start-object", new ObjectFrame(16, 8, 16));
|
||||||
fixture.object("north-object", new IrisObject(16, 8, 16));
|
fixture.object("north-object", new ObjectFrame(16, 8, 16));
|
||||||
fixture.object("east-object", new IrisObject(16, 8, 16));
|
fixture.object("east-object", new ObjectFrame(16, 8, 16));
|
||||||
fixture.object("south-object", new IrisObject(16, 8, 16));
|
fixture.object("south-object", new ObjectFrame(16, 8, 16));
|
||||||
fixture.object("west-object", new IrisObject(16, 8, 16));
|
fixture.object("west-object", new ObjectFrame(16, 8, 16));
|
||||||
IrisStructure structure = structure("start", 1)
|
IrisStructure structure = structure("start", 1)
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||||
.setCellSize(new IrisPosition(16, 8, 16));
|
.setCellSize(new BlockPosition(16, 8, 16));
|
||||||
|
|
||||||
List<PlacedStructurePiece> placed = completedPieces(
|
List<PlacedStructurePiece> placed = completedPieces(
|
||||||
fixture.assembler(structure, 32, 64, -48), new RNG(127L));
|
fixture.assembler(structure, 32, 64, -48), new RNG(127L));
|
||||||
@@ -336,23 +333,23 @@ public class StructureAssemblerTest {
|
|||||||
public void selectionPriorityProcessesHigherConnectorsFirstAndPreservesStableTies() {
|
public void selectionPriorityProcessesHigherConnectorsFirstAndPreservesStableTies() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawConnector eastSource = connector(
|
IrisJigsawConnector eastSource = connector(
|
||||||
IrisDirection.EAST_POSITIVE_X, "east", "start", "door").setSelectionPriority(-20);
|
JigsawDirection.EAST_POSITIVE_X, "east", "start", "door").setSelectionPriority(-20);
|
||||||
IrisJigsawConnector westSource = connector(
|
IrisJigsawConnector westSource = connector(
|
||||||
IrisDirection.WEST_NEGATIVE_X, "west", "start", "door").setSelectionPriority(-10);
|
JigsawDirection.WEST_NEGATIVE_X, "west", "start", "door").setSelectionPriority(-10);
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false, eastSource, westSource);
|
IrisJigsawPiece startPiece = piece("start-object", false, eastSource, westSource);
|
||||||
IrisJigsawPiece eastPiece = piece("east-object", false,
|
IrisJigsawPiece eastPiece = piece("east-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
IrisJigsawPiece westPiece = piece("west-object", false,
|
IrisJigsawPiece westPiece = piece("west-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "", "door", ""));
|
connector(JigsawDirection.EAST_POSITIVE_X, "", "door", ""));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("east", pool("", "east-piece"));
|
fixture.pool("east", pool("", "east-piece"));
|
||||||
fixture.pool("west", pool("", "west-piece"));
|
fixture.pool("west", pool("", "west-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("east-piece", eastPiece);
|
fixture.piece("east-piece", eastPiece);
|
||||||
fixture.piece("west-piece", westPiece);
|
fixture.piece("west-piece", westPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("east-object", new IrisObject(1, 1, 1));
|
fixture.object("east-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("west-object", new IrisObject(1, 1, 1));
|
fixture.object("west-object", new ObjectFrame(1, 1, 1));
|
||||||
IrisStructure structure = structure("start", 1);
|
IrisStructure structure = structure("start", 1);
|
||||||
|
|
||||||
List<PlacedStructurePiece> prioritized = completedPieces(
|
List<PlacedStructurePiece> prioritized = completedPieces(
|
||||||
@@ -374,20 +371,20 @@ public class StructureAssemblerTest {
|
|||||||
public void selectionPriorityChoosesHigherCandidateConnectorAndPreservesStableTies() {
|
public void selectionPriorityChoosesHigherCandidateConnectorAndPreservesStableTies() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "target", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "target", "start", "door"));
|
||||||
IrisJigsawConnector low = connector(IrisDirection.WEST_NEGATIVE_X, "", "door", "")
|
IrisJigsawConnector low = connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", "")
|
||||||
.setPosition(new IrisPosition(0, 0, 0))
|
.setPosition(new BlockPosition(0, 0, 0))
|
||||||
.setSelectionPriority(-20);
|
.setSelectionPriority(-20);
|
||||||
IrisJigsawConnector high = connector(IrisDirection.WEST_NEGATIVE_X, "", "door", "")
|
IrisJigsawConnector high = connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", "")
|
||||||
.setPosition(new IrisPosition(0, 0, 2))
|
.setPosition(new BlockPosition(0, 0, 2))
|
||||||
.setSelectionPriority(-10);
|
.setSelectionPriority(-10);
|
||||||
IrisJigsawPiece targetPiece = piece("target-object", false, low, high);
|
IrisJigsawPiece targetPiece = piece("target-object", false, low, high);
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("target", pool("", "target-piece"));
|
fixture.pool("target", pool("", "target-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("target-piece", targetPiece);
|
fixture.piece("target-piece", targetPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("target-object", new IrisObject(1, 1, 3));
|
fixture.object("target-object", new ObjectFrame(1, 1, 3));
|
||||||
IrisStructure structure = structure("start", 1);
|
IrisStructure structure = structure("start", 1);
|
||||||
|
|
||||||
List<PlacedStructurePiece> prioritized = completedPieces(
|
List<PlacedStructurePiece> prioritized = completedPieces(
|
||||||
@@ -406,20 +403,20 @@ public class StructureAssemblerTest {
|
|||||||
public void placementPrioritySchedulesChildExpansionAfterTheCurrentPieceAndPreservesStableTies() {
|
public void placementPrioritySchedulesChildExpansionAfterTheCurrentPieceAndPreservesStableTies() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawConnector eastSource = connector(
|
IrisJigsawConnector eastSource = connector(
|
||||||
IrisDirection.EAST_POSITIVE_X, "east", "start", "door").setPlacementPriority(-20);
|
JigsawDirection.EAST_POSITIVE_X, "east", "start", "door").setPlacementPriority(-20);
|
||||||
IrisJigsawConnector westSource = connector(
|
IrisJigsawConnector westSource = connector(
|
||||||
IrisDirection.WEST_NEGATIVE_X, "west", "start", "door").setPlacementPriority(-10);
|
JigsawDirection.WEST_NEGATIVE_X, "west", "start", "door").setPlacementPriority(-10);
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false, eastSource, westSource);
|
IrisJigsawPiece startPiece = piece("start-object", false, eastSource, westSource);
|
||||||
IrisJigsawPiece eastPiece = piece("east-object", false,
|
IrisJigsawPiece eastPiece = piece("east-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""),
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""),
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "east-leaf", "east", "leaf"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "east-leaf", "east", "leaf"));
|
||||||
IrisJigsawPiece westPiece = piece("west-object", false,
|
IrisJigsawPiece westPiece = piece("west-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "", "door", ""),
|
connector(JigsawDirection.EAST_POSITIVE_X, "", "door", ""),
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "west-leaf", "west", "leaf"));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "west-leaf", "west", "leaf"));
|
||||||
IrisJigsawPiece eastLeaf = piece("east-leaf-object", false,
|
IrisJigsawPiece eastLeaf = piece("east-leaf-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "leaf", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "leaf", ""));
|
||||||
IrisJigsawPiece westLeaf = piece("west-leaf-object", false,
|
IrisJigsawPiece westLeaf = piece("west-leaf-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "", "leaf", ""));
|
connector(JigsawDirection.EAST_POSITIVE_X, "", "leaf", ""));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("east", pool("", "east-piece"));
|
fixture.pool("east", pool("", "east-piece"));
|
||||||
fixture.pool("west", pool("", "west-piece"));
|
fixture.pool("west", pool("", "west-piece"));
|
||||||
@@ -430,11 +427,11 @@ public class StructureAssemblerTest {
|
|||||||
fixture.piece("west-piece", westPiece);
|
fixture.piece("west-piece", westPiece);
|
||||||
fixture.piece("east-leaf-piece", eastLeaf);
|
fixture.piece("east-leaf-piece", eastLeaf);
|
||||||
fixture.piece("west-leaf-piece", westLeaf);
|
fixture.piece("west-leaf-piece", westLeaf);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("east-object", new IrisObject(1, 1, 1));
|
fixture.object("east-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("west-object", new IrisObject(1, 1, 1));
|
fixture.object("west-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("east-leaf-object", new IrisObject(1, 1, 1));
|
fixture.object("east-leaf-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("west-leaf-object", new IrisObject(1, 1, 1));
|
fixture.object("west-leaf-object", new ObjectFrame(1, 1, 1));
|
||||||
IrisStructure structure = structure("start", 2);
|
IrisStructure structure = structure("start", 2);
|
||||||
|
|
||||||
List<PlacedStructurePiece> prioritized = completedPieces(
|
List<PlacedStructurePiece> prioritized = completedPieces(
|
||||||
@@ -458,17 +455,17 @@ public class StructureAssemblerTest {
|
|||||||
public void connectorChannelsMustMatchExactly() {
|
public void connectorChannelsMustMatchExactly() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawConnector source = connector(
|
IrisJigsawConnector source = connector(
|
||||||
IrisDirection.EAST_POSITIVE_X, "target", "start", "door").setChannel("road");
|
JigsawDirection.EAST_POSITIVE_X, "target", "start", "door").setChannel("road");
|
||||||
IrisJigsawConnector target = connector(
|
IrisJigsawConnector target = connector(
|
||||||
IrisDirection.WEST_NEGATIVE_X, "", "door", "").setChannel("room");
|
JigsawDirection.WEST_NEGATIVE_X, "", "door", "").setChannel("room");
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false, source);
|
IrisJigsawPiece startPiece = piece("start-object", false, source);
|
||||||
IrisJigsawPiece targetPiece = piece("target-object", false, target);
|
IrisJigsawPiece targetPiece = piece("target-object", false, target);
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("target", pool("", "target-piece"));
|
fixture.pool("target", pool("", "target-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("target-piece", targetPiece);
|
fixture.piece("target-piece", targetPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("target-object", new IrisObject(1, 1, 1));
|
fixture.object("target-object", new ObjectFrame(1, 1, 1));
|
||||||
IrisStructure structure = structure("start", 1);
|
IrisStructure structure = structure("start", 1);
|
||||||
|
|
||||||
assertEquals(StructureAssemblyStatus.FAILED_UNCAPPED,
|
assertEquals(StructureAssemblyStatus.FAILED_UNCAPPED,
|
||||||
@@ -493,15 +490,15 @@ public class StructureAssemblerTest {
|
|||||||
public void fallbackAtMaximumDepthDoesNotExpandAgain() {
|
public void fallbackAtMaximumDepthDoesNotExpandAgain() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
||||||
IrisJigsawPiece branchPiece = piece("branch-object", false,
|
IrisJigsawPiece branchPiece = piece("branch-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""),
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""),
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "terminal", "branch", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "terminal", "branch", "door"));
|
||||||
IrisJigsawPiece primaryTerminal = piece("primary-terminal-object", false,
|
IrisJigsawPiece primaryTerminal = piece("primary-terminal-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
IrisJigsawPiece fallbackTerminal = piece("fallback-terminal-object", false,
|
IrisJigsawPiece fallbackTerminal = piece("fallback-terminal-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""),
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""),
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "terminal", "terminal", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "terminal", "terminal", "door"));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("branch", pool("", "branch-piece"));
|
fixture.pool("branch", pool("", "branch-piece"));
|
||||||
fixture.pool("terminal", pool("terminal-fallback", "primary-terminal-piece"));
|
fixture.pool("terminal", pool("terminal-fallback", "primary-terminal-piece"));
|
||||||
@@ -510,10 +507,10 @@ public class StructureAssemblerTest {
|
|||||||
fixture.piece("branch-piece", branchPiece);
|
fixture.piece("branch-piece", branchPiece);
|
||||||
fixture.piece("primary-terminal-piece", primaryTerminal);
|
fixture.piece("primary-terminal-piece", primaryTerminal);
|
||||||
fixture.piece("fallback-terminal-piece", fallbackTerminal);
|
fixture.piece("fallback-terminal-piece", fallbackTerminal);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("branch-object", new IrisObject(1, 1, 1));
|
fixture.object("branch-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("primary-terminal-object", new IrisObject(1, 1, 1));
|
fixture.object("primary-terminal-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("fallback-terminal-object", new IrisObject(1, 1, 1));
|
fixture.object("fallback-terminal-object", new ObjectFrame(1, 1, 1));
|
||||||
IrisStructure structure = structure("start", 1);
|
IrisStructure structure = structure("start", 1);
|
||||||
structure.setMaxSizeChunks(1);
|
structure.setMaxSizeChunks(1);
|
||||||
|
|
||||||
@@ -529,17 +526,17 @@ public class StructureAssemblerTest {
|
|||||||
public void fallbackOfFallbackIsNotSelected() {
|
public void fallbackOfFallbackIsNotSelected() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
||||||
IrisJigsawPiece incompatiblePiece = piece("incompatible-object", false,
|
IrisJigsawPiece incompatiblePiece = piece("incompatible-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("branch", pool("terminators", "incompatible-piece"));
|
fixture.pool("branch", pool("terminators", "incompatible-piece"));
|
||||||
fixture.pool("terminators", pool("empty", "incompatible-piece"));
|
fixture.pool("terminators", pool("empty", "incompatible-piece"));
|
||||||
fixture.pool("empty", pool(""));
|
fixture.pool("empty", pool(""));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("incompatible-piece", incompatiblePiece);
|
fixture.piece("incompatible-piece", incompatiblePiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("incompatible-object", new IrisObject(1, 1, 1));
|
fixture.object("incompatible-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
assertEquals(StructureAssemblyStatus.FAILED_UNCAPPED,
|
assertEquals(StructureAssemblyStatus.FAILED_UNCAPPED,
|
||||||
fixture.assembler(structure("start", 2), 0, 0, 0)
|
fixture.assembler(structure("start", 2), 0, 0, 0)
|
||||||
@@ -552,7 +549,7 @@ public class StructureAssemblerTest {
|
|||||||
IrisJigsawPiece startPiece = piece("start-object", false);
|
IrisJigsawPiece startPiece = piece("start-object", false);
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.object("start-object", new IrisObject(4, 2, 6));
|
fixture.object("start-object", new ObjectFrame(4, 2, 6));
|
||||||
|
|
||||||
PlacedStructurePiece placed = completedPieces(
|
PlacedStructurePiece placed = completedPieces(
|
||||||
fixture.assembler(structure("start", 1), 10, 20, 30), new RNG(53L)).getFirst();
|
fixture.assembler(structure("start", 1), 10, 20, 30), new RNG(53L)).getFirst();
|
||||||
@@ -566,7 +563,7 @@ public class StructureAssemblerTest {
|
|||||||
IrisJigsawPiece startPiece = piece("start-object", true);
|
IrisJigsawPiece startPiece = piece("start-object", true);
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.object("start-object", new IrisObject(4, 2, 6));
|
fixture.object("start-object", new ObjectFrame(4, 2, 6));
|
||||||
|
|
||||||
StructureAssembler assembler = fixture.assembler(structure("start", 1), 10, 20, 30);
|
StructureAssembler assembler = fixture.assembler(structure("start", 1), 10, 20, 30);
|
||||||
assertBounds(completedPieces(assembler, rotationIndex(1)).getFirst(), 7, 19, 29, 12, 20, 32);
|
assertBounds(completedPieces(assembler, rotationIndex(1)).getFirst(), 7, 19, 29, 12, 20, 32);
|
||||||
@@ -579,12 +576,12 @@ public class StructureAssemblerTest {
|
|||||||
for (int quarterTurn = 0; quarterTurn < 4; quarterTurn++) {
|
for (int quarterTurn = 0; quarterTurn < 4; quarterTurn++) {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawConnector source = connector(
|
IrisJigsawConnector source = connector(
|
||||||
IrisDirection.NORTH_NEGATIVE_Z, "target", "start", "door")
|
JigsawDirection.NORTH_NEGATIVE_Z, "target", "start", "door")
|
||||||
.setPosition(new IrisPosition(2, 1, 0))
|
.setPosition(new BlockPosition(2, 1, 0))
|
||||||
.setJoint(JigsawJoint.ALIGNED);
|
.setJoint(JigsawJoint.ALIGNED);
|
||||||
IrisJigsawConnector target = connector(
|
IrisJigsawConnector target = connector(
|
||||||
IrisDirection.SOUTH_POSITIVE_Z, "", "door", "unused")
|
JigsawDirection.SOUTH_POSITIVE_Z, "", "door", "unused")
|
||||||
.setPosition(new IrisPosition(2, 1, 5))
|
.setPosition(new BlockPosition(2, 1, 5))
|
||||||
.setJoint(JigsawJoint.ALIGNED);
|
.setJoint(JigsawJoint.ALIGNED);
|
||||||
IrisJigsawPiece startPiece = piece("start-object", true, source);
|
IrisJigsawPiece startPiece = piece("start-object", true, source);
|
||||||
IrisJigsawPiece targetPiece = piece("target-object", true, target);
|
IrisJigsawPiece targetPiece = piece("target-object", true, target);
|
||||||
@@ -592,11 +589,11 @@ public class StructureAssemblerTest {
|
|||||||
fixture.pool("target", pool("", "target-piece"));
|
fixture.pool("target", pool("", "target-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("target-piece", targetPiece);
|
fixture.piece("target-piece", targetPiece);
|
||||||
fixture.object("start-object", new IrisObject(4, 2, 6));
|
fixture.object("start-object", new ObjectFrame(4, 2, 6));
|
||||||
fixture.object("target-object", new IrisObject(4, 2, 6));
|
fixture.object("target-object", new ObjectFrame(4, 2, 6));
|
||||||
IrisStructure structure = structure("start", 1)
|
IrisStructure structure = structure("start", 1)
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||||
.setCellSize(new IrisPosition(4, 2, 6));
|
.setCellSize(new BlockPosition(4, 2, 6));
|
||||||
|
|
||||||
List<PlacedStructurePiece> pieces = completedPieces(
|
List<PlacedStructurePiece> pieces = completedPieces(
|
||||||
fixture.assembler(structure, 10, 20, 30), rotationIndex(quarterTurn));
|
fixture.assembler(structure, 10, 20, 30), rotationIndex(quarterTurn));
|
||||||
@@ -662,18 +659,18 @@ public class StructureAssemblerTest {
|
|||||||
public void pillagerOutpostAirScaffoldAllowsTheWatchtowerToOverlapItsNativeBounds() {
|
public void pillagerOutpostAirScaffoldAllowsTheWatchtowerToOverlapItsNativeBounds() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawConnector baseEntrance = connector(
|
IrisJigsawConnector baseEntrance = connector(
|
||||||
IrisDirection.NORTH_NEGATIVE_Z,
|
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"towers",
|
"towers",
|
||||||
"minecraft:entrance",
|
"minecraft:entrance",
|
||||||
"minecraft:entrance")
|
"minecraft:entrance")
|
||||||
.setPosition(new IrisPosition(8, 1, 14))
|
.setPosition(new BlockPosition(8, 1, 14))
|
||||||
.setJoint(JigsawJoint.ALIGNED);
|
.setJoint(JigsawJoint.ALIGNED);
|
||||||
IrisJigsawConnector towerEntrance = connector(
|
IrisJigsawConnector towerEntrance = connector(
|
||||||
IrisDirection.SOUTH_POSITIVE_Z,
|
JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
"terminal",
|
"terminal",
|
||||||
"minecraft:entrance",
|
"minecraft:entrance",
|
||||||
"minecraft:entrance")
|
"minecraft:entrance")
|
||||||
.setPosition(new IrisPosition(7, 1, 13))
|
.setPosition(new BlockPosition(7, 1, 13))
|
||||||
.setJoint(JigsawJoint.ALIGNED);
|
.setJoint(JigsawJoint.ALIGNED);
|
||||||
IrisJigsawPiece basePlate = piece("base-plate-object", true, baseEntrance);
|
IrisJigsawPiece basePlate = piece("base-plate-object", true, baseEntrance);
|
||||||
IrisJigsawPiece watchtower = piece("watchtower-object", true, towerEntrance);
|
IrisJigsawPiece watchtower = piece("watchtower-object", true, towerEntrance);
|
||||||
@@ -681,8 +678,8 @@ public class StructureAssemblerTest {
|
|||||||
fixture.pool("towers", pool("terminal", "watchtower"));
|
fixture.pool("towers", pool("terminal", "watchtower"));
|
||||||
fixture.piece("base-plate", basePlate);
|
fixture.piece("base-plate", basePlate);
|
||||||
fixture.piece("watchtower", watchtower);
|
fixture.piece("watchtower", watchtower);
|
||||||
fixture.object("base-plate-object", new IrisObject(16, 30, 16));
|
fixture.object("base-plate-object", new ObjectFrame(16, 30, 16));
|
||||||
fixture.object("watchtower-object", new IrisObject(15, 21, 15));
|
fixture.object("watchtower-object", new ObjectFrame(15, 21, 15));
|
||||||
IrisStructure structure = structure("start", 1);
|
IrisStructure structure = structure("start", 1);
|
||||||
|
|
||||||
StructureAssemblyResult collidable = fixture.assembler(structure, 0, 0, 0)
|
StructureAssemblyResult collidable = fixture.assembler(structure, 0, 0, 0)
|
||||||
@@ -714,8 +711,8 @@ public class StructureAssemblerTest {
|
|||||||
fixture.pool("start", start);
|
fixture.pool("start", start);
|
||||||
fixture.piece("first-piece", first);
|
fixture.piece("first-piece", first);
|
||||||
fixture.piece("second-piece", second);
|
fixture.piece("second-piece", second);
|
||||||
fixture.object("first-object", new IrisObject(1, 1, 1));
|
fixture.object("first-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("second-object", new IrisObject(1, 1, 1));
|
fixture.object("second-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
for (long seed = 0; seed < 32; seed++) {
|
for (long seed = 0; seed < 32; seed++) {
|
||||||
List<PlacedStructurePiece> placed = completedPieces(
|
List<PlacedStructurePiece> placed = completedPieces(
|
||||||
@@ -731,7 +728,7 @@ public class StructureAssemblerTest {
|
|||||||
startPiece.setConnectors(null);
|
startPiece.setConnectors(null);
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
assertThrows(IllegalStateException.class,
|
assertThrows(IllegalStateException.class,
|
||||||
() -> fixture.assembler(structure("start", 1), 0, 0, 0).assemble(new RNG(3L)));
|
() -> fixture.assembler(structure("start", 1), 0, 0, 0).assemble(new RNG(3L)));
|
||||||
@@ -741,20 +738,20 @@ public class StructureAssemblerTest {
|
|||||||
public void corruptWeightedPeerFailsBeforeCandidateSelection() {
|
public void corruptWeightedPeerFailsBeforeCandidateSelection() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
||||||
IrisJigsawPiece validPiece = piece("valid-object", false,
|
IrisJigsawPiece validPiece = piece("valid-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
IrisJigsawPiece fallbackPiece = piece("fallback-object", false,
|
IrisJigsawPiece fallbackPiece = piece("fallback-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("branch", pool("fallback", "valid-piece", "missing-piece"));
|
fixture.pool("branch", pool("fallback", "valid-piece", "missing-piece"));
|
||||||
fixture.pool("fallback", pool("", "fallback-piece"));
|
fixture.pool("fallback", pool("", "fallback-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("valid-piece", validPiece);
|
fixture.piece("valid-piece", validPiece);
|
||||||
fixture.piece("fallback-piece", fallbackPiece);
|
fixture.piece("fallback-piece", fallbackPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("valid-object", new IrisObject(1, 1, 1));
|
fixture.object("valid-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("fallback-object", new IrisObject(1, 1, 1));
|
fixture.object("fallback-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
IllegalStateException failure = assertThrows(IllegalStateException.class,
|
IllegalStateException failure = assertThrows(IllegalStateException.class,
|
||||||
() -> fixture.assembler(structure("start", 2), 0, 0, 0).assemble(new RNG(17L)));
|
() -> fixture.assembler(structure("start", 2), 0, 0, 0).assemble(new RNG(17L)));
|
||||||
@@ -769,7 +766,7 @@ public class StructureAssemblerTest {
|
|||||||
IrisJigsawPiece validPiece = piece("valid-object", false);
|
IrisJigsawPiece validPiece = piece("valid-object", false);
|
||||||
fixture.pool("start", pool("", "valid-piece", "missing-piece"));
|
fixture.pool("start", pool("", "valid-piece", "missing-piece"));
|
||||||
fixture.piece("valid-piece", validPiece);
|
fixture.piece("valid-piece", validPiece);
|
||||||
fixture.object("valid-object", new IrisObject(1, 1, 1));
|
fixture.object("valid-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
IllegalStateException failure = assertThrows(IllegalStateException.class,
|
IllegalStateException failure = assertThrows(IllegalStateException.class,
|
||||||
() -> fixture.assembler(structure("start", 1), 0, 0, 0).assemble(new RNG(18L)));
|
() -> fixture.assembler(structure("start", 1), 0, 0, 0).assemble(new RNG(18L)));
|
||||||
@@ -782,20 +779,20 @@ public class StructureAssemblerTest {
|
|||||||
public void malformedNestedConnectorDoesNotFallThroughToAuthoredFallback() {
|
public void malformedNestedConnectorDoesNotFallThroughToAuthoredFallback() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
||||||
IrisJigsawPiece malformedPiece = piece("malformed-object", false);
|
IrisJigsawPiece malformedPiece = piece("malformed-object", false);
|
||||||
malformedPiece.getConnectors().add((IrisJigsawConnector) null);
|
malformedPiece.getConnectors().add((IrisJigsawConnector) null);
|
||||||
IrisJigsawPiece fallbackPiece = piece("fallback-object", false,
|
IrisJigsawPiece fallbackPiece = piece("fallback-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("branch", pool("fallback", "malformed-piece"));
|
fixture.pool("branch", pool("fallback", "malformed-piece"));
|
||||||
fixture.pool("fallback", pool("", "fallback-piece"));
|
fixture.pool("fallback", pool("", "fallback-piece"));
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.piece("malformed-piece", malformedPiece);
|
fixture.piece("malformed-piece", malformedPiece);
|
||||||
fixture.piece("fallback-piece", fallbackPiece);
|
fixture.piece("fallback-piece", fallbackPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("malformed-object", new IrisObject(1, 1, 1));
|
fixture.object("malformed-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("fallback-object", new IrisObject(1, 1, 1));
|
fixture.object("fallback-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
assertThrows(IllegalStateException.class,
|
assertThrows(IllegalStateException.class,
|
||||||
() -> fixture.assembler(structure("start", 2), 0, 0, 0).assemble(new RNG(19L)));
|
() -> fixture.assembler(structure("start", 2), 0, 0, 0).assemble(new RNG(19L)));
|
||||||
@@ -805,13 +802,13 @@ public class StructureAssemblerTest {
|
|||||||
public void emptyPoolChoiceTerminatesTheBranchWithoutPlacingAir() {
|
public void emptyPoolChoiceTerminatesTheBranchWithoutPlacingAir() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "terminal", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "terminal", "start", "door"));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
IrisJigsawPool terminal = new IrisJigsawPool();
|
IrisJigsawPool terminal = new IrisJigsawPool();
|
||||||
terminal.getPieces().add(new IrisJigsawPieceEntry().setEmpty(true).setWeight(1));
|
terminal.getPieces().add(new IrisJigsawPieceEntry().setEmpty(true).setWeight(1));
|
||||||
fixture.pool("terminal", terminal);
|
fixture.pool("terminal", terminal);
|
||||||
fixture.piece("start-piece", startPiece);
|
fixture.piece("start-piece", startPiece);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
List<PlacedStructurePiece> placed = completedPieces(
|
List<PlacedStructurePiece> placed = completedPieces(
|
||||||
fixture.assembler(structure("start", 2), 0, 0, 0), new RNG(7L));
|
fixture.assembler(structure("start", 2), 0, 0, 0), new RNG(7L));
|
||||||
@@ -859,8 +856,8 @@ public class StructureAssemblerTest {
|
|||||||
fixture.pool("start", pool("", "first-piece", "second-piece"));
|
fixture.pool("start", pool("", "first-piece", "second-piece"));
|
||||||
fixture.piece("first-piece", first);
|
fixture.piece("first-piece", first);
|
||||||
fixture.piece("second-piece", second);
|
fixture.piece("second-piece", second);
|
||||||
fixture.object("first-object", new IrisObject(1, 1, 1));
|
fixture.object("first-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("second-object", new IrisObject(1, 1, 1));
|
fixture.object("second-object", new ObjectFrame(1, 1, 1));
|
||||||
IrisStructure structure = structure("start", 1);
|
IrisStructure structure = structure("start", 1);
|
||||||
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-1", 1));
|
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-1", 1));
|
||||||
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-2", 1));
|
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-2", 1));
|
||||||
@@ -877,12 +874,12 @@ public class StructureAssemblerTest {
|
|||||||
public void unmetMinimumPlacementsTakePriorityWithinTheirPool() {
|
public void unmetMinimumPlacementsTakePriorityWithinTheirPool() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece start = piece("start-object", false,
|
IrisJigsawPiece start = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
||||||
IrisJigsawPiece required = piece("required-object", false,
|
IrisJigsawPiece required = piece("required-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
required.setRules(new IrisJigsawPieceRules().setMinimumPlacements(1));
|
required.setRules(new IrisJigsawPieceRules().setMinimumPlacements(1));
|
||||||
IrisJigsawPiece common = piece("common-object", false,
|
IrisJigsawPiece common = piece("common-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
IrisJigsawPool branch = new IrisJigsawPool();
|
IrisJigsawPool branch = new IrisJigsawPool();
|
||||||
branch.getPieces().add(new IrisJigsawPieceEntry("common-piece", 100));
|
branch.getPieces().add(new IrisJigsawPieceEntry("common-piece", 100));
|
||||||
@@ -891,9 +888,9 @@ public class StructureAssemblerTest {
|
|||||||
fixture.piece("start-piece", start);
|
fixture.piece("start-piece", start);
|
||||||
fixture.piece("required-piece", required);
|
fixture.piece("required-piece", required);
|
||||||
fixture.piece("common-piece", common);
|
fixture.piece("common-piece", common);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("required-object", new IrisObject(1, 1, 1));
|
fixture.object("required-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("common-object", new IrisObject(1, 1, 1));
|
fixture.object("common-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
StructureAssemblyResult result = fixture.assembler(structure("start", 2), 0, 0, 0)
|
StructureAssemblyResult result = fixture.assembler(structure("start", 2), 0, 0, 0)
|
||||||
.assemble(new RNG(61L));
|
.assemble(new RNG(61L));
|
||||||
@@ -906,16 +903,16 @@ public class StructureAssemblerTest {
|
|||||||
public void terminalPiecesNeverEnqueueTheirRemainingConnectors() {
|
public void terminalPiecesNeverEnqueueTheirRemainingConnectors() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece terminal = piece("terminal-object", false,
|
IrisJigsawPiece terminal = piece("terminal-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "child", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "child", "start", "door"));
|
||||||
terminal.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
terminal.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
||||||
IrisJigsawPiece child = piece("child-object", false,
|
IrisJigsawPiece child = piece("child-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
fixture.pool("start", pool("", "terminal-piece"));
|
fixture.pool("start", pool("", "terminal-piece"));
|
||||||
fixture.pool("child", pool("", "child-piece"));
|
fixture.pool("child", pool("", "child-piece"));
|
||||||
fixture.piece("terminal-piece", terminal);
|
fixture.piece("terminal-piece", terminal);
|
||||||
fixture.piece("child-piece", child);
|
fixture.piece("child-piece", child);
|
||||||
fixture.object("terminal-object", new IrisObject(1, 1, 1));
|
fixture.object("terminal-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("child-object", new IrisObject(1, 1, 1));
|
fixture.object("child-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
StructureAssemblyResult result = fixture.assembler(structure("start", 2), 0, 0, 0)
|
StructureAssemblyResult result = fixture.assembler(structure("start", 2), 0, 0, 0)
|
||||||
.assemble(new RNG(67L));
|
.assemble(new RNG(67L));
|
||||||
@@ -928,11 +925,11 @@ public class StructureAssemblerTest {
|
|||||||
public void requiredCapsResolveThroughACompatibleTerminalFallback() {
|
public void requiredCapsResolveThroughACompatibleTerminalFallback() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece start = piece("start-object", false,
|
IrisJigsawPiece start = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "branch", "start", "door"));
|
||||||
IrisJigsawPiece incompatible = piece("incompatible-object", false,
|
IrisJigsawPiece incompatible = piece("incompatible-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||||
IrisJigsawPiece cap = piece("cap-object", false,
|
IrisJigsawPiece cap = piece("cap-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||||
cap.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
cap.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("branch", pool("caps", "incompatible-piece"));
|
fixture.pool("branch", pool("caps", "incompatible-piece"));
|
||||||
@@ -940,9 +937,9 @@ public class StructureAssemblerTest {
|
|||||||
fixture.piece("start-piece", start);
|
fixture.piece("start-piece", start);
|
||||||
fixture.piece("incompatible-piece", incompatible);
|
fixture.piece("incompatible-piece", incompatible);
|
||||||
fixture.piece("cap-piece", cap);
|
fixture.piece("cap-piece", cap);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("incompatible-object", new IrisObject(1, 1, 1));
|
fixture.object("incompatible-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("cap-object", new IrisObject(1, 1, 1));
|
fixture.object("cap-object", new ObjectFrame(1, 1, 1));
|
||||||
IrisStructure structure = structure("start", 2).setRequireCaps(true);
|
IrisStructure structure = structure("start", 2).setRequireCaps(true);
|
||||||
|
|
||||||
StructureAssemblyResult result = fixture.assembler(structure, 0, 0, 0)
|
StructureAssemblyResult result = fixture.assembler(structure, 0, 0, 0)
|
||||||
@@ -957,20 +954,20 @@ public class StructureAssemblerTest {
|
|||||||
public void compatibleOpenConnectorsCloseAgainstAnAlreadyPlacedNeighbor() {
|
public void compatibleOpenConnectorsCloseAgainstAnAlreadyPlacedNeighbor() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece start = piece("start-object", false,
|
IrisJigsawPiece start = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "east", "start-east", "door"),
|
connector(JigsawDirection.EAST_POSITIVE_X, "east", "start-east", "door"),
|
||||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "south", "start-south", "door"));
|
connector(JigsawDirection.SOUTH_POSITIVE_Z, "south", "start-south", "door"));
|
||||||
IrisJigsawPiece east = piece("east-object", false,
|
IrisJigsawPiece east = piece("east-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"),
|
connector(JigsawDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"),
|
||||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "diagonal", "east-south", "door"));
|
connector(JigsawDirection.SOUTH_POSITIVE_Z, "diagonal", "east-south", "door"));
|
||||||
IrisJigsawPiece south = piece("south-object", false,
|
IrisJigsawPiece south = piece("south-object", false,
|
||||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused"),
|
connector(JigsawDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused"),
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "diagonal", "south-east", "door"));
|
connector(JigsawDirection.EAST_POSITIVE_X, "diagonal", "south-east", "door"));
|
||||||
IrisJigsawPiece diagonal = piece("diagonal-object", false,
|
IrisJigsawPiece diagonal = piece("diagonal-object", false,
|
||||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "loop", "door", "unused"),
|
connector(JigsawDirection.NORTH_NEGATIVE_Z, "loop", "door", "unused"),
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "loop", "door", "unused"));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "loop", "door", "unused"));
|
||||||
IrisJigsawPiece cap = piece("cap-object", true,
|
IrisJigsawPiece cap = piece("cap-object", true,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"),
|
connector(JigsawDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"),
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "terminal", "unused", "unused"));
|
connector(JigsawDirection.WEST_NEGATIVE_X, "terminal", "unused", "unused"));
|
||||||
cap.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
cap.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("east", pool("caps", "east-piece"));
|
fixture.pool("east", pool("caps", "east-piece"));
|
||||||
@@ -983,11 +980,11 @@ public class StructureAssemblerTest {
|
|||||||
fixture.piece("south-piece", south);
|
fixture.piece("south-piece", south);
|
||||||
fixture.piece("diagonal-piece", diagonal);
|
fixture.piece("diagonal-piece", diagonal);
|
||||||
fixture.piece("cap-piece", cap);
|
fixture.piece("cap-piece", cap);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("east-object", new IrisObject(1, 1, 1));
|
fixture.object("east-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("south-object", new IrisObject(1, 1, 1));
|
fixture.object("south-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("diagonal-object", new IrisObject(1, 1, 1));
|
fixture.object("diagonal-object", new ObjectFrame(1, 1, 1));
|
||||||
fixture.object("cap-object", new IrisObject(1, 1, 1));
|
fixture.object("cap-object", new ObjectFrame(1, 1, 1));
|
||||||
IrisStructure structure = structure("start", 2).setRequireCaps(true);
|
IrisStructure structure = structure("start", 2).setRequireCaps(true);
|
||||||
|
|
||||||
List<PlacedStructurePiece> placed = completedPieces(
|
List<PlacedStructurePiece> placed = completedPieces(
|
||||||
@@ -1001,26 +998,26 @@ public class StructureAssemblerTest {
|
|||||||
public void planarRequiredCapsRejectASecondOpenReservationForTheSameEmptyCell() {
|
public void planarRequiredCapsRejectASecondOpenReservationForTheSameEmptyCell() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece start = piece("start-object", false,
|
IrisJigsawPiece start = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "east", "start-east", "door")
|
connector(JigsawDirection.EAST_POSITIVE_X, "east", "start-east", "door")
|
||||||
.setPosition(new IrisPosition(2, 0, 1)),
|
.setPosition(new BlockPosition(2, 0, 1)),
|
||||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "south", "start-south", "door")
|
connector(JigsawDirection.SOUTH_POSITIVE_Z, "south", "start-south", "door")
|
||||||
.setPosition(new IrisPosition(1, 0, 2)));
|
.setPosition(new BlockPosition(1, 0, 2)));
|
||||||
IrisJigsawPiece east = piece("east-object", false,
|
IrisJigsawPiece east = piece("east-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "terminal", "door", "unused")
|
connector(JigsawDirection.WEST_NEGATIVE_X, "terminal", "door", "unused")
|
||||||
.setPosition(new IrisPosition(0, 0, 1)),
|
.setPosition(new BlockPosition(0, 0, 1)),
|
||||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "grow", "east-south", "door")
|
connector(JigsawDirection.SOUTH_POSITIVE_Z, "grow", "east-south", "door")
|
||||||
.setPosition(new IrisPosition(1, 0, 2)));
|
.setPosition(new BlockPosition(1, 0, 2)));
|
||||||
IrisJigsawPiece conflicting = piece("conflicting-object", false,
|
IrisJigsawPiece conflicting = piece("conflicting-object", false,
|
||||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
connector(JigsawDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
||||||
.setPosition(new IrisPosition(1, 0, 0)),
|
.setPosition(new BlockPosition(1, 0, 0)),
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "grow", "south-east", "door")
|
connector(JigsawDirection.EAST_POSITIVE_X, "grow", "south-east", "door")
|
||||||
.setPosition(new IrisPosition(2, 0, 1)));
|
.setPosition(new BlockPosition(2, 0, 1)));
|
||||||
IrisJigsawPiece compatible = piece("compatible-object", false,
|
IrisJigsawPiece compatible = piece("compatible-object", false,
|
||||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
connector(JigsawDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
||||||
.setPosition(new IrisPosition(1, 0, 0)));
|
.setPosition(new BlockPosition(1, 0, 0)));
|
||||||
IrisJigsawPiece cap = piece("cap-object", true,
|
IrisJigsawPiece cap = piece("cap-object", true,
|
||||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
connector(JigsawDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
||||||
.setPosition(new IrisPosition(1, 0, 0)));
|
.setPosition(new BlockPosition(1, 0, 0)));
|
||||||
cap.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
cap.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("east", pool("caps", "east-piece"));
|
fixture.pool("east", pool("caps", "east-piece"));
|
||||||
@@ -1032,14 +1029,14 @@ public class StructureAssemblerTest {
|
|||||||
fixture.piece("conflicting-piece", conflicting);
|
fixture.piece("conflicting-piece", conflicting);
|
||||||
fixture.piece("compatible-piece", compatible);
|
fixture.piece("compatible-piece", compatible);
|
||||||
fixture.piece("cap-piece", cap);
|
fixture.piece("cap-piece", cap);
|
||||||
fixture.object("start-object", new IrisObject(3, 1, 3));
|
fixture.object("start-object", new ObjectFrame(3, 1, 3));
|
||||||
fixture.object("east-object", new IrisObject(3, 1, 3));
|
fixture.object("east-object", new ObjectFrame(3, 1, 3));
|
||||||
fixture.object("conflicting-object", new IrisObject(3, 1, 3));
|
fixture.object("conflicting-object", new ObjectFrame(3, 1, 3));
|
||||||
fixture.object("compatible-object", new IrisObject(3, 1, 3));
|
fixture.object("compatible-object", new ObjectFrame(3, 1, 3));
|
||||||
fixture.object("cap-object", new IrisObject(3, 1, 3));
|
fixture.object("cap-object", new ObjectFrame(3, 1, 3));
|
||||||
IrisStructure structure = structure("start", 2)
|
IrisStructure structure = structure("start", 2)
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||||
.setCellSize(new IrisPosition(3, 1, 3))
|
.setCellSize(new BlockPosition(3, 1, 3))
|
||||||
.setRequireCaps(true);
|
.setRequireCaps(true);
|
||||||
|
|
||||||
List<PlacedStructurePiece> placed = completedPieces(
|
List<PlacedStructurePiece> placed = completedPieces(
|
||||||
@@ -1059,7 +1056,7 @@ public class StructureAssemblerTest {
|
|||||||
startPool.getPieces().getFirst().setChance(0D);
|
startPool.getPieces().getFirst().setChance(0D);
|
||||||
fixture.pool("start", startPool);
|
fixture.pool("start", startPool);
|
||||||
fixture.piece("start-piece", start);
|
fixture.piece("start-piece", start);
|
||||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
StructureAssemblyResult result = fixture.assembler(structure("start", 1), 0, 0, 0)
|
StructureAssemblyResult result = fixture.assembler(structure("start", 1), 0, 0, 0)
|
||||||
.assemble(new RNG(73L));
|
.assemble(new RNG(73L));
|
||||||
@@ -1072,18 +1069,18 @@ public class StructureAssemblerTest {
|
|||||||
public void branchingGeometryReturnsATypedHardCapFailure() {
|
public void branchingGeometryReturnsATypedHardCapFailure() {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawConnector[] connectors = {
|
IrisJigsawConnector[] connectors = {
|
||||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "branch", "door", "door"),
|
connector(JigsawDirection.NORTH_NEGATIVE_Z, "branch", "door", "door"),
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "branch", "door", "door"),
|
connector(JigsawDirection.EAST_POSITIVE_X, "branch", "door", "door"),
|
||||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "branch", "door", "door"),
|
connector(JigsawDirection.SOUTH_POSITIVE_Z, "branch", "door", "door"),
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "branch", "door", "door"),
|
connector(JigsawDirection.WEST_NEGATIVE_X, "branch", "door", "door"),
|
||||||
connector(IrisDirection.UP_POSITIVE_Y, "branch", "door", "door"),
|
connector(JigsawDirection.UP_POSITIVE_Y, "branch", "door", "door"),
|
||||||
connector(IrisDirection.DOWN_NEGATIVE_Y, "branch", "door", "door")
|
connector(JigsawDirection.DOWN_NEGATIVE_Y, "branch", "door", "door")
|
||||||
};
|
};
|
||||||
IrisJigsawPiece node = piece("node-object", false, connectors);
|
IrisJigsawPiece node = piece("node-object", false, connectors);
|
||||||
fixture.pool("start", pool("", "node-piece"));
|
fixture.pool("start", pool("", "node-piece"));
|
||||||
fixture.pool("branch", pool("terminal", "node-piece"));
|
fixture.pool("branch", pool("terminal", "node-piece"));
|
||||||
fixture.piece("node-piece", node);
|
fixture.piece("node-piece", node);
|
||||||
fixture.object("node-object", new IrisObject(1, 1, 1));
|
fixture.object("node-object", new ObjectFrame(1, 1, 1));
|
||||||
|
|
||||||
StructureAssemblyResult result = fixture.assembler(structure("start", 10), 0, 0, 0)
|
StructureAssemblyResult result = fixture.assembler(structure("start", 10), 0, 0, 0)
|
||||||
.assemble(new RNG(83L));
|
.assemble(new RNG(83L));
|
||||||
@@ -1093,9 +1090,9 @@ public class StructureAssemblerTest {
|
|||||||
assertFalse(result.hasOutput());
|
assertFalse(result.hasOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisJigsawConnector connector(IrisDirection direction, String pool, String name, String targetName) {
|
private static IrisJigsawConnector connector(JigsawDirection direction, String pool, String name, String targetName) {
|
||||||
return new IrisJigsawConnector()
|
return new IrisJigsawConnector()
|
||||||
.setPosition(new IrisPosition())
|
.setPosition(new BlockPosition(0, 0, 0))
|
||||||
.setDirection(direction)
|
.setDirection(direction)
|
||||||
.setPool(pool == null || pool.isBlank() ? "terminal" : pool)
|
.setPool(pool == null || pool.isBlank() ? "terminal" : pool)
|
||||||
.setName(name)
|
.setName(name)
|
||||||
@@ -1105,7 +1102,7 @@ public class StructureAssemblerTest {
|
|||||||
|
|
||||||
private static IrisJigsawPiece piece(String object, boolean rotatable, IrisJigsawConnector... connectors) {
|
private static IrisJigsawPiece piece(String object, boolean rotatable, IrisJigsawConnector... connectors) {
|
||||||
IrisJigsawPiece piece = new IrisJigsawPiece().setObject(object).setRotatable(rotatable);
|
IrisJigsawPiece piece = new IrisJigsawPiece().setObject(object).setRotatable(rotatable);
|
||||||
piece.getConnectors().add(connectors);
|
piece.getConnectors().addAll(List.of(connectors));
|
||||||
return piece;
|
return piece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1123,17 +1120,17 @@ public class StructureAssemblerTest {
|
|||||||
) {
|
) {
|
||||||
Fixture fixture = new Fixture();
|
Fixture fixture = new Fixture();
|
||||||
IrisJigsawPiece start = piece("start-object", false,
|
IrisJigsawPiece start = piece("start-object", false,
|
||||||
connector(IrisDirection.EAST_POSITIVE_X, "target", "start", "door"))
|
connector(JigsawDirection.EAST_POSITIVE_X, "target", "start", "door"))
|
||||||
.setCollidable(placedCollidable);
|
.setCollidable(placedCollidable);
|
||||||
IrisJigsawPiece candidate = piece("candidate-object", false,
|
IrisJigsawPiece candidate = piece("candidate-object", false,
|
||||||
connector(IrisDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"))
|
connector(JigsawDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"))
|
||||||
.setCollidable(candidateCollidable);
|
.setCollidable(candidateCollidable);
|
||||||
fixture.pool("start", pool("", "start-piece"));
|
fixture.pool("start", pool("", "start-piece"));
|
||||||
fixture.pool("target", pool("", "candidate-piece"));
|
fixture.pool("target", pool("", "candidate-piece"));
|
||||||
fixture.piece("start-piece", start);
|
fixture.piece("start-piece", start);
|
||||||
fixture.piece("candidate-piece", candidate);
|
fixture.piece("candidate-piece", candidate);
|
||||||
fixture.object("start-object", new IrisObject(3, 3, 3));
|
fixture.object("start-object", new ObjectFrame(3, 3, 3));
|
||||||
fixture.object("candidate-object", new IrisObject(3, 3, 3));
|
fixture.object("candidate-object", new ObjectFrame(3, 3, 3));
|
||||||
return fixture.assembler(structure("start", 1), 0, 0, 0).assemble(new RNG(137L));
|
return fixture.assembler(structure("start", 1), 0, 0, 0).assemble(new RNG(137L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1165,7 +1162,7 @@ public class StructureAssemblerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static PlacedStructurePiece bounds(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
private static PlacedStructurePiece bounds(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||||
return new PlacedStructurePiece(null, null, 0, 0, 0, null, minX, minY, minZ, maxX, maxY, maxZ);
|
return new PlacedStructurePiece(null, null, null, 0, 0, 0, null, minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<PlacedStructurePiece> completedPieces(StructureAssembler assembler, RNG rng) {
|
private static List<PlacedStructurePiece> completedPieces(StructureAssembler assembler, RNG rng) {
|
||||||
@@ -1195,26 +1192,26 @@ public class StructureAssemblerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class Fixture {
|
private static final class Fixture {
|
||||||
private final IrisData data = mock(IrisData.class);
|
private final MapStructureResolver resolver = new MapStructureResolver();
|
||||||
|
|
||||||
private Fixture() {
|
private Fixture() {
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, "terminal", new IrisJigsawPool());
|
resolver.pool("terminal", new IrisJigsawPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pool(String key, IrisJigsawPool pool) {
|
private void pool(String key, IrisJigsawPool pool) {
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, key, pool);
|
resolver.pool(key, pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void piece(String key, IrisJigsawPiece piece) {
|
private void piece(String key, IrisJigsawPiece piece) {
|
||||||
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, key, piece);
|
resolver.piece(key, piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void object(String key, IrisObject object) {
|
private void object(String key, ObjectFrame object) {
|
||||||
when(data.load(IrisObject.class, key, false)).thenReturn(object);
|
resolver.object(key, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StructureAssembler assembler(IrisStructure structure, int x, int y, int z) {
|
private StructureAssembler assembler(IrisStructure structure, int x, int y, int z) {
|
||||||
return StructureAssembler.forData(data, structure, new IrisPosition(x, y, z), ModuleLogs.discarding());
|
return StructureAssembler.forResolver("test", resolver, structure, new BlockPosition(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-6
@@ -1,6 +1,5 @@
|
|||||||
package art.arcane.iris.engine.framework.structure;
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@@ -15,14 +14,14 @@ import static org.junit.Assert.assertTrue;
|
|||||||
public class IrisObjectFrameReaderTest {
|
public class IrisObjectFrameReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void acceptsModernTileFrame() throws Exception {
|
public void acceptsModernTileFrame() throws Exception {
|
||||||
IrisObject object = readObject(tile -> {
|
ObjectFrame object = readObject(tile -> {
|
||||||
tile.writeUTF("minecraft:chest");
|
tile.writeUTF("minecraft:chest");
|
||||||
tile.writeUTF("{}");
|
tile.writeUTF("{}");
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals(1, object.getW());
|
assertEquals(1, object.width());
|
||||||
assertEquals(1, object.getH());
|
assertEquals(1, object.height());
|
||||||
assertEquals(1, object.getD());
|
assertEquals(1, object.depth());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -146,7 +145,7 @@ public class IrisObjectFrameReaderTest {
|
|||||||
new ByteArrayInputStream(content), "objects/trailing.iob"));
|
new ByteArrayInputStream(content), "objects/trailing.iob"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisObject readObject(TileWriter tileWriter) throws Exception {
|
private ObjectFrame readObject(TileWriter tileWriter) throws Exception {
|
||||||
return IrisObjectFrameReader.readBounds(
|
return IrisObjectFrameReader.readBounds(
|
||||||
new ByteArrayInputStream(objectBytes(tileWriter)), "objects/test.iob");
|
new ByteArrayInputStream(objectBytes(tileWriter)), "objects/test.iob");
|
||||||
}
|
}
|
||||||
|
|||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/** A structure graph resolver for tests: the pools, pieces and object sizes a test sets by key, and nothing else. */
|
||||||
|
public final class MapStructureResolver implements StructureGraphResolver {
|
||||||
|
private final Map<String, IrisJigsawPool> pools = new HashMap<>();
|
||||||
|
private final Map<String, IrisJigsawPiece> pieces = new HashMap<>();
|
||||||
|
private final Map<String, ObjectFrame> objects = new HashMap<>();
|
||||||
|
|
||||||
|
public MapStructureResolver pool(String key, IrisJigsawPool pool) {
|
||||||
|
pools.put(key, pool);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapStructureResolver piece(String key, IrisJigsawPiece piece) {
|
||||||
|
pieces.put(key, piece);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapStructureResolver object(String key, ObjectFrame object) {
|
||||||
|
objects.put(key, object);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IrisJigsawPool loadPool(String key) {
|
||||||
|
return pools.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IrisJigsawPiece loadPiece(String key) {
|
||||||
|
return pieces.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectFrame loadObject(String key) {
|
||||||
|
return objects.get(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-9
@@ -1,13 +1,12 @@
|
|||||||
package art.arcane.iris.engine.framework.structure;
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcell;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcell;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -19,14 +18,14 @@ import static org.junit.Assert.assertThrows;
|
|||||||
public class PlanarJigsawWorkcellResolverTest {
|
public class PlanarJigsawWorkcellResolverTest {
|
||||||
@Test
|
@Test
|
||||||
public void legacyCellSizeProducesSixEnabledRectangularWorkcells() {
|
public void legacyCellSizeProducesSixEnabledRectangularWorkcells() {
|
||||||
IrisStructure structure = new IrisStructure().setCellSize(new IrisPosition(12, 7, 18));
|
IrisStructure structure = new IrisStructure().setCellSize(new BlockPosition(12, 7, 18));
|
||||||
|
|
||||||
Map<IrisJigsawWorkcellArchetype, PlanarJigsawWorkcellResolver.ResolvedWorkcell> workcells =
|
Map<IrisJigsawWorkcellArchetype, PlanarJigsawWorkcellResolver.ResolvedWorkcell> workcells =
|
||||||
PlanarJigsawWorkcellResolver.resolve(structure);
|
PlanarJigsawWorkcellResolver.resolve(structure);
|
||||||
|
|
||||||
assertEquals(6, workcells.size());
|
assertEquals(6, workcells.size());
|
||||||
for (PlanarJigsawWorkcellResolver.ResolvedWorkcell workcell : workcells.values()) {
|
for (PlanarJigsawWorkcellResolver.ResolvedWorkcell workcell : workcells.values()) {
|
||||||
assertEquals(new IrisPosition(12, 7, 18), workcell.dimensions());
|
assertEquals(new BlockPosition(12, 7, 18), workcell.dimensions());
|
||||||
assertEquals(true, workcell.enabled());
|
assertEquals(true, workcell.enabled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,13 +59,13 @@ public class PlanarJigsawWorkcellResolverTest {
|
|||||||
@Test
|
@Test
|
||||||
public void canonicalDimensionsSwapRectangularRotatedVariants() {
|
public void canonicalDimensionsSwapRectangularRotatedVariants() {
|
||||||
IrisJigsawPiece eastEnd = new IrisJigsawPiece();
|
IrisJigsawPiece eastEnd = new IrisJigsawPiece();
|
||||||
eastEnd.getConnectors().add(new IrisJigsawConnector().setDirection(IrisDirection.EAST_POSITIVE_X));
|
eastEnd.getConnectors().add(new IrisJigsawConnector().setDirection(JigsawDirection.EAST_POSITIVE_X));
|
||||||
|
|
||||||
IrisPosition dimensions = PlanarJigsawWorkcellResolver.canonicalDimensions(
|
BlockPosition dimensions = PlanarJigsawWorkcellResolver.canonicalDimensions(
|
||||||
eastEnd,
|
eastEnd,
|
||||||
new IrisObject(7, 5, 13));
|
new ObjectFrame(7, 5, 13));
|
||||||
|
|
||||||
assertEquals(new IrisPosition(13, 5, 7), dimensions);
|
assertEquals(new BlockPosition(13, 5, 7), dimensions);
|
||||||
assertEquals(IrisJigsawWorkcellArchetype.END,
|
assertEquals(IrisJigsawWorkcellArchetype.END,
|
||||||
IrisJigsawWorkcellArchetype.fromPiece(eastEnd));
|
IrisJigsawWorkcellArchetype.fromPiece(eastEnd));
|
||||||
assertFalse(IrisJigsawWorkcellArchetype.fromPiece(eastEnd)
|
assertFalse(IrisJigsawWorkcellArchetype.fromPiece(eastEnd)
|
||||||
|
|||||||
+154
-152
@@ -1,6 +1,6 @@
|
|||||||
package art.arcane.iris.engine.framework.structure;
|
package art.arcane.iris.engine.framework.structure;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawCompatibility;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawCompatibility;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||||
@@ -10,8 +10,6 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
|||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceRules;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceRules;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||||
import art.arcane.iris.spi.IrisPlatform;
|
import art.arcane.iris.spi.IrisPlatform;
|
||||||
@@ -19,6 +17,7 @@ import art.arcane.iris.spi.IrisPlatforms;
|
|||||||
import art.arcane.iris.spi.PlatformBlockState;
|
import art.arcane.iris.spi.PlatformBlockState;
|
||||||
import art.arcane.iris.spi.PlatformRegistries;
|
import art.arcane.iris.spi.PlatformRegistries;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
|
import com.volmit.geometry.BlockPosition;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -60,8 +59,8 @@ public class StructureGraphCompilerTest {
|
|||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
IrisStructure structure = structure("pools/start");
|
IrisStructure structure = structure("pools/start");
|
||||||
|
|
||||||
StructureGraphCompilation first = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation first = compile(structure, resolver);
|
||||||
StructureGraphCompilation second = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation second = compile(structure, resolver);
|
||||||
|
|
||||||
assertTrue(first.getDiagnostics().isEmpty());
|
assertTrue(first.getDiagnostics().isEmpty());
|
||||||
assertTrue(first.isAssemblyViable());
|
assertTrue(first.isAssemblyViable());
|
||||||
@@ -84,7 +83,7 @@ public class StructureGraphCompilerTest {
|
|||||||
start.setFallback("pools/missing-fallback");
|
start.setFallback("pools/missing-fallback");
|
||||||
resolver.pools.put("pools/start", start);
|
resolver.pools.put("pools/start", start);
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure("pools/start"), resolver);
|
StructureGraphCompilation result = compile(structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertCodes(result,
|
assertCodes(result,
|
||||||
StructureGraphDiagnostic.Code.INVALID_WEIGHT,
|
StructureGraphDiagnostic.Code.INVALID_WEIGHT,
|
||||||
@@ -98,15 +97,15 @@ public class StructureGraphCompilerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void reportsEmptyPoolsAndConnectorFieldFailures() {
|
public void reportsEmptyPoolsAndConnectorFieldFailures() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector connector = connector(new IrisPosition(4, 1, 1), null, "", "path", "path");
|
IrisJigsawConnector connector = connector(new BlockPosition(4, 1, 1), null, "", "path", "path");
|
||||||
resolver.objects.put("objects/start", object());
|
resolver.objects.put("objects/start", object());
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start", connector));
|
resolver.pieces.put("pieces/start", piece("objects/start", connector));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
resolver.pools.put("pools/empty", pool());
|
resolver.pools.put("pools/empty", pool());
|
||||||
|
|
||||||
StructureGraphCompilation invalidConnector = StructureGraphCompiler.compile(
|
StructureGraphCompilation invalidConnector = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
StructureGraphCompilation emptyStart = StructureGraphCompiler.compile(
|
StructureGraphCompilation emptyStart = compile(
|
||||||
structure("pools/empty"), resolver);
|
structure("pools/empty"), resolver);
|
||||||
|
|
||||||
assertCodes(invalidConnector,
|
assertCodes(invalidConnector,
|
||||||
@@ -120,9 +119,9 @@ public class StructureGraphCompilerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void reportsIncompatibleDirectionsAndUnreachablePieces() {
|
public void reportsIncompatibleDirectionsAndUnreachablePieces() {
|
||||||
InMemoryResolver resolver = connectorGraph(false, IrisDirection.NORTH_NEGATIVE_Z);
|
InMemoryResolver resolver = connectorGraph(false, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertCodes(result,
|
assertCodes(result,
|
||||||
@@ -139,9 +138,9 @@ public class StructureGraphCompilerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void acceptsHorizontalRotationWithVanillaOneWayTargetMatching() {
|
public void acceptsHorizontalRotationWithVanillaOneWayTargetMatching() {
|
||||||
InMemoryResolver resolver = connectorGraph(true, IrisDirection.NORTH_NEGATIVE_Z);
|
InMemoryResolver resolver = connectorGraph(true, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertTrue(result.getDiagnostics().isEmpty());
|
assertTrue(result.getDiagnostics().isEmpty());
|
||||||
@@ -154,10 +153,10 @@ public class StructureGraphCompilerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void connectorNamesUseTheRuntimeExactMatchingContract() {
|
public void connectorNamesUseTheRuntimeExactMatchingContract() {
|
||||||
InMemoryResolver resolver = connectorGraph(false, IrisDirection.SOUTH_POSITIVE_Z);
|
InMemoryResolver resolver = connectorGraph(false, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
resolver.pieces.get("pieces/target").getConnectors().getFirst().setName(" door");
|
resolver.pieces.get("pieces/target").getConnectors().getFirst().setName(" door");
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertCodes(result,
|
assertCodes(result,
|
||||||
@@ -168,9 +167,9 @@ public class StructureGraphCompilerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rejectsVerticalConnectorsThatYRotationCannotAlign() {
|
public void rejectsVerticalConnectorsThatYRotationCannotAlign() {
|
||||||
InMemoryResolver resolver = connectorGraph(true, IrisDirection.UP_POSITIVE_Y);
|
InMemoryResolver resolver = connectorGraph(true, JigsawDirection.UP_POSITIVE_Y);
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertCodes(result,
|
assertCodes(result,
|
||||||
@@ -180,34 +179,34 @@ public class StructureGraphCompilerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void alignedConnectorsRequireMatchingTopOrientation() {
|
public void alignedConnectorsRequireMatchingTopOrientation() {
|
||||||
InMemoryResolver resolver = connectorGraph(false, IrisDirection.SOUTH_POSITIVE_Z);
|
InMemoryResolver resolver = connectorGraph(false, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
IrisJigsawConnector source = resolver.pieces.get("pieces/start").getConnectors().getFirst();
|
IrisJigsawConnector source = resolver.pieces.get("pieces/start").getConnectors().getFirst();
|
||||||
IrisJigsawConnector target = resolver.pieces.get("pieces/target").getConnectors().getFirst();
|
IrisJigsawConnector target = resolver.pieces.get("pieces/target").getConnectors().getFirst();
|
||||||
source.setJoint(JigsawJoint.ALIGNED);
|
source.setJoint(JigsawJoint.ALIGNED);
|
||||||
source.setTop(IrisDirection.UP_POSITIVE_Y);
|
source.setTop(JigsawDirection.UP_POSITIVE_Y);
|
||||||
target.setTop(IrisDirection.DOWN_NEGATIVE_Y);
|
target.setTop(JigsawDirection.DOWN_NEGATIVE_Y);
|
||||||
|
|
||||||
StructureGraphCompilation aligned = StructureGraphCompiler.compile(
|
StructureGraphCompilation aligned = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
assertCodes(aligned,
|
assertCodes(aligned,
|
||||||
StructureGraphDiagnostic.Code.NO_COMPATIBLE_CONNECTOR,
|
StructureGraphDiagnostic.Code.NO_COMPATIBLE_CONNECTOR,
|
||||||
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
||||||
|
|
||||||
source.setJoint(JigsawJoint.ROLLABLE);
|
source.setJoint(JigsawJoint.ROLLABLE);
|
||||||
StructureGraphCompilation rollable = StructureGraphCompiler.compile(
|
StructureGraphCompilation rollable = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
assertTrue(rollable.isAssemblyViable());
|
assertTrue(rollable.isAssemblyViable());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void channelsParticipateInMatchingAndPortableGraphsRejectThem() {
|
public void channelsParticipateInMatchingAndPortableGraphsRejectThem() {
|
||||||
InMemoryResolver resolver = connectorGraph(false, IrisDirection.SOUTH_POSITIVE_Z);
|
InMemoryResolver resolver = connectorGraph(false, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
IrisJigsawConnector source = resolver.pieces.get("pieces/start").getConnectors().getFirst();
|
IrisJigsawConnector source = resolver.pieces.get("pieces/start").getConnectors().getFirst();
|
||||||
IrisJigsawConnector target = resolver.pieces.get("pieces/target").getConnectors().getFirst();
|
IrisJigsawConnector target = resolver.pieces.get("pieces/target").getConnectors().getFirst();
|
||||||
source.setChannel("roads");
|
source.setChannel("roads");
|
||||||
target.setChannel("rooms");
|
target.setChannel("rooms");
|
||||||
|
|
||||||
StructureGraphCompilation mismatched = StructureGraphCompiler.compile(
|
StructureGraphCompilation mismatched = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertCodes(mismatched,
|
assertCodes(mismatched,
|
||||||
@@ -215,7 +214,7 @@ public class StructureGraphCompilerTest {
|
|||||||
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
||||||
|
|
||||||
target.setChannel("Roads");
|
target.setChannel("Roads");
|
||||||
StructureGraphCompilation mismatchedCase = StructureGraphCompiler.compile(
|
StructureGraphCompilation mismatchedCase = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertCodes(mismatchedCase,
|
assertCodes(mismatchedCase,
|
||||||
@@ -223,7 +222,7 @@ public class StructureGraphCompilerTest {
|
|||||||
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
||||||
|
|
||||||
target.setChannel(" roads");
|
target.setChannel(" roads");
|
||||||
StructureGraphCompilation mismatchedWhitespace = StructureGraphCompiler.compile(
|
StructureGraphCompilation mismatchedWhitespace = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertCodes(mismatchedWhitespace,
|
assertCodes(mismatchedWhitespace,
|
||||||
@@ -231,7 +230,7 @@ public class StructureGraphCompilerTest {
|
|||||||
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
||||||
|
|
||||||
target.setChannel("roads");
|
target.setChannel("roads");
|
||||||
StructureGraphCompilation matched = StructureGraphCompiler.compile(
|
StructureGraphCompilation matched = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertTrue(matched.isAssemblyViable());
|
assertTrue(matched.isAssemblyViable());
|
||||||
@@ -239,7 +238,7 @@ public class StructureGraphCompilerTest {
|
|||||||
IrisStructure portable = structure("pools/start")
|
IrisStructure portable = structure("pools/start")
|
||||||
.setCompatibility(IrisJigsawCompatibility.VANILLA_PORTABLE)
|
.setCompatibility(IrisJigsawCompatibility.VANILLA_PORTABLE)
|
||||||
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
||||||
StructureGraphCompilation rejectedPortable = StructureGraphCompiler.compile(portable, resolver);
|
StructureGraphCompilation rejectedPortable = compile(portable, resolver);
|
||||||
|
|
||||||
assertCodes(rejectedPortable, StructureGraphDiagnostic.Code.NON_PORTABLE_CONNECTOR);
|
assertCodes(rejectedPortable, StructureGraphDiagnostic.Code.NON_PORTABLE_CONNECTOR);
|
||||||
assertTrue(rejectedPortable.hasErrors());
|
assertTrue(rejectedPortable.hasErrors());
|
||||||
@@ -249,7 +248,7 @@ public class StructureGraphCompilerTest {
|
|||||||
public void validatesPlanarCellSizeAndConnectorMetadata() {
|
public void validatesPlanarCellSizeAndConnectorMetadata() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector connector = connector(
|
IrisJigsawConnector connector = connector(
|
||||||
new IrisPosition(1, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(1, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/terminal", "source", "door")
|
"pools/terminal", "source", "door")
|
||||||
.setFinalState("")
|
.setFinalState("")
|
||||||
.setSelectionPriority(-1);
|
.setSelectionPriority(-1);
|
||||||
@@ -259,9 +258,9 @@ public class StructureGraphCompilerTest {
|
|||||||
resolver.pools.put("pools/terminal", pool());
|
resolver.pools.put("pools/terminal", pool());
|
||||||
IrisStructure structure = structure("pools/start")
|
IrisStructure structure = structure("pools/start")
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||||
.setCellSize(new IrisPosition(16, 0, 16));
|
.setCellSize(new BlockPosition(16, 0, 16));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
|
|
||||||
assertCodes(result,
|
assertCodes(result,
|
||||||
StructureGraphDiagnostic.Code.INVALID_PLANAR_CELL_SIZE,
|
StructureGraphDiagnostic.Code.INVALID_PLANAR_CELL_SIZE,
|
||||||
@@ -272,14 +271,14 @@ public class StructureGraphCompilerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void acceptsRectangularPlanarCellSize() {
|
public void acceptsRectangularPlanarCellSize() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
resolver.objects.put("objects/start", new IrisObject(16, 8, 8));
|
resolver.objects.put("objects/start", new ObjectFrame(16, 8, 8));
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start"));
|
resolver.pieces.put("pieces/start", piece("objects/start"));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
IrisStructure structure = structure("pools/start")
|
IrisStructure structure = structure("pools/start")
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||||
.setCellSize(new IrisPosition(16, 8, 8));
|
.setCellSize(new BlockPosition(16, 8, 8));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
|
|
||||||
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.INVALID_PLANAR_CELL_SIZE));
|
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.INVALID_PLANAR_CELL_SIZE));
|
||||||
assertTrue(result.isAssemblyViable());
|
assertTrue(result.isAssemblyViable());
|
||||||
@@ -288,24 +287,24 @@ public class StructureGraphCompilerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void allowsSmallerPlanarObjectsAndRejectsObjectsOutsideTheirWorkcell() {
|
public void allowsSmallerPlanarObjectsAndRejectsObjectsOutsideTheirWorkcell() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
resolver.objects.put("objects/start", new IrisObject(4, 3, 4));
|
resolver.objects.put("objects/start", new ObjectFrame(4, 3, 4));
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start"));
|
resolver.pieces.put("pieces/start", piece("objects/start"));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
IrisStructure structure = structure("pools/start")
|
IrisStructure structure = structure("pools/start")
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||||
.setCellSize(new IrisPosition(4, 3, 4));
|
.setCellSize(new BlockPosition(4, 3, 4));
|
||||||
|
|
||||||
StructureGraphCompilation valid = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation valid = compile(structure, resolver);
|
||||||
|
|
||||||
assertFalse(hasCode(valid, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE));
|
assertFalse(hasCode(valid, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE));
|
||||||
|
|
||||||
resolver.objects.put("objects/start", new IrisObject(4, 2, 4));
|
resolver.objects.put("objects/start", new ObjectFrame(4, 2, 4));
|
||||||
StructureGraphCompilation smaller = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation smaller = compile(structure, resolver);
|
||||||
|
|
||||||
assertFalse(hasCode(smaller, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE));
|
assertFalse(hasCode(smaller, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE));
|
||||||
|
|
||||||
resolver.objects.put("objects/start", new IrisObject(5, 3, 4));
|
resolver.objects.put("objects/start", new ObjectFrame(5, 3, 4));
|
||||||
StructureGraphCompilation oversized = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation oversized = compile(structure, resolver);
|
||||||
|
|
||||||
assertCodes(oversized, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE);
|
assertCodes(oversized, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE);
|
||||||
assertTrue(oversized.getDiagnostics().stream().anyMatch(
|
assertTrue(oversized.getDiagnostics().stream().anyMatch(
|
||||||
@@ -316,22 +315,22 @@ public class StructureGraphCompilerTest {
|
|||||||
public void ignoresPlanarObjectSizeForPiecesThatCannotBeReached() {
|
public void ignoresPlanarObjectSizeForPiecesThatCannotBeReached() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector source = connector(
|
IrisJigsawConnector source = connector(
|
||||||
new IrisPosition(2, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(2, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/target", "source", "door");
|
"pools/target", "source", "door");
|
||||||
IrisJigsawConnector target = connector(
|
IrisJigsawConnector target = connector(
|
||||||
new IrisPosition(2, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(2, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/target", "door", "unused");
|
"pools/target", "door", "unused");
|
||||||
resolver.objects.put("objects/start", new IrisObject(4, 3, 4));
|
resolver.objects.put("objects/start", new ObjectFrame(4, 3, 4));
|
||||||
resolver.objects.put("objects/target", new IrisObject(4, 2, 4));
|
resolver.objects.put("objects/target", new ObjectFrame(4, 2, 4));
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start", source).setRotatable(false));
|
resolver.pieces.put("pieces/start", piece("objects/start", source).setRotatable(false));
|
||||||
resolver.pieces.put("pieces/target", piece("objects/target", target).setRotatable(false));
|
resolver.pieces.put("pieces/target", piece("objects/target", target).setRotatable(false));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
resolver.pools.put("pools/target", pool(entry("pieces/target", 1)));
|
resolver.pools.put("pools/target", pool(entry("pieces/target", 1)));
|
||||||
IrisStructure structure = structure("pools/start")
|
IrisStructure structure = structure("pools/start")
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||||
.setCellSize(new IrisPosition(4, 3, 4));
|
.setCellSize(new BlockPosition(4, 3, 4));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
|
|
||||||
assertFalse(result.getGraph().getReachablePieces().contains("pieces/target"));
|
assertFalse(result.getGraph().getReachablePieces().contains("pieces/target"));
|
||||||
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE));
|
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE));
|
||||||
@@ -341,26 +340,26 @@ public class StructureGraphCompilerTest {
|
|||||||
public void acceptsAllCanonicalPlanarFaceCenterSockets() {
|
public void acceptsAllCanonicalPlanarFaceCenterSockets() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector north = connector(
|
IrisJigsawConnector north = connector(
|
||||||
new IrisPosition(2, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(2, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/terminal", "north", "door");
|
"pools/terminal", "north", "door");
|
||||||
IrisJigsawConnector east = connector(
|
IrisJigsawConnector east = connector(
|
||||||
new IrisPosition(3, 1, 2), IrisDirection.EAST_POSITIVE_X,
|
new BlockPosition(3, 1, 2), JigsawDirection.EAST_POSITIVE_X,
|
||||||
"pools/terminal", "east", "door");
|
"pools/terminal", "east", "door");
|
||||||
IrisJigsawConnector south = connector(
|
IrisJigsawConnector south = connector(
|
||||||
new IrisPosition(2, 1, 3), IrisDirection.SOUTH_POSITIVE_Z,
|
new BlockPosition(2, 1, 3), JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
"pools/terminal", "south", "door");
|
"pools/terminal", "south", "door");
|
||||||
IrisJigsawConnector west = connector(
|
IrisJigsawConnector west = connector(
|
||||||
new IrisPosition(0, 1, 2), IrisDirection.WEST_NEGATIVE_X,
|
new BlockPosition(0, 1, 2), JigsawDirection.WEST_NEGATIVE_X,
|
||||||
"pools/terminal", "west", "door");
|
"pools/terminal", "west", "door");
|
||||||
resolver.objects.put("objects/start", new IrisObject(4, 3, 4));
|
resolver.objects.put("objects/start", new ObjectFrame(4, 3, 4));
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start", north, east, south, west));
|
resolver.pieces.put("pieces/start", piece("objects/start", north, east, south, west));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
resolver.pools.put("pools/terminal", pool());
|
resolver.pools.put("pools/terminal", pool());
|
||||||
IrisStructure structure = structure("pools/start")
|
IrisStructure structure = structure("pools/start")
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||||
.setCellSize(new IrisPosition(4, 3, 4));
|
.setCellSize(new BlockPosition(4, 3, 4));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
|
|
||||||
assertTrue(result.getDiagnostics().isEmpty());
|
assertTrue(result.getDiagnostics().isEmpty());
|
||||||
assertTrue(result.isAssemblyViable());
|
assertTrue(result.isAssemblyViable());
|
||||||
@@ -370,24 +369,24 @@ public class StructureGraphCompilerTest {
|
|||||||
public void rejectsOffsetVerticalAndTiltedPlanarConnectors() {
|
public void rejectsOffsetVerticalAndTiltedPlanarConnectors() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector offset = connector(
|
IrisJigsawConnector offset = connector(
|
||||||
new IrisPosition(1, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(1, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/terminal", "offset", "door");
|
"pools/terminal", "offset", "door");
|
||||||
IrisJigsawConnector vertical = connector(
|
IrisJigsawConnector vertical = connector(
|
||||||
new IrisPosition(2, 1, 2), IrisDirection.UP_POSITIVE_Y,
|
new BlockPosition(2, 1, 2), JigsawDirection.UP_POSITIVE_Y,
|
||||||
"pools/terminal", "vertical", "door");
|
"pools/terminal", "vertical", "door");
|
||||||
IrisJigsawConnector tilted = connector(
|
IrisJigsawConnector tilted = connector(
|
||||||
new IrisPosition(2, 1, 3), IrisDirection.SOUTH_POSITIVE_Z,
|
new BlockPosition(2, 1, 3), JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
"pools/terminal", "tilted", "door")
|
"pools/terminal", "tilted", "door")
|
||||||
.setTop(IrisDirection.DOWN_NEGATIVE_Y);
|
.setTop(JigsawDirection.DOWN_NEGATIVE_Y);
|
||||||
resolver.objects.put("objects/start", new IrisObject(4, 3, 4));
|
resolver.objects.put("objects/start", new ObjectFrame(4, 3, 4));
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start", offset, vertical, tilted));
|
resolver.pieces.put("pieces/start", piece("objects/start", offset, vertical, tilted));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
resolver.pools.put("pools/terminal", pool());
|
resolver.pools.put("pools/terminal", pool());
|
||||||
IrisStructure structure = structure("pools/start")
|
IrisStructure structure = structure("pools/start")
|
||||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||||
.setCellSize(new IrisPosition(4, 3, 4));
|
.setCellSize(new BlockPosition(4, 3, 4));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
for (StructureGraphDiagnostic diagnostic : result.getDiagnostics()) {
|
for (StructureGraphDiagnostic diagnostic : result.getDiagnostics()) {
|
||||||
if (diagnostic.code() == StructureGraphDiagnostic.Code.INVALID_PLANAR_CONNECTOR) {
|
if (diagnostic.code() == StructureGraphDiagnostic.Code.INVALID_PLANAR_CONNECTOR) {
|
||||||
@@ -406,18 +405,18 @@ public class StructureGraphCompilerTest {
|
|||||||
public void spatialGraphsIgnoreThePlanarGeometryContract() {
|
public void spatialGraphsIgnoreThePlanarGeometryContract() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector vertical = connector(
|
IrisJigsawConnector vertical = connector(
|
||||||
new IrisPosition(1, 4, 1), IrisDirection.UP_POSITIVE_Y,
|
new BlockPosition(1, 4, 1), JigsawDirection.UP_POSITIVE_Y,
|
||||||
"pools/terminal", "vertical", "door")
|
"pools/terminal", "vertical", "door")
|
||||||
.setTop(IrisDirection.DOWN_NEGATIVE_Y);
|
.setTop(JigsawDirection.DOWN_NEGATIVE_Y);
|
||||||
resolver.objects.put("objects/start", new IrisObject(2, 5, 3));
|
resolver.objects.put("objects/start", new ObjectFrame(2, 5, 3));
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start", vertical));
|
resolver.pieces.put("pieces/start", piece("objects/start", vertical));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
resolver.pools.put("pools/terminal", pool());
|
resolver.pools.put("pools/terminal", pool());
|
||||||
IrisStructure structure = structure("pools/start")
|
IrisStructure structure = structure("pools/start")
|
||||||
.setMode(IrisJigsawMode.SPATIAL_JIGSAW)
|
.setMode(IrisJigsawMode.SPATIAL_JIGSAW)
|
||||||
.setCellSize(new IrisPosition(16, 0, 8));
|
.setCellSize(new BlockPosition(16, 0, 8));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
|
|
||||||
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.INVALID_PLANAR_CELL_SIZE));
|
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.INVALID_PLANAR_CELL_SIZE));
|
||||||
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE));
|
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE));
|
||||||
@@ -429,20 +428,20 @@ public class StructureGraphCompilerTest {
|
|||||||
public void deterministicSamplesHonorSelectionPriorityAndStableTies() {
|
public void deterministicSamplesHonorSelectionPriorityAndStableTies() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector east = connector(
|
IrisJigsawConnector east = connector(
|
||||||
new IrisPosition(2, 1, 1), IrisDirection.EAST_POSITIVE_X,
|
new BlockPosition(2, 1, 1), JigsawDirection.EAST_POSITIVE_X,
|
||||||
"pools/east", "source", "door").setSelectionPriority(-20);
|
"pools/east", "source", "door").setSelectionPriority(-20);
|
||||||
IrisJigsawConnector west = connector(
|
IrisJigsawConnector west = connector(
|
||||||
new IrisPosition(0, 1, 1), IrisDirection.WEST_NEGATIVE_X,
|
new BlockPosition(0, 1, 1), JigsawDirection.WEST_NEGATIVE_X,
|
||||||
"pools/west", "source", "door").setSelectionPriority(-10);
|
"pools/west", "source", "door").setSelectionPriority(-10);
|
||||||
resolver.objects.put("objects/start", object());
|
resolver.objects.put("objects/start", object());
|
||||||
resolver.objects.put("objects/east", object());
|
resolver.objects.put("objects/east", object());
|
||||||
resolver.objects.put("objects/west", object());
|
resolver.objects.put("objects/west", object());
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start", east, west));
|
resolver.pieces.put("pieces/start", piece("objects/start", east, west));
|
||||||
resolver.pieces.put("pieces/east", piece("objects/east", connector(
|
resolver.pieces.put("pieces/east", piece("objects/east", connector(
|
||||||
new IrisPosition(0, 1, 1), IrisDirection.WEST_NEGATIVE_X,
|
new BlockPosition(0, 1, 1), JigsawDirection.WEST_NEGATIVE_X,
|
||||||
"pools/terminal", "door", "unused")));
|
"pools/terminal", "door", "unused")));
|
||||||
resolver.pieces.put("pieces/west", piece("objects/west", connector(
|
resolver.pieces.put("pieces/west", piece("objects/west", connector(
|
||||||
new IrisPosition(2, 1, 1), IrisDirection.EAST_POSITIVE_X,
|
new BlockPosition(2, 1, 1), JigsawDirection.EAST_POSITIVE_X,
|
||||||
"pools/terminal", "door", "unused")));
|
"pools/terminal", "door", "unused")));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
resolver.pools.put("pools/east", pool(entry("pieces/east", 1)));
|
resolver.pools.put("pools/east", pool(entry("pieces/east", 1)));
|
||||||
@@ -450,7 +449,7 @@ public class StructureGraphCompilerTest {
|
|||||||
resolver.pools.put("pools/terminal", pool());
|
resolver.pools.put("pools/terminal", pool());
|
||||||
IrisStructure structure = structure("pools/start");
|
IrisStructure structure = structure("pools/start");
|
||||||
|
|
||||||
StructureGraphCompilation prioritized = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation prioritized = compile(structure, resolver);
|
||||||
|
|
||||||
for (StructureGraphAssemblySample sample : prioritized.getAssemblySamples()) {
|
for (StructureGraphAssemblySample sample : prioritized.getAssemblySamples()) {
|
||||||
assertEquals(List.of("pieces/start", "pieces/west", "pieces/east"),
|
assertEquals(List.of("pieces/start", "pieces/west", "pieces/east"),
|
||||||
@@ -458,7 +457,7 @@ public class StructureGraphCompilerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
east.setSelectionPriority(-10);
|
east.setSelectionPriority(-10);
|
||||||
StructureGraphCompilation tied = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation tied = compile(structure, resolver);
|
||||||
|
|
||||||
for (StructureGraphAssemblySample sample : tied.getAssemblySamples()) {
|
for (StructureGraphAssemblySample sample : tied.getAssemblySamples()) {
|
||||||
assertEquals(List.of("pieces/start", "pieces/east", "pieces/west"),
|
assertEquals(List.of("pieces/start", "pieces/east", "pieces/west"),
|
||||||
@@ -470,22 +469,22 @@ public class StructureGraphCompilerTest {
|
|||||||
public void deterministicSamplesScheduleChildExpansionBySourcePlacementPriority() {
|
public void deterministicSamplesScheduleChildExpansionBySourcePlacementPriority() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector eastSource = connector(
|
IrisJigsawConnector eastSource = connector(
|
||||||
new IrisPosition(2, 1, 1), IrisDirection.EAST_POSITIVE_X,
|
new BlockPosition(2, 1, 1), JigsawDirection.EAST_POSITIVE_X,
|
||||||
"pools/east", "source", "door").setPlacementPriority(-20);
|
"pools/east", "source", "door").setPlacementPriority(-20);
|
||||||
IrisJigsawConnector westSource = connector(
|
IrisJigsawConnector westSource = connector(
|
||||||
new IrisPosition(0, 1, 1), IrisDirection.WEST_NEGATIVE_X,
|
new BlockPosition(0, 1, 1), JigsawDirection.WEST_NEGATIVE_X,
|
||||||
"pools/west", "source", "door").setPlacementPriority(-10);
|
"pools/west", "source", "door").setPlacementPriority(-10);
|
||||||
IrisJigsawConnector eastTarget = connector(
|
IrisJigsawConnector eastTarget = connector(
|
||||||
new IrisPosition(0, 1, 1), IrisDirection.WEST_NEGATIVE_X,
|
new BlockPosition(0, 1, 1), JigsawDirection.WEST_NEGATIVE_X,
|
||||||
"pools/terminal", "door", "unused");
|
"pools/terminal", "door", "unused");
|
||||||
IrisJigsawConnector eastBranch = connector(
|
IrisJigsawConnector eastBranch = connector(
|
||||||
new IrisPosition(2, 1, 1), IrisDirection.EAST_POSITIVE_X,
|
new BlockPosition(2, 1, 1), JigsawDirection.EAST_POSITIVE_X,
|
||||||
"pools/east-leaf", "east", "leaf");
|
"pools/east-leaf", "east", "leaf");
|
||||||
IrisJigsawConnector westTarget = connector(
|
IrisJigsawConnector westTarget = connector(
|
||||||
new IrisPosition(2, 1, 1), IrisDirection.EAST_POSITIVE_X,
|
new BlockPosition(2, 1, 1), JigsawDirection.EAST_POSITIVE_X,
|
||||||
"pools/terminal", "door", "unused");
|
"pools/terminal", "door", "unused");
|
||||||
IrisJigsawConnector westBranch = connector(
|
IrisJigsawConnector westBranch = connector(
|
||||||
new IrisPosition(0, 1, 1), IrisDirection.WEST_NEGATIVE_X,
|
new BlockPosition(0, 1, 1), JigsawDirection.WEST_NEGATIVE_X,
|
||||||
"pools/west-leaf", "west", "leaf");
|
"pools/west-leaf", "west", "leaf");
|
||||||
resolver.objects.put("objects/start", object());
|
resolver.objects.put("objects/start", object());
|
||||||
resolver.objects.put("objects/east", object());
|
resolver.objects.put("objects/east", object());
|
||||||
@@ -496,10 +495,10 @@ public class StructureGraphCompilerTest {
|
|||||||
resolver.pieces.put("pieces/east", piece("objects/east", eastTarget, eastBranch));
|
resolver.pieces.put("pieces/east", piece("objects/east", eastTarget, eastBranch));
|
||||||
resolver.pieces.put("pieces/west", piece("objects/west", westTarget, westBranch));
|
resolver.pieces.put("pieces/west", piece("objects/west", westTarget, westBranch));
|
||||||
resolver.pieces.put("pieces/east-leaf", piece("objects/east-leaf", connector(
|
resolver.pieces.put("pieces/east-leaf", piece("objects/east-leaf", connector(
|
||||||
new IrisPosition(0, 1, 1), IrisDirection.WEST_NEGATIVE_X,
|
new BlockPosition(0, 1, 1), JigsawDirection.WEST_NEGATIVE_X,
|
||||||
"pools/terminal", "leaf", "unused")));
|
"pools/terminal", "leaf", "unused")));
|
||||||
resolver.pieces.put("pieces/west-leaf", piece("objects/west-leaf", connector(
|
resolver.pieces.put("pieces/west-leaf", piece("objects/west-leaf", connector(
|
||||||
new IrisPosition(2, 1, 1), IrisDirection.EAST_POSITIVE_X,
|
new BlockPosition(2, 1, 1), JigsawDirection.EAST_POSITIVE_X,
|
||||||
"pools/terminal", "leaf", "unused")));
|
"pools/terminal", "leaf", "unused")));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
resolver.pools.put("pools/east", pool(entry("pieces/east", 1)));
|
resolver.pools.put("pools/east", pool(entry("pieces/east", 1)));
|
||||||
@@ -509,7 +508,7 @@ public class StructureGraphCompilerTest {
|
|||||||
resolver.pools.put("pools/terminal", pool());
|
resolver.pools.put("pools/terminal", pool());
|
||||||
IrisStructure structure = structure("pools/start");
|
IrisStructure structure = structure("pools/start");
|
||||||
|
|
||||||
StructureGraphCompilation prioritized = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation prioritized = compile(structure, resolver);
|
||||||
|
|
||||||
for (StructureGraphAssemblySample sample : prioritized.getAssemblySamples()) {
|
for (StructureGraphAssemblySample sample : prioritized.getAssemblySamples()) {
|
||||||
assertEquals(List.of(
|
assertEquals(List.of(
|
||||||
@@ -519,7 +518,7 @@ public class StructureGraphCompilerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
westSource.setPlacementPriority(-20);
|
westSource.setPlacementPriority(-20);
|
||||||
StructureGraphCompilation tied = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation tied = compile(structure, resolver);
|
||||||
|
|
||||||
for (StructureGraphAssemblySample sample : tied.getAssemblySamples()) {
|
for (StructureGraphAssemblySample sample : tied.getAssemblySamples()) {
|
||||||
assertEquals(List.of(
|
assertEquals(List.of(
|
||||||
@@ -533,25 +532,25 @@ public class StructureGraphCompilerTest {
|
|||||||
public void deterministicSamplesUseSelectionPriorityForCandidateConnectors() {
|
public void deterministicSamplesUseSelectionPriorityForCandidateConnectors() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector source = connector(
|
IrisJigsawConnector source = connector(
|
||||||
new IrisPosition(0, 1, 0), IrisDirection.EAST_POSITIVE_X,
|
new BlockPosition(0, 1, 0), JigsawDirection.EAST_POSITIVE_X,
|
||||||
"pools/target", "source", "door");
|
"pools/target", "source", "door");
|
||||||
IrisJigsawConnector low = connector(
|
IrisJigsawConnector low = connector(
|
||||||
new IrisPosition(0, 1, 0), IrisDirection.WEST_NEGATIVE_X,
|
new BlockPosition(0, 1, 0), JigsawDirection.WEST_NEGATIVE_X,
|
||||||
"pools/low", "door", "leaf").setSelectionPriority(-20);
|
"pools/low", "door", "leaf").setSelectionPriority(-20);
|
||||||
IrisJigsawConnector high = connector(
|
IrisJigsawConnector high = connector(
|
||||||
new IrisPosition(0, 1, 2), IrisDirection.WEST_NEGATIVE_X,
|
new BlockPosition(0, 1, 2), JigsawDirection.WEST_NEGATIVE_X,
|
||||||
"pools/high", "door", "leaf").setSelectionPriority(-10);
|
"pools/high", "door", "leaf").setSelectionPriority(-10);
|
||||||
resolver.objects.put("objects/start", new IrisObject(1, 3, 1));
|
resolver.objects.put("objects/start", new ObjectFrame(1, 3, 1));
|
||||||
resolver.objects.put("objects/target", new IrisObject(1, 3, 3));
|
resolver.objects.put("objects/target", new ObjectFrame(1, 3, 3));
|
||||||
resolver.objects.put("objects/low-leaf", new IrisObject(1, 3, 1));
|
resolver.objects.put("objects/low-leaf", new ObjectFrame(1, 3, 1));
|
||||||
resolver.objects.put("objects/high-leaf", new IrisObject(1, 3, 1));
|
resolver.objects.put("objects/high-leaf", new ObjectFrame(1, 3, 1));
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start", source).setRotatable(false));
|
resolver.pieces.put("pieces/start", piece("objects/start", source).setRotatable(false));
|
||||||
resolver.pieces.put("pieces/target", piece("objects/target", low, high).setRotatable(false));
|
resolver.pieces.put("pieces/target", piece("objects/target", low, high).setRotatable(false));
|
||||||
resolver.pieces.put("pieces/low-leaf", piece("objects/low-leaf", connector(
|
resolver.pieces.put("pieces/low-leaf", piece("objects/low-leaf", connector(
|
||||||
new IrisPosition(0, 1, 0), IrisDirection.EAST_POSITIVE_X,
|
new BlockPosition(0, 1, 0), JigsawDirection.EAST_POSITIVE_X,
|
||||||
"pools/terminal", "leaf", "unused")).setRotatable(false));
|
"pools/terminal", "leaf", "unused")).setRotatable(false));
|
||||||
resolver.pieces.put("pieces/high-leaf", piece("objects/high-leaf", connector(
|
resolver.pieces.put("pieces/high-leaf", piece("objects/high-leaf", connector(
|
||||||
new IrisPosition(0, 1, 0), IrisDirection.EAST_POSITIVE_X,
|
new BlockPosition(0, 1, 0), JigsawDirection.EAST_POSITIVE_X,
|
||||||
"pools/terminal", "leaf", "unused")).setRotatable(false));
|
"pools/terminal", "leaf", "unused")).setRotatable(false));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
resolver.pools.put("pools/target", pool(entry("pieces/target", 1)));
|
resolver.pools.put("pools/target", pool(entry("pieces/target", 1)));
|
||||||
@@ -560,7 +559,7 @@ public class StructureGraphCompilerTest {
|
|||||||
resolver.pools.put("pools/terminal", pool());
|
resolver.pools.put("pools/terminal", pool());
|
||||||
IrisStructure structure = structure("pools/start");
|
IrisStructure structure = structure("pools/start");
|
||||||
|
|
||||||
StructureGraphCompilation prioritized = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation prioritized = compile(structure, resolver);
|
||||||
|
|
||||||
for (StructureGraphAssemblySample sample : prioritized.getAssemblySamples()) {
|
for (StructureGraphAssemblySample sample : prioritized.getAssemblySamples()) {
|
||||||
assertEquals(List.of("pieces/start", "pieces/target", "pieces/low-leaf"),
|
assertEquals(List.of("pieces/start", "pieces/target", "pieces/low-leaf"),
|
||||||
@@ -568,7 +567,7 @@ public class StructureGraphCompilerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
low.setSelectionPriority(-10);
|
low.setSelectionPriority(-10);
|
||||||
StructureGraphCompilation tied = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation tied = compile(structure, resolver);
|
||||||
|
|
||||||
for (StructureGraphAssemblySample sample : tied.getAssemblySamples()) {
|
for (StructureGraphAssemblySample sample : tied.getAssemblySamples()) {
|
||||||
assertEquals(List.of("pieces/start", "pieces/target", "pieces/high-leaf"),
|
assertEquals(List.of("pieces/start", "pieces/target", "pieces/high-leaf"),
|
||||||
@@ -580,16 +579,16 @@ public class StructureGraphCompilerTest {
|
|||||||
public void deterministicSamplingUsesFallbackAtTheMaximumDepth() {
|
public void deterministicSamplingUsesFallbackAtTheMaximumDepth() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector source = connector(
|
IrisJigsawConnector source = connector(
|
||||||
new IrisPosition(1, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(1, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/primary", "source", "door");
|
"pools/primary", "source", "door");
|
||||||
IrisJigsawConnector primaryTarget = connector(
|
IrisJigsawConnector primaryTarget = connector(
|
||||||
new IrisPosition(1, 1, 2), IrisDirection.SOUTH_POSITIVE_Z,
|
new BlockPosition(1, 1, 2), JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
"pools/primary", "door", "unused");
|
"pools/primary", "door", "unused");
|
||||||
IrisJigsawConnector primarySource = connector(
|
IrisJigsawConnector primarySource = connector(
|
||||||
new IrisPosition(1, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(1, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/primary", "source", "door");
|
"pools/primary", "source", "door");
|
||||||
IrisJigsawConnector fallbackTarget = connector(
|
IrisJigsawConnector fallbackTarget = connector(
|
||||||
new IrisPosition(1, 1, 2), IrisDirection.SOUTH_POSITIVE_Z,
|
new BlockPosition(1, 1, 2), JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
"pools/primary", "door", "unused");
|
"pools/primary", "door", "unused");
|
||||||
resolver.objects.put("objects/start", object());
|
resolver.objects.put("objects/start", object());
|
||||||
resolver.objects.put("objects/primary", object());
|
resolver.objects.put("objects/primary", object());
|
||||||
@@ -605,7 +604,7 @@ public class StructureGraphCompilerTest {
|
|||||||
IrisStructure structure = structure("pools/start");
|
IrisStructure structure = structure("pools/start");
|
||||||
structure.setMaxDepth(1);
|
structure.setMaxDepth(1);
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
|
|
||||||
assertTrue(result.getDiagnostics().isEmpty());
|
assertTrue(result.getDiagnostics().isEmpty());
|
||||||
assertTrue(result.isAssemblyViable());
|
assertTrue(result.isAssemblyViable());
|
||||||
@@ -620,13 +619,13 @@ public class StructureGraphCompilerTest {
|
|||||||
public void deterministicSamplingDoesNotSelectFallbackOfFallback() {
|
public void deterministicSamplingDoesNotSelectFallbackOfFallback() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector source = connector(
|
IrisJigsawConnector source = connector(
|
||||||
new IrisPosition(1, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(1, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/primary", "source", "door");
|
"pools/primary", "source", "door");
|
||||||
IrisJigsawConnector incompatible = connector(
|
IrisJigsawConnector incompatible = connector(
|
||||||
new IrisPosition(1, 1, 2), IrisDirection.SOUTH_POSITIVE_Z,
|
new BlockPosition(1, 1, 2), JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
"pools/primary", "wrong", "unused");
|
"pools/primary", "wrong", "unused");
|
||||||
IrisJigsawConnector nestedTarget = connector(
|
IrisJigsawConnector nestedTarget = connector(
|
||||||
new IrisPosition(1, 1, 2), IrisDirection.SOUTH_POSITIVE_Z,
|
new BlockPosition(1, 1, 2), JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
"pools/primary", "door", "unused");
|
"pools/primary", "door", "unused");
|
||||||
resolver.objects.put("objects/start", object());
|
resolver.objects.put("objects/start", object());
|
||||||
resolver.objects.put("objects/incompatible", object());
|
resolver.objects.put("objects/incompatible", object());
|
||||||
@@ -643,7 +642,7 @@ public class StructureGraphCompilerTest {
|
|||||||
resolver.pools.put("pools/direct", direct);
|
resolver.pools.put("pools/direct", direct);
|
||||||
resolver.pools.put("pools/nested", pool(entry("pieces/nested", 1)));
|
resolver.pools.put("pools/nested", pool(entry("pieces/nested", 1)));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertFalse(result.getGraph().getReachablePools().contains("pools/nested"));
|
assertFalse(result.getGraph().getReachablePools().contains("pools/nested"));
|
||||||
@@ -671,7 +670,7 @@ public class StructureGraphCompilerTest {
|
|||||||
resolver.pools.put("pools/first", first);
|
resolver.pools.put("pools/first", first);
|
||||||
resolver.pools.put("pools/second", second);
|
resolver.pools.put("pools/second", second);
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertCodes(result,
|
assertCodes(result,
|
||||||
@@ -694,7 +693,7 @@ public class StructureGraphCompilerTest {
|
|||||||
resolver.pools.put("pools/chain-" + index, pool);
|
resolver.pools.put("pools/chain-" + index, pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/chain-0"), resolver);
|
structure("pools/chain-0"), resolver);
|
||||||
|
|
||||||
assertTrue(result.getDiagnostics().stream().noneMatch(
|
assertTrue(result.getDiagnostics().stream().noneMatch(
|
||||||
@@ -705,14 +704,14 @@ public class StructureGraphCompilerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void reportsMissingObjectsAndInvalidObjectBounds() {
|
public void reportsMissingObjectsAndInvalidObjectBounds() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
resolver.objects.put("objects/empty", new IrisObject());
|
resolver.objects.put("objects/empty", new ObjectFrame(0, 0, 0));
|
||||||
resolver.pieces.put("pieces/missing-object", piece("objects/missing"));
|
resolver.pieces.put("pieces/missing-object", piece("objects/missing"));
|
||||||
resolver.pieces.put("pieces/empty-object", piece("objects/empty"));
|
resolver.pieces.put("pieces/empty-object", piece("objects/empty"));
|
||||||
resolver.pools.put("pools/start", pool(
|
resolver.pools.put("pools/start", pool(
|
||||||
entry("pieces/missing-object", 1),
|
entry("pieces/missing-object", 1),
|
||||||
entry("pieces/empty-object", 1)));
|
entry("pieces/empty-object", 1)));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertCodes(result,
|
assertCodes(result,
|
||||||
@@ -730,15 +729,15 @@ public class StructureGraphCompilerTest {
|
|||||||
nullListResolver.pieces.put("pieces/start", nullListPiece);
|
nullListResolver.pieces.put("pieces/start", nullListPiece);
|
||||||
nullListResolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
nullListResolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
|
|
||||||
StructureGraphCompilation nullList = StructureGraphCompiler.compile(
|
StructureGraphCompilation nullList = compile(
|
||||||
structure("pools/start"), nullListResolver);
|
structure("pools/start"), nullListResolver);
|
||||||
|
|
||||||
assertCodes(nullList, StructureGraphDiagnostic.Code.INVALID_CONNECTOR);
|
assertCodes(nullList, StructureGraphDiagnostic.Code.INVALID_CONNECTOR);
|
||||||
assertTrue(nullList.hasErrors());
|
assertTrue(nullList.hasErrors());
|
||||||
|
|
||||||
InMemoryResolver nullNamesResolver = connectorGraph(true, IrisDirection.SOUTH_POSITIVE_Z);
|
InMemoryResolver nullNamesResolver = connectorGraph(true, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
nullNamesResolver.pieces.get("pieces/start").getConnectors().getFirst().setTargetName(null);
|
nullNamesResolver.pieces.get("pieces/start").getConnectors().getFirst().setTargetName(null);
|
||||||
StructureGraphCompilation nullNames = StructureGraphCompiler.compile(
|
StructureGraphCompilation nullNames = compile(
|
||||||
structure("pools/start"), nullNamesResolver);
|
structure("pools/start"), nullNamesResolver);
|
||||||
|
|
||||||
assertCodes(nullNames, StructureGraphDiagnostic.Code.INVALID_CONNECTOR);
|
assertCodes(nullNames, StructureGraphDiagnostic.Code.INVALID_CONNECTOR);
|
||||||
@@ -759,11 +758,11 @@ public class StructureGraphCompilerTest {
|
|||||||
IrisStructure overflowing = structure("pools/start");
|
IrisStructure overflowing = structure("pools/start");
|
||||||
overflowing.setMaxSizeChunks(Integer.MAX_VALUE);
|
overflowing.setMaxSizeChunks(Integer.MAX_VALUE);
|
||||||
|
|
||||||
assertCodes(StructureGraphCompiler.compile(deep, resolver),
|
assertCodes(compile(deep, resolver),
|
||||||
StructureGraphDiagnostic.Code.INVALID_MAX_DEPTH);
|
StructureGraphDiagnostic.Code.INVALID_MAX_DEPTH);
|
||||||
assertCodes(StructureGraphCompiler.compile(wide, resolver),
|
assertCodes(compile(wide, resolver),
|
||||||
StructureGraphDiagnostic.Code.INVALID_MAX_SIZE);
|
StructureGraphDiagnostic.Code.INVALID_MAX_SIZE);
|
||||||
assertCodes(StructureGraphCompiler.compile(overflowing, resolver),
|
assertCodes(compile(overflowing, resolver),
|
||||||
StructureGraphDiagnostic.Code.INVALID_MAX_SIZE);
|
StructureGraphDiagnostic.Code.INVALID_MAX_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -771,14 +770,14 @@ public class StructureGraphCompilerTest {
|
|||||||
public void emptyPoolChoiceTerminatesABranchWithoutAPlaceholderPiece() {
|
public void emptyPoolChoiceTerminatesABranchWithoutAPlaceholderPiece() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector source = connector(
|
IrisJigsawConnector source = connector(
|
||||||
new IrisPosition(1, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(1, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/terminal", "source", "door");
|
"pools/terminal", "source", "door");
|
||||||
resolver.objects.put("objects/start", object());
|
resolver.objects.put("objects/start", object());
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start", source));
|
resolver.pieces.put("pieces/start", piece("objects/start", source));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
resolver.pools.put("pools/terminal", pool(emptyEntry(4)));
|
resolver.pools.put("pools/terminal", pool(emptyEntry(4)));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertTrue(result.getDiagnostics().isEmpty());
|
assertTrue(result.getDiagnostics().isEmpty());
|
||||||
@@ -794,7 +793,7 @@ public class StructureGraphCompilerTest {
|
|||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
resolver.pools.put("pools/start", pool(emptyEntry(1)));
|
resolver.pools.put("pools/start", pool(emptyEntry(1)));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertTrue(result.isAssemblyViable());
|
assertTrue(result.isAssemblyViable());
|
||||||
@@ -815,7 +814,7 @@ public class StructureGraphCompilerTest {
|
|||||||
resolver.pools.put("pools/start", pool(
|
resolver.pools.put("pools/start", pool(
|
||||||
entry("pieces/start", Integer.MAX_VALUE), emptyEntry(1)));
|
entry("pieces/start", Integer.MAX_VALUE), emptyEntry(1)));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertTrue(result.isAssemblyViable());
|
assertTrue(result.isAssemblyViable());
|
||||||
@@ -827,11 +826,11 @@ public class StructureGraphCompilerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void oversizedStartPreventsGuaranteedReplacementOutput() {
|
public void oversizedStartPreventsGuaranteedReplacementOutput() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
resolver.objects.put("objects/start", new IrisObject(130, 3, 3));
|
resolver.objects.put("objects/start", new ObjectFrame(130, 3, 3));
|
||||||
resolver.pieces.put("pieces/start", piece("objects/start"));
|
resolver.pieces.put("pieces/start", piece("objects/start"));
|
||||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertTrue(result.isAssemblyViable());
|
assertTrue(result.isAssemblyViable());
|
||||||
@@ -840,9 +839,9 @@ public class StructureGraphCompilerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void reachableBranchRequiresAuthoredEmptyTerminationForReplacementOutput() {
|
public void reachableBranchRequiresAuthoredEmptyTerminationForReplacementOutput() {
|
||||||
InMemoryResolver resolver = connectorGraph(true, IrisDirection.NORTH_NEGATIVE_Z);
|
InMemoryResolver resolver = connectorGraph(true, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
|
|
||||||
StructureGraphCompilation unbounded = StructureGraphCompiler.compile(
|
StructureGraphCompilation unbounded = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertTrue(unbounded.isAssemblyViable());
|
assertTrue(unbounded.isAssemblyViable());
|
||||||
@@ -850,7 +849,7 @@ public class StructureGraphCompilerTest {
|
|||||||
|
|
||||||
resolver.pools.get("pools/target").setFallback("pools/empty");
|
resolver.pools.get("pools/target").setFallback("pools/empty");
|
||||||
resolver.pools.put("pools/empty", pool());
|
resolver.pools.put("pools/empty", pool());
|
||||||
StructureGraphCompilation terminated = StructureGraphCompiler.compile(
|
StructureGraphCompilation terminated = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertTrue(terminated.isAssemblyViable());
|
assertTrue(terminated.isAssemblyViable());
|
||||||
@@ -859,13 +858,13 @@ public class StructureGraphCompilerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void branchTerminationPolicyMakesUnmatchedOptionalBranchesViable() {
|
public void branchTerminationPolicyMakesUnmatchedOptionalBranchesViable() {
|
||||||
InMemoryResolver resolver = connectorGraph(false, IrisDirection.NORTH_NEGATIVE_Z);
|
InMemoryResolver resolver = connectorGraph(false, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||||
IrisStructure strictStructure = structure("pools/start");
|
IrisStructure strictStructure = structure("pools/start");
|
||||||
IrisStructure terminatingStructure = structure("pools/start")
|
IrisStructure terminatingStructure = structure("pools/start")
|
||||||
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
||||||
|
|
||||||
StructureGraphCompilation strict = StructureGraphCompiler.compile(strictStructure, resolver);
|
StructureGraphCompilation strict = compile(strictStructure, resolver);
|
||||||
StructureGraphCompilation terminating = StructureGraphCompiler.compile(terminatingStructure, resolver);
|
StructureGraphCompilation terminating = compile(terminatingStructure, resolver);
|
||||||
|
|
||||||
assertCodes(strict,
|
assertCodes(strict,
|
||||||
StructureGraphDiagnostic.Code.NO_COMPATIBLE_CONNECTOR,
|
StructureGraphDiagnostic.Code.NO_COMPATIBLE_CONNECTOR,
|
||||||
@@ -892,9 +891,9 @@ public class StructureGraphCompilerTest {
|
|||||||
IrisStructure structure = structure("pools/start")
|
IrisStructure structure = structure("pools/start")
|
||||||
.setCompatibility(IrisJigsawCompatibility.VANILLA_PORTABLE);
|
.setCompatibility(IrisJigsawCompatibility.VANILLA_PORTABLE);
|
||||||
|
|
||||||
StructureGraphCompilation strict = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation strict = compile(structure, resolver);
|
||||||
structure.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
structure.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
||||||
StructureGraphCompilation terminating = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation terminating = compile(structure, resolver);
|
||||||
|
|
||||||
assertCodes(strict, StructureGraphDiagnostic.Code.NON_PORTABLE_METADATA);
|
assertCodes(strict, StructureGraphDiagnostic.Code.NON_PORTABLE_METADATA);
|
||||||
assertTrue(strict.hasErrors());
|
assertTrue(strict.hasErrors());
|
||||||
@@ -906,16 +905,16 @@ public class StructureGraphCompilerTest {
|
|||||||
public void authoritativeGeometrySamplingDoesNotReportTopologyOnlyPieceCaps() {
|
public void authoritativeGeometrySamplingDoesNotReportTopologyOnlyPieceCaps() {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector startSource = connector(
|
IrisJigsawConnector startSource = connector(
|
||||||
new IrisPosition(1, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(1, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/recursive", "source", "door");
|
"pools/recursive", "source", "door");
|
||||||
IrisJigsawConnector recursiveTarget = connector(
|
IrisJigsawConnector recursiveTarget = connector(
|
||||||
new IrisPosition(1, 1, 2), IrisDirection.SOUTH_POSITIVE_Z,
|
new BlockPosition(1, 1, 2), JigsawDirection.SOUTH_POSITIVE_Z,
|
||||||
"pools/recursive", "door", "unused");
|
"pools/recursive", "door", "unused");
|
||||||
IrisJigsawConnector firstBranch = connector(
|
IrisJigsawConnector firstBranch = connector(
|
||||||
new IrisPosition(1, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(1, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/recursive", "source", "door");
|
"pools/recursive", "source", "door");
|
||||||
IrisJigsawConnector secondBranch = connector(
|
IrisJigsawConnector secondBranch = connector(
|
||||||
new IrisPosition(1, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(1, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/recursive", "source", "door");
|
"pools/recursive", "source", "door");
|
||||||
resolver.objects.put("objects/start", object());
|
resolver.objects.put("objects/start", object());
|
||||||
resolver.objects.put("objects/recursive", object());
|
resolver.objects.put("objects/recursive", object());
|
||||||
@@ -931,7 +930,7 @@ public class StructureGraphCompilerTest {
|
|||||||
structure.setMaxDepth(30);
|
structure.setMaxDepth(30);
|
||||||
structure.setMaxSizeChunks(8);
|
structure.setMaxSizeChunks(8);
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
|
|
||||||
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.ASSEMBLY_PIECE_CAP_REACHED));
|
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.ASSEMBLY_PIECE_CAP_REACHED));
|
||||||
assertTrue(result.isAssemblyViable());
|
assertTrue(result.isAssemblyViable());
|
||||||
@@ -955,7 +954,7 @@ public class StructureGraphCompilerTest {
|
|||||||
IrisStructure structure = structure("pools/start");
|
IrisStructure structure = structure("pools/start");
|
||||||
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-1", 1));
|
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-1", 1));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
|
|
||||||
assertCodes(result,
|
assertCodes(result,
|
||||||
StructureGraphDiagnostic.Code.INVALID_CHANCE,
|
StructureGraphDiagnostic.Code.INVALID_CHANCE,
|
||||||
@@ -976,18 +975,18 @@ public class StructureGraphCompilerTest {
|
|||||||
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-1", 1));
|
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-1", 1));
|
||||||
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-2", 1));
|
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-2", 1));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
|
|
||||||
assertCodes(result, StructureGraphDiagnostic.Code.UNSATISFIABLE_PIECE_RULE);
|
assertCodes(result, StructureGraphDiagnostic.Code.UNSATISFIABLE_PIECE_RULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void terminalPiecesDoNotMakeTheirOutgoingPoolsReachable() {
|
public void terminalPiecesDoNotMakeTheirOutgoingPoolsReachable() {
|
||||||
InMemoryResolver resolver = connectorGraph(true, IrisDirection.SOUTH_POSITIVE_Z);
|
InMemoryResolver resolver = connectorGraph(true, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
resolver.pieces.get("pieces/start").setRules(
|
resolver.pieces.get("pieces/start").setRules(
|
||||||
new IrisJigsawPieceRules().setTerminal(true));
|
new IrisJigsawPieceRules().setTerminal(true));
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
StructureGraphCompilation result = compile(
|
||||||
structure("pools/start"), resolver);
|
structure("pools/start"), resolver);
|
||||||
|
|
||||||
assertTrue(result.getGraph().getReachablePieces().contains("pieces/start"));
|
assertTrue(result.getGraph().getReachablePieces().contains("pieces/start"));
|
||||||
@@ -997,20 +996,20 @@ public class StructureGraphCompilerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void requiredCapsNeedACompatibleTerminalInTheDirectFallback() {
|
public void requiredCapsNeedACompatibleTerminalInTheDirectFallback() {
|
||||||
InMemoryResolver resolver = connectorGraph(true, IrisDirection.SOUTH_POSITIVE_Z);
|
InMemoryResolver resolver = connectorGraph(true, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||||
resolver.pools.get("pools/target").setFallback("pools/fallback");
|
resolver.pools.get("pools/target").setFallback("pools/fallback");
|
||||||
resolver.pools.put("pools/fallback", pool(entry("pieces/target", 1)));
|
resolver.pools.put("pools/fallback", pool(entry("pieces/target", 1)));
|
||||||
IrisStructure structure = structure("pools/start").setRequireCaps(true);
|
IrisStructure structure = structure("pools/start").setRequireCaps(true);
|
||||||
|
|
||||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
StructureGraphCompilation result = compile(structure, resolver);
|
||||||
|
|
||||||
assertCodes(result, StructureGraphDiagnostic.Code.NO_REQUIRED_TERMINAL);
|
assertCodes(result, StructureGraphDiagnostic.Code.NO_REQUIRED_TERMINAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InMemoryResolver connectorGraph(boolean rotatable, IrisDirection targetDirection) {
|
private static InMemoryResolver connectorGraph(boolean rotatable, JigsawDirection targetDirection) {
|
||||||
InMemoryResolver resolver = new InMemoryResolver();
|
InMemoryResolver resolver = new InMemoryResolver();
|
||||||
IrisJigsawConnector source = connector(
|
IrisJigsawConnector source = connector(
|
||||||
new IrisPosition(1, 1, 0), IrisDirection.NORTH_NEGATIVE_Z,
|
new BlockPosition(1, 1, 0), JigsawDirection.NORTH_NEGATIVE_Z,
|
||||||
"pools/target", "source", "door");
|
"pools/target", "source", "door");
|
||||||
IrisJigsawConnector target = connector(
|
IrisJigsawConnector target = connector(
|
||||||
canonicalPosition(targetDirection), targetDirection,
|
canonicalPosition(targetDirection), targetDirection,
|
||||||
@@ -1030,25 +1029,24 @@ public class StructureGraphCompilerTest {
|
|||||||
|
|
||||||
private static IrisStructure structure(String startPool) {
|
private static IrisStructure structure(String startPool) {
|
||||||
IrisStructure structure = new IrisStructure();
|
IrisStructure structure = new IrisStructure();
|
||||||
structure.setLoadKey("structures/test");
|
|
||||||
structure.setStartPool(startPool);
|
structure.setStartPool(startPool);
|
||||||
structure.setMaxDepth(3);
|
structure.setMaxDepth(3);
|
||||||
structure.setMaxSizeChunks(4);
|
structure.setMaxSizeChunks(4);
|
||||||
return structure;
|
return structure;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisObject object() {
|
private static ObjectFrame object() {
|
||||||
return new IrisObject(3, 3, 3);
|
return new ObjectFrame(3, 3, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisPosition canonicalPosition(IrisDirection direction) {
|
private static BlockPosition canonicalPosition(JigsawDirection direction) {
|
||||||
return switch (direction) {
|
return switch (direction) {
|
||||||
case NORTH_NEGATIVE_Z -> new IrisPosition(1, 1, 0);
|
case NORTH_NEGATIVE_Z -> new BlockPosition(1, 1, 0);
|
||||||
case EAST_POSITIVE_X -> new IrisPosition(2, 1, 1);
|
case EAST_POSITIVE_X -> new BlockPosition(2, 1, 1);
|
||||||
case SOUTH_POSITIVE_Z -> new IrisPosition(1, 1, 2);
|
case SOUTH_POSITIVE_Z -> new BlockPosition(1, 1, 2);
|
||||||
case WEST_NEGATIVE_X -> new IrisPosition(0, 1, 1);
|
case WEST_NEGATIVE_X -> new BlockPosition(0, 1, 1);
|
||||||
case UP_POSITIVE_Y -> new IrisPosition(1, 2, 1);
|
case UP_POSITIVE_Y -> new BlockPosition(1, 2, 1);
|
||||||
case DOWN_NEGATIVE_Y -> new IrisPosition(1, 0, 1);
|
case DOWN_NEGATIVE_Y -> new BlockPosition(1, 0, 1);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1073,7 +1071,7 @@ public class StructureGraphCompilerTest {
|
|||||||
return new IrisJigsawPieceEntry().setEmpty(true).setWeight(weight);
|
return new IrisJigsawPieceEntry().setEmpty(true).setWeight(weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisJigsawConnector connector(IrisPosition position, IrisDirection direction, String pool,
|
private static IrisJigsawConnector connector(BlockPosition position, JigsawDirection direction, String pool,
|
||||||
String name, String targetName) {
|
String name, String targetName) {
|
||||||
return new IrisJigsawConnector()
|
return new IrisJigsawConnector()
|
||||||
.setPosition(position)
|
.setPosition(position)
|
||||||
@@ -1104,10 +1102,14 @@ public class StructureGraphCompilerTest {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static StructureGraphCompilation compile(IrisStructure structure, StructureGraphResolver resolver) {
|
||||||
|
return StructureGraphCompiler.compile("test", structure, resolver);
|
||||||
|
}
|
||||||
|
|
||||||
private static final class InMemoryResolver implements StructureGraphResolver {
|
private static final class InMemoryResolver implements StructureGraphResolver {
|
||||||
private final Map<String, IrisJigsawPool> pools = new LinkedHashMap<>();
|
private final Map<String, IrisJigsawPool> pools = new LinkedHashMap<>();
|
||||||
private final Map<String, IrisJigsawPiece> pieces = new LinkedHashMap<>();
|
private final Map<String, IrisJigsawPiece> pieces = new LinkedHashMap<>();
|
||||||
private final Map<String, IrisObject> objects = new LinkedHashMap<>();
|
private final Map<String, ObjectFrame> objects = new LinkedHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisJigsawPool loadPool(String key) {
|
public IrisJigsawPool loadPool(String key) {
|
||||||
@@ -1120,7 +1122,7 @@ public class StructureGraphCompilerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisObject loadObject(String key) {
|
public ObjectFrame loadObject(String key) {
|
||||||
return objects.get(key);
|
return objects.get(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-4
@@ -45,7 +45,7 @@ public class StructureGraphValidationTest {
|
|||||||
Path pack = temporaryFolder.newFolder("pack").toPath();
|
Path pack = temporaryFolder.newFolder("pack").toPath();
|
||||||
write(pack, "structures/castle.json", "{\"startPool\":\"castle/start\"}");
|
write(pack, "structures/castle.json", "{\"startPool\":\"castle/start\"}");
|
||||||
write(pack, "jigsaw-pools/castle/start.json",
|
write(pack, "jigsaw-pools/castle/start.json",
|
||||||
"{\"pieces\":[{\"piece\":\"castle/start\",\"weight\":0}]}");
|
"{\"pieces\":[{\"piece\":\"castle/start\",\"weight\":1}]}");
|
||||||
write(pack, "jigsaw-pieces/castle/start.json",
|
write(pack, "jigsaw-pieces/castle/start.json",
|
||||||
"{\"object\":\"castle/start\",\"connectors\":[{\"position\":{\"x\":2,\"y\":0,\"z\":0},"
|
"{\"object\":\"castle/start\",\"connectors\":[{\"position\":{\"x\":2,\"y\":0,\"z\":0},"
|
||||||
+ "\"direction\":\"NORTH_NEGATIVE_Z\",\"pool\":\"castle/start\",\"name\":\"path\",\"targetName\":\"path\"}]}");
|
+ "\"direction\":\"NORTH_NEGATIVE_Z\",\"pool\":\"castle/start\",\"name\":\"path\",\"targetName\":\"path\"}]}");
|
||||||
@@ -53,8 +53,22 @@ public class StructureGraphValidationTest {
|
|||||||
|
|
||||||
StructureGraphValidation.Validation validation = validate(pack, null);
|
StructureGraphValidation.Validation validation = validate(pack, null);
|
||||||
|
|
||||||
assertTrue(validation.errors().stream().anyMatch(message -> message.contains("non-positive weight 0")));
|
assertTrue(validation.errors().toString(), validation.errors().stream().anyMatch(message -> message.contains("outside object bounds")));
|
||||||
assertTrue(validation.errors().stream().anyMatch(message -> message.contains("outside object bounds")));
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aNonPositiveWeightFailsTheLoadOfItsPool() throws Exception {
|
||||||
|
Path pack = temporaryFolder.newFolder("pack").toPath();
|
||||||
|
write(pack, "structures/castle.json", "{\"startPool\":\"castle/start\"}");
|
||||||
|
write(pack, "jigsaw-pools/castle/start.json",
|
||||||
|
"{\"pieces\":[{\"piece\":\"castle/start\",\"weight\":0}]}");
|
||||||
|
IrisData data = IrisData.openValidation(pack.toFile());
|
||||||
|
try {
|
||||||
|
assertThrows(IllegalStateException.class, () -> data.getPackResources().find(
|
||||||
|
StructureResources.POOLS, data.getPackResources().idOf("castle/start")));
|
||||||
|
} finally {
|
||||||
|
data.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -322,7 +336,7 @@ public class StructureGraphValidationTest {
|
|||||||
private static StructureGraphValidation.Validation validate(Path pack, Set<String> activeStructureKeys) {
|
private static StructureGraphValidation.Validation validate(Path pack, Set<String> activeStructureKeys) {
|
||||||
IrisData data = IrisData.openValidation(pack.toFile());
|
IrisData data = IrisData.openValidation(pack.toFile());
|
||||||
try {
|
try {
|
||||||
return StructureGraphValidation.validate(data, activeStructureKeys);
|
return StructureGraphValidation.validate(data.getPackResources(), pack.toFile(), activeStructureKeys);
|
||||||
} finally {
|
} finally {
|
||||||
data.close();
|
data.close();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -78,7 +78,6 @@ public class StructureResourcesTest {
|
|||||||
|
|
||||||
assertEquals("castle/start", castle.getStartPool());
|
assertEquals("castle/start", castle.getStartPool());
|
||||||
assertEquals(5, castle.getMaxDepth());
|
assertEquals(5, castle.getMaxDepth());
|
||||||
assertEquals("castle", castle.getLoadKey());
|
|
||||||
assertSame(castle, data.getPackResources().find(StructureResources.STRUCTURES, new ResourceId("castles", "castle")).orElseThrow());
|
assertSame(castle, data.getPackResources().find(StructureResources.STRUCTURES, new ResourceId("castles", "castle")).orElseThrow());
|
||||||
assertEquals("castle/start", StructureResources.pool(data.getPackResources(), "castle/start").getPieces().getFirst().getPiece());
|
assertEquals("castle/start", StructureResources.pool(data.getPackResources(), "castle/start").getPieces().getFirst().getPiece());
|
||||||
assertEquals("castle/start", StructureResources.piece(data.getPackResources(), "castle/start").getObject());
|
assertEquals("castle/start", StructureResources.piece(data.getPackResources(), "castle/start").getObject());
|
||||||
@@ -149,7 +148,7 @@ public class StructureResourcesTest {
|
|||||||
entries.stream().map(entry -> entry.getString("url")).filter(url -> url.contains("jigsaw") || url.contains("structures-")).toList());
|
entries.stream().map(entry -> entry.getString("url")).filter(url -> url.contains("jigsaw") || url.contains("structures-")).toList());
|
||||||
JSONObject structures = new JSONObject(Files.readString(pack.resolve(".iris/schema/structures-schema.json")));
|
JSONObject structures = new JSONObject(Files.readString(pack.resolve(".iris/schema/structures-schema.json")));
|
||||||
JSONObject startPool = structures.getJSONObject("properties").getJSONObject("startPool");
|
JSONObject startPool = structures.getJSONObject("properties").getJSONObject("startPool");
|
||||||
assertEquals("#/definitions/erzjigsaw-pools", startPool.getString("$ref"));
|
assertEquals("#/definitions/erzjigsaw-pools", startPool.optString("$ref", startPool.toString()));
|
||||||
assertEquals("[\"castle/start\"]",
|
assertEquals("[\"castle/start\"]",
|
||||||
structures.getJSONObject("definitions").getJSONObject("erzjigsaw-pools").getJSONArray("enum").toString());
|
structures.getJSONObject("definitions").getJSONObject("erzjigsaw-pools").getJSONArray("enum").toString());
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
+71
-59
@@ -1,30 +1,31 @@
|
|||||||
package art.arcane.iris.engine.mantle.components;
|
package art.arcane.iris.engine.mantle.components;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
import art.arcane.iris.engine.framework.structure.assembly.AssembledPiece;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import art.arcane.iris.spi.PlatformBlockState;
|
import com.volmit.resource.ResourceId;
|
||||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
public class StructureCarvingFootprintTest {
|
public class StructureCarvingFootprintTest {
|
||||||
@Test
|
@Test
|
||||||
public void preservesIrregularFootprintInsteadOfFillingItsBoundingBox() {
|
public void preservesIrregularFootprintInsteadOfFillingItsBoundingBox() {
|
||||||
PlacedStructurePiece piece = piece(10, 40, 20, ObjectTurn.of(0, 0, 0),
|
Piece piece = piece(10, 40, 20, PieceTurn.NONE,
|
||||||
block(0, 0, 0), block(1, 0, 0), block(2, 0, 0),
|
block(0, 0, 0), block(1, 0, 0), block(2, 0, 0),
|
||||||
block(0, 0, 1), block(0, 0, 2));
|
block(0, 0, 1), block(0, 0, 2));
|
||||||
|
|
||||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 0);
|
StructureCarvingFootprint footprint = footprintOf(pieces(piece), 0);
|
||||||
|
|
||||||
assertNotNull(footprint);
|
assertNotNull(footprint);
|
||||||
assertEquals(10, footprint.minX());
|
assertEquals(10, footprint.minX());
|
||||||
@@ -39,11 +40,11 @@ public class StructureCarvingFootprintTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void reportsExactDistanceAndNearestColumnHeights() {
|
public void reportsExactDistanceAndNearestColumnHeights() {
|
||||||
PlacedStructurePiece piece = piece(0, 0, 0, ObjectTurn.of(0, 0, 0),
|
Piece piece = piece(0, 0, 0, PieceTurn.NONE,
|
||||||
block(0, 10, 0), block(0, 12, 0),
|
block(0, 10, 0), block(0, 12, 0),
|
||||||
block(4, 30, 0), block(4, 35, 0));
|
block(4, 30, 0), block(4, 35, 0));
|
||||||
|
|
||||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 2);
|
StructureCarvingFootprint footprint = footprintOf(pieces(piece), 2);
|
||||||
StructureCarvingFootprint.Column nearestRight = footprint.sample(3, 2);
|
StructureCarvingFootprint.Column nearestRight = footprint.sample(3, 2);
|
||||||
StructureCarvingFootprint.Column tied = footprint.sample(2, 0);
|
StructureCarvingFootprint.Column tied = footprint.sample(2, 0);
|
||||||
|
|
||||||
@@ -59,12 +60,12 @@ public class StructureCarvingFootprintTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rotatesAndMergesOverlappingColumns() {
|
public void rotatesAndMergesOverlappingColumns() {
|
||||||
PlacedStructurePiece rotated = piece(10, 20, 30, ObjectTurn.of(0, 90, 0),
|
Piece rotated = piece(10, 20, 30, PieceTurn.aroundY(90),
|
||||||
block(2, 1, 0));
|
block(2, 1, 0));
|
||||||
PlacedStructurePiece overlapping = piece(10, 5, 28, ObjectTurn.of(0, 0, 0),
|
Piece overlapping = piece(10, 5, 28, PieceTurn.NONE,
|
||||||
block(0, 3, 0), block(0, 9, 0));
|
block(0, 3, 0), block(0, 9, 0));
|
||||||
|
|
||||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(
|
StructureCarvingFootprint footprint = footprintOf(
|
||||||
pieces(rotated, overlapping), 0);
|
pieces(rotated, overlapping), 0);
|
||||||
|
|
||||||
assertNotNull(footprint);
|
assertNotNull(footprint);
|
||||||
@@ -82,18 +83,18 @@ public class StructureCarvingFootprintTest {
|
|||||||
int[][] sourceBlocks = new int[][]{
|
int[][] sourceBlocks = new int[][]{
|
||||||
block(0, 2, 0), block(3, 4, 1), block(1, 6, 4), block(5, 8, 5)
|
block(0, 2, 0), block(3, 4, 1), block(1, 6, 4), block(5, 8, 5)
|
||||||
};
|
};
|
||||||
PlacedStructurePiece piece = piece(
|
Piece piece = piece(
|
||||||
-8, 30, 11, ObjectTurn.of(0, 0, 0), sourceBlocks);
|
-8, 30, 11, PieceTurn.NONE, sourceBlocks);
|
||||||
|
|
||||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 3);
|
StructureCarvingFootprint footprint = footprintOf(pieces(piece), 3);
|
||||||
|
|
||||||
assertNotNull(footprint);
|
assertNotNull(footprint);
|
||||||
for (int z = footprint.minZ(); z <= footprint.maxZ(); z++) {
|
for (int z = footprint.minZ(); z <= footprint.maxZ(); z++) {
|
||||||
for (int x = footprint.minX(); x <= footprint.maxX(); x++) {
|
for (int x = footprint.minX(); x <= footprint.maxX(); x++) {
|
||||||
long expected = Long.MAX_VALUE;
|
long expected = Long.MAX_VALUE;
|
||||||
for (int[] source : sourceBlocks) {
|
for (int[] source : sourceBlocks) {
|
||||||
long deltaX = (long) x - (piece.getX() + source[0]);
|
long deltaX = (long) x - (piece.assembled.x() + source[0]);
|
||||||
long deltaZ = (long) z - (piece.getZ() + source[2]);
|
long deltaZ = (long) z - (piece.assembled.z() + source[2]);
|
||||||
expected = Math.min(expected, deltaX * deltaX + deltaZ * deltaZ);
|
expected = Math.min(expected, deltaX * deltaX + deltaZ * deltaZ);
|
||||||
}
|
}
|
||||||
assertEquals(expected, footprint.distanceSquaredAt(x, z));
|
assertEquals(expected, footprint.distanceSquaredAt(x, z));
|
||||||
@@ -103,23 +104,22 @@ public class StructureCarvingFootprintTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void returnsNullForEmptyInvalidOrOversizedInputs() {
|
public void returnsNullForEmptyInvalidOrOversizedInputs() {
|
||||||
assertNull(StructureCarvingFootprint.from(null, 0));
|
assertNull(footprintOf(null, 0));
|
||||||
assertNull(StructureCarvingFootprint.from(new KList<>(), 0));
|
assertNull(footprintOf(new ArrayList<>(), 0));
|
||||||
|
|
||||||
KList<PlacedStructurePiece> invalidPieces = new KList<>();
|
List<Piece> invalidPieces = new ArrayList<>();
|
||||||
invalidPieces.add((PlacedStructurePiece) null);
|
invalidPieces.add(null);
|
||||||
invalidPieces.add(new PlacedStructurePiece(
|
invalidPieces.add(new Piece(piece(0, 0, 0, PieceTurn.NONE).assembled, null));
|
||||||
null, null, 0, 0, 0, null, 0, 0, 0, 0, 0, 0));
|
assertNull(footprintOf(invalidPieces, 0));
|
||||||
assertNull(StructureCarvingFootprint.from(invalidPieces, 0));
|
|
||||||
|
|
||||||
PlacedStructurePiece piece = piece(0, 0, 0, ObjectTurn.of(0, 0, 0), block(0, 0, 0));
|
Piece piece = piece(0, 0, 0, PieceTurn.NONE, block(0, 0, 0));
|
||||||
assertNull(StructureCarvingFootprint.from(pieces(piece), 2, 24));
|
assertNull(footprintOf(pieces(piece), 2, 24));
|
||||||
PlacedStructurePiece overflowing = piece(
|
Piece overflowing = piece(
|
||||||
Integer.MAX_VALUE, 0, 0, ObjectTurn.of(0, 0, 0), block(1, 0, 0));
|
Integer.MAX_VALUE, 0, 0, PieceTurn.NONE, block(1, 0, 0));
|
||||||
assertNull(StructureCarvingFootprint.from(pieces(overflowing), 0));
|
assertNull(footprintOf(pieces(overflowing), 0));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StructureCarvingFootprint.from(pieces(piece), -1);
|
footprintOf(pieces(piece), -1);
|
||||||
fail("Expected negative padding to fail");
|
fail("Expected negative padding to fail");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
assertEquals("padding must be non-negative", e.getMessage());
|
assertEquals("padding must be non-negative", e.getMessage());
|
||||||
@@ -128,9 +128,9 @@ public class StructureCarvingFootprintTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void includesTheEntirePaddingBoundary() {
|
public void includesTheEntirePaddingBoundary() {
|
||||||
PlacedStructurePiece piece = piece(7, 14, -4, ObjectTurn.of(0, 0, 0), block(0, 0, 0));
|
Piece piece = piece(7, 14, -4, PieceTurn.NONE, block(0, 0, 0));
|
||||||
|
|
||||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 2, 25);
|
StructureCarvingFootprint footprint = footprintOf(pieces(piece), 2, 25);
|
||||||
|
|
||||||
assertNotNull(footprint);
|
assertNotNull(footprint);
|
||||||
assertEquals(5, footprint.minX());
|
assertEquals(5, footprint.minX());
|
||||||
@@ -148,17 +148,12 @@ public class StructureCarvingFootprintTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void explicitAirDoesNotExpandTheExteriorFootprint() {
|
public void explicitAirDoesNotExpandTheExteriorFootprint() {
|
||||||
IrisObject object = new IrisObject(1, 1, 1);
|
Piece piece = new Piece(new AssembledPiece(new ResourceId("test", "piece"), 10, 20, 30, PieceTurn.NONE,
|
||||||
PlatformBlockState solid = mock(PlatformBlockState.class);
|
10, 20, 30, 18, 24, 38), List.of(
|
||||||
PlatformBlockState air = mock(PlatformBlockState.class);
|
new StructurePieceColumns.PieceBlock(new BlockPosition(0, 0, 0), false),
|
||||||
when(air.isAir()).thenReturn(true);
|
new StructurePieceColumns.PieceBlock(new BlockPosition(8, 4, 8), true)));
|
||||||
object.getBlocks().put(new IrisBlockVector(0, 0, 0), solid);
|
|
||||||
object.getBlocks().put(new IrisBlockVector(8, 4, 8), air);
|
|
||||||
PlacedStructurePiece piece = new PlacedStructurePiece(
|
|
||||||
null, object, 10, 20, 30, ObjectTurn.of(0, 0, 0),
|
|
||||||
10, 20, 30, 18, 24, 38);
|
|
||||||
|
|
||||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 0);
|
StructureCarvingFootprint footprint = footprintOf(pieces(piece), 0);
|
||||||
|
|
||||||
assertNotNull(footprint);
|
assertNotNull(footprint);
|
||||||
assertEquals(10, footprint.minX());
|
assertEquals(10, footprint.minX());
|
||||||
@@ -167,23 +162,40 @@ public class StructureCarvingFootprintTest {
|
|||||||
assertEquals(30, footprint.maxZ());
|
assertEquals(30, footprint.maxZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PlacedStructurePiece piece(int x, int y, int z, ObjectTurn rotation,
|
private record Piece(AssembledPiece assembled, List<StructurePieceColumns.PieceBlock> blocks) {
|
||||||
int[]... blocks) {
|
|
||||||
IrisObject object = new IrisObject(1, 1, 1);
|
|
||||||
PlatformBlockState state = mock(PlatformBlockState.class);
|
|
||||||
for (int[] block : blocks) {
|
|
||||||
object.getBlocks().put(new IrisBlockVector(block[0], block[1], block[2]), state);
|
|
||||||
}
|
|
||||||
return new PlacedStructurePiece(
|
|
||||||
null, object, x, y, z, rotation, x, y, z, x, y, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KList<PlacedStructurePiece> pieces(PlacedStructurePiece... pieces) {
|
private static StructureCarvingFootprint footprintOf(List<Piece> pieces, int padding) {
|
||||||
KList<PlacedStructurePiece> result = new KList<>();
|
return footprintOf(pieces, padding, StructureCarvingFootprint.DEFAULT_MAX_CELLS);
|
||||||
for (PlacedStructurePiece piece : pieces) {
|
}
|
||||||
result.add(piece);
|
|
||||||
|
private static StructureCarvingFootprint footprintOf(List<Piece> pieces, int padding, int maxCells) {
|
||||||
|
Map<AssembledPiece, List<StructurePieceColumns.PieceBlock>> blocksOf = new IdentityHashMap<>();
|
||||||
|
List<AssembledPiece> assembled = pieces == null ? null : new ArrayList<>();
|
||||||
|
if (pieces != null) {
|
||||||
|
for (Piece piece : pieces) {
|
||||||
|
if (piece == null) {
|
||||||
|
assembled.add(null);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assembled.add(piece.assembled);
|
||||||
|
blocksOf.put(piece.assembled, piece.blocks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return StructureCarvingFootprint.fromColumns(
|
||||||
|
sink -> StructurePieceColumns.emit(assembled, blocksOf::get, sink), padding, maxCells);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Piece piece(int x, int y, int z, PieceTurn turn, int[]... blocks) {
|
||||||
|
List<StructurePieceColumns.PieceBlock> pieceBlocks = new ArrayList<>();
|
||||||
|
for (int[] block : blocks) {
|
||||||
|
pieceBlocks.add(new StructurePieceColumns.PieceBlock(new BlockPosition(block[0], block[1], block[2]), false));
|
||||||
|
}
|
||||||
|
return new Piece(new AssembledPiece(new ResourceId("test", "piece"), x, y, z, turn, x, y, z, x, y, z), pieceBlocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Piece> pieces(Piece... pieces) {
|
||||||
|
return new ArrayList<>(List.of(pieces));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] block(int x, int y, int z) {
|
private static int[] block(int x, int y, int z) {
|
||||||
|
|||||||
Loaded 100 of 122 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user