mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +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;
|
||||
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.pack.BrokenPackException;
|
||||
import art.arcane.iris.core.runtime.StudioOpenCoordinator;
|
||||
import art.arcane.iris.core.service.JigsawStudioService;
|
||||
@@ -46,11 +45,6 @@ public final class BukkitJigsawStudioHost implements JigsawStudioHost {
|
||||
return Iris.jigsawStudio();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisData dataOf(ToolPack pack) {
|
||||
return IrisToolPack.dataOf(pack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String packKey(ToolPack pack) {
|
||||
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:snow", "iris:vanilla-features", "iris:carve", "iris:deposit", "iris:decorant", "iris:terrain", "iris:objects",
|
||||
"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 BUNDLED_JAR_RESOURCE = "/" + MissingBuiltInModules.JAR_NAME;
|
||||
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. */
|
||||
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() {
|
||||
return ModuleHost.of(builtInModules())
|
||||
.exposing(EXPOSED_PACKAGES.toArray(String[]::new))
|
||||
.reservingFields(ModuleTargets.reservedFields())
|
||||
.describingHostTypesIn(HOST_TYPE_PACKAGE)
|
||||
.describingHostTypesIn(HOST_TYPE_PACKAGES)
|
||||
.reservingFolders(IrisData.ownFolderNames().toArray(String[]::new))
|
||||
.bundlingJars(bundledJars())
|
||||
.copyingJarsTo(jarCopyRoot())
|
||||
|
||||
@@ -28,9 +28,11 @@ import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
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
|
||||
@@ -51,6 +53,12 @@ final class PackDeclaredSettings implements PackSettings {
|
||||
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
|
||||
public <F extends IrisFeature> SettingsStack<F> declared(Class<F> featureType) {
|
||||
List<Entry<F>> entries = new ArrayList<>();
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
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.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
|
||||
@@ -31,8 +31,8 @@ public final class StructureAssemblies {
|
||||
private StructureAssemblies() {
|
||||
}
|
||||
|
||||
/** The assembler of {@code structure}, compiled from the pack {@code data} serves, for a start at {@code origin}. */
|
||||
public static StructureAssembler forData(IrisData data, IrisStructure structure, IrisPosition origin) {
|
||||
return StructureAssembler.forData(data, structure, origin, IrisModuleHost.hostLog());
|
||||
/** The assembler of {@code structure}, the structure {@code structureKey} of {@code pack}, for a start at {@code origin}. */
|
||||
public static StructureAssembler forPack(PackResources pack, String structureKey, IrisStructure structure, BlockPosition origin) {
|
||||
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.tooling.PlatformStructuresAccess;
|
||||
import art.arcane.iris.core.tooling.IrisToolPack;
|
||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.tooling.Argument;
|
||||
import com.volmit.tooling.Command;
|
||||
@@ -79,7 +78,7 @@ final class StructureCommands {
|
||||
ResourceId id = context.get(STRUCTURE);
|
||||
IrisStructure structure = context.pack().resources().require(StructureResources.STRUCTURES, id);
|
||||
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));
|
||||
if (!assembly.hasOutput()) {
|
||||
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.JigsawStudioHost;
|
||||
import art.arcane.iris.engine.framework.structure.JigsawStructureAssembly;
|
||||
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.StructureValidator;
|
||||
import art.arcane.iris.engine.framework.structure.StructureVanillaStructures;
|
||||
@@ -61,6 +63,7 @@ public final class StructureModelModule implements IrisModule {
|
||||
public void setup(ModuleSetup setup) {
|
||||
var registry = setup.registry();
|
||||
registry.registerValidator(new StructureValidator());
|
||||
registry.registerService(StructureAssembly.class, new JigsawStructureAssembly(setup.log()));
|
||||
registry.registerService(StructureLocator.class, new StructureLocating());
|
||||
registry.registerService(VanillaStructures.class, new StructureVanillaStructures());
|
||||
setup.tooling().registerCommand(StructureCommands.root());
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.core.pack;
|
||||
|
||||
import art.arcane.iris.builtin.loot.LootTable;
|
||||
import art.arcane.iris.builtin.structure.IrisStructureRef;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
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 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 Map<Class<?>, ResourceKind<?>> kindsByType = new HashMap<>();
|
||||
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. */
|
||||
private static Class<?> referencedType(Field field) {
|
||||
ResourceRef reference = field.getAnnotation(ResourceRef.class);
|
||||
@@ -173,6 +189,9 @@ public final class ModuleResourceClosure {
|
||||
if (field.isAnnotationPresent(IrisStructureRef.class)) {
|
||||
return IrisStructure.class;
|
||||
}
|
||||
if (field.equals(STRUCTURE_LOOT_FIELD)) {
|
||||
return LootTable.class;
|
||||
}
|
||||
RegistryListResource registry = field.getAnnotation(RegistryListResource.class);
|
||||
return registry == null ? null : registry.value();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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 {
|
||||
NORTH(1),
|
||||
@@ -18,12 +18,12 @@ public enum JigsawPlanarDirection {
|
||||
return bit;
|
||||
}
|
||||
|
||||
public IrisDirection irisDirection() {
|
||||
public JigsawDirection direction() {
|
||||
return switch (this) {
|
||||
case NORTH -> IrisDirection.NORTH_NEGATIVE_Z;
|
||||
case EAST -> IrisDirection.EAST_POSITIVE_X;
|
||||
case SOUTH -> IrisDirection.SOUTH_POSITIVE_Z;
|
||||
case WEST -> IrisDirection.WEST_NEGATIVE_X;
|
||||
case NORTH -> JigsawDirection.NORTH_NEGATIVE_Z;
|
||||
case EAST -> JigsawDirection.EAST_POSITIVE_X;
|
||||
case SOUTH -> JigsawDirection.SOUTH_POSITIVE_Z;
|
||||
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.engine.framework.structure.PlanarJigsawWorkcellResolver;
|
||||
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.IrisJigsawMode;
|
||||
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.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.jigsaw.JigsawJoint;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
@@ -91,14 +90,14 @@ public final class JigsawStudioGraphEditor {
|
||||
.setObject(normalizedPiece)
|
||||
.setRotatable(true);
|
||||
if (topology != null) {
|
||||
IrisPosition cellSize = new IrisPosition(
|
||||
BlockPosition cellSize = new BlockPosition(
|
||||
dimensions.width(), dimensions.height(), dimensions.depth());
|
||||
for (JigsawPlanarDirection planarDirection : topology.directions()) {
|
||||
IrisDirection direction = planarDirection.irisDirection();
|
||||
JigsawDirection direction = planarDirection.direction();
|
||||
piece.getConnectors().add(new IrisJigsawConnector()
|
||||
.setPosition(IrisJigsawConnector.canonicalPlanarPosition(cellSize, direction))
|
||||
.setDirection(direction)
|
||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
||||
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||
.setPool(normalizedPool)
|
||||
.setName("iris:planar")
|
||||
.setTargetName("iris:planar")
|
||||
@@ -632,11 +631,11 @@ public final class JigsawStudioGraphEditor {
|
||||
Path packRoot,
|
||||
String structureKey,
|
||||
String pieceKey,
|
||||
IrisPosition position,
|
||||
BlockPosition position,
|
||||
String channel
|
||||
) throws IOException {
|
||||
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);
|
||||
OwnedGraph graph = loadOwnedGraph(packRoot, structureKey);
|
||||
String pieceResource = "jigsaw-pieces/" + normalizedPiece + ".json";
|
||||
@@ -669,8 +668,8 @@ public final class JigsawStudioGraphEditor {
|
||||
}
|
||||
if (!found) {
|
||||
throw new IOException("Piece '" + normalizedPiece + "' has no connector at "
|
||||
+ connectorPosition.getX() + "," + connectorPosition.getY() + ","
|
||||
+ connectorPosition.getZ());
|
||||
+ connectorPosition.x() + "," + connectorPosition.y() + ","
|
||||
+ connectorPosition.z());
|
||||
}
|
||||
return write(graph, bundle.build());
|
||||
}
|
||||
@@ -1301,7 +1300,7 @@ public final class JigsawStudioGraphEditor {
|
||||
connectorResize.targetCanonical(),
|
||||
resizedSourceDimensions,
|
||||
quarterTurns);
|
||||
connectorResize.connector().setPosition(sourcePosition.toIrisPosition());
|
||||
connectorResize.connector().setPosition(sourcePosition.toBlockPosition());
|
||||
if (!connectorResize.sourceCanonical().equals(connectorResize.targetCanonical())) {
|
||||
relocatedConnectors++;
|
||||
}
|
||||
@@ -1370,9 +1369,9 @@ public final class JigsawStudioGraphEditor {
|
||||
List<ConnectorResize> planned = new ArrayList<>(connectors.size());
|
||||
Set<LocalPosition> sourcePositions = new LinkedHashSet<>();
|
||||
Set<LocalPosition> targetPositions = new LinkedHashSet<>();
|
||||
IrisPosition sourceSize = dimensionsPosition(sourceDimensions);
|
||||
IrisPosition canonicalSize = dimensionsPosition(canonicalDimensions);
|
||||
IrisPosition targetSize = dimensionsPosition(targetDimensions);
|
||||
BlockPosition sourceSize = dimensionsPosition(sourceDimensions);
|
||||
BlockPosition canonicalSize = dimensionsPosition(canonicalDimensions);
|
||||
BlockPosition targetSize = dimensionsPosition(targetDimensions);
|
||||
for (int index = 0; index < connectors.size(); index++) {
|
||||
IrisJigsawConnector connector = connectors.get(index);
|
||||
if (connector == null || connector.getPosition() == null || connector.getDirection() == null
|
||||
@@ -1396,7 +1395,7 @@ public final class JigsawStudioGraphEditor {
|
||||
sourceDimensions.width(),
|
||||
sourceDimensions.depth(),
|
||||
quarterTurns);
|
||||
IrisDirection canonicalDirection = rotateHorizontalDirection(
|
||||
JigsawDirection canonicalDirection = rotateHorizontalDirection(
|
||||
connector.getDirection(),
|
||||
quarterTurns);
|
||||
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) {
|
||||
case NORTH_NEGATIVE_Z -> JigsawPlanarDirection.NORTH;
|
||||
case EAST_POSITIVE_X -> JigsawPlanarDirection.EAST;
|
||||
@@ -1594,11 +1593,11 @@ public final class JigsawStudioGraphEditor {
|
||||
case UP_POSITIVE_Y, DOWN_NEGATIVE_Y -> throw new IllegalArgumentException(
|
||||
"Planar connector direction must be horizontal");
|
||||
};
|
||||
return planarDirection.rotateClockwise(quarterTurns).irisDirection();
|
||||
return planarDirection.rotateClockwise(quarterTurns).direction();
|
||||
}
|
||||
|
||||
private static IrisPosition dimensionsPosition(JigsawStudioCellDimensions dimensions) {
|
||||
return new IrisPosition(dimensions.width(), dimensions.height(), dimensions.depth());
|
||||
private static BlockPosition dimensionsPosition(JigsawStudioCellDimensions dimensions) {
|
||||
return new BlockPosition(dimensions.width(), dimensions.height(), dimensions.depth());
|
||||
}
|
||||
|
||||
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 static LocalPosition from(IrisPosition position) {
|
||||
return new LocalPosition(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
private static LocalPosition from(BlockPosition position) {
|
||||
return new LocalPosition(position.x(), position.y(), position.z());
|
||||
}
|
||||
@@ -1843,10 +1838,6 @@ public final class JigsawStudioGraphEditor {
|
||||
return new BlockPosition(x, y, z);
|
||||
}
|
||||
|
||||
private IrisPosition toIrisPosition() {
|
||||
return new IrisPosition(x, y, z);
|
||||
}
|
||||
|
||||
private String describe() {
|
||||
return x + "," + y + "," + z;
|
||||
}
|
||||
|
||||
+53
-41
@@ -1,23 +1,23 @@
|
||||
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.core.loader.IrisData;
|
||||
import art.arcane.iris.core.structure.authoring.StructureKey;
|
||||
import art.arcane.iris.core.structure.authoring.StructureOwnershipManifest;
|
||||
import art.arcane.iris.core.structure.authoring.StructureTransactionWriter;
|
||||
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.IrisJigsawMode;
|
||||
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.IrisJigsawPool;
|
||||
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 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.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
@@ -38,20 +38,24 @@ public final class 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");
|
||||
JigsawStudioMode mode = structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW
|
||||
? JigsawStudioMode.PLANAR_JIGSAW
|
||||
: JigsawStudioMode.SPATIAL_JIGSAW;
|
||||
JigsawStudioVariantCatalog catalog = catalog(data, structure, mode);
|
||||
IrisPosition configuredCell = structure.getCellSize();
|
||||
BlockPosition configuredCell = structure.getCellSize();
|
||||
JigsawStudioCellDimensions dimensions = configuredCell == null
|
||||
? new JigsawStudioCellDimensions(15, 15, 15)
|
||||
: new JigsawStudioCellDimensions(
|
||||
Math.max(1, configuredCell.getX()),
|
||||
Math.max(1, configuredCell.getY()),
|
||||
Math.max(1, configuredCell.getZ()));
|
||||
Math.max(1, configuredCell.x()),
|
||||
Math.max(1, configuredCell.y()),
|
||||
Math.max(1, configuredCell.z()));
|
||||
if (mode == JigsawStudioMode.SPATIAL_JIGSAW) {
|
||||
dimensions = expandSpatialDimensions(data, catalog, dimensions);
|
||||
return JigsawStudioLayout.createSpatial(
|
||||
@@ -77,11 +81,18 @@ public final class JigsawStudioGraphMapper {
|
||||
}
|
||||
|
||||
public static JigsawStudioVariantCatalog catalog(
|
||||
IrisData data,
|
||||
ToolPack pack,
|
||||
Path packRoot,
|
||||
String structureKey,
|
||||
IrisStructure structure,
|
||||
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");
|
||||
JigsawStudioMode activeMode = Objects.requireNonNull(mode, "Jigsaw Studio catalog mode");
|
||||
OwnedResources owned = ownedResources(source, root);
|
||||
@@ -123,37 +134,34 @@ public final class JigsawStudioGraphMapper {
|
||||
}
|
||||
|
||||
static JigsawStudioCellDimensions expandSpatialDimensions(
|
||||
IrisData data,
|
||||
Source data,
|
||||
JigsawStudioVariantCatalog catalog,
|
||||
JigsawStudioCellDimensions configured
|
||||
) {
|
||||
if (data.getObjectLoader() == null) {
|
||||
return configured;
|
||||
}
|
||||
int width = configured.width();
|
||||
int height = configured.height();
|
||||
int depth = configured.depth();
|
||||
for (JigsawStudioVariant variant : catalog.spatialVariants()) {
|
||||
IrisObject object = data.getObjectLoader().load(variant.objectKey());
|
||||
ObjectFrame object = data.objectFrame(variant.objectKey());
|
||||
if (object == null) {
|
||||
continue;
|
||||
}
|
||||
int objectWidth = object.getW();
|
||||
int objectDepth = object.getD();
|
||||
int objectWidth = object.width();
|
||||
int objectDepth = object.depth();
|
||||
if (variant.rotatable()) {
|
||||
int horizontalSpan = Math.max(objectWidth, objectDepth);
|
||||
objectWidth = horizontalSpan;
|
||||
objectDepth = horizontalSpan;
|
||||
}
|
||||
width = Math.max(width, objectWidth);
|
||||
height = Math.max(height, object.getH());
|
||||
height = Math.max(height, object.height());
|
||||
depth = Math.max(depth, objectDepth);
|
||||
}
|
||||
return new JigsawStudioCellDimensions(width, height, depth);
|
||||
}
|
||||
|
||||
private static void traversePools(
|
||||
IrisData data,
|
||||
Source data,
|
||||
JigsawStudioMode mode,
|
||||
OwnedResources owned,
|
||||
ArrayDeque<String> pools,
|
||||
@@ -166,7 +174,7 @@ public final class JigsawStudioGraphMapper {
|
||||
if (!visitedPools.add(poolKey)) {
|
||||
continue;
|
||||
}
|
||||
IrisJigsawPool pool = StructureResources.pool(data.getPackResources(), poolKey);
|
||||
IrisJigsawPool pool = StructureResources.pool(data.resources(), poolKey);
|
||||
if (pool == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -180,7 +188,7 @@ public final class JigsawStudioGraphMapper {
|
||||
continue;
|
||||
}
|
||||
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()) {
|
||||
continue;
|
||||
}
|
||||
@@ -202,7 +210,7 @@ public final class JigsawStudioGraphMapper {
|
||||
}
|
||||
|
||||
private static void addOwnedVariant(
|
||||
IrisData data,
|
||||
Source data,
|
||||
JigsawStudioMode mode,
|
||||
OwnedResources owned,
|
||||
String pieceKey,
|
||||
@@ -211,21 +219,20 @@ public final class JigsawStudioGraphMapper {
|
||||
if (variants.containsKey(pieceKey)) {
|
||||
return;
|
||||
}
|
||||
IrisJigsawPiece piece = StructureResources.piece(data.getPackResources(), pieceKey);
|
||||
IrisJigsawPiece piece = StructureResources.piece(data.resources(), pieceKey);
|
||||
if (piece == null || piece.getObject() == null || piece.getObject().isBlank()) {
|
||||
return;
|
||||
}
|
||||
variants.put(pieceKey, new MutableVariant(pieceKey, piece, mode, owned.owns(pieceKey, piece.getObject())));
|
||||
}
|
||||
|
||||
private static OwnedResources ownedResources(IrisData data, IrisStructure structure) {
|
||||
String structureKey = structure.getLoadKey();
|
||||
File dataFolder = data.getDataFolder();
|
||||
if (structureKey == null || structureKey.isBlank() || dataFolder == null) {
|
||||
private static OwnedResources ownedResources(Source data, IrisStructure structure) {
|
||||
String structureKey = data.structureKey();
|
||||
if (structureKey == null || structureKey.isBlank()) {
|
||||
return OwnedResources.empty();
|
||||
}
|
||||
try {
|
||||
Path root = dataFolder.toPath().toAbsolutePath().normalize();
|
||||
Path root = data.root().toAbsolutePath().normalize();
|
||||
StructureTransactionWriter writer = new StructureTransactionWriter(root);
|
||||
Path manifestPath = writer.ownershipManifestPath(StructureKey.parse(structureKey, "iris"));
|
||||
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) {
|
||||
case NORTH_NEGATIVE_Z -> JigsawPlanarDirection.NORTH.bit();
|
||||
case EAST_POSITIVE_X -> JigsawPlanarDirection.EAST.bit();
|
||||
@@ -310,7 +317,7 @@ public final class JigsawStudioGraphMapper {
|
||||
memberships.add(membership);
|
||||
}
|
||||
|
||||
private JigsawStudioVariant build(IrisData data) {
|
||||
private JigsawStudioVariant build(Source data) {
|
||||
Optional<JigsawStudioCellDimensions> dimensions = objectDimensions(data, piece, mode);
|
||||
return new JigsawStudioVariant(
|
||||
pieceKey,
|
||||
@@ -329,21 +336,18 @@ public final class JigsawStudioGraphMapper {
|
||||
}
|
||||
|
||||
private static Optional<JigsawStudioCellDimensions> objectDimensions(
|
||||
IrisData data,
|
||||
Source data,
|
||||
IrisJigsawPiece piece,
|
||||
JigsawStudioMode mode
|
||||
) {
|
||||
if (data.getObjectLoader() == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
IrisObject object = data.getObjectLoader().load(piece.getObject());
|
||||
ObjectFrame object = data.objectFrame(piece.getObject());
|
||||
if (object == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
JigsawStudioCellDimensions sourceDimensions = new JigsawStudioCellDimensions(
|
||||
object.getW(),
|
||||
object.getH(),
|
||||
object.getD());
|
||||
object.width(),
|
||||
object.height(),
|
||||
object.depth());
|
||||
if (mode == JigsawStudioMode.SPATIAL_JIGSAW) {
|
||||
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(
|
||||
Set<String> pieceKeys,
|
||||
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.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
|
||||
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.IrisJigsawMode;
|
||||
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.IrisJigsawWorkcell;
|
||||
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 com.volmit.geometry.BlockPosition;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -36,13 +36,13 @@ import java.util.Objects;
|
||||
|
||||
public final class JigsawStudioProjectCreator {
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final List<IrisDirection> SPATIAL_CONNECTOR_ORDER = List.of(
|
||||
IrisDirection.NORTH_NEGATIVE_Z,
|
||||
IrisDirection.SOUTH_POSITIVE_Z,
|
||||
IrisDirection.EAST_POSITIVE_X,
|
||||
IrisDirection.WEST_NEGATIVE_X,
|
||||
IrisDirection.UP_POSITIVE_Y,
|
||||
IrisDirection.DOWN_NEGATIVE_Y);
|
||||
private static final List<JigsawDirection> SPATIAL_CONNECTOR_ORDER = List.of(
|
||||
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||
JigsawDirection.SOUTH_POSITIVE_Z,
|
||||
JigsawDirection.EAST_POSITIVE_X,
|
||||
JigsawDirection.WEST_NEGATIVE_X,
|
||||
JigsawDirection.UP_POSITIVE_Y,
|
||||
JigsawDirection.DOWN_NEGATIVE_Y);
|
||||
|
||||
private JigsawStudioProjectCreator() {
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public final class JigsawStudioProjectCreator {
|
||||
.setMode(toModelMode(options.mode()))
|
||||
.setCompatibility(toModelCompatibility(options.compatibilityTarget()))
|
||||
.setBranchFailurePolicy(toBranchFailurePolicy(options.compatibilityTarget()))
|
||||
.setCellSize(new IrisPosition(
|
||||
.setCellSize(new BlockPosition(
|
||||
options.cellDimensions().width(),
|
||||
options.cellDimensions().height(),
|
||||
options.cellDimensions().depth()));
|
||||
@@ -123,7 +123,7 @@ public final class JigsawStudioProjectCreator {
|
||||
Options options
|
||||
) throws IOException {
|
||||
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 capPoolKey = options.structureKey() + "/caps";
|
||||
IrisJigsawPool piecePool = new IrisJigsawPool().setFallback(capPoolKey);
|
||||
@@ -209,13 +209,13 @@ public final class JigsawStudioProjectCreator {
|
||||
.setRotatable(true)
|
||||
.setRules(new IrisJigsawPieceRules().setMaximumPlacements(16));
|
||||
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()
|
||||
.setPosition(spatialConnectorPosition(dimensions, direction))
|
||||
.setDirection(direction)
|
||||
.setTop(direction.isVertical()
|
||||
? IrisDirection.NORTH_NEGATIVE_Z
|
||||
: IrisDirection.UP_POSITIVE_Y)
|
||||
? JigsawDirection.NORTH_NEGATIVE_Z
|
||||
: JigsawDirection.UP_POSITIVE_Y)
|
||||
.setPool(poolKey)
|
||||
.setName("iris:spatial")
|
||||
.setTargetName("iris:spatial")
|
||||
@@ -225,36 +225,36 @@ public final class JigsawStudioProjectCreator {
|
||||
return piece;
|
||||
}
|
||||
|
||||
private static IrisPosition spatialConnectorPosition(
|
||||
private static BlockPosition spatialConnectorPosition(
|
||||
JigsawStudioCellDimensions dimensions,
|
||||
IrisDirection direction
|
||||
JigsawDirection direction
|
||||
) {
|
||||
int centerX = dimensions.width() / 2;
|
||||
int centerY = dimensions.height() / 2;
|
||||
int centerZ = dimensions.depth() / 2;
|
||||
return switch (direction) {
|
||||
case NORTH_NEGATIVE_Z -> new IrisPosition(centerX, centerY, 0);
|
||||
case SOUTH_POSITIVE_Z -> new IrisPosition(centerX, centerY, dimensions.depth() - 1);
|
||||
case EAST_POSITIVE_X -> new IrisPosition(dimensions.width() - 1, centerY, centerZ);
|
||||
case WEST_NEGATIVE_X -> new IrisPosition(0, centerY, centerZ);
|
||||
case UP_POSITIVE_Y -> new IrisPosition(centerX, dimensions.height() - 1, centerZ);
|
||||
case DOWN_NEGATIVE_Y -> new IrisPosition(centerX, 0, centerZ);
|
||||
case NORTH_NEGATIVE_Z -> new BlockPosition(centerX, centerY, 0);
|
||||
case SOUTH_POSITIVE_Z -> new BlockPosition(centerX, centerY, dimensions.depth() - 1);
|
||||
case EAST_POSITIVE_X -> new BlockPosition(dimensions.width() - 1, centerY, centerZ);
|
||||
case WEST_NEGATIVE_X -> new BlockPosition(0, centerY, centerZ);
|
||||
case UP_POSITIVE_Y -> new BlockPosition(centerX, dimensions.height() - 1, centerZ);
|
||||
case DOWN_NEGATIVE_Y -> new BlockPosition(centerX, 0, centerZ);
|
||||
};
|
||||
}
|
||||
|
||||
private static IrisJigsawPiece planarPiece(
|
||||
String objectKey,
|
||||
String poolKey,
|
||||
IrisPosition dimensions,
|
||||
BlockPosition dimensions,
|
||||
JigsawPlanarArchetype archetype
|
||||
) {
|
||||
IrisJigsawPiece piece = new IrisJigsawPiece().setObject(objectKey).setRotatable(true);
|
||||
for (JigsawPlanarDirection planarDirection : archetype.canonicalTopology().directions()) {
|
||||
IrisDirection direction = planarDirection.irisDirection();
|
||||
JigsawDirection direction = planarDirection.direction();
|
||||
piece.getConnectors().add(new IrisJigsawConnector()
|
||||
.setPosition(IrisJigsawConnector.canonicalPlanarPosition(dimensions, direction))
|
||||
.setDirection(direction)
|
||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
||||
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||
.setPool(poolKey)
|
||||
.setName("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.IrisJigsawThemeSet;
|
||||
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.volmlib.util.math.IrisBlockVector;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
@@ -22,6 +20,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@@ -270,17 +269,24 @@ public final class JigsawStudioStructureEditor {
|
||||
continue;
|
||||
}
|
||||
Path objectPath = resolveOwnedResource(root, relativePath);
|
||||
IrisBlockVector size = IrisObject.sampleSize(objectPath.toFile());
|
||||
if (size.getBlockX() > dimensions.width()
|
||||
|| size.getBlockY() > dimensions.height()
|
||||
|| size.getBlockZ() > dimensions.depth()) {
|
||||
int[] size = sampleSize(objectPath);
|
||||
if (size[0] > dimensions.width()
|
||||
|| size[1] > dimensions.height()
|
||||
|| size[2] > dimensions.depth()) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 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(
|
||||
byte[] content,
|
||||
JigsawStudioCellDimensions dimensions,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.Objects;
|
||||
@@ -61,8 +61,8 @@ public record JigsawStudioVariant(
|
||||
.canonicalToSourceQuarterTurns(topology);
|
||||
}
|
||||
|
||||
public IrisPosition sourceToCanonicalPosition(
|
||||
IrisPosition sourcePosition,
|
||||
public BlockPosition sourceToCanonicalPosition(
|
||||
BlockPosition sourcePosition,
|
||||
JigsawStudioCellDimensions sourceDimensions
|
||||
) {
|
||||
return rotatePosition(
|
||||
@@ -71,8 +71,8 @@ public record JigsawStudioVariant(
|
||||
sourceToCanonicalQuarterTurns());
|
||||
}
|
||||
|
||||
public IrisPosition canonicalToSourcePosition(
|
||||
IrisPosition canonicalPosition,
|
||||
public BlockPosition canonicalToSourcePosition(
|
||||
BlockPosition canonicalPosition,
|
||||
JigsawStudioCellDimensions sourceDimensions
|
||||
) {
|
||||
JigsawStudioCellDimensions canonicalDimensions = canonicalDimensions(sourceDimensions);
|
||||
@@ -98,34 +98,34 @@ public record JigsawStudioVariant(
|
||||
return !memberships.isEmpty();
|
||||
}
|
||||
|
||||
private static IrisPosition rotatePosition(
|
||||
IrisPosition position,
|
||||
private static BlockPosition rotatePosition(
|
||||
BlockPosition position,
|
||||
JigsawStudioCellDimensions dimensions,
|
||||
int quarterTurns
|
||||
) {
|
||||
IrisPosition source = Objects.requireNonNull(position, "Jigsaw Studio variant position");
|
||||
BlockPosition source = Objects.requireNonNull(position, "Jigsaw Studio variant position");
|
||||
JigsawStudioCellDimensions bounds = Objects.requireNonNull(
|
||||
dimensions,
|
||||
"Jigsaw Studio variant position bounds");
|
||||
if (source.getX() < 0 || source.getX() >= bounds.width()
|
||||
|| source.getY() < 0 || source.getY() >= bounds.height()
|
||||
|| source.getZ() < 0 || source.getZ() >= bounds.depth()) {
|
||||
if (source.x() < 0 || source.x() >= bounds.width()
|
||||
|| source.y() < 0 || source.y() >= bounds.height()
|
||||
|| source.z() < 0 || source.z() >= bounds.depth()) {
|
||||
throw new IllegalArgumentException("Jigsaw Studio variant position is outside its object bounds");
|
||||
}
|
||||
return switch (Math.floorMod(quarterTurns, 4)) {
|
||||
case 0 -> new IrisPosition(source.getX(), source.getY(), source.getZ());
|
||||
case 1 -> new IrisPosition(
|
||||
bounds.depth() - 1 - source.getZ(),
|
||||
source.getY(),
|
||||
source.getX());
|
||||
case 2 -> new IrisPosition(
|
||||
bounds.width() - 1 - source.getX(),
|
||||
source.getY(),
|
||||
bounds.depth() - 1 - source.getZ());
|
||||
case 3 -> new IrisPosition(
|
||||
source.getZ(),
|
||||
source.getY(),
|
||||
bounds.width() - 1 - source.getX());
|
||||
case 0 -> new BlockPosition(source.x(), source.y(), source.z());
|
||||
case 1 -> new BlockPosition(
|
||||
bounds.depth() - 1 - source.z(),
|
||||
source.y(),
|
||||
source.x());
|
||||
case 2 -> new BlockPosition(
|
||||
bounds.width() - 1 - source.x(),
|
||||
source.y(),
|
||||
bounds.depth() - 1 - source.z());
|
||||
case 3 -> new BlockPosition(
|
||||
source.z(),
|
||||
source.y(),
|
||||
bounds.width() - 1 - source.x());
|
||||
default -> throw new IllegalStateException("Unreachable Jigsaw Studio rotation");
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.BlockState;
|
||||
|
||||
@@ -39,8 +39,8 @@ public final class JigsawStudioBlocks {
|
||||
}
|
||||
|
||||
/** {@code state} turned like {@code rotation}; null when the registry cannot turn the block. */
|
||||
public static BlockState rotated(BlockRegistry registry, BlockState state, ObjectTurn rotation) {
|
||||
if (!rotation.canRotate()) {
|
||||
public static BlockState rotated(BlockRegistry registry, BlockState state, PieceTurn rotation) {
|
||||
if (rotation.quarterTurns() == 0) {
|
||||
return state;
|
||||
}
|
||||
return registry.tryRotate(state, rotation.blockTurn()).orElse(null);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package art.arcane.iris.core.service;
|
||||
|
||||
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.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -31,7 +31,7 @@ final class JigsawStudioMarkerParser {
|
||||
throw new IllegalArgumentException("Unsupported jigsaw joint '" + jointName + "'", exception);
|
||||
}
|
||||
return new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(x, y, z))
|
||||
.setPosition(new BlockPosition(x, y, z))
|
||||
.setDirection(directions.front())
|
||||
.setTop(directions.top())
|
||||
.setPool(JigsawStudioMarkerKeyCodec.decodePool(requiredString(properties, "pool")))
|
||||
@@ -48,18 +48,18 @@ final class JigsawStudioMarkerParser {
|
||||
static Directions directions(String orientation) {
|
||||
String name = Objects.requireNonNull(orientation, "Jigsaw orientation").toLowerCase(Locale.ROOT);
|
||||
return switch (name) {
|
||||
case "down_east" -> new Directions(IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.EAST_POSITIVE_X);
|
||||
case "down_north" -> new Directions(IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.NORTH_NEGATIVE_Z);
|
||||
case "down_south" -> new Directions(IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.SOUTH_POSITIVE_Z);
|
||||
case "down_west" -> new Directions(IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.WEST_NEGATIVE_X);
|
||||
case "up_east" -> new Directions(IrisDirection.UP_POSITIVE_Y, IrisDirection.EAST_POSITIVE_X);
|
||||
case "up_north" -> new Directions(IrisDirection.UP_POSITIVE_Y, IrisDirection.NORTH_NEGATIVE_Z);
|
||||
case "up_south" -> new Directions(IrisDirection.UP_POSITIVE_Y, IrisDirection.SOUTH_POSITIVE_Z);
|
||||
case "up_west" -> new Directions(IrisDirection.UP_POSITIVE_Y, IrisDirection.WEST_NEGATIVE_X);
|
||||
case "west_up" -> new Directions(IrisDirection.WEST_NEGATIVE_X, IrisDirection.UP_POSITIVE_Y);
|
||||
case "east_up" -> new Directions(IrisDirection.EAST_POSITIVE_X, IrisDirection.UP_POSITIVE_Y);
|
||||
case "north_up" -> new Directions(IrisDirection.NORTH_NEGATIVE_Z, IrisDirection.UP_POSITIVE_Y);
|
||||
case "south_up" -> new Directions(IrisDirection.SOUTH_POSITIVE_Z, IrisDirection.UP_POSITIVE_Y);
|
||||
case "down_east" -> new Directions(JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.EAST_POSITIVE_X);
|
||||
case "down_north" -> new Directions(JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||
case "down_south" -> new Directions(JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||
case "down_west" -> new Directions(JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.WEST_NEGATIVE_X);
|
||||
case "up_east" -> new Directions(JigsawDirection.UP_POSITIVE_Y, JigsawDirection.EAST_POSITIVE_X);
|
||||
case "up_north" -> new Directions(JigsawDirection.UP_POSITIVE_Y, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||
case "up_south" -> new Directions(JigsawDirection.UP_POSITIVE_Y, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||
case "up_west" -> new Directions(JigsawDirection.UP_POSITIVE_Y, JigsawDirection.WEST_NEGATIVE_X);
|
||||
case "west_up" -> new Directions(JigsawDirection.WEST_NEGATIVE_X, JigsawDirection.UP_POSITIVE_Y);
|
||||
case "east_up" -> new Directions(JigsawDirection.EAST_POSITIVE_X, JigsawDirection.UP_POSITIVE_Y);
|
||||
case "north_up" -> new Directions(JigsawDirection.NORTH_NEGATIVE_Z, JigsawDirection.UP_POSITIVE_Y);
|
||||
case "south_up" -> new Directions(JigsawDirection.SOUTH_POSITIVE_Z, JigsawDirection.UP_POSITIVE_Y);
|
||||
default -> throw new IllegalArgumentException("Unsupported jigsaw orientation '" + orientation + "'");
|
||||
};
|
||||
}
|
||||
@@ -98,7 +98,7 @@ final class JigsawStudioMarkerParser {
|
||||
return (int) longValue;
|
||||
}
|
||||
|
||||
record Directions(IrisDirection front, IrisDirection top) {
|
||||
record Directions(JigsawDirection front, JigsawDirection top) {
|
||||
Directions {
|
||||
Objects.requireNonNull(front, "Jigsaw front direction");
|
||||
Objects.requireNonNull(top, "Jigsaw top direction");
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package art.arcane.iris.core.service;
|
||||
|
||||
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.prefab.ObjectTurn;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.object.ObjectBlock;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.tooling.world.ToolWorld;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -39,7 +40,8 @@ public final class JigsawStudioPreviewRenderer {
|
||||
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(
|
||||
pieces,
|
||||
"Jigsaw Studio preview pieces"));
|
||||
@@ -64,7 +66,7 @@ public final class JigsawStudioPreviewRenderer {
|
||||
maximumX = Math.max(maximumX, piece.getMaxX());
|
||||
maximumY = Math.max(maximumY, piece.getMaxY());
|
||||
maximumZ = Math.max(maximumZ, piece.getMaxZ());
|
||||
appendObject(blocks, piece, registry);
|
||||
appendObject(blocks, piece, pack);
|
||||
appendFinalStates(blocks, piece, registry);
|
||||
if (blocks.size() > MAX_BLOCKS) {
|
||||
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(
|
||||
Map<BlockPosition, String> blocks,
|
||||
PlacedStructurePiece piece,
|
||||
BlockRegistry registry
|
||||
PackResources pack
|
||||
) throws IOException {
|
||||
ObjectTurn rotation = piece.getRotation();
|
||||
for (ObjectBlock block : piece.getObject().geometry().blocks()) {
|
||||
IrisBlockVector rotated = rotation.rotate(new IrisBlockVector(
|
||||
block.position().x(), block.position().y(), block.position().z()));
|
||||
PieceTurn rotation = piece.getRotation();
|
||||
PlaceableObject object = pack.objects().object(pack.idOf(piece.getObjectKey()))
|
||||
.orElseThrow(() -> new IOException("Jigsaw Studio preview cannot find object '" + piece.getObjectKey() + "'"));
|
||||
for (ObjectBlock block : object.geometry().blocks()) {
|
||||
com.volmit.geometry.BlockPosition rotated = rotation.rotate(block.position());
|
||||
putState(
|
||||
blocks,
|
||||
new BlockPosition(
|
||||
piece.getX() + rotated.getBlockX(),
|
||||
piece.getY() + rotated.getBlockY(),
|
||||
piece.getZ() + rotated.getBlockZ()),
|
||||
JigsawStudioBlocks.rotated(registry, block.state(), rotation),
|
||||
new BlockPosition(piece.getX() + rotated.x(), piece.getY() + rotated.y(), piece.getZ() + rotated.z()),
|
||||
JigsawStudioBlocks.rotated(pack.blocks(), block.state(), rotation),
|
||||
"object block");
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public final class JigsawStudioPreviewRenderer {
|
||||
PlacedStructurePiece piece,
|
||||
BlockRegistry registry
|
||||
) throws IOException {
|
||||
ObjectTurn rotation = piece.getRotation();
|
||||
PieceTurn rotation = piece.getRotation();
|
||||
if (piece.getPiece().getConnectors() == null) {
|
||||
return;
|
||||
}
|
||||
@@ -218,18 +218,14 @@ public final class JigsawStudioPreviewRenderer {
|
||||
if (connector == null || connector.getPosition() == null) {
|
||||
throw new IOException("Jigsaw Studio preview contains an incomplete connector");
|
||||
}
|
||||
IrisBlockVector signed = new IrisBlockVector(
|
||||
connector.getPosition().getX() - piece.getObject().center().x(),
|
||||
connector.getPosition().getY() - piece.getObject().center().y(),
|
||||
connector.getPosition().getZ() - piece.getObject().center().z());
|
||||
IrisBlockVector rotated = rotation.rotate(signed);
|
||||
com.volmit.geometry.BlockPosition rotated = rotation.rotate(new com.volmit.geometry.BlockPosition(
|
||||
connector.getPosition().x() - piece.getObject().center().x(),
|
||||
connector.getPosition().y() - piece.getObject().center().y(),
|
||||
connector.getPosition().z() - piece.getObject().center().z()));
|
||||
BlockState source = registry.find(connector.getFinalState()).orElse(null);
|
||||
putState(
|
||||
blocks,
|
||||
new BlockPosition(
|
||||
piece.getX() + rotated.getBlockX(),
|
||||
piece.getY() + rotated.getBlockY(),
|
||||
piece.getZ() + rotated.getBlockZ()),
|
||||
new BlockPosition(piece.getX() + rotated.x(), piece.getY() + rotated.y(), piece.getZ() + rotated.z()),
|
||||
source == null ? null : JigsawStudioBlocks.rotated(registry, source, rotation),
|
||||
"connector final state");
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
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.JigsawStudioCompatibilityTarget;
|
||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioLayout;
|
||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMode;
|
||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioSession;
|
||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioVariantCatalog;
|
||||
import com.volmit.tooling.ToolPack;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -31,7 +31,7 @@ public final class JigsawStudioRegistry {
|
||||
JigsawStudioMode mode,
|
||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||
JigsawStudioCellDimensions cellDimensions,
|
||||
IrisData source
|
||||
ToolPack source
|
||||
) {
|
||||
JigsawStudioLayout layout = JigsawStudioLayout.create(
|
||||
mode,
|
||||
@@ -55,7 +55,7 @@ public final class JigsawStudioRegistry {
|
||||
JigsawStudioMode mode,
|
||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||
JigsawStudioCellDimensions cellDimensions,
|
||||
IrisData source,
|
||||
ToolPack source,
|
||||
JigsawStudioLayout initialLayout
|
||||
) {
|
||||
return activate(
|
||||
@@ -76,7 +76,7 @@ public final class JigsawStudioRegistry {
|
||||
JigsawStudioMode mode,
|
||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||
JigsawStudioCellDimensions cellDimensions,
|
||||
IrisData source,
|
||||
ToolPack source,
|
||||
JigsawStudioLayout initialLayout,
|
||||
UUID ownerId
|
||||
) {
|
||||
@@ -109,7 +109,7 @@ public final class JigsawStudioRegistry {
|
||||
JigsawStudioMode mode,
|
||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||
JigsawStudioCellDimensions cellDimensions,
|
||||
IrisData source,
|
||||
ToolPack source,
|
||||
JigsawStudioLayout initialLayout,
|
||||
UUID ownerId,
|
||||
UUID preservedRequestId
|
||||
@@ -299,7 +299,7 @@ public final class JigsawStudioRegistry {
|
||||
JigsawStudioMode mode,
|
||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||
JigsawStudioCellDimensions cellDimensions,
|
||||
IrisData source,
|
||||
ToolPack source,
|
||||
JigsawStudioLayout initialLayout,
|
||||
UUID ownerId
|
||||
) {
|
||||
@@ -311,6 +311,7 @@ public final class JigsawStudioRegistry {
|
||||
compatibilityTarget,
|
||||
cellDimensions,
|
||||
source,
|
||||
JigsawStudioRequest.rootOf(source),
|
||||
ownerId);
|
||||
JigsawStudioLayout layout = Objects.requireNonNull(initialLayout, "Initial Jigsaw Studio layout");
|
||||
if (layout.mode() != mode) {
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
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.JigsawStudioCompatibilityTarget;
|
||||
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.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(
|
||||
UUID requestId,
|
||||
String packKey,
|
||||
@@ -16,9 +24,33 @@ public record JigsawStudioRequest(
|
||||
JigsawStudioMode mode,
|
||||
JigsawStudioCompatibilityTarget compatibilityTarget,
|
||||
JigsawStudioCellDimensions cellDimensions,
|
||||
IrisData source,
|
||||
ToolPack source,
|
||||
Path packRoot,
|
||||
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 {
|
||||
requestId = Objects.requireNonNull(requestId, "Jigsaw Studio request ID");
|
||||
packKey = requireKey(packKey, "pack");
|
||||
@@ -29,7 +61,8 @@ public record JigsawStudioRequest(
|
||||
"Jigsaw Studio compatibility target"
|
||||
);
|
||||
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) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package art.arcane.iris.core.service;
|
||||
|
||||
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.JigsawPlanarDirection;
|
||||
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.StructureGraphResolver;
|
||||
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.IrisJigsawPiece;
|
||||
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.jigsaw.JigsawJoint;
|
||||
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",
|
||||
"say", "tell", "ver", "version", "w", "whisper");
|
||||
private static final Comparator<IrisJigsawConnector> NEW_CONNECTOR_SOURCE_POSITION_ORDER = Comparator
|
||||
.comparingInt((IrisJigsawConnector connector) -> connector.getPosition().getX())
|
||||
.thenComparingInt(connector -> connector.getPosition().getY())
|
||||
.thenComparingInt(connector -> connector.getPosition().getZ());
|
||||
.comparingInt((IrisJigsawConnector connector) -> connector.getPosition().x())
|
||||
.thenComparingInt(connector -> connector.getPosition().y())
|
||||
.thenComparingInt(connector -> connector.getPosition().z());
|
||||
private final ModuleLog log;
|
||||
private final JigsawStudioRegistry registry = new JigsawStudioRegistry();
|
||||
private final JigsawStudioScheduler scheduler;
|
||||
@@ -999,7 +997,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
throw new IOException("Jigsaw Studio undo failed: "
|
||||
+ writeFailure(result.writeResult()));
|
||||
}
|
||||
request.source().invalidateStructureResources();
|
||||
request.reloadSource();
|
||||
JigsawStudioLayout restoredLayout = loadMappedLayout(studio);
|
||||
VariantReloadRequest reload = activeReloads.get(result.pieceKey());
|
||||
Optional<VariantReloadRequest> activeReload = reload == null
|
||||
@@ -1380,7 +1378,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
archetype,
|
||||
dimensions);
|
||||
}
|
||||
request.source().invalidateStructureResources();
|
||||
request.reloadSource();
|
||||
String resizeSummary = capacityResult == null
|
||||
? ""
|
||||
: " Verified " + capacityResult.checkedVariants() + " existing variant"
|
||||
@@ -2379,7 +2377,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
return false;
|
||||
}
|
||||
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();
|
||||
ToolPack pack = studio.generator().getPack();
|
||||
scheduler.async(() -> {
|
||||
@@ -2389,8 +2387,8 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
if (structure == null) {
|
||||
throw new IOException("The active structure resource no longer exists");
|
||||
}
|
||||
StructureAssembler assembler = StructureAssembler.forData(
|
||||
request.source(), structure, origin, pack.log());
|
||||
StructureAssembler assembler = StructureAssembler.forPack(
|
||||
request.source().resources(), request.structureKey(), structure, origin, pack.log());
|
||||
StructureAssemblyResult assembly = assembler.assemble(new RNG(seed));
|
||||
if (!assembly.hasOutput()) {
|
||||
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");
|
||||
}
|
||||
StructureGraphCompilation compilation = StructureGraphCompiler.compile(
|
||||
request.structureKey(),
|
||||
structure,
|
||||
StructureGraphResolver.forData(request.source()));
|
||||
StructureGraphResolver.forPack(request.source().resources()));
|
||||
StructureGraphDiagnostic firstError = firstDiagnostic(
|
||||
compilation,
|
||||
StructureGraphDiagnostic.Severity.ERROR);
|
||||
@@ -2526,7 +2525,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
generation,
|
||||
firstError.code() + ": " + firstError.message());
|
||||
} else {
|
||||
IrisPosition origin = previewOrigin(studio.generator().getLayout(), structure);
|
||||
BlockPosition origin = previewOrigin(studio.generator().getLayout(), structure);
|
||||
StructureAssembler assembler = StructureAssembler.forCompilation(compilation, origin);
|
||||
StructureAssemblyResult assembly = assembler.assemble(new RNG(PREVIEW_SEED));
|
||||
computation = evaluationForAssembly(
|
||||
@@ -2535,7 +2534,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
compilation,
|
||||
assembly,
|
||||
studio.generator().getLayout().mode(),
|
||||
studio.generator().getPack().resources().blocks());
|
||||
studio.generator().getPack().resources());
|
||||
}
|
||||
} catch (Throwable exception) {
|
||||
reportError(exception);
|
||||
@@ -2550,7 +2549,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
StructureGraphCompilation compilation,
|
||||
StructureAssemblyResult assembly,
|
||||
JigsawStudioMode mode,
|
||||
BlockRegistry blocks
|
||||
PackResources pack
|
||||
) throws IOException {
|
||||
if (assembly.status().isFailure()) {
|
||||
return invalidEvaluation(
|
||||
@@ -2574,7 +2573,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
JigsawStudioPreviewRenderer.PreviewPlan.empty());
|
||||
}
|
||||
List<PlacedStructurePiece> aligned = alignPreviewPieces(assembly.pieces(), mode);
|
||||
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(aligned, blocks);
|
||||
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(aligned, pack);
|
||||
StructureGraphDiagnostic firstWarning = firstDiagnostic(
|
||||
compilation,
|
||||
StructureGraphDiagnostic.Severity.WARNING);
|
||||
@@ -2667,9 +2666,9 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
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;
|
||||
return new IrisPosition(
|
||||
return new BlockPosition(
|
||||
-radius - 32,
|
||||
0,
|
||||
Math.max(16, layout.extentZ() / 2));
|
||||
@@ -2691,6 +2690,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
aligned.add(new PlacedStructurePiece(
|
||||
piece.getPiece(),
|
||||
piece.getObjectKey(),
|
||||
piece.getObject(),
|
||||
piece.getX(),
|
||||
piece.getY() + shiftY,
|
||||
@@ -3709,13 +3709,12 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
|
||||
private static JigsawStudioLayout loadMappedLayout(ActiveStudio studio) throws IOException {
|
||||
JigsawStudioRequest request = studio.generator().getRequest();
|
||||
IrisData source = request.source();
|
||||
source.invalidateStructureResources();
|
||||
IrisStructure structure = StructureResources.structure(source.getPackResources(), request.structureKey());
|
||||
request.reloadSource();
|
||||
IrisStructure structure = StructureResources.structure(request.source().resources(), request.structureKey());
|
||||
if (structure == null) {
|
||||
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) {
|
||||
@@ -5774,7 +5773,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
int sourceDepth = (quarterTurns & 1) == 0
|
||||
? displayDimensions.depth()
|
||||
: 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());
|
||||
for (IrisJigsawConnector sourceConnector : source.getConnectors()) {
|
||||
LocalPosition sourcePosition = connectorPosition(sourceConnector, "source piece");
|
||||
@@ -5786,9 +5785,9 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
sourceDepth,
|
||||
quarterTurns);
|
||||
IrisJigsawConnector connector = CapturedConnector.from(sourceConnector).toConnector()
|
||||
.setPosition(new IrisPosition(position.x(), position.y(), position.z()))
|
||||
.setDirection(rotation.rotate(sourceConnector.getDirection()))
|
||||
.setTop(rotation.rotate(sourceConnector.getTop()));
|
||||
.setPosition(new BlockPosition(position.x(), position.y(), position.z()))
|
||||
.setDirection(sourceConnector.getDirection().turnedBy(rotation.quarterTurns()))
|
||||
.setTop(sourceConnector.getTop().turnedBy(rotation.quarterTurns()));
|
||||
if (displayed.put(position, connector) != null) {
|
||||
throw new IOException("Jigsaw Studio source piece has duplicate displayed connector position "
|
||||
+ connectorLocation(position));
|
||||
@@ -5903,7 +5902,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
: captureBounds.dimensions().width();
|
||||
int sourceHeight = captureBounds.dimensions().height();
|
||||
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<>();
|
||||
Set<LocalPosition> capturedBlocks = new HashSet<>();
|
||||
Set<LocalPosition> capturedConnectors = new HashSet<>();
|
||||
@@ -5959,9 +5958,9 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
}
|
||||
IrisJigsawConnector connector = capturedConnector.toConnector();
|
||||
if (quarterTurns != 0) {
|
||||
connector.setPosition(new IrisPosition(position.x(), position.y(), position.z()));
|
||||
connector.setDirection(inverseRotation.rotate(connector.getDirection()));
|
||||
connector.setTop(inverseRotation.rotate(connector.getTop()));
|
||||
connector.setPosition(new BlockPosition(position.x(), position.y(), position.z()));
|
||||
connector.setDirection(connector.getDirection().turnedBy(inverseRotation.quarterTurns()));
|
||||
connector.setTop(connector.getTop().turnedBy(inverseRotation.quarterTurns()));
|
||||
BlockState finalState = registry.find(connector.getFinalState()).orElse(null);
|
||||
if (finalState == null) {
|
||||
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) {
|
||||
throw new IOException("Jigsaw Studio " + owner + " contains a connector without a position");
|
||||
}
|
||||
IrisPosition position = connector.getPosition();
|
||||
return new LocalPosition(position.getX(), position.getY(), position.getZ());
|
||||
BlockPosition position = connector.getPosition();
|
||||
return new LocalPosition(position.x(), position.y(), position.z());
|
||||
}
|
||||
|
||||
private static String connectorLocation(LocalPosition position) {
|
||||
@@ -6478,24 +6477,24 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
? displayDimensions.depth()
|
||||
: displayDimensions.width();
|
||||
LocalPosition position = inversePosition(
|
||||
captured.getPosition().getX(),
|
||||
captured.getPosition().getY(),
|
||||
captured.getPosition().getZ(),
|
||||
captured.getPosition().x(),
|
||||
captured.getPosition().y(),
|
||||
captured.getPosition().z(),
|
||||
sourceWidth,
|
||||
sourceDepth,
|
||||
quarterTurns);
|
||||
ObjectTurn inverseRotation = ObjectTurn.of(0, 90.0D * quarterTurns, 0);
|
||||
PieceTurn inverseRotation = PieceTurn.aroundY(90 * quarterTurns);
|
||||
IrisJigsawConnector sourceOriented = CapturedConnector.from(captured).toConnector()
|
||||
.setPosition(new IrisPosition(position.x(), position.y(), position.z()))
|
||||
.setDirection(inverseRotation.rotate(captured.getDirection()))
|
||||
.setTop(inverseRotation.rotate(captured.getTop()));
|
||||
.setPosition(new BlockPosition(position.x(), position.y(), position.z()))
|
||||
.setDirection(captured.getDirection().turnedBy(inverseRotation.quarterTurns()))
|
||||
.setTop(captured.getTop().turnedBy(inverseRotation.quarterTurns()));
|
||||
restoreCapturedMetadata(sourceOriented, sourcePiece);
|
||||
captured.setName(sourceOriented.getName());
|
||||
captured.setTargetName(sourceOriented.getTargetName());
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
@@ -7087,7 +7086,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
}
|
||||
for (JigsawStudioGenerator.RenderedConnector renderedConnector : rendered.connectors()) {
|
||||
IrisJigsawConnector connector = renderedConnector.connector();
|
||||
IrisDirection direction = connector.getDirection();
|
||||
JigsawDirection direction = connector.getDirection();
|
||||
drawConnectorLine(
|
||||
playerLocation,
|
||||
bay.bounds().originX() + renderedConnector.x() + 0.5D,
|
||||
@@ -7107,7 +7106,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
double startX,
|
||||
double startY,
|
||||
double startZ,
|
||||
IrisDirection direction,
|
||||
JigsawDirection direction,
|
||||
int color,
|
||||
ParticleBudget budget
|
||||
) {
|
||||
@@ -8182,8 +8181,8 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
IrisDirection direction,
|
||||
IrisDirection top,
|
||||
JigsawDirection direction,
|
||||
JigsawDirection top,
|
||||
String pool,
|
||||
String name,
|
||||
String targetName,
|
||||
@@ -8206,11 +8205,11 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
|
||||
static CapturedConnector from(IrisJigsawConnector connector) {
|
||||
IrisJigsawConnector source = Objects.requireNonNull(connector, "Jigsaw Studio captured connector");
|
||||
IrisPosition position = source.getPosition();
|
||||
BlockPosition position = source.getPosition();
|
||||
return new CapturedConnector(
|
||||
position.getX(),
|
||||
position.getY(),
|
||||
position.getZ(),
|
||||
position.x(),
|
||||
position.y(),
|
||||
position.z(),
|
||||
source.getDirection(),
|
||||
source.getTop(),
|
||||
source.getPool(),
|
||||
@@ -8225,7 +8224,7 @@ public final class JigsawStudioService implements JigsawStudioMenuController.Act
|
||||
|
||||
IrisJigsawConnector toConnector() {
|
||||
return new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(x, y, z))
|
||||
.setPosition(new BlockPosition(x, y, z))
|
||||
.setDirection(direction)
|
||||
.setTop(top)
|
||||
.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.IrisJigsawPool;
|
||||
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.volmlib.util.math.IrisBlockVector;
|
||||
import com.volmit.block.BlockState;
|
||||
@@ -66,10 +64,11 @@ final class VanillaJigsawExportCompiler {
|
||||
return rejected(diagnostics);
|
||||
}
|
||||
|
||||
validateStructure(structure, request.settings(), diagnostics);
|
||||
validateStructure(request.source().structureKey(), structure, request.settings(), diagnostics);
|
||||
StructureGraphCompilation graphCompilation;
|
||||
try {
|
||||
graphCompilation = StructureGraphCompiler.compile(structure, request.source().resolver());
|
||||
graphCompilation = StructureGraphCompiler.compile(
|
||||
request.source().structureKey(), structure, request.source().resolver());
|
||||
} catch (RuntimeException exception) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.GRAPH_VALIDATION,
|
||||
@@ -79,7 +78,7 @@ final class VanillaJigsawExportCompiler {
|
||||
}
|
||||
addGraphDiagnostics(graphCompilation, diagnostics);
|
||||
CompiledStructureGraph graph = graphCompilation.getGraph();
|
||||
validateGraph(graph, diagnostics);
|
||||
validateGraph(graph, request.source(), diagnostics);
|
||||
if (hasErrors(diagnostics)) {
|
||||
return rejected(diagnostics);
|
||||
}
|
||||
@@ -167,6 +166,7 @@ final class VanillaJigsawExportCompiler {
|
||||
}
|
||||
|
||||
private void validateStructure(
|
||||
String structureKey,
|
||||
IrisStructure structure,
|
||||
VanillaJigsawExportSettings settings,
|
||||
List<VanillaJigsawExportDiagnostic> diagnostics
|
||||
@@ -174,50 +174,50 @@ final class VanillaJigsawExportCompiler {
|
||||
if (structure.resolvedCompatibility() != IrisJigsawCompatibility.VANILLA_PORTABLE) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_COMPATIBILITY,
|
||||
structureKey(structure),
|
||||
structureKey,
|
||||
"Strict export requires compatibility VANILLA_PORTABLE.");
|
||||
}
|
||||
if (!structure.stampsPiecesWhereAssembled()) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_PLACE_MODE,
|
||||
structureKey(structure),
|
||||
structureKey,
|
||||
"Vanilla export requires placeMode STRUCTURE_PIECE; Iris terrain and stilt modes have no vanilla jigsaw equivalent.");
|
||||
}
|
||||
if (structure.getEdit() != null && !structure.getEdit().isEmpty()) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_EDIT,
|
||||
structureKey(structure),
|
||||
structureKey,
|
||||
"Structure-wide Iris block edits cannot be represented losslessly by vanilla template pools.");
|
||||
}
|
||||
if (structure.getLoot() != null && !structure.getLoot().isEmpty()) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_LOOT,
|
||||
structureKey(structure),
|
||||
structureKey,
|
||||
"Structure-wide Iris loot injection cannot be represented losslessly by this vanilla exporter.");
|
||||
}
|
||||
if (structure.getThemeSets() != null && !structure.getThemeSets().isEmpty()) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_THEME_METADATA,
|
||||
structureKey(structure),
|
||||
structureKey,
|
||||
"Coherent Iris theme selection has no lossless vanilla jigsaw representation.");
|
||||
}
|
||||
if (structure.isRequireCaps()) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_REQUIRED_CAPS,
|
||||
structureKey(structure),
|
||||
structureKey,
|
||||
"Vanilla jigsaws cannot enforce Iris requireCaps terminal-closure semantics.");
|
||||
}
|
||||
if (structure.getMaxDepth() < 1 || structure.getMaxDepth() > MAX_DEPTH) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.INVALID_MAX_DEPTH,
|
||||
structureKey(structure),
|
||||
structureKey,
|
||||
"Minecraft 26.2 jigsaw size must be within 0..20; Iris export requires 1..20.");
|
||||
}
|
||||
long horizontalDistance = (long) structure.getMaxSizeChunks() * 16L;
|
||||
if (horizontalDistance < 1L || horizontalDistance > MAX_HORIZONTAL_DISTANCE) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.INVALID_MAX_DISTANCE,
|
||||
structureKey(structure),
|
||||
structureKey,
|
||||
"Iris maxSizeChunks maps to " + horizontalDistance
|
||||
+ " blocks, outside Minecraft 26.2's 1..128 horizontal limit.");
|
||||
}
|
||||
@@ -226,7 +226,7 @@ final class VanillaJigsawExportCompiler {
|
||||
if (horizontalDistance + terrainPadding > MAX_HORIZONTAL_DISTANCE) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.INVALID_MAX_DISTANCE,
|
||||
structureKey(structure),
|
||||
structureKey,
|
||||
"Horizontal distance plus vanilla terrain-adaptation padding must not exceed 128 blocks.");
|
||||
}
|
||||
}
|
||||
@@ -250,6 +250,7 @@ final class VanillaJigsawExportCompiler {
|
||||
|
||||
private void validateGraph(
|
||||
CompiledStructureGraph graph,
|
||||
VanillaJigsawExportSource source,
|
||||
List<VanillaJigsawExportDiagnostic> diagnostics
|
||||
) {
|
||||
Map<IrisJigsawWorkcellArchetype, PlanarJigsawWorkcellResolver.ResolvedWorkcell> workcells =
|
||||
@@ -275,7 +276,7 @@ final class VanillaJigsawExportCompiler {
|
||||
pieceKey,
|
||||
"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(
|
||||
CompiledStructureGraph graph,
|
||||
VanillaJigsawExportSource source,
|
||||
String pieceKey,
|
||||
IrisJigsawPiece piece,
|
||||
List<VanillaJigsawExportDiagnostic> diagnostics
|
||||
@@ -367,7 +369,7 @@ final class VanillaJigsawExportCompiler {
|
||||
pieceKey,
|
||||
"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) {
|
||||
return;
|
||||
}
|
||||
@@ -377,10 +379,10 @@ final class VanillaJigsawExportCompiler {
|
||||
|
||||
private void validateObject(
|
||||
String pieceKey,
|
||||
IrisObject object,
|
||||
ObjectContents object,
|
||||
List<VanillaJigsawExportDiagnostic> diagnostics
|
||||
) {
|
||||
IrisObject.ApiContents contents = object.apiContents();
|
||||
ObjectContents contents = object;
|
||||
if (!contents.blockEntities().isEmpty()) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.UNSUPPORTED_TILE_DATA,
|
||||
@@ -391,13 +393,13 @@ final class VanillaJigsawExportCompiler {
|
||||
BlockState state = entry.getValue();
|
||||
BlockPosition position = entry.getKey();
|
||||
String resource = pieceKey + "@" + new IrisBlockVector(
|
||||
position.x() - object.getCenter().getX(),
|
||||
position.y() - object.getCenter().getY(),
|
||||
position.z() - object.getCenter().getZ());
|
||||
position.x() - object.center().x(),
|
||||
position.y() - object.center().y(),
|
||||
position.z() - object.center().z());
|
||||
int x = position.x();
|
||||
int y = position.y();
|
||||
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,
|
||||
VanillaJigsawExportDiagnostic.Code.INVALID_BLOCK_STATE,
|
||||
resource,
|
||||
@@ -440,14 +442,14 @@ final class VanillaJigsawExportCompiler {
|
||||
CompiledStructureGraph graph,
|
||||
String pieceKey,
|
||||
IrisJigsawPiece piece,
|
||||
IrisObject object,
|
||||
ObjectContents object,
|
||||
List<VanillaJigsawExportDiagnostic> diagnostics
|
||||
) {
|
||||
if (piece.getConnectors() == null) {
|
||||
return;
|
||||
}
|
||||
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++) {
|
||||
IrisJigsawConnector connector = piece.getConnectors().get(index);
|
||||
if (connector == null) {
|
||||
@@ -477,11 +479,11 @@ final class VanillaJigsawExportCompiler {
|
||||
resource,
|
||||
exception.getMessage() == null ? "Connector orientation is incomplete." : exception.getMessage());
|
||||
}
|
||||
IrisPosition position = connector.getPosition();
|
||||
BlockPosition position = connector.getPosition();
|
||||
if (position == null || !inside(position, object)) {
|
||||
continue;
|
||||
}
|
||||
String positionKey = position.getX() + "," + position.getY() + "," + position.getZ();
|
||||
String positionKey = position.x() + "," + position.y() + "," + position.z();
|
||||
if (!positions.add(positionKey)) {
|
||||
addError(diagnostics,
|
||||
VanillaJigsawExportDiagnostic.Code.DUPLICATE_CONNECTOR_POSITION,
|
||||
@@ -523,8 +525,8 @@ final class VanillaJigsawExportCompiler {
|
||||
exception.getMessage());
|
||||
return;
|
||||
}
|
||||
IrisPosition position = connector.getPosition();
|
||||
BlockState objectState = storedBlocks.get(new BlockPosition(position.getX(), position.getY(), position.getZ()));
|
||||
BlockPosition position = connector.getPosition();
|
||||
BlockState objectState = storedBlocks.get(position);
|
||||
String expectedSource = objectState == null ? "minecraft:structure_void" : objectState.key();
|
||||
try {
|
||||
VanillaBlockState expected = VanillaBlockState.parse(expectedSource);
|
||||
@@ -567,7 +569,7 @@ final class VanillaJigsawExportCompiler {
|
||||
if (!pieceEnabled(workcells, pieceEntry.getValue())) {
|
||||
continue;
|
||||
}
|
||||
IrisObject object = graph.getObjects().get(trim(pieceEntry.getValue().getObject()));
|
||||
ObjectContents object = request.source().contents(trim(pieceEntry.getValue().getObject()));
|
||||
byte[] template = encoder.encode(
|
||||
object,
|
||||
pieceEntry.getValue(),
|
||||
@@ -757,10 +759,10 @@ final class VanillaJigsawExportCompiler {
|
||||
return request.namespace() + ":" + request.resourcePath() + "/piece/" + pieceKey;
|
||||
}
|
||||
|
||||
private boolean inside(IrisPosition position, IrisObject object) {
|
||||
return position.getX() >= 0 && position.getX() < object.getW()
|
||||
&& position.getY() >= 0 && position.getY() < object.getH()
|
||||
&& position.getZ() >= 0 && position.getZ() < object.getD();
|
||||
private boolean inside(BlockPosition position, ObjectContents object) {
|
||||
return position.x() >= 0 && position.x() < object.width()
|
||||
&& position.y() >= 0 && position.y() < object.height()
|
||||
&& position.z() >= 0 && position.z() < object.depth();
|
||||
}
|
||||
|
||||
private boolean hasErrors(List<VanillaJigsawExportDiagnostic> diagnostics) {
|
||||
@@ -789,11 +791,6 @@ final class VanillaJigsawExportCompiler {
|
||||
message));
|
||||
}
|
||||
|
||||
private String structureKey(IrisStructure structure) {
|
||||
String key = structure.getLoadKey();
|
||||
return key == null || key.isBlank() ? "<unloaded>" : key;
|
||||
}
|
||||
|
||||
private String trim(String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
|
||||
+26
-12
@@ -1,48 +1,57 @@
|
||||
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.StructureResources;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class VanillaJigsawExportSource {
|
||||
private final String structureKey;
|
||||
private final IrisData data;
|
||||
private final PackResources pack;
|
||||
private final IrisStructure structure;
|
||||
private final StructureGraphResolver resolver;
|
||||
private final Function<String, ObjectContents> objects;
|
||||
|
||||
private VanillaJigsawExportSource(
|
||||
String structureKey,
|
||||
IrisData data,
|
||||
PackResources pack,
|
||||
IrisStructure structure,
|
||||
StructureGraphResolver resolver
|
||||
StructureGraphResolver resolver,
|
||||
Function<String, ObjectContents> objects
|
||||
) {
|
||||
this.structureKey = requireKey(structureKey);
|
||||
this.data = data;
|
||||
this.pack = pack;
|
||||
this.structure = structure;
|
||||
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(
|
||||
structureKey,
|
||||
Objects.requireNonNull(data),
|
||||
pack,
|
||||
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(
|
||||
String structureKey,
|
||||
IrisStructure structure,
|
||||
StructureGraphResolver resolver
|
||||
StructureGraphResolver resolver,
|
||||
Function<String, ObjectContents> objects
|
||||
) {
|
||||
return new VanillaJigsawExportSource(
|
||||
structureKey,
|
||||
null,
|
||||
Objects.requireNonNull(structure),
|
||||
Objects.requireNonNull(resolver));
|
||||
Objects.requireNonNull(resolver),
|
||||
Objects.requireNonNull(objects));
|
||||
}
|
||||
|
||||
public String structureKey() {
|
||||
@@ -53,13 +62,18 @@ public final class VanillaJigsawExportSource {
|
||||
if (structure != null) {
|
||||
return structure;
|
||||
}
|
||||
return StructureResources.structure(data.getPackResources(), structureKey);
|
||||
return StructureResources.structure(pack, structureKey);
|
||||
}
|
||||
|
||||
public StructureGraphResolver 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) {
|
||||
String key = Objects.requireNonNull(value).trim();
|
||||
if (key.isEmpty()) {
|
||||
|
||||
+15
-17
@@ -1,10 +1,8 @@
|
||||
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.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.NamedTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
||||
@@ -29,7 +27,7 @@ final class VanillaStructureTemplateEncoder {
|
||||
.thenComparingInt(entry -> entry.position().z());
|
||||
|
||||
byte[] encode(
|
||||
IrisObject object,
|
||||
ObjectContents object,
|
||||
IrisJigsawPiece piece,
|
||||
Function<String, String> poolIdentifier
|
||||
) throws IOException {
|
||||
@@ -49,7 +47,7 @@ final class VanillaStructureTemplateEncoder {
|
||||
}
|
||||
|
||||
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("blocks", blocks(orderedBlocks, paletteIndexes));
|
||||
root.put("entities", new ListTag<>(CompoundTag.class));
|
||||
@@ -60,9 +58,9 @@ final class VanillaStructureTemplateEncoder {
|
||||
return output.toByteArray();
|
||||
}
|
||||
|
||||
private Map<BlockPosition, BlockEntry> objectBlocks(IrisObject object) {
|
||||
private Map<BlockPosition, BlockEntry> objectBlocks(ObjectContents object) {
|
||||
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());
|
||||
VanillaBlockState state = VanillaBlockState.parse(entry.getValue().key());
|
||||
blocks.put(position, new BlockEntry(position, state, null));
|
||||
@@ -76,9 +74,9 @@ final class VanillaStructureTemplateEncoder {
|
||||
Function<String, String> poolIdentifier
|
||||
) {
|
||||
for (IrisJigsawConnector connector : piece.getConnectors()) {
|
||||
IrisPosition sourcePosition = connector.getPosition();
|
||||
var sourcePosition = connector.getPosition();
|
||||
BlockPosition position = new BlockPosition(
|
||||
sourcePosition.getX(), sourcePosition.getY(), sourcePosition.getZ());
|
||||
sourcePosition.x(), sourcePosition.y(), sourcePosition.z());
|
||||
String orientation = orientation(connector.getDirection(), connector.getTop());
|
||||
VanillaBlockState state = VanillaBlockState.parse(
|
||||
"minecraft:jigsaw[orientation=" + orientation + "]");
|
||||
@@ -100,23 +98,23 @@ final class VanillaStructureTemplateEncoder {
|
||||
return nbt;
|
||||
}
|
||||
|
||||
static String orientation(IrisDirection front, IrisDirection top) {
|
||||
if (front == IrisDirection.UP_POSITIVE_Y || front == IrisDirection.DOWN_NEGATIVE_Y) {
|
||||
if (top == IrisDirection.NORTH_NEGATIVE_Z
|
||||
|| top == IrisDirection.SOUTH_POSITIVE_Z
|
||||
|| top == IrisDirection.EAST_POSITIVE_X
|
||||
|| top == IrisDirection.WEST_NEGATIVE_X) {
|
||||
static String orientation(JigsawDirection front, JigsawDirection top) {
|
||||
if (front == JigsawDirection.UP_POSITIVE_Y || front == JigsawDirection.DOWN_NEGATIVE_Y) {
|
||||
if (top == JigsawDirection.NORTH_NEGATIVE_Z
|
||||
|| top == JigsawDirection.SOUTH_POSITIVE_Z
|
||||
|| top == JigsawDirection.EAST_POSITIVE_X
|
||||
|| top == JigsawDirection.WEST_NEGATIVE_X) {
|
||||
return directionName(front) + "_" + directionName(top);
|
||||
}
|
||||
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");
|
||||
}
|
||||
return directionName(front) + "_up";
|
||||
}
|
||||
|
||||
private static String directionName(IrisDirection direction) {
|
||||
private static String directionName(JigsawDirection direction) {
|
||||
return switch (direction) {
|
||||
case UP_POSITIVE_Y -> "up";
|
||||
case DOWN_NEGATIVE_Y -> "down";
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
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.StructureOwnershipManifest;
|
||||
import art.arcane.iris.core.structure.authoring.StructureTransactionWriter;
|
||||
@@ -82,7 +82,6 @@ final class AdoptionCommands {
|
||||
return;
|
||||
}
|
||||
StudioUse use = begun.get();
|
||||
IrisData data = use.host().dataOf(context.pack());
|
||||
String sourceKey;
|
||||
Optional<StructureKey> targetKey;
|
||||
IrisStructureAdoptionStrategy adoptionStrategy;
|
||||
@@ -91,14 +90,14 @@ final class AdoptionCommands {
|
||||
sourceKey = parseAdoptionSource(context.get(SOURCE));
|
||||
targetKey = parseAdoptionTarget(context.get(TARGET));
|
||||
adoptionStrategy = parseAdoptionStrategy(context.get(STRATEGY));
|
||||
root = canonicalAdoptionRoot(data.getDataFolder().toPath());
|
||||
root = canonicalAdoptionRoot(JigsawStudioRequest.rootOf(context.pack()));
|
||||
} catch (IOException | IllegalArgumentException exception) {
|
||||
use.error("Could not inspect adoption source: " + exception.getMessage());
|
||||
return;
|
||||
}
|
||||
UUID ownerId = use.player().id();
|
||||
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) {
|
||||
@@ -176,7 +175,6 @@ final class AdoptionCommands {
|
||||
private static void runAdoptionInspect(
|
||||
StudioUse use,
|
||||
UUID ownerId,
|
||||
IrisData data,
|
||||
Path root,
|
||||
String sourceKey,
|
||||
Optional<StructureKey> targetKey,
|
||||
@@ -197,13 +195,12 @@ final class AdoptionCommands {
|
||||
failure = 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(
|
||||
StudioUse use,
|
||||
UUID ownerId,
|
||||
IrisData data,
|
||||
IrisStructureAdoptionService service,
|
||||
IrisStructureAdoptionPlan plan,
|
||||
Throwable failure
|
||||
@@ -216,7 +213,7 @@ final class AdoptionCommands {
|
||||
pruneAdoptionPlanBindings();
|
||||
if (service.plan(plan.planId()).isPresent()) {
|
||||
ADOPTION_PLANS.put(plan.planId(), new AdoptionPlanBinding(
|
||||
ownerId, use.pack(), data, service, plan));
|
||||
ownerId, use.pack(), service, plan));
|
||||
}
|
||||
reportAdoptionPlan(use, plan);
|
||||
}
|
||||
@@ -236,7 +233,7 @@ final class AdoptionCommands {
|
||||
return;
|
||||
}
|
||||
StructureKey target = result.receipt().orElseThrow().targetStructure();
|
||||
binding.data().invalidateStructureResources();
|
||||
JigsawStudioRequest.reload(binding.pack());
|
||||
StudioLifecycleCommands.openProject(use.onPack(binding.pack()), target.path());
|
||||
}
|
||||
|
||||
@@ -337,7 +334,6 @@ final class AdoptionCommands {
|
||||
private record AdoptionPlanBinding(
|
||||
UUID ownerId,
|
||||
ToolPack pack,
|
||||
IrisData data,
|
||||
IrisStructureAdoptionService service,
|
||||
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.structure.tooling.GraphMutations.PieceWorkcellResolution;
|
||||
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.object.prefab.IrisObject;
|
||||
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.tooling.Argument;
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
IrisObject object = active.request().source().getObjectLoader().load(activeVariant.objectKey());
|
||||
ObjectFrame object = GraphMutations.objectFrame(active, activeVariant.objectKey());
|
||||
if (object == null) {
|
||||
use.error("The active variant object '" + activeVariant.objectKey() + "' is missing.");
|
||||
return;
|
||||
}
|
||||
IrisPosition canonicalPosition = new IrisPosition(
|
||||
BlockPosition canonicalPosition = new BlockPosition(
|
||||
target.x() - bay.bounds().originX(),
|
||||
target.y() - bay.bounds().originY(),
|
||||
target.z() - bay.bounds().originZ());
|
||||
IrisPosition position;
|
||||
BlockPosition position;
|
||||
try {
|
||||
position = activeVariant.canonicalToSourcePosition(
|
||||
canonicalPosition,
|
||||
new JigsawStudioCellDimensions(object.getW(), object.getH(), object.getD()));
|
||||
new JigsawStudioCellDimensions(object.width(), object.height(), object.depth()));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
use.error("Connector channel update failed: " + exception.getMessage());
|
||||
return;
|
||||
@@ -232,7 +231,7 @@ final class GraphEditCommands {
|
||||
: channel.trim();
|
||||
runGraphMutation(use, active, () -> {
|
||||
JigsawStudioGraphEditor.updateConnectorChannel(
|
||||
active.request().source().getDataFolder().toPath(),
|
||||
active.request().packRoot(),
|
||||
active.request().structureKey(),
|
||||
activeVariant.pieceKey(),
|
||||
position,
|
||||
@@ -242,8 +241,8 @@ final class GraphEditCommands {
|
||||
"",
|
||||
"",
|
||||
"Persisted connector channel '" + normalized + "' on piece '"
|
||||
+ activeVariant.pieceKey() + "' at " + position.getX() + "," + position.getY()
|
||||
+ "," + position.getZ() + ".");
|
||||
+ activeVariant.pieceKey() + "' at " + position.x() + "," + position.y()
|
||||
+ "," + position.z() + ".");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -281,7 +280,7 @@ final class GraphEditCommands {
|
||||
String fallback = NONE.equalsIgnoreCase(fallbackPoolKey) ? "" : fallbackPoolKey;
|
||||
runGraphMutation(use, active, () -> {
|
||||
JigsawStudioGraphEditor.createPool(
|
||||
active.request().source().getDataFolder().toPath(),
|
||||
active.request().packRoot(),
|
||||
active.request().structureKey(),
|
||||
poolKey,
|
||||
fallback);
|
||||
@@ -334,7 +333,7 @@ final class GraphEditCommands {
|
||||
String topologyText = selectedTopology == null ? "blank spatial" : selectedTopology.name();
|
||||
runGraphMutation(use, active, () -> {
|
||||
JigsawStudioGraphEditor.createPiece(
|
||||
active.request().source().getDataFolder().toPath(),
|
||||
active.request().packRoot(),
|
||||
active.request().structureKey(),
|
||||
poolKey,
|
||||
pieceKey,
|
||||
@@ -363,7 +362,7 @@ final class GraphEditCommands {
|
||||
String poolKey = context.get(OWNED_POOL);
|
||||
String pieceKey = context.get(EXISTING_PIECE);
|
||||
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) {
|
||||
use.error("No jigsaw piece '" + pieceKey + "' exists in this pack.");
|
||||
return;
|
||||
@@ -372,7 +371,7 @@ final class GraphEditCommands {
|
||||
use.error("Jigsaw piece '" + pieceKey + "' does not declare an object.");
|
||||
return;
|
||||
}
|
||||
IrisObject object = active.request().source().getObjectLoader().load(piece.getObject());
|
||||
ObjectFrame object = GraphMutations.objectFrame(active, piece.getObject());
|
||||
if (object == null) {
|
||||
use.error("Jigsaw piece '" + pieceKey + "' has no loadable object.");
|
||||
return;
|
||||
@@ -386,10 +385,10 @@ final class GraphEditCommands {
|
||||
return;
|
||||
}
|
||||
if (!resolution.fits()) {
|
||||
IrisPosition required = resolution.requiredDimensions();
|
||||
BlockPosition required = resolution.requiredDimensions();
|
||||
JigsawStudioCellDimensions capacity = resolution.workcell().capacity();
|
||||
use.error("Jigsaw piece '" + pieceKey + "' requires " + required.getX() + "x"
|
||||
+ required.getY() + "x" + required.getZ() + " in " + resolution.workcell().displayName()
|
||||
use.error("Jigsaw piece '" + pieceKey + "' requires " + required.x() + "x"
|
||||
+ required.y() + "x" + required.z() + " in " + resolution.workcell().displayName()
|
||||
+ ", but that workcell capacity is " + capacity.width() + "x" + capacity.height()
|
||||
+ "x" + capacity.depth() + ".");
|
||||
return;
|
||||
@@ -397,7 +396,7 @@ final class GraphEditCommands {
|
||||
String objectKey = piece.getObject();
|
||||
runGraphMutation(use, active, () -> {
|
||||
if (!JigsawStudioGraphEditor.ownsPiece(
|
||||
active.request().source().getDataFolder().toPath(),
|
||||
active.request().packRoot(),
|
||||
active.request().structureKey(),
|
||||
pieceKey,
|
||||
objectKey)) {
|
||||
@@ -405,7 +404,7 @@ final class GraphEditCommands {
|
||||
+ "use piece create for a new owned piece");
|
||||
}
|
||||
JigsawStudioPoolEditor.PoolUpdate update = JigsawStudioPoolEditor.addPiece(
|
||||
active.request().source().getDataFolder().toPath(),
|
||||
active.request().packRoot(),
|
||||
active.request().structureKey(),
|
||||
poolKey,
|
||||
pieceKey,
|
||||
@@ -442,7 +441,7 @@ final class GraphEditCommands {
|
||||
String pieceKey = selected.pieceKey();
|
||||
runGraphMutation(use, active, () -> {
|
||||
JigsawStudioPoolEditor.PoolUpdate update = JigsawStudioPoolEditor.removePiece(
|
||||
active.request().source().getDataFolder().toPath(),
|
||||
active.request().packRoot(),
|
||||
active.request().structureKey(),
|
||||
poolKey,
|
||||
pieceKey);
|
||||
@@ -482,7 +481,7 @@ final class GraphEditCommands {
|
||||
String pieceKey = selected.pieceKey();
|
||||
runGraphMutation(use, active, () -> {
|
||||
JigsawStudioGraphEditor.updateRotatable(
|
||||
active.request().source().getDataFolder().toPath(),
|
||||
active.request().packRoot(),
|
||||
active.request().structureKey(),
|
||||
pieceKey,
|
||||
rotatable);
|
||||
@@ -585,7 +584,7 @@ final class GraphEditCommands {
|
||||
String pieceKey = selected.pieceKey();
|
||||
runGraphMutation(use, active, () -> {
|
||||
JigsawStudioPoolEditor.WeightUpdate update = JigsawStudioPoolEditor.updateWeight(
|
||||
active.request().source().getDataFolder().toPath(),
|
||||
active.request().packRoot(),
|
||||
active.request().structureKey(),
|
||||
poolKey,
|
||||
pieceKey,
|
||||
@@ -727,7 +726,7 @@ final class GraphEditCommands {
|
||||
}
|
||||
runGraphMutation(use, active, () -> {
|
||||
JigsawStudioStructureEditor.updateLimits(
|
||||
active.request().source().getDataFolder().toPath(),
|
||||
active.request().packRoot(),
|
||||
active.request().structureKey(),
|
||||
maxDepth,
|
||||
maxSizeChunks);
|
||||
@@ -755,7 +754,7 @@ final class GraphEditCommands {
|
||||
String fallback = NONE.equalsIgnoreCase(fallbackPoolKey) ? "" : fallbackPoolKey;
|
||||
runGraphMutation(use, active, () -> {
|
||||
JigsawStudioPoolEditor.PoolUpdate update = JigsawStudioPoolEditor.updateFallback(
|
||||
active.request().source().getDataFolder().toPath(),
|
||||
active.request().packRoot(),
|
||||
active.request().structureKey(),
|
||||
poolKey,
|
||||
fallback);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
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.JigsawStudioBay;
|
||||
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.JigsawStudioMode;
|
||||
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.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.StructureResources;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
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.IrisJigsawThemeSet;
|
||||
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.util.HashSet;
|
||||
@@ -58,13 +59,19 @@ final class GraphMutations {
|
||||
}
|
||||
|
||||
static JigsawStudioLayout loadPersistedLayout(ActiveContext context) throws IOException {
|
||||
IrisData source = context.request().source();
|
||||
source.invalidateStructureResources();
|
||||
IrisStructure structure = StructureResources.structure(source.getPackResources(), context.request().structureKey());
|
||||
JigsawStudioRequest request = context.request();
|
||||
request.reloadSource();
|
||||
IrisStructure structure = StructureResources.structure(request.source().resources(), request.structureKey());
|
||||
if (structure == null) {
|
||||
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(
|
||||
@@ -93,23 +100,23 @@ final class GraphMutations {
|
||||
static PieceWorkcellResolution resolvePieceWorkcell(
|
||||
JigsawStudioLayout layout,
|
||||
IrisJigsawPiece piece,
|
||||
IrisObject object
|
||||
ObjectFrame object
|
||||
) {
|
||||
JigsawStudioLayout activeLayout = Objects.requireNonNull(layout, "Jigsaw Studio layout");
|
||||
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;
|
||||
IrisPosition requiredDimensions;
|
||||
BlockPosition requiredDimensions;
|
||||
if (activeLayout.mode() == JigsawStudioMode.PLANAR_JIGSAW) {
|
||||
IrisJigsawWorkcellArchetype modelArchetype = IrisJigsawWorkcellArchetype.fromPiece(activePiece);
|
||||
workcellId = JigsawPlanarArchetype.fromModel(modelArchetype).stableId();
|
||||
requiredDimensions = PlanarJigsawWorkcellResolver.canonicalDimensions(activePiece, activeObject);
|
||||
} else {
|
||||
workcellId = JigsawStudioLayout.SPATIAL_WORKCELL_ID;
|
||||
requiredDimensions = new IrisPosition(
|
||||
activeObject.getW(),
|
||||
activeObject.getH(),
|
||||
activeObject.getD());
|
||||
requiredDimensions = new BlockPosition(
|
||||
activeObject.width(),
|
||||
activeObject.height(),
|
||||
activeObject.depth());
|
||||
}
|
||||
JigsawStudioBay workcell = activeLayout.get(workcellId);
|
||||
if (workcell == null) {
|
||||
@@ -120,7 +127,7 @@ final class GraphMutations {
|
||||
|
||||
static String nextThemeKey(ActiveContext context) throws IOException {
|
||||
IrisStructure structure = StructureResources.structure(
|
||||
context.request().source().getPackResources(),
|
||||
context.request().source().resources(),
|
||||
context.request().structureKey());
|
||||
if (structure == null) {
|
||||
throw new IOException("The active jigsaw structure could not be loaded");
|
||||
@@ -146,7 +153,7 @@ final class GraphMutations {
|
||||
|
||||
record PieceWorkcellResolution(
|
||||
JigsawStudioBay workcell,
|
||||
IrisPosition requiredDimensions
|
||||
BlockPosition requiredDimensions
|
||||
) {
|
||||
PieceWorkcellResolution {
|
||||
workcell = Objects.requireNonNull(workcell, "Jigsaw Studio workcell");
|
||||
@@ -155,9 +162,9 @@ final class GraphMutations {
|
||||
|
||||
boolean fits() {
|
||||
JigsawStudioCellDimensions capacity = workcell.capacity();
|
||||
return requiredDimensions.getX() <= capacity.width()
|
||||
&& requiredDimensions.getY() <= capacity.height()
|
||||
&& requiredDimensions.getZ() <= capacity.depth();
|
||||
return requiredDimensions.x() <= capacity.width()
|
||||
&& requiredDimensions.y() <= capacity.height()
|
||||
&& requiredDimensions.z() <= capacity.depth();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,8 +103,8 @@ final class JigsawExportCommand {
|
||||
VanillaJigsawExportRequest request;
|
||||
try {
|
||||
request = VanillaJigsawExportRequest.builder(
|
||||
VanillaJigsawExportSource.forData(
|
||||
active.request().source(), active.request().structureKey()), destination)
|
||||
VanillaJigsawExportSource.forPack(
|
||||
active.request().source().resources(), active.request().structureKey()), destination)
|
||||
.namespace(context.get(NAMESPACE))
|
||||
.resourcePath(active.request().structureKey())
|
||||
.format(exportFormat)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.core.structure.tooling;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.service.JigsawStudioService;
|
||||
import com.volmit.tooling.Sender;
|
||||
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
|
||||
* 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.
|
||||
*/
|
||||
public interface JigsawStudioHost {
|
||||
/** The studio, which keeps the sessions of its players. */
|
||||
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. */
|
||||
String packKey(ToolPack pack);
|
||||
|
||||
|
||||
+2
-4
@@ -18,7 +18,6 @@
|
||||
|
||||
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.JigsawStudioCellDimensions;
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
IrisData data = host.dataOf(pack);
|
||||
IrisStructure irisStructure = StructureResources.structure(pack.resources(), structure);
|
||||
if (irisStructure == null) {
|
||||
use.error("No Iris jigsaw structure '" + structure + "' exists in this pack.");
|
||||
@@ -304,7 +302,7 @@ final class StudioLifecycleCommands {
|
||||
|
||||
JigsawStudioLayout layout;
|
||||
try {
|
||||
layout = JigsawStudioGraphMapper.map(data, irisStructure);
|
||||
layout = JigsawStudioGraphMapper.map(pack, JigsawStudioRequest.rootOf(pack), structure, irisStructure);
|
||||
} catch (RuntimeException exception) {
|
||||
pack.log().error("Failed to map Jigsaw Studio graph '" + structure + "'.", exception);
|
||||
use.error("Could not map this jigsaw graph: " + exception.getMessage());
|
||||
@@ -341,7 +339,7 @@ final class StudioLifecycleCommands {
|
||||
layout.mode(),
|
||||
compatibilityOf(irisStructure),
|
||||
layout.cellDimensions(),
|
||||
data,
|
||||
pack,
|
||||
layout,
|
||||
playerId,
|
||||
closingRequestId);
|
||||
|
||||
@@ -19,17 +19,16 @@
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
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.StructureResources;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.structure.StructureGraphCatalog;
|
||||
import art.arcane.iris.engine.framework.structure.StructureGraphCompilation;
|
||||
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
||||
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.world.biome.IrisBiome;
|
||||
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.structure.IrisStructure;
|
||||
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
||||
import art.arcane.iris.builtin.structure.StructureCarveShape;
|
||||
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.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.core.modules.IrisModuleHost;
|
||||
import com.volmit.ModuleLog;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -171,7 +170,7 @@ public final class IrisStructureLocator {
|
||||
return false;
|
||||
}
|
||||
for (StructurePlacement placement : index(engine).placements) {
|
||||
if (placement.hasIrisStructures() && matches(placement, key, engine.getData())) {
|
||||
if (placement.hasIrisStructures() && matches(placement, key, engine)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -516,32 +515,33 @@ public final class IrisStructureLocator {
|
||||
if (selectedKey == null || selectedKey.isBlank()) {
|
||||
throw new IllegalStateException("Iris structure placement selected a blank structure key");
|
||||
}
|
||||
IrisStructure structure = StructureResources.structure(engine.getData().getPackResources(), selectedKey);
|
||||
if (structure == null) {
|
||||
PackResources pack = engine.getData().getPackResources();
|
||||
ResourceId structureId = pack.idOf(selectedKey);
|
||||
StructureAssembly provider = providerOf(engine, structureId);
|
||||
if (provider == null) {
|
||||
throw new IllegalStateException("Iris structure placement references missing structure '"
|
||||
+ selectedKey + "'");
|
||||
}
|
||||
StructureGraphCompilation compilation = StructureGraphCatalog.compile(engine.getData(), structure, IrisModuleHost.hostLog());
|
||||
if (!compilation.isAssemblyViable()) {
|
||||
if (!provider.viability(pack, structureId).isViable()) {
|
||||
throw new IllegalStateException("Iris structure '" + selectedKey
|
||||
+ "' has no runtime-viable assembly graph");
|
||||
}
|
||||
|
||||
StructureAssembler assembler = StructureAssembler.forData(
|
||||
engine.getData(), structure, new IrisPosition(originX, baseY, originZ), IrisModuleHost.hostLog());
|
||||
StructureAssemblyResult assembly = assembler.assemble(rng);
|
||||
Assembly assembly = provider.assemble(pack, structureId, new BlockPosition(originX, baseY, originZ), rng)
|
||||
.orElseThrow();
|
||||
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
|
||||
assembly.hasOutput(), "runtime assembly produced " + assembly.status() + ": " + assembly.detail())) {
|
||||
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 = alignSurfacePieces(pieces, placement, structure, baseY);
|
||||
pieces = alignSurfacePieces(pieces, placement, stamp, baseY);
|
||||
if (!requirePlacementOutput(placement, selectedKey, cx, cz,
|
||||
pieces != null && !pieces.isEmpty(), "surface alignment produced no pieces")) {
|
||||
return null;
|
||||
}
|
||||
boolean exactY = hasExactY(placement, structure, pieces);
|
||||
boolean exactY = hasExactY(placement, stamp, pieces);
|
||||
|
||||
int worldMin = engine.getMinHeight() + 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);
|
||||
boolean withinBounds = fitsHorizontalBounds(pieces, originX, originZ, structureRadius)
|
||||
&& (!exactY || fitsVerticalBounds(pieces, worldMin, worldMax));
|
||||
@@ -577,7 +577,29 @@ public final class IrisStructureLocator {
|
||||
"assembled pieces exceed the configured structure or world bounds")) {
|
||||
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,
|
||||
@@ -599,7 +621,7 @@ public final class IrisStructureLocator {
|
||||
+ ". 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[] bounds = computeBounds(pieces);
|
||||
if (bounds == null) {
|
||||
@@ -610,7 +632,6 @@ public final class IrisStructureLocator {
|
||||
}
|
||||
|
||||
private static ResolvedStart resolveInChunk(Engine engine, String key, int cx, int cz) {
|
||||
IrisData data = engine.getData();
|
||||
String normalizedKey = normalize(key);
|
||||
if (hasNativePlacement(engine, key)) {
|
||||
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);
|
||||
for (StructurePlacement placement : placements) {
|
||||
if (!matches(placement, key, data)) {
|
||||
if (!matches(placement, key, engine)) {
|
||||
continue;
|
||||
}
|
||||
if (placement.hasNativeStructures()) {
|
||||
@@ -676,7 +697,7 @@ public final class IrisStructureLocator {
|
||||
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[] bounds = computeBounds(pieces);
|
||||
if (bounds == null) {
|
||||
@@ -701,7 +722,7 @@ public final class IrisStructureLocator {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Integer resolveUndergroundBurialShift(Engine engine, KList<PlacedStructurePiece> pieces,
|
||||
static Integer resolveUndergroundBurialShift(Engine engine, KList<AssembledPiece> pieces,
|
||||
StructurePlacement placement, int baseY,
|
||||
int worldMin, int worldMax) {
|
||||
int[] bounds = computeBounds(pieces);
|
||||
@@ -729,8 +750,7 @@ public final class IrisStructureLocator {
|
||||
return null;
|
||||
}
|
||||
|
||||
Long2IntOpenHashMap surfaceHeights = new Long2IntOpenHashMap();
|
||||
surfaceHeights.defaultReturnValue(Integer.MIN_VALUE);
|
||||
ColumnHeights surfaceHeights = new ColumnHeights(Integer.MIN_VALUE);
|
||||
if (bore || forceCarve && carveShape == StructureCarveShape.BOX) {
|
||||
maximumShift = resolveBurialEnvelopeShift(
|
||||
engine,
|
||||
@@ -746,14 +766,14 @@ public final class IrisStructureLocator {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
for (AssembledPiece piece : pieces) {
|
||||
maximumShift = resolveBurialEnvelopeShift(
|
||||
engine,
|
||||
piece.getMinX() - sideExtension,
|
||||
piece.getMaxX() + sideExtension,
|
||||
piece.getMinZ() - sideExtension,
|
||||
piece.getMaxZ() + sideExtension,
|
||||
piece.getMaxY() + topExtension,
|
||||
piece.minX() - sideExtension,
|
||||
piece.maxX() + sideExtension,
|
||||
piece.minZ() - sideExtension,
|
||||
piece.maxZ() + sideExtension,
|
||||
piece.maxY() + topExtension,
|
||||
maximumShift,
|
||||
surfaceHeights
|
||||
);
|
||||
@@ -767,7 +787,7 @@ public final class IrisStructureLocator {
|
||||
|
||||
private static int resolveBurialEnvelopeShift(Engine engine, int minX, int maxX, int minZ, int maxZ,
|
||||
int envelopeTopY, int maximumShift,
|
||||
Long2IntOpenHashMap surfaceHeights) {
|
||||
ColumnHeights surfaceHeights) {
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
long columnKey = ((long) x << 32) ^ (z & 0xffffffffL);
|
||||
@@ -793,8 +813,8 @@ public final class IrisStructureLocator {
|
||||
return placement.structures().get(rng.nextInt(placement.structures().size()));
|
||||
}
|
||||
|
||||
static KList<PlacedStructurePiece> alignCavePieces(
|
||||
KList<PlacedStructurePiece> pieces,
|
||||
static KList<AssembledPiece> alignCavePieces(
|
||||
KList<AssembledPiece> pieces,
|
||||
StructurePlacement placement,
|
||||
int anchorY
|
||||
) {
|
||||
@@ -815,24 +835,24 @@ public final class IrisStructureLocator {
|
||||
return shiftPieces(pieces, anchorY - targetY);
|
||||
}
|
||||
|
||||
private static KList<PlacedStructurePiece> alignSurfacePieces(KList<PlacedStructurePiece> pieces,
|
||||
private static KList<AssembledPiece> alignSurfacePieces(KList<AssembledPiece> pieces,
|
||||
StructurePlacement placement,
|
||||
IrisStructure structure, int baseY) {
|
||||
StructureStamp stamp, int baseY) {
|
||||
if (placement.isAnchoredUnderground() || pieces.size() <= 1
|
||||
|| structure.getPlaceMode().placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
||||
|| stamp.placeMode().placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
||||
return pieces;
|
||||
}
|
||||
int[] bounds = computeBounds(pieces);
|
||||
return bounds == null ? pieces : shiftPieces(pieces, baseY - bounds[1]);
|
||||
}
|
||||
|
||||
static boolean hasExactY(StructurePlacement placement, IrisStructure structure,
|
||||
KList<PlacedStructurePiece> pieces) {
|
||||
static boolean hasExactY(StructurePlacement placement, StructureStamp stamp,
|
||||
KList<AssembledPiece> pieces) {
|
||||
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);
|
||||
return bounds != null && fitsVerticalBounds(bounds, worldMin, worldMax);
|
||||
}
|
||||
@@ -841,7 +861,7 @@ public final class IrisStructureLocator {
|
||||
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[] bounds = computeBounds(pieces);
|
||||
return bounds != null && fitsHorizontalBounds(bounds, originX, originZ, structureRadius);
|
||||
@@ -852,18 +872,15 @@ public final class IrisStructureLocator {
|
||||
&& bounds[2] >= originZ - structureRadius && bounds[5] <= originZ + structureRadius;
|
||||
}
|
||||
|
||||
private static KList<PlacedStructurePiece> shiftPieces(KList<PlacedStructurePiece> pieces, int shiftY) {
|
||||
KList<PlacedStructurePiece> shifted = new KList<>();
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
shifted.add(new PlacedStructurePiece(
|
||||
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()));
|
||||
private static KList<AssembledPiece> shiftPieces(KList<AssembledPiece> pieces, int shiftY) {
|
||||
KList<AssembledPiece> shifted = new KList<>();
|
||||
for (AssembledPiece piece : pieces) {
|
||||
shifted.add(piece.shiftedUp(shiftY));
|
||||
}
|
||||
return shifted;
|
||||
}
|
||||
|
||||
private static int[] computeBounds(KList<PlacedStructurePiece> pieces) {
|
||||
private static int[] computeBounds(KList<AssembledPiece> pieces) {
|
||||
if (pieces == null || pieces.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -873,13 +890,13 @@ public final class IrisStructureLocator {
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
int maxZ = Integer.MIN_VALUE;
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
minX = Math.min(minX, piece.getMinX());
|
||||
minY = Math.min(minY, piece.getMinY());
|
||||
minZ = Math.min(minZ, piece.getMinZ());
|
||||
maxX = Math.max(maxX, piece.getMaxX());
|
||||
maxY = Math.max(maxY, piece.getMaxY());
|
||||
maxZ = Math.max(maxZ, piece.getMaxZ());
|
||||
for (AssembledPiece piece : pieces) {
|
||||
minX = Math.min(minX, piece.minX());
|
||||
minY = Math.min(minY, piece.minY());
|
||||
minZ = Math.min(minZ, piece.minZ());
|
||||
maxX = Math.max(maxX, piece.maxX());
|
||||
maxY = Math.max(maxY, piece.maxY());
|
||||
maxZ = Math.max(maxZ, piece.maxZ());
|
||||
}
|
||||
return new int[]{minX, minY, minZ, maxX, maxY, maxZ};
|
||||
}
|
||||
@@ -897,7 +914,7 @@ public final class IrisStructureLocator {
|
||||
boolean hasDensity = false;
|
||||
for (StructurePlacement placement : index(engine).placements) {
|
||||
if (!isSearchablePlacement(engine, placement)
|
||||
|| !matches(placement, key, engine.getData())) {
|
||||
|| !matches(placement, key, engine)) {
|
||||
continue;
|
||||
}
|
||||
if (placement.distribution() == StructureDistribution.RANDOM_SPREAD) {
|
||||
@@ -1016,8 +1033,8 @@ public final class IrisStructureLocator {
|
||||
private record PlacementAnchor(int x, int y, int z) {
|
||||
}
|
||||
|
||||
private static boolean matches(StructurePlacement placement, String key, IrisData data) {
|
||||
if (placement == null || key == null || data == null) {
|
||||
private static boolean matches(StructurePlacement placement, String key, Engine engine) {
|
||||
if (placement == null || key == null || engine == null || engine.getData() == null) {
|
||||
return false;
|
||||
}
|
||||
String normalizedKey = normalize(key);
|
||||
@@ -1030,13 +1047,12 @@ public final class IrisStructureLocator {
|
||||
if (structureKey == null || structureKey.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey);
|
||||
if (structure == null) {
|
||||
StructureStamp stamp = stampOf(engine, structureKey);
|
||||
if (stamp == null) {
|
||||
continue;
|
||||
}
|
||||
if (normalize(structureKey).equals(normalizedKey)
|
||||
|| normalize(structure.getLoadKey()).equals(normalizedKey)
|
||||
|| normalize(structure.getVanillaSource()).equals(normalizedKey)) {
|
||||
|| normalize(stamp.vanillaSource()).equals(normalizedKey)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1046,8 +1062,7 @@ public final class IrisStructureLocator {
|
||||
static boolean matchesResolved(ResolvedPlacement resolved, String key) {
|
||||
String normalizedKey = normalize(key);
|
||||
return normalize(resolved.structureKey()).equals(normalizedKey)
|
||||
|| normalize(resolved.structure().getLoadKey()).equals(normalizedKey)
|
||||
|| normalize(resolved.structure().getVanillaSource()).equals(normalizedKey);
|
||||
|| normalize(resolved.stamp().vanillaSource()).equals(normalizedKey);
|
||||
}
|
||||
|
||||
private static String normalize(String key) {
|
||||
@@ -1072,7 +1087,6 @@ public final class IrisStructureLocator {
|
||||
}
|
||||
|
||||
private static LocatableIndex buildLocatableIndex(Engine engine) {
|
||||
IrisData data = engine.getData();
|
||||
Set<String> keys = new LinkedHashSet<>();
|
||||
Set<String> normalizedKeys = new LinkedHashSet<>();
|
||||
Set<String> editableKeys = new LinkedHashSet<>();
|
||||
@@ -1091,17 +1105,15 @@ public final class IrisStructureLocator {
|
||||
continue;
|
||||
}
|
||||
for (String structureKey : placement.structures()) {
|
||||
IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey);
|
||||
if (structure == null) {
|
||||
StructureStamp stamp = stampOf(engine, structureKey);
|
||||
if (stamp == null) {
|
||||
throw new IllegalStateException(
|
||||
"Iris structure placement references missing structure '" + structureKey + "'");
|
||||
}
|
||||
addLocatableKey(structureKey, keys, normalizedKeys);
|
||||
addLocatableKey(structureKey, editableKeys, normalizedEditableKeys);
|
||||
addLocatableKey(structure.getLoadKey(), keys, normalizedKeys);
|
||||
addLocatableKey(structure.getLoadKey(), editableKeys, normalizedEditableKeys);
|
||||
addLocatableKey(structure.getVanillaSource(), keys, normalizedKeys);
|
||||
addLocatableKey(structure.getVanillaSource(), editableKeys, normalizedEditableKeys);
|
||||
addLocatableKey(stamp.vanillaSource(), keys, normalizedKeys);
|
||||
addLocatableKey(stamp.vanillaSource(), editableKeys, normalizedEditableKeys);
|
||||
}
|
||||
}
|
||||
return new LocatableIndex(
|
||||
@@ -1123,19 +1135,17 @@ public final class IrisStructureLocator {
|
||||
}
|
||||
|
||||
private static PlacementIndex build(Engine engine) {
|
||||
IrisData data = engine.getData();
|
||||
ModuleLog log = IrisModuleHost.hostLog();
|
||||
Set<String> loadKeys = new LinkedHashSet<>();
|
||||
Set<String> normalizedLoadKeys = new LinkedHashSet<>();
|
||||
Set<String> vanillaAliases = new LinkedHashSet<>();
|
||||
Set<String> suppressedVanillaSources = new LinkedHashSet<>();
|
||||
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);
|
||||
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
|
||||
if (regions != null) {
|
||||
for (IrisRegion region : regions) {
|
||||
collect(StructurePlacementScope.placementsOf(region), data, log,
|
||||
collect(StructurePlacementScope.placementsOf(region), engine,
|
||||
loadKeys, normalizedLoadKeys, vanillaAliases,
|
||||
suppressedVanillaSources, placements, false);
|
||||
}
|
||||
@@ -1143,7 +1153,7 @@ public final class IrisStructureLocator {
|
||||
KList<IrisBiome> biomes = engine.getDimension().getReachableBiomes(engine);
|
||||
if (biomes != null) {
|
||||
for (IrisBiome biome : biomes) {
|
||||
collect(StructurePlacementScope.placementsOf(biome), data, log,
|
||||
collect(StructurePlacementScope.placementsOf(biome), engine,
|
||||
loadKeys, normalizedLoadKeys, vanillaAliases,
|
||||
suppressedVanillaSources, placements, false);
|
||||
}
|
||||
@@ -1172,7 +1182,7 @@ public final class IrisStructureLocator {
|
||||
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> suppressedVanillaSources,
|
||||
List<StructurePlacement> placements, boolean allowNativeSuppression) {
|
||||
@@ -1209,8 +1219,8 @@ public final class IrisStructureLocator {
|
||||
? "REPLACE_SOURCE contains a blank Iris structure reference"
|
||||
: "Iris structure placement contains a blank structure reference");
|
||||
}
|
||||
IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey);
|
||||
if (structure == null) {
|
||||
StructureStamp stamp = stampOf(engine, structureKey);
|
||||
if (stamp == null) {
|
||||
throw new IllegalStateException((replacesNative
|
||||
? "REPLACE_SOURCE references missing Iris structure '"
|
||||
: "Iris structure placement references missing structure '")
|
||||
@@ -1218,20 +1228,18 @@ public final class IrisStructureLocator {
|
||||
}
|
||||
loadKeys.add(structureKey);
|
||||
normalizedLoadKeys.add(normalize(structureKey));
|
||||
if (structure.getLoadKey() != null && !structure.getLoadKey().isBlank()) {
|
||||
loadKeys.add(structure.getLoadKey());
|
||||
normalizedLoadKeys.add(normalize(structure.getLoadKey()));
|
||||
}
|
||||
if (structure.getVanillaSource() != null && !structure.getVanillaSource().isBlank()) {
|
||||
vanillaAliases.add(normalize(structure.getVanillaSource()));
|
||||
if (!stamp.vanillaSource().isBlank()) {
|
||||
vanillaAliases.add(normalize(stamp.vanillaSource()));
|
||||
}
|
||||
if (replacesNative) {
|
||||
String vanillaSource = structure.getVanillaSource();
|
||||
if (vanillaSource == null || !NAMESPACED_RESOURCE_KEY.matcher(vanillaSource).matches()) {
|
||||
String vanillaSource = stamp.vanillaSource();
|
||||
if (!NAMESPACED_RESOURCE_KEY.matcher(vanillaSource).matches()) {
|
||||
throw new IllegalStateException("REPLACE_SOURCE structure '" + structureKey
|
||||
+ "' 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
|
||||
+ "' 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,
|
||||
KList<PlacedStructurePiece> pieces, RNG rng,
|
||||
public record ResolvedPlacement(StructurePlacement placement, String structureKey, StructureStamp stamp,
|
||||
KList<AssembledPiece> pieces, RNG rng,
|
||||
int originX, int baseY, int originZ, boolean exactY) {
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
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.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -28,11 +28,14 @@ import lombok.Data;
|
||||
@AllArgsConstructor
|
||||
public class PlacedStructurePiece {
|
||||
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 y;
|
||||
private final int z;
|
||||
private final ObjectTurn rotation;
|
||||
private final PieceTurn rotation;
|
||||
private final int minX;
|
||||
private final int minY;
|
||||
private final int minZ;
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
|
||||
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.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.PlanarJigsawWorkcellResolver;
|
||||
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.StructureGraphDiagnostic;
|
||||
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.IrisJigsawConnector;
|
||||
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.IrisJigsawPool;
|
||||
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.jigsaw.JigsawJoint;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.resource.PackResources;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -79,9 +79,9 @@ public final class StructureAssembler {
|
||||
this.resolver = options.resolver();
|
||||
this.graph = options.graph();
|
||||
this.structure = options.structure();
|
||||
this.originX = options.origin().getX();
|
||||
this.originY = options.origin().getY();
|
||||
this.originZ = options.origin().getZ();
|
||||
this.originX = options.origin().x();
|
||||
this.originY = options.origin().y();
|
||||
this.originZ = options.origin().z();
|
||||
this.planarWorkcells = this.structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW
|
||||
? PlanarJigsawWorkcellResolver.resolve(this.structure)
|
||||
: Map.of();
|
||||
@@ -90,23 +90,25 @@ public final class StructureAssembler {
|
||||
? this.structure.getMaxSizeChunks() * 16 : 0;
|
||||
}
|
||||
|
||||
public static StructureAssembler forData(IrisData data, IrisStructure structure, IrisPosition origin, ModuleLog log) {
|
||||
IrisData activeData = Objects.requireNonNull(data, "Structure assembly data must not be null");
|
||||
/** An assembler of {@code structure}, the pack's structure {@code structureKey}, from {@code origin}. */
|
||||
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(
|
||||
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,
|
||||
IrisPosition origin) {
|
||||
public static StructureAssembler forResolver(String structureKey, StructureGraphResolver resolver, IrisStructure structure,
|
||||
BlockPosition origin) {
|
||||
StructureGraphResolver activeResolver = Objects.requireNonNull(
|
||||
resolver, "Structure assembly resolver must not be null");
|
||||
IrisStructure activeStructure = Objects.requireNonNull(
|
||||
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(
|
||||
compilation, "Structure graph compilation must not be null");
|
||||
if (activeCompilation.hasErrors()) {
|
||||
@@ -120,17 +122,17 @@ public final class StructureAssembler {
|
||||
public StructureAssemblyResult assemble(RNG rng) {
|
||||
Objects.requireNonNull(rng, "Structure assembly RNG must not be null");
|
||||
if (radius == 0) {
|
||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
||||
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||
+ "' has maxSizeChunks outside 1.." + MAX_SIZE_CHUNKS);
|
||||
}
|
||||
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);
|
||||
}
|
||||
String startPoolKey = normalize(structure.getStartPool());
|
||||
IrisJigsawPool startPool = resolver.loadPool(startPoolKey);
|
||||
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 + "'");
|
||||
}
|
||||
|
||||
@@ -160,7 +162,7 @@ public final class StructureAssembler {
|
||||
}
|
||||
IrisJigsawPieceEntry startEntry = weightedPick(startEntries, rng);
|
||||
if (startEntry == null) {
|
||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
||||
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||
+ "' start pool has no positively weighted entry");
|
||||
}
|
||||
if (startEntry.isEmpty()) {
|
||||
@@ -171,23 +173,23 @@ public final class StructureAssembler {
|
||||
String startPieceKey = normalize(startEntry.getPiece());
|
||||
IrisJigsawPiece startPiece = resolver.loadPiece(startPieceKey);
|
||||
if (startPiece == null) {
|
||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
||||
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||
+ "' start pool references missing piece '" + startPieceKey + "'");
|
||||
}
|
||||
String startObjectKey = normalize(startPiece.getObject());
|
||||
IrisObject startObject = resolver.loadObject(startObjectKey);
|
||||
ObjectFrame startObject = resolver.loadObject(startObjectKey);
|
||||
if (startObject == null) {
|
||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
||||
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||
+ "' start piece references missing object '" + startObjectKey + "'");
|
||||
}
|
||||
if (startPiece.getConnectors() == null) {
|
||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
||||
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||
+ "' start piece has no connector list");
|
||||
}
|
||||
|
||||
int startRotY = startPiece.isRotatable() ? Y_DEGREES[rng.i(Y_DEGREES.length)] : 0;
|
||||
ObjectTurn startRot = ObjectTurn.of(0, startRotY, 0);
|
||||
PlacedStructurePiece start = build(startPiece, startObject, originX, originY, originZ, startRot);
|
||||
PieceTurn startRot = PieceTurn.aroundY(startRotY);
|
||||
PlacedStructurePiece start = build(startPiece, startObjectKey, startObject, originX, originY, originZ, startRot);
|
||||
placed.add(start);
|
||||
registerPlacedPiece(consumedConnectors, start, null);
|
||||
incrementPlacement(placementCounts, startPieceKey);
|
||||
@@ -216,7 +218,7 @@ public final class StructureAssembler {
|
||||
|
||||
IrisJigsawPool pool = resolver.loadPool(connector.pool);
|
||||
if (pool == null) {
|
||||
throw new IllegalStateException("Structure '" + structure.getLoadKey()
|
||||
throw new IllegalStateException("Structure '" + graph.getStructureKey()
|
||||
+ "' references missing connector pool '" + connector.pool + "'");
|
||||
}
|
||||
|
||||
@@ -380,7 +382,7 @@ public final class StructureAssembler {
|
||||
if (objectKey.isEmpty()) {
|
||||
throw assemblyFailure("piece '" + pieceName + "' has no object key");
|
||||
}
|
||||
IrisObject object = resolver.loadObject(objectKey);
|
||||
ObjectFrame object = resolver.loadObject(objectKey);
|
||||
if (object == null) {
|
||||
throw assemblyFailure("piece '" + pieceName + "' references missing object '"
|
||||
+ objectKey + "'");
|
||||
@@ -404,27 +406,27 @@ public final class StructureAssembler {
|
||||
continue;
|
||||
}
|
||||
|
||||
IrisDirection needed = connector.facing.reverse();
|
||||
JigsawDirection needed = connector.facing.reverse();
|
||||
int[] rotations = piece.isRotatable() ? rotationCandidates(connector.joint, rng) : NO_ROTATION;
|
||||
for (int yDeg : rotations) {
|
||||
ObjectTurn rot = ObjectTurn.of(0, yDeg, 0);
|
||||
IrisDirection rotatedFace = rot.rotate(cb.getDirection());
|
||||
PieceTurn rot = PieceTurn.aroundY(yDeg);
|
||||
JigsawDirection rotatedFace = rotate(rot, cb.getDirection());
|
||||
if (rotatedFace != needed) {
|
||||
continue;
|
||||
}
|
||||
if (connector.joint == JigsawJoint.ALIGNED && rot.rotate(cb.getTop()) != connector.top) {
|
||||
if (connector.joint == JigsawJoint.ALIGNED && rotate(rot, cb.getTop()) != connector.top) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IrisPosition rcr = connectorOffset(object, cb, rot);
|
||||
BlockPosition rcr = connectorOffset(object, cb, rot);
|
||||
int wcx = connector.wx + connector.facing.x();
|
||||
int wcy = connector.wy + connector.facing.y();
|
||||
int wcz = connector.wz + connector.facing.z();
|
||||
int px = wcx - rcr.getX();
|
||||
int py = wcy - rcr.getY();
|
||||
int pz = wcz - rcr.getZ();
|
||||
int px = wcx - rcr.x();
|
||||
int py = wcy - rcr.y();
|
||||
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)) {
|
||||
continue;
|
||||
}
|
||||
@@ -527,7 +529,7 @@ public final class StructureAssembler {
|
||||
|| isMatched(matchedExisting, existingPiece, existingConnector)) {
|
||||
continue;
|
||||
}
|
||||
IrisPosition target = connectorTarget(existingPiece, existingConnector);
|
||||
BlockPosition target = connectorTarget(existingPiece, existingConnector);
|
||||
if (!contains(candidatePiece, target)) {
|
||||
continue;
|
||||
}
|
||||
@@ -556,7 +558,7 @@ public final class StructureAssembler {
|
||||
|| normalize(candidateConnector.getPool()).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
IrisPosition target = connectorTarget(candidatePiece, candidateConnector);
|
||||
BlockPosition target = connectorTarget(candidatePiece, candidateConnector);
|
||||
PlacedStructurePiece occupied = containingPiece(placed, target);
|
||||
if (occupied == null) {
|
||||
continue;
|
||||
@@ -706,7 +708,8 @@ public final class StructureAssembler {
|
||||
if (piece == null || piece.getConnectors() == null) {
|
||||
continue;
|
||||
}
|
||||
IrisObject object = resolver.loadObject(normalize(piece.getObject()));
|
||||
String objectKey = normalize(piece.getObject());
|
||||
ObjectFrame object = resolver.loadObject(objectKey);
|
||||
if (object == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -717,18 +720,19 @@ public final class StructureAssembler {
|
||||
}
|
||||
int[] rotations = piece.isRotatable() ? Y_DEGREES : NO_ROTATION;
|
||||
for (int yDegrees : rotations) {
|
||||
ObjectTurn rotation = ObjectTurn.of(0, yDegrees, 0);
|
||||
if (rotation.rotate(connector.getDirection()) != source.facing().reverse()
|
||||
PieceTurn rotation = PieceTurn.aroundY(yDegrees);
|
||||
if (rotate(rotation, connector.getDirection()) != source.facing().reverse()
|
||||
|| source.joint() == JigsawJoint.ALIGNED
|
||||
&& rotation.rotate(connector.getTop()) != source.top()) {
|
||||
&& rotate(rotation, connector.getTop()) != source.top()) {
|
||||
continue;
|
||||
}
|
||||
IrisPosition offset = connectorOffset(object, connector, rotation);
|
||||
int logicalX = source.wx() + source.facing().x() - offset.getX();
|
||||
int logicalY = source.wy() + source.facing().y() - offset.getY();
|
||||
int logicalZ = source.wz() + source.facing().z() - offset.getZ();
|
||||
BlockPosition offset = connectorOffset(object, connector, rotation);
|
||||
int logicalX = source.wx() + source.facing().x() - offset.x();
|
||||
int logicalY = source.wy() + source.facing().y() - offset.y();
|
||||
int logicalZ = source.wz() + source.facing().z() - offset.z();
|
||||
PlacedStructurePiece reservation = build(
|
||||
piece,
|
||||
objectKey,
|
||||
object,
|
||||
logicalX,
|
||||
logicalY,
|
||||
@@ -749,49 +753,49 @@ public final class StructureAssembler {
|
||||
PlacedStructurePiece targetPiece,
|
||||
Set<IrisJigsawConnector> unavailable
|
||||
) {
|
||||
IrisPosition target = connectorTarget(sourcePiece, sourceConnector);
|
||||
IrisDirection sourceFacing = sourcePiece.getRotation().rotate(sourceConnector.getDirection());
|
||||
IrisDirection sourceTop = sourcePiece.getRotation().rotate(sourceConnector.getTop());
|
||||
BlockPosition target = connectorTarget(sourcePiece, sourceConnector);
|
||||
JigsawDirection sourceFacing = rotate(sourcePiece.getRotation(), sourceConnector.getDirection());
|
||||
JigsawDirection sourceTop = rotate(sourcePiece.getRotation(), sourceConnector.getTop());
|
||||
for (IrisJigsawConnector candidate : targetPiece.getPiece().getConnectors()) {
|
||||
if (unavailable.contains(candidate)
|
||||
|| !Objects.equals(sourceConnector.getChannel(), candidate.getChannel())
|
||||
|| !Objects.equals(sourceConnector.getTargetName(), candidate.getName())) {
|
||||
continue;
|
||||
}
|
||||
IrisPosition candidatePosition = connectorPosition(targetPiece, candidate);
|
||||
BlockPosition candidatePosition = connectorPosition(targetPiece, candidate);
|
||||
if (!target.equals(candidatePosition)
|
||||
|| targetPiece.getRotation().rotate(candidate.getDirection()) != sourceFacing.reverse()) {
|
||||
|| rotate(targetPiece.getRotation(), candidate.getDirection()) != sourceFacing.reverse()) {
|
||||
continue;
|
||||
}
|
||||
if (sourceConnector.getJoint() != JigsawJoint.ALIGNED
|
||||
|| targetPiece.getRotation().rotate(candidate.getTop()) == sourceTop) {
|
||||
|| rotate(targetPiece.getRotation(), candidate.getTop()) == sourceTop) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private IrisPosition connectorPosition(PlacedStructurePiece piece, IrisJigsawConnector connector) {
|
||||
IrisPosition center = logicalCenter(piece);
|
||||
IrisPosition offset = connectorOffset(piece.getObject(), connector, piece.getRotation());
|
||||
return new IrisPosition(
|
||||
center.getX() + offset.getX(),
|
||||
center.getY() + offset.getY(),
|
||||
center.getZ() + offset.getZ());
|
||||
private BlockPosition connectorPosition(PlacedStructurePiece piece, IrisJigsawConnector connector) {
|
||||
BlockPosition center = logicalCenter(piece);
|
||||
BlockPosition offset = connectorOffset(piece.getObject(), connector, piece.getRotation());
|
||||
return new BlockPosition(
|
||||
center.x() + offset.x(),
|
||||
center.y() + offset.y(),
|
||||
center.z() + offset.z());
|
||||
}
|
||||
|
||||
private IrisPosition connectorTarget(PlacedStructurePiece piece, IrisJigsawConnector connector) {
|
||||
IrisPosition position = connectorPosition(piece, connector);
|
||||
IrisDirection facing = piece.getRotation().rotate(connector.getDirection());
|
||||
return new IrisPosition(
|
||||
position.getX() + facing.x(),
|
||||
position.getY() + facing.y(),
|
||||
position.getZ() + facing.z());
|
||||
private BlockPosition connectorTarget(PlacedStructurePiece piece, IrisJigsawConnector connector) {
|
||||
BlockPosition position = connectorPosition(piece, connector);
|
||||
JigsawDirection facing = rotate(piece.getRotation(), connector.getDirection());
|
||||
return new BlockPosition(
|
||||
position.x() + facing.x(),
|
||||
position.y() + facing.y(),
|
||||
position.z() + facing.z());
|
||||
}
|
||||
|
||||
private PlacedStructurePiece containingPiece(
|
||||
KList<PlacedStructurePiece> pieces,
|
||||
IrisPosition position
|
||||
BlockPosition position
|
||||
) {
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
if (contains(piece, position)) {
|
||||
@@ -801,10 +805,10 @@ public final class StructureAssembler {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean contains(PlacedStructurePiece piece, IrisPosition position) {
|
||||
return position.getX() >= piece.getMinX() && position.getX() <= piece.getMaxX()
|
||||
&& position.getY() >= piece.getMinY() && position.getY() <= piece.getMaxY()
|
||||
&& position.getZ() >= piece.getMinZ() && position.getZ() <= piece.getMaxZ();
|
||||
private boolean contains(PlacedStructurePiece piece, BlockPosition position) {
|
||||
return position.x() >= piece.getMinX() && position.x() <= piece.getMaxX()
|
||||
&& position.y() >= piece.getMinY() && position.y() <= piece.getMaxY()
|
||||
&& position.z() >= piece.getMinZ() && position.z() <= piece.getMaxZ();
|
||||
}
|
||||
|
||||
private boolean isMatched(
|
||||
@@ -824,24 +828,24 @@ public final class StructureAssembler {
|
||||
int targetY,
|
||||
int targetZ
|
||||
) {
|
||||
requireConnector(candidate, candidatePiece.getObject().getLoadKey());
|
||||
requireConnector(candidate, candidatePiece.getObjectKey());
|
||||
if (!Objects.equals(source.channel(), candidate.getChannel())
|
||||
|| !Objects.equals(source.targetName(), candidate.getName())) {
|
||||
return false;
|
||||
}
|
||||
IrisPosition rotated = connectorOffset(
|
||||
BlockPosition rotated = connectorOffset(
|
||||
candidatePiece.getObject(), candidate, candidatePiece.getRotation());
|
||||
IrisPosition center = logicalCenter(candidatePiece);
|
||||
if (center.getX() + rotated.getX() != targetX
|
||||
|| center.getY() + rotated.getY() != targetY
|
||||
|| center.getZ() + rotated.getZ() != targetZ) {
|
||||
BlockPosition center = logicalCenter(candidatePiece);
|
||||
if (center.x() + rotated.x() != targetX
|
||||
|| center.y() + rotated.y() != targetY
|
||||
|| center.z() + rotated.z() != targetZ) {
|
||||
return false;
|
||||
}
|
||||
if (candidatePiece.getRotation().rotate(candidate.getDirection()) != source.facing().reverse()) {
|
||||
if (rotate(candidatePiece.getRotation(), candidate.getDirection()) != source.facing().reverse()) {
|
||||
return false;
|
||||
}
|
||||
return source.joint() != JigsawJoint.ALIGNED
|
||||
|| candidatePiece.getRotation().rotate(candidate.getTop()) == source.top();
|
||||
|| rotate(candidatePiece.getRotation(), candidate.getTop()) == source.top();
|
||||
}
|
||||
|
||||
private void registerPlacedPiece(
|
||||
@@ -890,15 +894,15 @@ public final class StructureAssembler {
|
||||
Deque<PieceExpansion> pending,
|
||||
Map<PlacedStructurePiece, Map<IrisJigsawConnector, OpenConnector>> openConnectors,
|
||||
PlacedStructurePiece p,
|
||||
IrisObject object, int depth, int pieceDepth, IrisJigsawConnector skip,
|
||||
ObjectFrame object, int depth, int pieceDepth, IrisJigsawConnector skip,
|
||||
int placementPriority) {
|
||||
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<>();
|
||||
Map<IrisJigsawConnector, OpenConnector> definitions = new IdentityHashMap<>();
|
||||
for (IrisJigsawConnector con : orderedConnectors(p.getPiece().getConnectors(), skip)) {
|
||||
requireConnector(con, object.getLoadKey());
|
||||
requireConnector(con, p.getObjectKey());
|
||||
if (con.getPool() == null || con.getPool().isBlank()) {
|
||||
continue;
|
||||
}
|
||||
@@ -914,21 +918,21 @@ public final class StructureAssembler {
|
||||
|
||||
private OpenConnector openConnector(
|
||||
PlacedStructurePiece piece,
|
||||
IrisObject object,
|
||||
ObjectFrame object,
|
||||
IrisJigsawConnector connector,
|
||||
int depth,
|
||||
int pieceDepth
|
||||
) {
|
||||
IrisPosition offset = connectorOffset(object, connector, piece.getRotation());
|
||||
IrisPosition center = logicalCenter(piece);
|
||||
BlockPosition offset = connectorOffset(object, connector, piece.getRotation());
|
||||
BlockPosition center = logicalCenter(piece);
|
||||
return new OpenConnector(
|
||||
piece,
|
||||
connector,
|
||||
center.getX() + offset.getX(),
|
||||
center.getY() + offset.getY(),
|
||||
center.getZ() + offset.getZ(),
|
||||
piece.getRotation().rotate(connector.getDirection()),
|
||||
piece.getRotation().rotate(connector.getTop()),
|
||||
center.x() + offset.x(),
|
||||
center.y() + offset.y(),
|
||||
center.z() + offset.z(),
|
||||
rotate(piece.getRotation(), connector.getDirection()),
|
||||
rotate(piece.getRotation(), connector.getTop()),
|
||||
normalize(connector.getPool()),
|
||||
connector.getName(),
|
||||
connector.getTargetName(),
|
||||
@@ -968,29 +972,30 @@ public final class StructureAssembler {
|
||||
throw assemblyFailure("piece expansion queue was unexpectedly empty");
|
||||
}
|
||||
|
||||
private PlacedStructurePiece build(IrisJigsawPiece piece, IrisObject object, int x, int y, int z, ObjectTurn rot) {
|
||||
int width = Math.max(1, object.getW());
|
||||
int height = Math.max(1, object.getH());
|
||||
int depth = Math.max(1, object.getD());
|
||||
private PlacedStructurePiece build(IrisJigsawPiece piece, String objectKey, ObjectFrame object, int x, int y, int z, PieceTurn rot) {
|
||||
int width = Math.max(1, object.width());
|
||||
int height = Math.max(1, object.height());
|
||||
int depth = Math.max(1, object.depth());
|
||||
if (structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW) {
|
||||
IrisPosition dimensions = rotatedDimensions(object, rot);
|
||||
IrisPosition offset = planarPlacementOffset(object, rot);
|
||||
int minX = x - dimensions.getX() / 2;
|
||||
int minY = y - dimensions.getY() / 2;
|
||||
int minZ = z - dimensions.getZ() / 2;
|
||||
BlockPosition dimensions = rotatedDimensions(object, rot);
|
||||
BlockPosition offset = planarPlacementOffset(object, rot);
|
||||
int minX = x - dimensions.x() / 2;
|
||||
int minY = y - dimensions.y() / 2;
|
||||
int minZ = z - dimensions.z() / 2;
|
||||
return new PlacedStructurePiece(
|
||||
piece,
|
||||
objectKey,
|
||||
object,
|
||||
x + offset.getX(),
|
||||
y + offset.getY(),
|
||||
z + offset.getZ(),
|
||||
x + offset.x(),
|
||||
y + offset.y(),
|
||||
z + offset.z(),
|
||||
rot,
|
||||
minX,
|
||||
minY,
|
||||
minZ,
|
||||
minX + dimensions.getX() - 1,
|
||||
minY + dimensions.getY() - 1,
|
||||
minZ + dimensions.getZ() - 1);
|
||||
minX + dimensions.x() - 1,
|
||||
minY + dimensions.y() - 1,
|
||||
minZ + dimensions.z() - 1);
|
||||
}
|
||||
int localMinX = -(width / 2);
|
||||
int localMinY = -(height / 2);
|
||||
@@ -998,15 +1003,15 @@ public final class StructureAssembler {
|
||||
int localMaxX = localMinX + width - 1;
|
||||
int localMaxY = localMinY + height - 1;
|
||||
int localMaxZ = localMinZ + depth - 1;
|
||||
IrisPosition rotatedMin = rot.rotate(new IrisPosition(localMinX, localMinY, localMinZ));
|
||||
IrisPosition rotatedMax = rot.rotate(new IrisPosition(localMaxX, localMaxY, localMaxZ));
|
||||
int minX = Math.min(rotatedMin.getX(), rotatedMax.getX());
|
||||
int minY = Math.min(rotatedMin.getY(), rotatedMax.getY());
|
||||
int minZ = Math.min(rotatedMin.getZ(), rotatedMax.getZ());
|
||||
int maxX = Math.max(rotatedMin.getX(), rotatedMax.getX());
|
||||
int maxY = Math.max(rotatedMin.getY(), rotatedMax.getY());
|
||||
int maxZ = Math.max(rotatedMin.getZ(), rotatedMax.getZ());
|
||||
return new PlacedStructurePiece(piece, object, x, y, z, rot,
|
||||
BlockPosition rotatedMin = rot.rotate(new BlockPosition(localMinX, localMinY, localMinZ));
|
||||
BlockPosition rotatedMax = rot.rotate(new BlockPosition(localMaxX, localMaxY, localMaxZ));
|
||||
int minX = Math.min(rotatedMin.x(), rotatedMax.x());
|
||||
int minY = Math.min(rotatedMin.y(), rotatedMax.y());
|
||||
int minZ = Math.min(rotatedMin.z(), rotatedMax.z());
|
||||
int maxX = Math.max(rotatedMin.x(), rotatedMax.x());
|
||||
int maxY = Math.max(rotatedMin.y(), rotatedMax.y());
|
||||
int maxZ = Math.max(rotatedMin.z(), rotatedMax.z());
|
||||
return new PlacedStructurePiece(piece, objectKey, object, x, y, z, rot,
|
||||
x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ);
|
||||
}
|
||||
|
||||
@@ -1041,70 +1046,74 @@ public final class StructureAssembler {
|
||||
return shuffled;
|
||||
}
|
||||
|
||||
private IrisPosition centerOf(IrisObject object) {
|
||||
return new IrisPosition(object.getW() / 2, object.getH() / 2, object.getD() / 2);
|
||||
private BlockPosition centerOf(ObjectFrame object) {
|
||||
return object.center();
|
||||
}
|
||||
|
||||
private IrisPosition connectorOffset(
|
||||
IrisObject object,
|
||||
private BlockPosition connectorOffset(
|
||||
ObjectFrame object,
|
||||
IrisJigsawConnector connector,
|
||||
ObjectTurn rotation
|
||||
PieceTurn rotation
|
||||
) {
|
||||
if (structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW) {
|
||||
IrisPosition dimensions = rotatedDimensions(object, rotation);
|
||||
IrisPosition position = IrisJigsawConnector.canonicalPlanarPosition(
|
||||
BlockPosition dimensions = rotatedDimensions(object, rotation);
|
||||
BlockPosition position = IrisJigsawConnector.canonicalPlanarPosition(
|
||||
dimensions,
|
||||
rotation.rotate(connector.getDirection()));
|
||||
return new IrisPosition(
|
||||
position.getX() - dimensions.getX() / 2,
|
||||
position.getY() - dimensions.getY() / 2,
|
||||
position.getZ() - dimensions.getZ() / 2);
|
||||
rotate(rotation, connector.getDirection()));
|
||||
return new BlockPosition(
|
||||
position.x() - dimensions.x() / 2,
|
||||
position.y() - dimensions.y() / 2,
|
||||
position.z() - dimensions.z() / 2);
|
||||
}
|
||||
IrisPosition center = centerOf(object);
|
||||
IrisPosition relative = new IrisPosition(
|
||||
connector.getPosition().getX() - center.getX(),
|
||||
connector.getPosition().getY() - center.getY(),
|
||||
connector.getPosition().getZ() - center.getZ());
|
||||
BlockPosition center = centerOf(object);
|
||||
BlockPosition relative = new BlockPosition(
|
||||
connector.getPosition().x() - center.x(),
|
||||
connector.getPosition().y() - center.y(),
|
||||
connector.getPosition().z() - center.z());
|
||||
return rotation.rotate(relative);
|
||||
}
|
||||
|
||||
private IrisPosition logicalCenter(PlacedStructurePiece piece) {
|
||||
private BlockPosition logicalCenter(PlacedStructurePiece piece) {
|
||||
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());
|
||||
return new IrisPosition(
|
||||
piece.getX() - offset.getX(),
|
||||
piece.getY() - offset.getY(),
|
||||
piece.getZ() - offset.getZ());
|
||||
BlockPosition offset = planarPlacementOffset(piece.getObject(), piece.getRotation());
|
||||
return new BlockPosition(
|
||||
piece.getX() - offset.x(),
|
||||
piece.getY() - offset.y(),
|
||||
piece.getZ() - offset.z());
|
||||
}
|
||||
|
||||
private IrisPosition rotatedDimensions(IrisObject object, ObjectTurn rotation) {
|
||||
int width = Math.max(1, object.getW());
|
||||
int height = Math.max(1, object.getH());
|
||||
int depth = Math.max(1, object.getD());
|
||||
private BlockPosition rotatedDimensions(ObjectFrame object, PieceTurn rotation) {
|
||||
int width = Math.max(1, object.width());
|
||||
int height = Math.max(1, object.height());
|
||||
int depth = Math.max(1, object.depth());
|
||||
return quarterTurns(rotation) % 2 == 0
|
||||
? new IrisPosition(width, height, depth)
|
||||
: new IrisPosition(depth, height, width);
|
||||
? new BlockPosition(width, height, depth)
|
||||
: new BlockPosition(depth, height, width);
|
||||
}
|
||||
|
||||
private IrisPosition planarPlacementOffset(IrisObject object, ObjectTurn rotation) {
|
||||
int width = Math.max(1, object.getW());
|
||||
int depth = Math.max(1, object.getD());
|
||||
private BlockPosition planarPlacementOffset(ObjectFrame object, PieceTurn rotation) {
|
||||
int width = Math.max(1, object.width());
|
||||
int depth = Math.max(1, object.depth());
|
||||
return switch (quarterTurns(rotation)) {
|
||||
case 0 -> new IrisPosition();
|
||||
case 1 -> new IrisPosition(0, 0, width % 2 == 0 ? -1 : 0);
|
||||
case 2 -> new IrisPosition(
|
||||
case 0 -> new BlockPosition(0, 0, 0);
|
||||
case 1 -> new BlockPosition(0, 0, width % 2 == 0 ? -1 : 0);
|
||||
case 2 -> new BlockPosition(
|
||||
width % 2 == 0 ? -1 : 0,
|
||||
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");
|
||||
};
|
||||
}
|
||||
|
||||
private int quarterTurns(ObjectTurn rotation) {
|
||||
return switch (rotation.rotate(IrisDirection.NORTH_NEGATIVE_Z)) {
|
||||
private static JigsawDirection rotate(PieceTurn turn, JigsawDirection direction) {
|
||||
return direction.turnedBy(turn.quarterTurns());
|
||||
}
|
||||
|
||||
private int quarterTurns(PieceTurn rotation) {
|
||||
return switch (rotate(rotation, JigsawDirection.NORTH_NEGATIVE_Z)) {
|
||||
case NORTH_NEGATIVE_Z -> 0;
|
||||
case WEST_NEGATIVE_X -> 1;
|
||||
case SOUTH_POSITIVE_Z -> 2;
|
||||
@@ -1280,7 +1289,7 @@ public final class StructureAssembler {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -1300,7 +1309,7 @@ public final class StructureAssembler {
|
||||
}
|
||||
|
||||
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 targetName, String channel, JigsawJoint joint, int depth,
|
||||
int pieceDepth, int placementPriority) {
|
||||
@@ -1347,7 +1356,7 @@ public final class StructureAssembler {
|
||||
|
||||
private record AssemblyOptions(StructureGraphResolver resolver, CompiledStructureGraph graph,
|
||||
IrisStructure structure,
|
||||
IrisPosition origin) {
|
||||
BlockPosition origin) {
|
||||
private AssemblyOptions {
|
||||
Objects.requireNonNull(resolver, "Structure assembly resolver 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.IrisJigsawPool;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -13,14 +12,18 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public final class CompiledStructureGraph {
|
||||
private static final String UNKEYED = "<unloaded>";
|
||||
|
||||
private final String structureKey;
|
||||
private final IrisStructure structure;
|
||||
private final Map<String, IrisJigsawPool> pools;
|
||||
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> reachablePieces;
|
||||
|
||||
private CompiledStructureGraph(Builder builder) {
|
||||
structureKey = builder.structureKey;
|
||||
structure = builder.structure;
|
||||
pools = Collections.unmodifiableMap(new LinkedHashMap<>(builder.pools));
|
||||
pieces = Collections.unmodifiableMap(new LinkedHashMap<>(builder.pieces));
|
||||
@@ -29,17 +32,17 @@ public final class CompiledStructureGraph {
|
||||
reachablePieces = Collections.unmodifiableSet(new LinkedHashSet<>(builder.reachablePieces));
|
||||
}
|
||||
|
||||
static Builder builder(IrisStructure structure) {
|
||||
return new Builder(structure);
|
||||
static Builder builder(String structureKey, IrisStructure structure) {
|
||||
return new Builder(structureKey, structure);
|
||||
}
|
||||
|
||||
public IrisStructure getStructure() {
|
||||
return structure;
|
||||
}
|
||||
|
||||
/** The pack key of the structure, or a placeholder when the graph was compiled for a structure without one. */
|
||||
public String getStructureKey() {
|
||||
String key = structure.getLoadKey();
|
||||
return key == null || key.isBlank() ? "<unloaded>" : key;
|
||||
return structureKey == null || structureKey.isBlank() ? UNKEYED : structureKey;
|
||||
}
|
||||
|
||||
public Map<String, IrisJigsawPool> getPools() {
|
||||
@@ -50,7 +53,7 @@ public final class CompiledStructureGraph {
|
||||
return pieces;
|
||||
}
|
||||
|
||||
public Map<String, IrisObject> getObjects() {
|
||||
public Map<String, ObjectFrame> getObjects() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
@@ -63,14 +66,16 @@ public final class CompiledStructureGraph {
|
||||
}
|
||||
|
||||
static final class Builder {
|
||||
private final String structureKey;
|
||||
private final IrisStructure structure;
|
||||
private final Map<String, IrisJigsawPool> pools = 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> reachablePieces = new LinkedHashSet<>();
|
||||
|
||||
private Builder(IrisStructure structure) {
|
||||
private Builder(String structureKey, IrisStructure structure) {
|
||||
this.structureKey = structureKey;
|
||||
this.structure = Objects.requireNonNull(structure);
|
||||
}
|
||||
|
||||
@@ -82,7 +87,7 @@ public final class CompiledStructureGraph {
|
||||
return pieces;
|
||||
}
|
||||
|
||||
Map<String, IrisObject> objects() {
|
||||
Map<String, ObjectFrame> objects() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -1,6 +1,5 @@
|
||||
package art.arcane.iris.engine.framework.structure;
|
||||
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
@@ -23,7 +22,7 @@ public final class 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()
|
||||
? "<unknown>" : resourceName;
|
||||
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);
|
||||
DataInputStream input = new DataInputStream(bytes);
|
||||
int width = input.readInt();
|
||||
@@ -88,7 +87,7 @@ public final class IrisObjectFrameReader {
|
||||
}
|
||||
int tileStart = content.length - bytes.available();
|
||||
requireCompleteTileFraming(content, tileStart, tileCount, width, height, depth, resourceName);
|
||||
return new IrisObject(width, height, depth);
|
||||
return new ObjectFrame(width, height, depth);
|
||||
}
|
||||
|
||||
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.ObjectPlaceMode;
|
||||
import art.arcane.iris.core.pack.PackValidationIo;
|
||||
import art.arcane.volmlib.util.json.JSONArray;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.volmit.validation.Problem;
|
||||
@@ -77,14 +76,14 @@ public final class NativeReplacementValidation {
|
||||
if (!resourceFolder.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
List<File> resourceFiles = PackValidationIo.listJsonRecursive(resourceFolder);
|
||||
List<File> resourceFiles = PackJsonFiles.listRecursive(resourceFolder);
|
||||
resourceFiles.sort(Comparator.comparing(File::getPath));
|
||||
for (File resourceFile : resourceFiles) {
|
||||
JSONObject resource = PackValidationIo.readJson(resourceFile);
|
||||
JSONObject resource = PackJsonFiles.read(resourceFile);
|
||||
if (resource == null) {
|
||||
continue;
|
||||
}
|
||||
String resourceKey = PackValidationIo.deriveKey(resourceFolder, resourceFile);
|
||||
String resourceKey = PackJsonFiles.keyOf(resourceFolder, resourceFile);
|
||||
Subject file = Subject.file(folderName + "/" + resourceKey + JSON_EXTENSION);
|
||||
for (String error : validateResource(folderName, resourceKey, resource, structures, viableStructures, verticalEnvelopes)) {
|
||||
problems.add(Problem.error(file, error));
|
||||
@@ -97,10 +96,10 @@ public final class NativeReplacementValidation {
|
||||
private static Map<String, JSONObject> readStructures(File packFolder) {
|
||||
File structuresFolder = new File(packFolder, StructureResources.STRUCTURES.folder());
|
||||
Map<String, JSONObject> structures = new HashMap<>();
|
||||
for (File structureFile : PackValidationIo.listJsonRecursive(structuresFolder)) {
|
||||
JSONObject structure = PackValidationIo.readJson(structureFile);
|
||||
for (File structureFile : PackJsonFiles.listRecursive(structuresFolder)) {
|
||||
JSONObject structure = PackJsonFiles.read(structureFile);
|
||||
if (structure != null) {
|
||||
structures.put(PackValidationIo.deriveKey(structuresFolder, structureFile), structure);
|
||||
structures.put(PackJsonFiles.keyOf(structuresFolder, structureFile), structure);
|
||||
}
|
||||
}
|
||||
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.IrisJigsawWorkcell;
|
||||
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 com.volmit.geometry.BlockPosition;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
@@ -27,16 +26,16 @@ public final class PlanarJigsawWorkcellResolver {
|
||||
EnumMap<IrisJigsawWorkcellArchetype, ResolvedWorkcell> resolved =
|
||||
new EnumMap<>(IrisJigsawWorkcellArchetype.class);
|
||||
if (source.getPlanarWorkcells() == null || source.getPlanarWorkcells().isEmpty()) {
|
||||
IrisPosition fallback = source.getCellSize() == null
|
||||
? new IrisPosition(DEFAULT_SIZE, DEFAULT_SIZE, DEFAULT_SIZE)
|
||||
BlockPosition fallback = source.getCellSize() == null
|
||||
? new BlockPosition(DEFAULT_SIZE, DEFAULT_SIZE, DEFAULT_SIZE)
|
||||
: source.getCellSize();
|
||||
for (IrisJigsawWorkcellArchetype archetype : IrisJigsawWorkcellArchetype.values()) {
|
||||
ResolvedWorkcell workcell = new ResolvedWorkcell(
|
||||
archetype,
|
||||
"",
|
||||
fallback.getX(),
|
||||
fallback.getY(),
|
||||
fallback.getZ(),
|
||||
fallback.x(),
|
||||
fallback.y(),
|
||||
fallback.z(),
|
||||
true);
|
||||
validate(workcell);
|
||||
resolved.put(archetype, workcell);
|
||||
@@ -86,14 +85,14 @@ public final class PlanarJigsawWorkcellResolver {
|
||||
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");
|
||||
IrisObject sourceObject = Objects.requireNonNull(object, "Planar jigsaw object");
|
||||
ObjectFrame sourceObject = Objects.requireNonNull(object, "Planar jigsaw object");
|
||||
IrisJigsawWorkcellArchetype archetype = IrisJigsawWorkcellArchetype.fromPiece(sourcePiece);
|
||||
int quarterTurns = archetype.sourceToCanonicalQuarterTurns(sourcePiece);
|
||||
return Math.floorMod(quarterTurns, 2) == 0
|
||||
? new IrisPosition(sourceObject.getW(), sourceObject.getH(), sourceObject.getD())
|
||||
: new IrisPosition(sourceObject.getD(), sourceObject.getH(), sourceObject.getW());
|
||||
? new BlockPosition(sourceObject.width(), sourceObject.height(), sourceObject.depth())
|
||||
: new BlockPosition(sourceObject.depth(), sourceObject.height(), sourceObject.width());
|
||||
}
|
||||
|
||||
public record ResolvedWorkcell(
|
||||
@@ -109,13 +108,13 @@ public final class PlanarJigsawWorkcellResolver {
|
||||
displayName = normalizeDisplayName(displayName);
|
||||
}
|
||||
|
||||
public IrisPosition dimensions() {
|
||||
return new IrisPosition(width, height, depth);
|
||||
public BlockPosition dimensions() {
|
||||
return new BlockPosition(width, height, depth);
|
||||
}
|
||||
|
||||
public boolean contains(IrisPosition dimensions) {
|
||||
IrisPosition size = Objects.requireNonNull(dimensions, "Planar jigsaw object dimensions");
|
||||
return size.getX() <= width && size.getY() <= height && size.getZ() <= depth;
|
||||
public boolean contains(BlockPosition dimensions) {
|
||||
BlockPosition size = Objects.requireNonNull(dimensions, "Planar jigsaw object dimensions");
|
||||
return size.x() <= width && size.y() <= height && size.z() <= depth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+33
-35
@@ -1,70 +1,69 @@
|
||||
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.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
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.geometry.BlockPosition;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
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
|
||||
* 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 {
|
||||
private static final Cache<IrisPackResources, ConcurrentMap<String, StructureGraphCompilation>> CACHE =
|
||||
Caffeine.newBuilder().weakKeys().build();
|
||||
private static final Cache<IrisPackResources, ConcurrentMap<String, Boolean>> RUNTIME_OUTPUT =
|
||||
Caffeine.newBuilder().weakKeys().build();
|
||||
private static final Map<PackResources, ConcurrentMap<String, StructureGraphCompilation>> CACHE =
|
||||
Collections.synchronizedMap(new WeakHashMap<>());
|
||||
private static final Map<PackResources, ConcurrentMap<String, Boolean>> RUNTIME_OUTPUT =
|
||||
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(
|
||||
0L, 1L, 2L, 3L, 5L, 8L, 13L, 21L, 34L, 55L, 89L, 144L, 233L, 377L, 610L, 987L);
|
||||
|
||||
private StructureGraphCatalog() {
|
||||
}
|
||||
|
||||
public static StructureGraphCompilation compile(IrisData data, IrisStructure structure, ModuleLog log) {
|
||||
IrisData activeData = Objects.requireNonNull(data);
|
||||
/** The compilation of {@code structure}, the pack's structure {@code structureKey} (blank for one that is not in the pack, which is not kept). */
|
||||
public static StructureGraphCompilation compile(PackResources pack, String structureKey, IrisStructure structure, ModuleLog log) {
|
||||
PackResources activePack = Objects.requireNonNull(pack);
|
||||
IrisStructure activeStructure = Objects.requireNonNull(structure);
|
||||
String structureKey = activeStructure.getLoadKey();
|
||||
if (structureKey == null || structureKey.isBlank()) {
|
||||
return compileAndReport(activeData, activeStructure, log);
|
||||
return compileAndReport(activePack, structureKey, activeStructure, log);
|
||||
}
|
||||
ConcurrentMap<String, StructureGraphCompilation> catalog = CACHE.get(
|
||||
activeData.getPackResources(), ignored -> new ConcurrentHashMap<>());
|
||||
return catalog.computeIfAbsent(structureKey, ignored -> compileAndReport(activeData, activeStructure, log));
|
||||
ConcurrentMap<String, StructureGraphCompilation> catalog = CACHE.computeIfAbsent(
|
||||
activePack, ignored -> new ConcurrentHashMap<>());
|
||||
return catalog.computeIfAbsent(structureKey, ignored -> compileAndReport(activePack, structureKey, activeStructure, log));
|
||||
}
|
||||
|
||||
public static boolean guaranteesRuntimeOutput(IrisData data, IrisStructure structure, ModuleLog log) {
|
||||
IrisData activeData = Objects.requireNonNull(data);
|
||||
public static boolean guaranteesRuntimeOutput(PackResources pack, String structureKey, IrisStructure structure, ModuleLog log) {
|
||||
PackResources activePack = Objects.requireNonNull(pack);
|
||||
IrisStructure activeStructure = Objects.requireNonNull(structure);
|
||||
if (!compile(activeData, activeStructure, log).guaranteesAssemblyOutput()) {
|
||||
if (!compile(activePack, structureKey, activeStructure, log).guaranteesAssemblyOutput()) {
|
||||
return false;
|
||||
}
|
||||
String structureKey = activeStructure.getLoadKey();
|
||||
if (structureKey == null || structureKey.isBlank()) {
|
||||
return sampleRuntimeAssembly(activeData, activeStructure, log);
|
||||
return sampleRuntimeAssembly(activePack, structureKey, activeStructure, log);
|
||||
}
|
||||
ConcurrentMap<String, Boolean> catalog = RUNTIME_OUTPUT.get(
|
||||
activeData.getPackResources(), ignored -> new ConcurrentHashMap<>());
|
||||
ConcurrentMap<String, Boolean> catalog = RUNTIME_OUTPUT.computeIfAbsent(
|
||||
activePack, ignored -> new ConcurrentHashMap<>());
|
||||
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(
|
||||
structure, StructureGraphResolver.forData(data));
|
||||
String structureKey = structure.getLoadKey() == null || structure.getLoadKey().isBlank()
|
||||
? "<unkeyed>" : structure.getLoadKey();
|
||||
structureKey, structure, StructureGraphResolver.forPack(pack));
|
||||
String reportedKey = structureKey == null || structureKey.isBlank() ? "<unkeyed>" : structureKey;
|
||||
for (StructureGraphDiagnostic diagnostic : compilation.getDiagnostics()) {
|
||||
String message = "[StructureGraph:" + structureKey + "] " + diagnostic.message();
|
||||
String message = "[StructureGraph:" + reportedKey + "] " + diagnostic.message();
|
||||
if (diagnostic.severity() == StructureGraphDiagnostic.Severity.ERROR) {
|
||||
log.error(message, null);
|
||||
} else {
|
||||
@@ -72,17 +71,16 @@ public final class StructureGraphCatalog {
|
||||
}
|
||||
}
|
||||
if (!compilation.isAssemblyViable()) {
|
||||
log.error("[StructureGraph:" + structureKey
|
||||
log.error("[StructureGraph:" + reportedKey
|
||||
+ "] Graph rejected because deterministic assembly did not complete.", null);
|
||||
}
|
||||
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) {
|
||||
try {
|
||||
StructureAssembler assembler = StructureAssembler.forData(
|
||||
data, structure, new IrisPosition(0, 64, 0), log);
|
||||
StructureAssembler assembler = StructureAssembler.forPack(pack, structureKey, structure, SAMPLE_ORIGIN, log);
|
||||
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
||||
if (!result.hasOutput()) {
|
||||
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.IrisJigsawPool;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -96,7 +95,7 @@ public final class StructureGraphCompilation {
|
||||
if (piece == null || !JigsawPoolSelection.pieceEligible(piece, theme, 0, 0)) {
|
||||
continue;
|
||||
}
|
||||
IrisObject object = graph.getObjects().get(normalize(piece.getObject()));
|
||||
ObjectFrame object = graph.getObjects().get(normalize(piece.getObject()));
|
||||
if (object == null || !fitsStartRadius(object)) {
|
||||
return false;
|
||||
}
|
||||
@@ -185,9 +184,9 @@ public final class StructureGraphCompilation {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean fitsStartRadius(IrisObject object) {
|
||||
private boolean fitsStartRadius(ObjectFrame object) {
|
||||
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() {
|
||||
|
||||
+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.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.IrisJigsawCompatibility;
|
||||
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.IrisJigsawThemeSet;
|
||||
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.jigsaw.JigsawJoint;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
@@ -44,9 +43,10 @@ public final class 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(
|
||||
Objects.requireNonNull(structure), Objects.requireNonNull(resolver));
|
||||
structureKey, Objects.requireNonNull(structure), Objects.requireNonNull(resolver));
|
||||
state.loadClosure();
|
||||
state.detectFallbackCycles();
|
||||
state.analyzeReachability();
|
||||
@@ -66,6 +66,7 @@ public final class StructureGraphCompiler {
|
||||
}
|
||||
|
||||
private static final class CompilationState {
|
||||
private final String structureKey;
|
||||
private final IrisStructure structure;
|
||||
private final StructureGraphResolver resolver;
|
||||
private final CompiledStructureGraph.Builder graph;
|
||||
@@ -89,10 +90,11 @@ public final class StructureGraphCompiler {
|
||||
private Map<IrisJigsawWorkcellArchetype, PlanarJigsawWorkcellResolver.ResolvedWorkcell>
|
||||
planarWorkcells = Map.of();
|
||||
|
||||
private CompilationState(IrisStructure structure, StructureGraphResolver resolver) {
|
||||
private CompilationState(String structureKey, IrisStructure structure, StructureGraphResolver resolver) {
|
||||
this.structureKey = structureKey;
|
||||
this.structure = structure;
|
||||
this.resolver = resolver;
|
||||
this.graph = CompiledStructureGraph.builder(structure);
|
||||
this.graph = CompiledStructureGraph.builder(structureKey, structure);
|
||||
}
|
||||
|
||||
private void loadClosure() {
|
||||
@@ -145,7 +147,7 @@ public final class StructureGraphCompiler {
|
||||
}
|
||||
|
||||
private void validateThemes() {
|
||||
KList<IrisJigsawThemeSet> themeSets = structure.getThemeSets();
|
||||
List<IrisJigsawThemeSet> themeSets = structure.getThemeSets();
|
||||
if (themeSets == null) {
|
||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_THEME,
|
||||
"Structure '" + structureKey() + "' declares a null themeSets list.",
|
||||
@@ -235,7 +237,7 @@ public final class StructureGraphCompiler {
|
||||
graph.pools().put(key, pool);
|
||||
List<PoolEntryReference> entries = new ArrayList<>();
|
||||
poolEntries.put(key, entries);
|
||||
KList<IrisJigsawPieceEntry> configuredEntries = pool.getPieces();
|
||||
List<IrisJigsawPieceEntry> configuredEntries = pool.getPieces();
|
||||
if (configuredEntries == null || configuredEntries.isEmpty()) {
|
||||
if (key.equals(normalize(structure.getStartPool()))) {
|
||||
addDiagnostic(StructureGraphDiagnostic.Code.EMPTY_START_POOL,
|
||||
@@ -339,13 +341,13 @@ public final class StructureGraphCompiler {
|
||||
}
|
||||
|
||||
graph.pieces().put(key, piece);
|
||||
IrisObject object = loadPieceObject(key, piece);
|
||||
ObjectFrame object = loadPieceObject(key, piece);
|
||||
validatePieceMetadata(key, piece);
|
||||
scanConnectors(key, piece, object);
|
||||
}
|
||||
|
||||
private void validatePieceMetadata(String pieceKey, IrisJigsawPiece piece) {
|
||||
KList<String> themes = piece.getThemes();
|
||||
List<String> themes = piece.getThemes();
|
||||
if (themes == null) {
|
||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_THEME,
|
||||
"Jigsaw piece '" + pieceKey + "' declares a null themes list.",
|
||||
@@ -419,7 +421,7 @@ public final class StructureGraphCompiler {
|
||||
&& !rules.isTerminal();
|
||||
}
|
||||
|
||||
private IrisObject loadPieceObject(String pieceKey, IrisJigsawPiece piece) {
|
||||
private ObjectFrame loadPieceObject(String pieceKey, IrisJigsawPiece piece) {
|
||||
String objectKey = normalize(piece.getObject());
|
||||
pieceObjects.put(pieceKey, objectKey);
|
||||
if (objectKey.isEmpty()) {
|
||||
@@ -438,7 +440,7 @@ public final class StructureGraphCompiler {
|
||||
return graph.objects().get(objectKey);
|
||||
}
|
||||
|
||||
IrisObject object = resolver.loadObject(objectKey);
|
||||
ObjectFrame object = resolver.loadObject(objectKey);
|
||||
if (object == null) {
|
||||
missingObjects.add(objectKey);
|
||||
addDiagnostic(StructureGraphDiagnostic.Code.MISSING_OBJECT,
|
||||
@@ -447,20 +449,20 @@ public final class StructureGraphCompiler {
|
||||
return null;
|
||||
}
|
||||
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,
|
||||
"Object '" + objectKey + "' used by jigsaw piece '" + pieceKey
|
||||
+ "' has invalid dimensions " + object.getW() + "x" + object.getH() + "x"
|
||||
+ object.getD() + ".",
|
||||
+ "' has invalid dimensions " + object.width() + "x" + object.height() + "x"
|
||||
+ object.depth() + ".",
|
||||
"object-bounds:" + objectKey);
|
||||
}
|
||||
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<>();
|
||||
pieceConnectors.put(pieceKey, references);
|
||||
KList<IrisJigsawConnector> connectors = piece.getConnectors();
|
||||
List<IrisJigsawConnector> connectors = piece.getConnectors();
|
||||
if (connectors == null) {
|
||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_CONNECTOR,
|
||||
"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,
|
||||
IrisObject object, boolean validDirection, boolean validTop,
|
||||
ObjectFrame object, boolean validDirection, boolean validTop,
|
||||
boolean validPosition) {
|
||||
if (structure.resolvedMode() != IrisJigsawMode.PLANAR_JIGSAW) {
|
||||
return true;
|
||||
@@ -568,7 +570,7 @@ public final class StructureGraphCompiler {
|
||||
"connector:planar-direction:" + pieceKey + ":" + index);
|
||||
valid = false;
|
||||
}
|
||||
if (validTop && connector.getTop() != IrisDirection.UP_POSITIVE_Y) {
|
||||
if (validTop && connector.getTop() != JigsawDirection.UP_POSITIVE_Y) {
|
||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_PLANAR_CONNECTOR,
|
||||
"Jigsaw piece '" + pieceKey + "' connectors[" + index + "] has top "
|
||||
+ connector.getTop().name()
|
||||
@@ -582,8 +584,8 @@ public final class StructureGraphCompiler {
|
||||
|| object == null || !validPosition) {
|
||||
return valid;
|
||||
}
|
||||
IrisPosition objectSize = new IrisPosition(object.getW(), object.getH(), object.getD());
|
||||
IrisPosition expected = IrisJigsawConnector.canonicalPlanarPosition(
|
||||
BlockPosition objectSize = new BlockPosition(object.width(), object.height(), object.depth());
|
||||
BlockPosition expected = IrisJigsawConnector.canonicalPlanarPosition(
|
||||
objectSize, connector.getDirection());
|
||||
if (!expected.equals(connector.getPosition())) {
|
||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_PLANAR_CONNECTOR,
|
||||
@@ -596,7 +598,7 @@ public final class StructureGraphCompiler {
|
||||
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) {
|
||||
return "Jigsaw piece '" + pieceKey + "' connectors[" + index
|
||||
+ "] does not declare a position.";
|
||||
@@ -606,17 +608,17 @@ public final class StructureGraphCompiler {
|
||||
+ "] position " + position + " cannot be checked because its object is missing.";
|
||||
}
|
||||
return "Jigsaw piece '" + pieceKey + "' connectors[" + index + "] position " + position
|
||||
+ " is outside object bounds 0.." + (object.getW() - 1) + ", 0.." + (object.getH() - 1)
|
||||
+ ", 0.." + (object.getD() - 1) + ".";
|
||||
+ " is outside object bounds 0.." + (object.width() - 1) + ", 0.." + (object.height() - 1)
|
||||
+ ", 0.." + (object.depth() - 1) + ".";
|
||||
}
|
||||
|
||||
private boolean isValidPosition(IrisPosition position, IrisObject object) {
|
||||
private boolean isValidPosition(BlockPosition position, ObjectFrame object) {
|
||||
if (position == null || object == null) {
|
||||
return false;
|
||||
}
|
||||
return position.getX() >= 0 && position.getX() < object.getW()
|
||||
&& position.getY() >= 0 && position.getY() < object.getH()
|
||||
&& position.getZ() >= 0 && position.getZ() < object.getD();
|
||||
return position.x() >= 0 && position.x() < object.width()
|
||||
&& position.y() >= 0 && position.y() < object.height()
|
||||
&& position.z() >= 0 && position.z() < object.depth();
|
||||
}
|
||||
|
||||
private void detectFallbackCycles() {
|
||||
@@ -785,21 +787,21 @@ public final class StructureGraphCompiler {
|
||||
for (String pieceKey : graph.reachablePieces()) {
|
||||
IrisJigsawPiece piece = graph.pieces().get(pieceKey);
|
||||
String objectKey = pieceObjects.get(pieceKey);
|
||||
IrisObject object = graph.objects().get(objectKey);
|
||||
ObjectFrame object = graph.objects().get(objectKey);
|
||||
if (piece == null || object == null) {
|
||||
continue;
|
||||
}
|
||||
PlanarJigsawWorkcellResolver.ResolvedWorkcell workcell =
|
||||
PlanarJigsawWorkcellResolver.workcell(planarWorkcells, piece);
|
||||
IrisPosition dimensions = PlanarJigsawWorkcellResolver.canonicalDimensions(piece, object);
|
||||
BlockPosition dimensions = PlanarJigsawWorkcellResolver.canonicalDimensions(piece, object);
|
||||
if (workcell.contains(dimensions)) {
|
||||
continue;
|
||||
}
|
||||
addDiagnostic(StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE,
|
||||
"Object '" + objectKey + "' used by reachable planar piece '" + pieceKey
|
||||
+ "' is " + object.getW() + "x" + object.getH() + "x" + object.getD()
|
||||
+ " and canonically occupies " + dimensions.getX() + "x" + dimensions.getY()
|
||||
+ "x" + dimensions.getZ() + "; it does not fit " + workcell.archetype()
|
||||
+ "' is " + object.width() + "x" + object.height() + "x" + object.depth()
|
||||
+ " and canonically occupies " + dimensions.x() + "x" + dimensions.y()
|
||||
+ "x" + dimensions.z() + "; it does not fit " + workcell.archetype()
|
||||
+ " workcell " + workcell.width() + "x" + workcell.height() + "x"
|
||||
+ workcell.depth() + ".",
|
||||
"object:planar-size:" + pieceKey);
|
||||
@@ -985,9 +987,9 @@ public final class StructureGraphCompiler {
|
||||
return false;
|
||||
}
|
||||
|
||||
IrisDirection sourceDirection = rotateDirection(
|
||||
JigsawDirection sourceDirection = rotateDirection(
|
||||
sourceConnector.getDirection(), source.rotation());
|
||||
IrisDirection candidateDirection = rotateDirection(
|
||||
JigsawDirection candidateDirection = rotateDirection(
|
||||
candidateConnector.getDirection(), candidateRotation);
|
||||
if (candidateDirection != sourceDirection.reverse()) {
|
||||
return false;
|
||||
@@ -995,8 +997,8 @@ public final class StructureGraphCompiler {
|
||||
if (sourceConnector.getJoint() != JigsawJoint.ALIGNED) {
|
||||
return true;
|
||||
}
|
||||
IrisDirection sourceTop = rotateDirection(sourceConnector.getTop(), source.rotation());
|
||||
IrisDirection candidateTop = rotateDirection(candidateConnector.getTop(), candidateRotation);
|
||||
JigsawDirection sourceTop = rotateDirection(sourceConnector.getTop(), source.rotation());
|
||||
JigsawDirection candidateTop = rotateDirection(candidateConnector.getTop(), candidateRotation);
|
||||
return candidateTop == sourceTop;
|
||||
}
|
||||
|
||||
@@ -1116,7 +1118,7 @@ public final class StructureGraphCompiler {
|
||||
for (long seed : ASSEMBLY_SEEDS) {
|
||||
try {
|
||||
StructureAssembler assembler = StructureAssembler.forCompilation(
|
||||
compilation, new IrisPosition(0, 64, 0));
|
||||
compilation, new BlockPosition(0, 64, 0));
|
||||
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
||||
List<String> pieces = new ArrayList<>(result.pieces().size());
|
||||
for (PlacedStructurePiece placed : result.pieces()) {
|
||||
@@ -1175,8 +1177,7 @@ public final class StructureGraphCompiler {
|
||||
}
|
||||
|
||||
private String structureKey() {
|
||||
String key = structure.getLoadKey();
|
||||
return key == null || key.isBlank() ? "<unloaded>" : key;
|
||||
return structureKey == null || structureKey.isBlank() ? "<unloaded>" : structureKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1188,18 +1189,18 @@ public final class StructureGraphCompiler {
|
||||
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()) {
|
||||
return direction;
|
||||
}
|
||||
int turns = Math.floorMod(degrees, 360) / 90;
|
||||
IrisDirection rotated = direction;
|
||||
JigsawDirection rotated = direction;
|
||||
for (int turn = 0; turn < turns; turn++) {
|
||||
rotated = switch (rotated) {
|
||||
case NORTH_NEGATIVE_Z -> IrisDirection.WEST_NEGATIVE_X;
|
||||
case WEST_NEGATIVE_X -> IrisDirection.SOUTH_POSITIVE_Z;
|
||||
case SOUTH_POSITIVE_Z -> IrisDirection.EAST_POSITIVE_X;
|
||||
case EAST_POSITIVE_X -> IrisDirection.NORTH_NEGATIVE_Z;
|
||||
case NORTH_NEGATIVE_Z -> JigsawDirection.WEST_NEGATIVE_X;
|
||||
case WEST_NEGATIVE_X -> JigsawDirection.SOUTH_POSITIVE_Z;
|
||||
case SOUTH_POSITIVE_Z -> JigsawDirection.EAST_POSITIVE_X;
|
||||
case EAST_POSITIVE_X -> JigsawDirection.NORTH_NEGATIVE_Z;
|
||||
case UP_POSITIVE_Y, DOWN_NEGATIVE_Y -> rotated;
|
||||
};
|
||||
}
|
||||
|
||||
+17
-14
@@ -1,9 +1,8 @@
|
||||
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.IrisJigsawPool;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -12,10 +11,11 @@ public interface StructureGraphResolver {
|
||||
|
||||
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) {
|
||||
return new IrisDataStructureGraphResolver(Objects.requireNonNull(data));
|
||||
static StructureGraphResolver forPack(PackResources pack) {
|
||||
return new PackStructureGraphResolver(Objects.requireNonNull(pack));
|
||||
}
|
||||
|
||||
static StructureGraphResolver forCompiledGraph(CompiledStructureGraph graph) {
|
||||
@@ -23,26 +23,29 @@ public interface StructureGraphResolver {
|
||||
}
|
||||
}
|
||||
|
||||
final class IrisDataStructureGraphResolver implements StructureGraphResolver {
|
||||
private final IrisData data;
|
||||
final class PackStructureGraphResolver implements StructureGraphResolver {
|
||||
private final PackResources pack;
|
||||
|
||||
IrisDataStructureGraphResolver(IrisData data) {
|
||||
this.data = data;
|
||||
PackStructureGraphResolver(PackResources pack) {
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisJigsawPool loadPool(String key) {
|
||||
return StructureResources.pool(data.getPackResources(), key);
|
||||
return StructureResources.pool(pack, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisJigsawPiece loadPiece(String key) {
|
||||
return StructureResources.piece(data.getPackResources(), key);
|
||||
return StructureResources.piece(pack, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject loadObject(String key) {
|
||||
return data.load(IrisObject.class, key, false);
|
||||
public ObjectFrame loadObject(String key) {
|
||||
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
|
||||
public IrisObject loadObject(String key) {
|
||||
public ObjectFrame loadObject(String key) {
|
||||
return graph.getObjects().get(normalize(key));
|
||||
}
|
||||
|
||||
|
||||
+25
-25
@@ -18,21 +18,21 @@
|
||||
|
||||
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.StructureAssembler;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
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.IrisJigsawPool;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
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.validation.Problem;
|
||||
import com.volmit.validation.Severity;
|
||||
import com.volmit.validation.Subject;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -65,43 +65,43 @@ public final class StructureGraphValidation {
|
||||
private StructureGraphValidation() {
|
||||
}
|
||||
|
||||
/** Checks every structure of the pack {@code data} holds. */
|
||||
public static Validation validate(IrisData data) {
|
||||
return validate(data, null);
|
||||
/** Checks every structure of {@code pack}, whose objects are the files below {@code packFolder}. */
|
||||
public static Validation validate(PackResources pack, File packFolder) {
|
||||
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. */
|
||||
public static Validation validate(IrisData data, Set<String> activeStructureKeys) {
|
||||
/** Checks the structures of {@code pack} whose keys are in {@code activeStructureKeys}, or all when it is null. */
|
||||
public static Validation validate(PackResources pack, File packFolder, Set<String> activeStructureKeys) {
|
||||
List<Problem> problems = new ArrayList<>();
|
||||
Set<String> replacementOutputStructures = new LinkedHashSet<>();
|
||||
Map<String, List<SampledVerticalEnvelope>> sampledVerticalEnvelopes = new LinkedHashMap<>();
|
||||
PackStructureResolver resolver = new PackStructureResolver(data);
|
||||
for (ResourceId id : data.getPackResources().ids(StructureResources.STRUCTURES)) {
|
||||
PackStructureResolver resolver = new PackStructureResolver(pack, packFolder);
|
||||
for (ResourceId id : pack.ids(StructureResources.STRUCTURES)) {
|
||||
String structureKey = id.path();
|
||||
if (activeStructureKeys != null && !activeStructureKeys.contains(structureKey)) {
|
||||
continue;
|
||||
}
|
||||
IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey);
|
||||
IrisStructure structure = StructureResources.structure(pack, structureKey);
|
||||
if (structure == null) {
|
||||
continue;
|
||||
}
|
||||
validateStructure(structure, resolver, problems, replacementOutputStructures, sampledVerticalEnvelopes);
|
||||
validateStructure(structureKey, structure, resolver, problems, replacementOutputStructures, sampledVerticalEnvelopes);
|
||||
}
|
||||
return new Validation(problems, replacementOutputStructures, sampledVerticalEnvelopes);
|
||||
}
|
||||
|
||||
private static void validateStructure(
|
||||
String structureKey,
|
||||
IrisStructure structure,
|
||||
StructureGraphResolver resolver,
|
||||
List<Problem> problems,
|
||||
Set<String> replacementOutputStructures,
|
||||
Map<String, List<SampledVerticalEnvelope>> sampledVerticalEnvelopes
|
||||
) {
|
||||
String structureKey = structure.getLoadKey();
|
||||
Subject file = Subject.file(StructureResources.STRUCTURES.folder() + "/" + structureKey + JSON_EXTENSION);
|
||||
StructureGraphCompilation compilation;
|
||||
try {
|
||||
compilation = StructureGraphCompiler.compile(structure, resolver);
|
||||
compilation = StructureGraphCompiler.compile(structureKey, structure, resolver);
|
||||
} catch (MalformedObjectResourceException e) {
|
||||
problems.add(Problem.error(file, e.getMessage()));
|
||||
return;
|
||||
@@ -139,7 +139,7 @@ public final class StructureGraphValidation {
|
||||
for (long seed : GEOMETRY_SAMPLE_SEEDS) {
|
||||
try {
|
||||
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));
|
||||
if (result.status().isFailure()) {
|
||||
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. */
|
||||
private static final class PackStructureResolver implements StructureGraphResolver {
|
||||
private final IrisData data;
|
||||
private final PackResources pack;
|
||||
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 PackStructureResolver(IrisData data) {
|
||||
this.data = data;
|
||||
this.objectsRoot = data.getDataFolder().toPath().toAbsolutePath().normalize().resolve(OBJECTS_FOLDER);
|
||||
private PackStructureResolver(PackResources pack, File packFolder) {
|
||||
this.pack = pack;
|
||||
this.objectsRoot = packFolder.toPath().toAbsolutePath().normalize().resolve(OBJECTS_FOLDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisJigsawPool loadPool(String key) {
|
||||
return StructureResources.pool(data.getPackResources(), key);
|
||||
return StructureResources.pool(pack, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisJigsawPiece loadPiece(String key) {
|
||||
return StructureResources.piece(data.getPackResources(), key);
|
||||
return StructureResources.piece(pack, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject loadObject(String key) {
|
||||
public ObjectFrame loadObject(String key) {
|
||||
if (objects.containsKey(key)) {
|
||||
return objects.get(key);
|
||||
}
|
||||
@@ -286,7 +286,7 @@ public final class StructureGraphValidation {
|
||||
return null;
|
||||
}
|
||||
Path file = resolveObject(key);
|
||||
IrisObject object = file == null ? null : readObjectBounds(file);
|
||||
ObjectFrame object = file == null ? null : readObjectBounds(file);
|
||||
if (object == null) {
|
||||
missingObjects.add(key);
|
||||
return null;
|
||||
@@ -306,7 +306,7 @@ public final class StructureGraphValidation {
|
||||
return file;
|
||||
}
|
||||
|
||||
private IrisObject readObjectBounds(Path file) {
|
||||
private ObjectFrame readObjectBounds(Path file) {
|
||||
try (BufferedInputStream input = new BufferedInputStream(Files.newInputStream(file))) {
|
||||
return IrisObjectFrameReader.readBounds(input, file.toString());
|
||||
} 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.object.structure.jigsaw.IrisJigsawPiece;
|
||||
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.volmlib.util.math.RNG;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -49,8 +48,8 @@ public final class StructureResourceBundleGraphCompiler {
|
||||
public static List<StructureGraphCompilation> compile(StructureResourceBundle bundle) {
|
||||
BundleGraph graph = parse(Objects.requireNonNull(bundle));
|
||||
List<StructureGraphCompilation> compilations = new ArrayList<>(graph.structures().size());
|
||||
for (IrisStructure structure : graph.structures().values()) {
|
||||
compilations.add(StructureGraphCompiler.compile(structure, graph.resolver()));
|
||||
for (Map.Entry<String, IrisStructure> structure : graph.structures().entrySet()) {
|
||||
compilations.add(StructureGraphCompiler.compile(structure.getKey(), structure.getValue(), graph.resolver()));
|
||||
}
|
||||
return List.copyOf(compilations);
|
||||
}
|
||||
@@ -60,8 +59,9 @@ public final class StructureResourceBundleGraphCompiler {
|
||||
if (graph.structures().isEmpty()) {
|
||||
throw new StructureGraphValidationException("Structure bundle does not contain a root structure resource");
|
||||
}
|
||||
for (IrisStructure structure : graph.structures().values()) {
|
||||
StructureGraphCompilation compilation = StructureGraphCompiler.compile(structure, graph.resolver());
|
||||
for (Map.Entry<String, IrisStructure> structure : graph.structures().entrySet()) {
|
||||
StructureGraphCompilation compilation = StructureGraphCompiler.compile(
|
||||
structure.getKey(), structure.getValue(), graph.resolver());
|
||||
if (!compilation.isAssemblyViable()) {
|
||||
throw new StructureGraphValidationException(
|
||||
"Structure bundle graph is not viable: " + viabilityFailure(compilation));
|
||||
@@ -90,14 +90,11 @@ public final class StructureResourceBundleGraphCompiler {
|
||||
Map<String, IrisStructure> structures = new LinkedHashMap<>();
|
||||
Map<String, IrisJigsawPool> pools = 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()) {
|
||||
String path = resource.relativePath();
|
||||
if (matches(path, "structures/", ".json")) {
|
||||
IrisStructure structure = readJson(resource, IrisStructure.class);
|
||||
String key = key(path, "structures/", ".json");
|
||||
structure.setLoadKey(key);
|
||||
structures.put(key, structure);
|
||||
structures.put(key(path, "structures/", ".json"), readJson(resource, IrisStructure.class));
|
||||
} else if (matches(path, "jigsaw-pools/", ".json")) {
|
||||
pools.put(key(path, "jigsaw-pools/", ".json"), readJson(resource, IrisJigsawPool.class));
|
||||
} else if (matches(path, "jigsaw-pieces/", ".json")) {
|
||||
@@ -114,7 +111,7 @@ public final class StructureResourceBundleGraphCompiler {
|
||||
for (long seed : ASSEMBLY_SEEDS) {
|
||||
try {
|
||||
StructureAssembler assembler = StructureAssembler.forCompilation(
|
||||
compilation, new IrisPosition(0, 64, 0));
|
||||
compilation, new BlockPosition(0, 64, 0));
|
||||
StructureAssemblyResult result = assembler.assemble(new RNG(seed));
|
||||
if (result.status().isFailure()) {
|
||||
throw new StructureGraphValidationException("Structure bundle graph '" + structureKey
|
||||
@@ -157,7 +154,7 @@ public final class StructureResourceBundleGraphCompiler {
|
||||
return value;
|
||||
}
|
||||
|
||||
private static IrisObject readObjectBounds(StructureResourceBundle.Resource resource) {
|
||||
private static ObjectFrame readObjectBounds(StructureResourceBundle.Resource resource) {
|
||||
try (ByteArrayInputStream input = new ByteArrayInputStream(resource.content())) {
|
||||
return IrisObjectFrameReader.readBounds(input, resource.relativePath());
|
||||
} catch (IOException e) {
|
||||
@@ -168,7 +165,7 @@ public final class StructureResourceBundleGraphCompiler {
|
||||
private record BundleResolver(
|
||||
Map<String, IrisJigsawPool> pools,
|
||||
Map<String, IrisJigsawPiece> pieces,
|
||||
Map<String, IrisObject> objects
|
||||
Map<String, ObjectFrame> objects
|
||||
) implements StructureGraphResolver {
|
||||
private BundleResolver {
|
||||
pools = Map.copyOf(pools);
|
||||
@@ -187,7 +184,7 @@ public final class StructureResourceBundleGraphCompiler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject loadObject(String key) {
|
||||
public ObjectFrame loadObject(String key) {
|
||||
return objects.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-45
@@ -18,11 +18,9 @@
|
||||
|
||||
package art.arcane.iris.engine.framework.structure;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisValidationContext;
|
||||
import art.arcane.iris.core.pack.PackValidationIo;
|
||||
import art.arcane.volmlib.util.json.JSONArray;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import art.arcane.iris.builtin.structure.StructurePlacement;
|
||||
import art.arcane.iris.builtin.structure.StructurePlacementSettings;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.validation.Problem;
|
||||
import com.volmit.validation.ValidationContext;
|
||||
import com.volmit.validation.Validator;
|
||||
@@ -30,6 +28,7 @@ import com.volmit.validation.Validator;
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
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.
|
||||
*/
|
||||
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
|
||||
public void validate(ValidationContext pack) {
|
||||
IrisData data = IrisValidationContext.of(pack).data();
|
||||
StructureGraphValidation.Validation graphs = StructureGraphValidation.validate(data, placedStructureKeys(data.getDataFolder()));
|
||||
File packFolder = pack.settings().extension(File.class).orElse(null);
|
||||
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);
|
||||
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);
|
||||
StructurePlacementValidation.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);
|
||||
}
|
||||
|
||||
/**
|
||||
* The keys of the structures the dimension, region and biome files of the pack in {@code packFolder} place, read
|
||||
* from their JSON as written, like the other checks of these files.
|
||||
*/
|
||||
public static Set<String> placedStructureKeys(File packFolder) {
|
||||
/** The keys of the structures the dimensions, regions and biomes of the pack place, whether or not a dimension reaches them. */
|
||||
public static Set<String> placedStructureKeys(ValidationContext pack) {
|
||||
Set<String> structureKeys = new LinkedHashSet<>();
|
||||
if (packFolder == null || !packFolder.isDirectory()) {
|
||||
return structureKeys;
|
||||
}
|
||||
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));
|
||||
for (FeatureSettings.Entry<StructurePlacementSettings> declared : pack.settings().declared(StructurePlacementSettings.class).entries()) {
|
||||
for (StructurePlacement placement : declared.value().placements()) {
|
||||
placement.structures().stream().filter(key -> key != null && !key.isBlank()).forEach(structureKeys::add);
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
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.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class StructureCarvingFootprint {
|
||||
static final int DEFAULT_MAX_CELLS = 1_048_576;
|
||||
@@ -38,14 +31,6 @@ public final class StructureCarvingFootprint {
|
||||
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
|
||||
* 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[] sourceMaxY = new int[sourceCount];
|
||||
int sourceId = 0;
|
||||
for (Long2LongMap.Entry entry : sources.columns().long2LongEntrySet()) {
|
||||
int localX = unpackX(entry.getLongKey()) - bounds.minX();
|
||||
int localZ = unpackZ(entry.getLongKey()) - bounds.minZ();
|
||||
long heights = entry.getLongValue();
|
||||
for (Map.Entry<Long, Long> entry : sources.columns().entrySet()) {
|
||||
int localX = unpackX(entry.getKey()) - bounds.minX();
|
||||
int localZ = unpackZ(entry.getKey()) - bounds.minZ();
|
||||
long heights = entry.getValue();
|
||||
sourceX[sourceId] = localX;
|
||||
sourceZ[sourceId] = localZ;
|
||||
sourceMinY[sourceId] = unpackMinY(heights);
|
||||
@@ -170,7 +155,7 @@ public final class StructureCarvingFootprint {
|
||||
}
|
||||
|
||||
private static SourceCollection collectSources(ColumnSource source) {
|
||||
Long2LongOpenHashMap columns = new Long2LongOpenHashMap();
|
||||
Map<Long, Long> columns = new HashMap<>();
|
||||
MutableBounds bounds = new MutableBounds();
|
||||
boolean usable = source.emit((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());
|
||||
}
|
||||
|
||||
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) {
|
||||
long paddedMinX = (long) sourceBounds.minX() - padding;
|
||||
long paddedMaxX = (long) sourceBounds.maxX() + padding;
|
||||
@@ -233,7 +188,7 @@ public final class StructureCarvingFootprint {
|
||||
(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);
|
||||
if (!columns.containsKey(key)) {
|
||||
columns.put(key, packHeights(minY, maxY));
|
||||
@@ -430,7 +385,7 @@ public final class StructureCarvingFootprint {
|
||||
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) {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.engine.framework.structure.ColumnHeights;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntPredicate;
|
||||
@@ -12,7 +12,7 @@ final class 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) {
|
||||
if (columns == null || state == null
|
||||
|| !(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.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.prepare.ObjectRotation;
|
||||
import art.arcane.iris.core.IrisSettings;
|
||||
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.iris.engine.framework.IrisStructureLocator;
|
||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||
import art.arcane.iris.engine.framework.StructurePlacementScope;
|
||||
import art.arcane.iris.core.modules.PlacementMarkers;
|
||||
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.prefab.IrisObject;
|
||||
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.StructurePlacement;
|
||||
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.MatterStructurePOI;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -112,8 +112,8 @@ public class StructurePlacing {
|
||||
}
|
||||
|
||||
String key = resolved.structureKey();
|
||||
IrisStructure structure = resolved.structure();
|
||||
KList<PlacedStructurePiece> pieces = resolvedPiecesOrNull(resolved, cx, cz);
|
||||
StructureStamp stamp = resolved.stamp();
|
||||
KList<AssembledPiece> pieces = resolvedPiecesOrNull(resolved, cx, cz);
|
||||
if (pieces == null) {
|
||||
return;
|
||||
}
|
||||
@@ -139,36 +139,36 @@ public class StructurePlacing {
|
||||
+ " is not implemented for structure '" + key + "'");
|
||||
}
|
||||
|
||||
ObjectPlaceMode mode = structure.getPlaceMode();
|
||||
ObjectPlaceMode mode = stamp.placeMode();
|
||||
int failedPieces = 0;
|
||||
StructureStilts stilt = placement.stilt().orElse(null);
|
||||
Long2IntOpenHashMap foundationColumns = stilt == null
|
||||
? null : new Long2IntOpenHashMap();
|
||||
ColumnHeights foundationColumns = stilt == null
|
||||
? null : new ColumnHeights(0);
|
||||
boolean supportNonOccluding = stilt != null && stilt.supportNonOccluding();
|
||||
if (placement.isAnchoredUnderground()) {
|
||||
ObjectPlaceMode undergroundMode = mode.placeMode().has(PlaceTrait.CAVE_ANCHORED)
|
||||
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
if (placeObject(writer, structure, p, undergroundMode, p.getY(), rng,
|
||||
for (AssembledPiece p : pieces) {
|
||||
if (placeObject(writer, key, stamp, p, undergroundMode, p.y(), rng,
|
||||
foundationColumns, supportNonOccluding) == -1) {
|
||||
failedPieces++;
|
||||
}
|
||||
}
|
||||
} else if (mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, p.getY(), rng,
|
||||
for (AssembledPiece p : pieces) {
|
||||
if (placeObject(writer, key, stamp, p, ObjectPlaceMode.STRUCTURE_PIECE, p.y(), rng,
|
||||
foundationColumns, supportNonOccluding) == -1) {
|
||||
failedPieces++;
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
failedPieces++;
|
||||
}
|
||||
} else {
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, p.getY(), rng,
|
||||
for (AssembledPiece p : pieces) {
|
||||
if (placeObject(writer, key, stamp, p, ObjectPlaceMode.STRUCTURE_PIECE, p.y(), rng,
|
||||
foundationColumns, supportNonOccluding) == -1) {
|
||||
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,
|
||||
boolean surfaceStructure) {
|
||||
PaletteSpec palette = settings.palette().orElseThrow(
|
||||
@@ -188,14 +188,13 @@ public class StructurePlacing {
|
||||
PaletteSampler picker = engine.getData().getPackResources().blocks().palette(palette, rng.getSeed());
|
||||
int mantleOffset = engine.getMinHeight();
|
||||
int maxDepth = Math.max(1, settings.maxDepth());
|
||||
for (Long2IntMap.Entry column : columns.long2IntEntrySet()) {
|
||||
int worldX = StructureFoundationPlanner.unpackX(column.getLongKey());
|
||||
int worldZ = StructureFoundationPlanner.unpackZ(column.getLongKey());
|
||||
int foundationY = column.getIntValue();
|
||||
columns.forEach((column, foundationY) -> {
|
||||
int worldX = StructureFoundationPlanner.unpackX(column);
|
||||
int worldZ = StructureFoundationPlanner.unpackZ(column);
|
||||
PlatformBlockState foundationState = writer.getDataIfPresent(
|
||||
worldX, foundationY, worldZ, PlatformBlockState.class);
|
||||
if (foundationState == null || !foundationState.isSolid()) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
int terrainHeight = engine.getMantle().trueHeight(worldX, worldZ);
|
||||
int groundY = StructureFoundationPlanner.findGroundY(
|
||||
@@ -212,12 +211,12 @@ public class StructurePlacing {
|
||||
overlay, carved, y, terrainHeight);
|
||||
});
|
||||
if (groundY == StructureFoundationPlanner.NO_GROUND) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
StructureFoundationPlanner.fillSupportColumn(foundationY, groundY, y -> {
|
||||
writeFoundationSupport(writer, picker, worldX, y, worldZ, mantleOffset);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 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);
|
||||
}
|
||||
|
||||
static KList<PlacedStructurePiece> resolvedPiecesOrNull(
|
||||
static KList<AssembledPiece> resolvedPiecesOrNull(
|
||||
IrisStructureLocator.ResolvedPlacement resolved,
|
||||
int chunkX,
|
||||
int chunkZ
|
||||
@@ -241,7 +240,7 @@ public class StructurePlacing {
|
||||
if (resolved == null) {
|
||||
return null;
|
||||
}
|
||||
KList<PlacedStructurePiece> pieces = resolved.pieces();
|
||||
KList<AssembledPiece> pieces = resolved.pieces();
|
||||
if (!IrisStructureLocator.requirePlacementOutput(
|
||||
resolved.placement(), resolved.structureKey(), chunkX, chunkZ,
|
||||
pieces != null && !pieces.isEmpty(), "placement application received no assembled pieces")) {
|
||||
@@ -258,7 +257,7 @@ public class StructurePlacing {
|
||||
+ " assembled piece(s)");
|
||||
}
|
||||
|
||||
private void boreStructure(MantleWriter writer, KList<PlacedStructurePiece> pieces,
|
||||
private void boreStructure(MantleWriter writer, KList<AssembledPiece> pieces,
|
||||
StructureTerrain terrain) {
|
||||
int[] bounds = computePieceBounds(pieces);
|
||||
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) {
|
||||
int[] bounds = computePieceBounds(pieces);
|
||||
if (bounds == null) {
|
||||
@@ -310,8 +309,8 @@ public class StructurePlacing {
|
||||
}
|
||||
|
||||
long work = overboreCandidateVolume(bounds, margin, upExtension, floorCut);
|
||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(
|
||||
pieces, margin, Integer.MAX_VALUE);
|
||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.fromColumns(
|
||||
sink -> StructurePieceColumns.emit(pieces, this::blocksOf, sink), margin, Integer.MAX_VALUE);
|
||||
if (footprint == null) {
|
||||
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 worldHeight = engine.getHeight();
|
||||
Map<String, ObjectMarkerBounds> intersectingObjects = new HashMap<>();
|
||||
for (PlacedStructurePiece piece : resolved.pieces()) {
|
||||
for (IrisBlockVector local : piece.getObject().getBlocks().keys()) {
|
||||
PlatformBlockState structureState = piece.getObject().getBlocks().get(local);
|
||||
for (AssembledPiece piece : resolved.pieces()) {
|
||||
IrisObject object = objectOf(piece);
|
||||
for (IrisBlockVector local : object.getBlocks().keys()) {
|
||||
PlatformBlockState structureState = object.getBlocks().get(local);
|
||||
if (!isOccupiedStructureState(structureState)) {
|
||||
continue;
|
||||
}
|
||||
IrisBlockVector rotated = piece.getRotation().rotate(local.clone());
|
||||
int y = piece.getY() - mantleOffset + rotated.getBlockY();
|
||||
BlockPosition rotated = piece.turn().rotate(
|
||||
new BlockPosition(local.getBlockX(), local.getBlockY(), local.getBlockZ()));
|
||||
int y = piece.y() - mantleOffset + rotated.y();
|
||||
if (y >= 0 && y < worldHeight) {
|
||||
collectIntersectingObjectTreeMarker(
|
||||
writer, piece.getX() + rotated.getBlockX(), y,
|
||||
piece.getZ() + rotated.getBlockZ(), intersectingObjects);
|
||||
writer, piece.x() + rotated.x(), y,
|
||||
piece.z() + rotated.z(), intersectingObjects);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -520,7 +521,29 @@ public class StructurePlacing {
|
||||
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()) {
|
||||
return null;
|
||||
}
|
||||
@@ -530,29 +553,29 @@ public class StructurePlacing {
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
int maxZ = Integer.MIN_VALUE;
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
minX = Math.min(minX, p.getMinX());
|
||||
minY = Math.min(minY, p.getMinY());
|
||||
minZ = Math.min(minZ, p.getMinZ());
|
||||
maxX = Math.max(maxX, p.getMaxX());
|
||||
maxY = Math.max(maxY, p.getMaxY());
|
||||
maxZ = Math.max(maxZ, p.getMaxZ());
|
||||
for (AssembledPiece p : pieces) {
|
||||
minX = Math.min(minX, p.minX());
|
||||
minY = Math.min(minY, p.minY());
|
||||
minZ = Math.min(minZ, p.minZ());
|
||||
maxX = Math.max(maxX, p.maxX());
|
||||
maxY = Math.max(maxY, p.maxY());
|
||||
maxZ = Math.max(maxZ, p.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. */
|
||||
public static ObjectPlacement lootPlacement(IrisStructure structure, String objectKey) {
|
||||
return lootPlacementBuilder(structure, objectKey).build();
|
||||
/** A placement of the piece object {@code objectKey} whose containers draw from the stamp's loot tables. */
|
||||
public static ObjectPlacement lootPlacement(StructureStamp stamp, String objectKey) {
|
||||
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));
|
||||
if (structure.getLoot() == null) {
|
||||
if (stamp.loot().isEmpty()) {
|
||||
return placement;
|
||||
}
|
||||
List<ObjectLoot> loot = new ArrayList<>();
|
||||
for (String lootTable : structure.getLoot()) {
|
||||
for (String lootTable : stamp.loot()) {
|
||||
if (lootTable != null && !lootTable.isBlank()) {
|
||||
loot.add(new ObjectLoot(lootTable, 1));
|
||||
}
|
||||
@@ -560,22 +583,22 @@ public class StructurePlacing {
|
||||
return placement.loot(loot);
|
||||
}
|
||||
|
||||
private int placeObject(MantleWriter writer, IrisStructure structure, PlacedStructurePiece p,
|
||||
ObjectPlaceMode mode, int y, RNG rng, Long2IntOpenHashMap foundationColumns,
|
||||
private int placeObject(MantleWriter writer, String structureKey, StructureStamp stamp, AssembledPiece p,
|
||||
ObjectPlaceMode mode, int y, RNG rng, ColumnHeights foundationColumns,
|
||||
boolean supportNonOccluding) {
|
||||
IrisObject object = p.getObject();
|
||||
IrisObject object = objectOf(p);
|
||||
String objectKey = object.getLoadKey();
|
||||
ObjectPlacement.Builder builder = lootPlacementBuilder(structure, objectKey).mode(mode).rotation(moduleRotation(p.getRotation()));
|
||||
if (!structure.getEdit().isEmpty()) {
|
||||
builder.edit(structure.getEdit());
|
||||
ObjectPlacement.Builder builder = lootPlacementBuilder(stamp, objectKey).mode(mode).rotation(moduleRotation(p.turn()));
|
||||
if (!stamp.edits().isEmpty()) {
|
||||
builder.edit(new KList<>(stamp.edits()));
|
||||
}
|
||||
if (!mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
|
||||
builder.forcePlace(true);
|
||||
}
|
||||
ObjectPlacement config = builder.build();
|
||||
int placeY = (y == -1) ? -1 : y - engine.getMinHeight();
|
||||
String marker = structurePlacementMarker(structure, p, objectKey);
|
||||
return ModuleObjectPlacement.place(object, p.getX(), placeY, p.getZ(), writer, config, rng, (position, state) -> {
|
||||
String marker = structurePlacementMarker(structureKey, p, objectKey);
|
||||
return ModuleObjectPlacement.place(object, p.x(), placeY, p.z(), writer, config, rng, (position, state) -> {
|
||||
StructureFoundationPlanner.recordBaseCell(
|
||||
foundationColumns, position.getX(), position.getY(), position.getZ(), state,
|
||||
supportNonOccluding);
|
||||
@@ -586,8 +609,8 @@ public class StructurePlacing {
|
||||
}
|
||||
|
||||
/** The placement rotation that turns a placed piece the way {@code turn} does. */
|
||||
public static ObjectRotation moduleRotation(ObjectTurn turn) {
|
||||
return ObjectRotation.of(turn.xDegrees(), turn.yDegrees(), turn.zDegrees());
|
||||
public static ObjectRotation moduleRotation(PieceTurn turn) {
|
||||
return ObjectRotation.of(0, turn.yDegrees(), 0);
|
||||
}
|
||||
|
||||
static boolean shouldWriteStructureMarker(PlatformBlockState state) {
|
||||
@@ -604,12 +627,11 @@ public class StructurePlacing {
|
||||
return hash & Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
private static String structurePlacementMarker(IrisStructure structure, PlacedStructurePiece piece, String objectKey) {
|
||||
String structureKey = structure.getLoadKey();
|
||||
private static String structurePlacementMarker(String structureKey, AssembledPiece piece, String objectKey) {
|
||||
if (structureKey == null || structureKey.isBlank() || objectKey == null || objectKey.isBlank()) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -640,9 +662,11 @@ public class StructurePlacing {
|
||||
|| terrain.resolvedMode() == StructureTerrainMode.BORE
|
||||
? Math.max(0, terrain.horizontalPadding()) : 0;
|
||||
for (String key : placement.structures()) {
|
||||
IrisStructure structure = StructureResources.structure(engine.getData().getPackResources(), key);
|
||||
if (structure != null) {
|
||||
max = Math.max(max, Math.max(1, structure.getMaxSizeChunks()) * 16 + carvePadding);
|
||||
var pack = engine.getData().getPackResources();
|
||||
var structure = pack.idOf(key);
|
||||
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.service.JigsawStudioBlocks;
|
||||
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.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.volmlib.util.collection.KList;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
@@ -426,7 +425,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
"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);
|
||||
if (blocks == null) {
|
||||
return RenderedBay.invalid(
|
||||
@@ -434,7 +433,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
"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()) {
|
||||
return RenderedBay.invalid(dimensions, connectors.failure());
|
||||
}
|
||||
@@ -446,7 +445,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
PlaceableObject object,
|
||||
JigsawStudioCellDimensions dimensions,
|
||||
int quarterTurns,
|
||||
ObjectTurn rotation
|
||||
PieceTurn rotation
|
||||
) {
|
||||
BlockPosition center = object.center();
|
||||
List<ObjectBlock> sourceBlocks = object.geometry().blocks();
|
||||
@@ -491,15 +490,16 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
}
|
||||
|
||||
private ConnectorRenderResult renderConnectors(
|
||||
String pieceKey,
|
||||
IrisJigsawPiece piece,
|
||||
PlaceableObject object,
|
||||
JigsawStudioCellDimensions dimensions,
|
||||
int quarterTurns,
|
||||
ObjectTurn rotation
|
||||
PieceTurn rotation
|
||||
) {
|
||||
KList<IrisJigsawConnector> sourceConnectors = piece.getConnectors();
|
||||
List<IrisJigsawConnector> sourceConnectors = piece.getConnectors();
|
||||
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());
|
||||
for (int index = 0; index < sourceConnectors.size(); index++) {
|
||||
@@ -507,29 +507,29 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
if (!validConnectorMetadata(source)) {
|
||||
return ConnectorRenderResult.invalid("connector " + index + " has incomplete metadata");
|
||||
}
|
||||
IrisPosition sourcePosition = source.getPosition();
|
||||
BlockPosition sourcePosition = source.getPosition();
|
||||
if (!inside(
|
||||
sourcePosition.getX(),
|
||||
sourcePosition.getY(),
|
||||
sourcePosition.getZ(),
|
||||
sourcePosition.x(),
|
||||
sourcePosition.y(),
|
||||
sourcePosition.z(),
|
||||
object.width(),
|
||||
object.height(),
|
||||
object.depth())) {
|
||||
return ConnectorRenderResult.invalid("connector " + index + " is outside its object bounds");
|
||||
}
|
||||
RotatedPosition position = rotatePosition(
|
||||
sourcePosition.getX(),
|
||||
sourcePosition.getY(),
|
||||
sourcePosition.getZ(),
|
||||
sourcePosition.x(),
|
||||
sourcePosition.y(),
|
||||
sourcePosition.z(),
|
||||
object.width(),
|
||||
object.depth(),
|
||||
quarterTurns);
|
||||
IrisDirection front = quarterTurns == 0
|
||||
JigsawDirection front = quarterTurns == 0
|
||||
? source.getDirection()
|
||||
: rotation.rotate(source.getDirection());
|
||||
IrisDirection top = quarterTurns == 0
|
||||
: source.getDirection().turnedBy(rotation.quarterTurns());
|
||||
JigsawDirection top = quarterTurns == 0
|
||||
? source.getTop()
|
||||
: rotation.rotate(source.getTop());
|
||||
: source.getTop().turnedBy(rotation.quarterTurns());
|
||||
String orientation;
|
||||
try {
|
||||
orientation = orientation(front, top);
|
||||
@@ -543,7 +543,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
+ source.getFinalState() + "' cannot be parsed and rotated");
|
||||
}
|
||||
IrisJigsawConnector connector = copyConnector(source)
|
||||
.setPosition(new IrisPosition(position.x(), position.y(), position.z()))
|
||||
.setPosition(new BlockPosition(position.x(), position.y(), position.z()))
|
||||
.setDirection(front)
|
||||
.setTop(top)
|
||||
.setFinalState(finalState);
|
||||
@@ -562,7 +562,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
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();
|
||||
BlockState state = registry.find(finalState).orElse(null);
|
||||
if (state == null) {
|
||||
@@ -712,16 +712,16 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
};
|
||||
}
|
||||
|
||||
static String orientation(IrisDirection front, IrisDirection top) {
|
||||
IrisDirection activeFront = Objects.requireNonNull(front, "Jigsaw connector front");
|
||||
IrisDirection activeTop = Objects.requireNonNull(top, "Jigsaw connector top");
|
||||
if (activeFront == IrisDirection.UP_POSITIVE_Y || activeFront == IrisDirection.DOWN_NEGATIVE_Y) {
|
||||
static String orientation(JigsawDirection front, JigsawDirection top) {
|
||||
JigsawDirection activeFront = Objects.requireNonNull(front, "Jigsaw connector front");
|
||||
JigsawDirection activeTop = Objects.requireNonNull(top, "Jigsaw connector top");
|
||||
if (activeFront == JigsawDirection.UP_POSITIVE_Y || activeFront == JigsawDirection.DOWN_NEGATIVE_Y) {
|
||||
if (activeTop.isVertical()) {
|
||||
throw new IllegalArgumentException("Vertical jigsaw fronts require a horizontal top direction");
|
||||
}
|
||||
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");
|
||||
}
|
||||
return directionName(activeFront) + "_up";
|
||||
@@ -763,10 +763,10 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
|
||||
private static IrisJigsawConnector copyConnector(IrisJigsawConnector source) {
|
||||
return new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(
|
||||
source.getPosition().getX(),
|
||||
source.getPosition().getY(),
|
||||
source.getPosition().getZ()))
|
||||
.setPosition(new BlockPosition(
|
||||
source.getPosition().x(),
|
||||
source.getPosition().y(),
|
||||
source.getPosition().z()))
|
||||
.setDirection(source.getDirection())
|
||||
.setTop(source.getTop())
|
||||
.setPool(source.getPool())
|
||||
@@ -779,7 +779,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
.setPlacementPriority(source.getPlacementPriority());
|
||||
}
|
||||
|
||||
private static String directionName(IrisDirection direction) {
|
||||
private static String directionName(JigsawDirection direction) {
|
||||
return switch (direction) {
|
||||
case UP_POSITIVE_Y -> "up";
|
||||
case DOWN_NEGATIVE_Y -> "down";
|
||||
@@ -884,7 +884,7 @@ public final class JigsawStudioGenerator implements ChunkPainter {
|
||||
|
||||
@FunctionalInterface
|
||||
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) {
|
||||
|
||||
@@ -110,7 +110,7 @@ public final class BuiltInPack {
|
||||
LoadedPack pack = LoadedPack.load(packFolder, ModuleHost.of(modules)
|
||||
.exposing(IrisModuleHost.EXPOSED_PACKAGES.toArray(String[]::new))
|
||||
.reservingFields(ModuleTargets.reservedFields())
|
||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE)
|
||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES)
|
||||
.copyingJarsTo(folder.newFolder().toPath()));
|
||||
PackModuleSet moduleSet = mock(PackModuleSet.class);
|
||||
when(moduleSet.pack()).thenReturn(pack);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class CarveSettingsDecodingTest {
|
||||
packFolder = Path.of(CarveSettingsDecodingTest.class.getResource(PACK).toURI());
|
||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||
.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);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class DecorantSettingsDecodingTest {
|
||||
Path snippets = Files.createDirectories(packFolder.resolve("snippet/iris/decorant/decorator"));
|
||||
Files.writeString(snippets.resolve("bush.json"), "{\"chance\": 0.2, \"palette\": [{\"block\": \"minecraft:fern\"}]}");
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class DepositSettingsDecodingTest {
|
||||
Path snippets = Files.createDirectories(packFolder.resolve("snippet/iris/deposit/deposit"));
|
||||
Files.writeString(snippets.resolve("diamonds.json"), "{\"maxHeight\": 16, \"palette\": [{\"block\": \"minecraft:diamond_ore\"}]}");
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class FloatingSettingsDecodingTest {
|
||||
packFolder = Path.of(FloatingSettingsDecodingTest.class.getResource(PACK).toURI());
|
||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||
.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);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class LootAndSpawnPackDecodingTest {
|
||||
packFolder = Path.of(LootAndSpawnPackDecodingTest.class.getResource(PACK).toURI());
|
||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||
.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);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleRegistry;
|
||||
import com.volmit.host.ModuleSetups;
|
||||
import com.volmit.host.StageGraphBuilder;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.object.PackObjects;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.resource.ResourceKind;
|
||||
|
||||
@@ -46,6 +48,7 @@ public final class ModuleResourceFixture {
|
||||
public static synchronized ModuleResourceFixture serve(IrisData data) {
|
||||
IrisPackResources resources = mock(IrisPackResources.class);
|
||||
when(data.getPackResources()).thenReturn(resources);
|
||||
when(resources.objects()).thenReturn(mock(PackObjects.class));
|
||||
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(ResourceKind.class), any(ResourceId.class))).thenAnswer(invocation -> keyOf(invocation.getArgument(1)));
|
||||
@@ -108,6 +111,12 @@ public final class ModuleResourceFixture {
|
||||
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) {
|
||||
return new ResourceId(NAMESPACE, key.toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9_./-]", "_"));
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class ModuleSettingsDecoderTest {
|
||||
public void loadPack() throws IOException {
|
||||
packFolder = folder.newFolder("pack").toPath();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class OreSettingsDecodingTest {
|
||||
packFolder = Path.of(OreSettingsDecodingTest.class.getResource(PACK).toURI());
|
||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||
.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);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class PackBeforeThePortDecodingTest {
|
||||
packFolder = Path.of(PackBeforeThePortDecodingTest.class.getResource(PACK).toURI());
|
||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||
.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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ public class StructurePlacementSettingsDecodingTest {
|
||||
public void loadBuiltIns() throws IOException {
|
||||
Path packFolder = folder.newFolder("pack").toPath();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class StructureSettingsDecodingTest {
|
||||
public void loadBuiltIns() throws IOException {
|
||||
Path packFolder = folder.newFolder("pack").toPath();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class TerrainSettingsDecodingTest {
|
||||
packFolder = Path.of(TerrainSettingsDecodingTest.class.getResource(PACK).toURI());
|
||||
pack = LoadedPack.load(packFolder, ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||
.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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class VanillaFeaturesSettingsDecodingTest {
|
||||
public void loadBuiltIns() throws IOException {
|
||||
Path packFolder = folder.newFolder("pack").toPath();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,13 @@ public class PackValidatorStructureGraphTest {
|
||||
write(pack, "structures/regional.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
|
||||
|
||||
@@ -889,7 +889,7 @@ public class SchemaBuilderParityTest {
|
||||
try (LoadedPack pack = LoadedPack.load(Files.createDirectory(root.resolve("pack")),
|
||||
ModuleHost.of(modules)
|
||||
.exposing(IrisModuleHost.EXPOSED_PACKAGES.toArray(String[]::new))
|
||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE)
|
||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES)
|
||||
.copyingJarsTo(Files.createDirectory(root.resolve("copies"))))) {
|
||||
return pack.schema();
|
||||
}
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
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 java.util.EnumMap;
|
||||
@@ -86,17 +86,17 @@ public class JigsawPlanarTopologyTest {
|
||||
new JigsawStudioPieceRules(0, 30, 0, 0, false),
|
||||
List.of());
|
||||
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);
|
||||
IrisPosition restored = east.canonicalToSourcePosition(canonical, sourceDimensions);
|
||||
BlockPosition canonical = east.sourceToCanonicalPosition(source, sourceDimensions);
|
||||
BlockPosition restored = east.canonicalToSourcePosition(canonical, sourceDimensions);
|
||||
|
||||
assertEquals(new JigsawStudioCellDimensions(5, 3, 3), east.canonicalDimensions(sourceDimensions));
|
||||
assertEquals(1, canonical.getX());
|
||||
assertEquals(1, canonical.getY());
|
||||
assertEquals(0, canonical.getZ());
|
||||
assertEquals(source.getX(), restored.getX());
|
||||
assertEquals(source.getY(), restored.getY());
|
||||
assertEquals(source.getZ(), restored.getZ());
|
||||
assertEquals(1, canonical.x());
|
||||
assertEquals(1, canonical.y());
|
||||
assertEquals(0, canonical.z());
|
||||
assertEquals(source.x(), restored.x());
|
||||
assertEquals(source.y(), restored.y());
|
||||
assertEquals(source.z(), restored.z());
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -1,10 +1,10 @@
|
||||
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.IrisJigsawPiece;
|
||||
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.volmlib.util.math.IrisBlockVector;
|
||||
import com.google.gson.JsonArray;
|
||||
@@ -70,8 +70,8 @@ public class JigsawStudioGraphEditorResizeTest {
|
||||
JsonArray connectors = readJson(packRoot.resolve(
|
||||
"jigsaw-pieces/resize/atomic/variants/corner/variant-2.json"))
|
||||
.getAsJsonArray("connectors");
|
||||
assertEquals(new IrisPosition(3, 2, 0), connectorPosition(connectors, "NORTH_NEGATIVE_Z"));
|
||||
assertEquals(new IrisPosition(6, 2, 4), connectorPosition(connectors, "EAST_POSITIVE_X"));
|
||||
assertEquals(new BlockPosition(3, 2, 0), connectorPosition(connectors, "NORTH_NEGATIVE_Z"));
|
||||
assertEquals(new BlockPosition(6, 2, 4), connectorPosition(connectors, "EAST_POSITIVE_X"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,7 +124,7 @@ public class JigsawStudioGraphEditorResizeTest {
|
||||
PlatformBlockState stone = state("minecraft:stone", false);
|
||||
source.setUnsigned(6, 1, 2, explicitAir);
|
||||
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.resizePlanarPieceObject(
|
||||
@@ -139,7 +139,7 @@ public class JigsawStudioGraphEditorResizeTest {
|
||||
assertEquals(3, resized.getH());
|
||||
assertEquals(9, resized.getD());
|
||||
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));
|
||||
assertFalse(resized.getBlocks().containsKey(resized.getSigned(10, 1, 2)));
|
||||
assertSame(stone, blockAt(resized, 8, 1, 1));
|
||||
@@ -173,8 +173,8 @@ public class JigsawStudioGraphEditorResizeTest {
|
||||
PlatformBlockState collision = state("minecraft:stone", false);
|
||||
source.setUnsigned(2, 1, 0, underlay);
|
||||
source.setUnsigned(3, 1, 0, collision);
|
||||
IrisPosition originalPosition = new IrisPosition(2, 1, 0);
|
||||
IrisJigsawPiece piece = endPiece(IrisDirection.NORTH_NEGATIVE_Z, originalPosition.copy());
|
||||
BlockPosition originalPosition = new BlockPosition(2, 1, 0);
|
||||
IrisJigsawPiece piece = endPiece(JigsawDirection.NORTH_NEGATIVE_Z, originalPosition);
|
||||
|
||||
IOException failure = assertThrows(
|
||||
IOException.class,
|
||||
@@ -202,7 +202,7 @@ public class JigsawStudioGraphEditorResizeTest {
|
||||
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");
|
||||
piece.getConnectors().add(new IrisJigsawConnector()
|
||||
.setDirection(direction)
|
||||
@@ -245,14 +245,14 @@ public class JigsawStudioGraphEditorResizeTest {
|
||||
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++) {
|
||||
JsonObject connector = connectors.get(index).getAsJsonObject();
|
||||
if (!direction.equals(connector.get("direction").getAsString())) {
|
||||
continue;
|
||||
}
|
||||
JsonObject position = connector.getAsJsonObject("position");
|
||||
return new IrisPosition(
|
||||
return new BlockPosition(
|
||||
position.get("x").getAsInt(),
|
||||
position.get("y").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.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.ResourceLoader;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import art.arcane.iris.core.structure.authoring.StructureBackend;
|
||||
import art.arcane.iris.core.structure.authoring.StructureKey;
|
||||
import art.arcane.iris.core.structure.authoring.StructureOwnershipManifest;
|
||||
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.IrisJigsawMode;
|
||||
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.IrisJigsawWorkcell;
|
||||
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.volmlib.util.collection.KList;
|
||||
import org.junit.Rule;
|
||||
@@ -44,8 +43,8 @@ public class JigsawStudioGraphMapperTest {
|
||||
@Test
|
||||
public void horizontalConnectorsMapToPlanarTopology() {
|
||||
IrisJigsawPiece corner = new IrisJigsawPiece().setConnectors(new KList<>());
|
||||
corner.getConnectors().add(connector(IrisDirection.NORTH_NEGATIVE_Z));
|
||||
corner.getConnectors().add(connector(IrisDirection.EAST_POSITIVE_X));
|
||||
corner.getConnectors().add(connector(JigsawDirection.NORTH_NEGATIVE_Z));
|
||||
corner.getConnectors().add(connector(JigsawDirection.EAST_POSITIVE_X));
|
||||
|
||||
assertEquals(JigsawPlanarTopology.NORTH_EAST_CORNER,
|
||||
JigsawStudioGraphMapper.topologyOf(corner));
|
||||
@@ -54,8 +53,8 @@ public class JigsawStudioGraphMapperTest {
|
||||
@Test
|
||||
public void verticalConnectorsDoNotChangePlanarMask() {
|
||||
IrisJigsawPiece end = new IrisJigsawPiece().setConnectors(new KList<>());
|
||||
end.getConnectors().add(connector(IrisDirection.WEST_NEGATIVE_X));
|
||||
end.getConnectors().add(connector(IrisDirection.UP_POSITIVE_Y));
|
||||
end.getConnectors().add(connector(JigsawDirection.WEST_NEGATIVE_X));
|
||||
end.getConnectors().add(connector(JigsawDirection.UP_POSITIVE_Y));
|
||||
|
||||
assertEquals(JigsawPlanarTopology.WEST_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/east", 5));
|
||||
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()
|
||||
.setMinimumDepth(1)
|
||||
.setMaximumDepth(4)
|
||||
@@ -82,13 +81,12 @@ public class JigsawStudioGraphMapperTest {
|
||||
endPiece.getThemes().add("spruce");
|
||||
resources.resource(StructureResources.PIECES, "village/end", endPiece);
|
||||
resources.resource(StructureResources.PIECES, "village/east", planarPiece(
|
||||
"village/east", IrisDirection.EAST_POSITIVE_X));
|
||||
"village/east", JigsawDirection.EAST_POSITIVE_X));
|
||||
IrisStructure structure = new IrisStructure()
|
||||
.setStartPool("village/start")
|
||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
||||
|
||||
JigsawStudioVariantCatalog catalog = JigsawStudioGraphMapper.catalog(
|
||||
data, structure, JigsawStudioMode.PLANAR_JIGSAW);
|
||||
JigsawStudioVariantCatalog catalog = planarCatalog(data, Path.of("pack"), "village/demo", structure);
|
||||
JigsawStudioVariant end = catalog.find("village/end").orElseThrow();
|
||||
JigsawStudioVariant east = catalog.find("village/east").orElseThrow();
|
||||
|
||||
@@ -110,14 +108,13 @@ public class JigsawStudioGraphMapperTest {
|
||||
when(data.getDataFolder()).thenReturn(root.toFile());
|
||||
ModuleResourceFixture resources = ModuleResourceFixture.serve(data);
|
||||
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(
|
||||
"village/incomplete", IrisDirection.EAST_POSITIVE_X));
|
||||
"village/incomplete", JigsawDirection.EAST_POSITIVE_X));
|
||||
|
||||
IrisStructure structure = new IrisStructure()
|
||||
.setStartPool("village/start")
|
||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
||||
structure.setLoadKey("village/demo");
|
||||
StructureKey key = new StructureKey("iris", "village/demo");
|
||||
String hash = "0".repeat(64);
|
||||
StructureOwnershipManifest manifest = new StructureOwnershipManifest(
|
||||
@@ -135,8 +132,7 @@ public class JigsawStudioGraphMapperTest {
|
||||
Files.createDirectories(manifestPath.getParent());
|
||||
Files.write(manifestPath, manifest.toJson());
|
||||
|
||||
JigsawStudioVariantCatalog catalog = JigsawStudioGraphMapper.catalog(
|
||||
data, structure, JigsawStudioMode.PLANAR_JIGSAW);
|
||||
JigsawStudioVariantCatalog catalog = planarCatalog(data, root, "village/demo", structure);
|
||||
JigsawStudioVariant orphan = catalog.find("village/orphan").orElseThrow();
|
||||
JigsawStudioVariant incomplete = catalog.find("village/incomplete").orElseThrow();
|
||||
|
||||
@@ -155,12 +151,11 @@ public class JigsawStudioGraphMapperTest {
|
||||
when(data.getDataFolder()).thenReturn(root.toFile());
|
||||
ModuleResourceFixture resources = ModuleResourceFixture.serve(data);
|
||||
resources.resource(StructureResources.PIECES, "village/managed", planarPiece(
|
||||
"village/managed", IrisDirection.NORTH_NEGATIVE_Z));
|
||||
"village/managed", JigsawDirection.NORTH_NEGATIVE_Z));
|
||||
|
||||
IrisStructure structure = new IrisStructure()
|
||||
.setStartPool("village/start")
|
||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
||||
structure.setLoadKey("village/managed");
|
||||
StructureKey key = new StructureKey("iris", "village/managed");
|
||||
String hash = "0".repeat(64);
|
||||
String sourcePath = "data/example/worldgen/template_pool/village/start.json";
|
||||
@@ -188,10 +183,7 @@ public class JigsawStudioGraphMapperTest {
|
||||
Files.createDirectories(manifestPath.getParent());
|
||||
Files.write(manifestPath, manifest.toJson());
|
||||
|
||||
JigsawStudioVariantCatalog catalog = JigsawStudioGraphMapper.catalog(
|
||||
data,
|
||||
structure,
|
||||
JigsawStudioMode.PLANAR_JIGSAW);
|
||||
JigsawStudioVariantCatalog catalog = planarCatalog(data, root, "village/managed", structure);
|
||||
JigsawStudioVariant managed = catalog.find("village/managed").orElseThrow();
|
||||
|
||||
assertFalse(managed.owned());
|
||||
@@ -203,9 +195,7 @@ public class JigsawStudioGraphMapperTest {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void spatialLayoutExpandsToFitLargestReachableObject() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ResourceLoader<IrisObject> objectLoader = mock(ResourceLoader.class);
|
||||
when(data.getObjectLoader()).thenReturn(objectLoader);
|
||||
when(objectLoader.load("stronghold/tall-room")).thenReturn(new IrisObject(24, 32, 20));
|
||||
ModuleResourceFixture.serve(data).object("stronghold/tall-room", 24, 32, 20);
|
||||
JigsawStudioVariant variant = new JigsawStudioVariant(
|
||||
"stronghold/tall-room",
|
||||
"stronghold/tall-room",
|
||||
@@ -220,7 +210,7 @@ public class JigsawStudioGraphMapperTest {
|
||||
List.of());
|
||||
|
||||
JigsawStudioCellDimensions dimensions = JigsawStudioGraphMapper.expandSpatialDimensions(
|
||||
data,
|
||||
new JigsawStudioGraphMapper.Source(data.getPackResources(), Path.of("pack"), "stronghold"),
|
||||
new JigsawStudioVariantCatalog(List.of(variant)),
|
||||
new JigsawStudioCellDimensions(16, 16, 16));
|
||||
|
||||
@@ -231,16 +221,14 @@ public class JigsawStudioGraphMapperTest {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void mapsAuthorLabelsAndCanonicalPerVariantDimensionsIndependently() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ResourceLoader<IrisObject> objectLoader = mock(ResourceLoader.class);
|
||||
ModuleResourceFixture resources = ModuleResourceFixture.serve(data);
|
||||
when(data.getObjectLoader()).thenReturn(objectLoader);
|
||||
IrisJigsawPool start = new IrisJigsawPool().setPieces(new KList<>());
|
||||
start.getPieces().add(new IrisJigsawPieceEntry("village/east-gate", 1));
|
||||
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");
|
||||
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()
|
||||
.setStartPool("village/start")
|
||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW);
|
||||
@@ -255,7 +243,7 @@ public class JigsawStudioGraphMapperTest {
|
||||
true));
|
||||
}
|
||||
|
||||
JigsawStudioLayout layout = JigsawStudioGraphMapper.map(data, structure);
|
||||
JigsawStudioLayout layout = map(data, structure);
|
||||
JigsawStudioBay workcell = layout.get(JigsawPlanarArchetype.END.stableId());
|
||||
JigsawStudioVariant variant = layout.variantCatalog().find("village/east-gate").orElseThrow();
|
||||
|
||||
@@ -276,7 +264,7 @@ public class JigsawStudioGraphMapperTest {
|
||||
.setMode(IrisJigsawMode.SPATIAL_JIGSAW)
|
||||
.setSpatialWorkcellDisplayName("Stronghold Rooms");
|
||||
|
||||
JigsawStudioBay workcell = JigsawStudioGraphMapper.map(data, structure)
|
||||
JigsawStudioBay workcell = map(data, structure)
|
||||
.get(JigsawStudioLayout.SPATIAL_WORKCELL_ID);
|
||||
|
||||
assertEquals("Spatial", workcell.canonicalDisplayName());
|
||||
@@ -302,7 +290,7 @@ public class JigsawStudioGraphMapperTest {
|
||||
archetype != IrisJigsawWorkcellArchetype.TEE));
|
||||
}
|
||||
|
||||
JigsawStudioLayout layout = JigsawStudioGraphMapper.map(data, structure);
|
||||
JigsawStudioLayout layout = map(data, structure);
|
||||
|
||||
assertEquals(new JigsawStudioCellDimensions(11, 9, 13),
|
||||
layout.get("workcell/corner").bounds().dimensions());
|
||||
@@ -312,7 +300,16 @@ public class JigsawStudioGraphMapperTest {
|
||||
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()
|
||||
.setObject(objectKey)
|
||||
.setConnectors(new KList<>());
|
||||
@@ -320,7 +317,7 @@ public class JigsawStudioGraphMapperTest {
|
||||
return piece;
|
||||
}
|
||||
|
||||
private static IrisJigsawConnector connector(IrisDirection direction) {
|
||||
private static IrisJigsawConnector connector(JigsawDirection 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.StructureResourceBundleGraphCompiler;
|
||||
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.RNG;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -200,7 +200,7 @@ public class JigsawStudioProjectCreatorTest {
|
||||
for (long seed : List.of(0L, 1337L)) {
|
||||
StructureAssemblyResult result = StructureAssembler.forCompilation(
|
||||
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());
|
||||
}
|
||||
@@ -258,7 +258,7 @@ public class JigsawStudioProjectCreatorTest {
|
||||
JigsawStudioProjectCreator.bundle(options)).getFirst();
|
||||
StructureAssemblyResult preview = StructureAssembler.forCompilation(
|
||||
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());
|
||||
assertTrue(preview.pieces().size() > 1);
|
||||
assertTrue(preview.pieces().size() <= 96);
|
||||
@@ -328,7 +328,7 @@ public class JigsawStudioProjectCreatorTest {
|
||||
temporaryDirectory,
|
||||
"settlement/test",
|
||||
"settlement/test/side",
|
||||
new IrisPosition(8, 8, 0),
|
||||
new BlockPosition(8, 8, 0),
|
||||
"village/road").successful());
|
||||
JsonObject channeledPiece = JsonParser.parseString(Files.readString(
|
||||
temporaryDirectory.resolve("jigsaw-pieces/settlement/test/side.json"),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.BlockState;
|
||||
import org.junit.Test;
|
||||
@@ -18,7 +18,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
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
|
||||
public void aBlockTheRegistryCannotTurnComesBackAsNothingNotAsAir() {
|
||||
@@ -43,7 +43,7 @@ public class JigsawStudioBlocksTest {
|
||||
BlockRegistry registry = mock(BlockRegistry.class);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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.JigsawStudioCellDimensions;
|
||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCompatibilityTarget;
|
||||
@@ -299,7 +298,7 @@ public class JigsawStudioLifecycleTest {
|
||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||
new JigsawStudioCellDimensions(16, 16, 16),
|
||||
mock(IrisData.class),
|
||||
StudioToolPacks.toolPack(),
|
||||
JigsawStudioLayout.create(
|
||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||
new JigsawStudioCellDimensions(16, 16, 16),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.JigsawJoint;
|
||||
import org.junit.Test;
|
||||
@@ -14,18 +14,18 @@ import static org.junit.Assert.assertThrows;
|
||||
public class JigsawStudioMarkerParserTest {
|
||||
@Test
|
||||
public void mapsEveryJigsawOrientation() {
|
||||
assertDirections("down_east", IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.EAST_POSITIVE_X);
|
||||
assertDirections("down_north", IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.NORTH_NEGATIVE_Z);
|
||||
assertDirections("down_south", IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.SOUTH_POSITIVE_Z);
|
||||
assertDirections("down_west", IrisDirection.DOWN_NEGATIVE_Y, IrisDirection.WEST_NEGATIVE_X);
|
||||
assertDirections("up_east", IrisDirection.UP_POSITIVE_Y, IrisDirection.EAST_POSITIVE_X);
|
||||
assertDirections("up_north", IrisDirection.UP_POSITIVE_Y, IrisDirection.NORTH_NEGATIVE_Z);
|
||||
assertDirections("up_south", IrisDirection.UP_POSITIVE_Y, IrisDirection.SOUTH_POSITIVE_Z);
|
||||
assertDirections("up_west", IrisDirection.UP_POSITIVE_Y, IrisDirection.WEST_NEGATIVE_X);
|
||||
assertDirections("west_up", IrisDirection.WEST_NEGATIVE_X, IrisDirection.UP_POSITIVE_Y);
|
||||
assertDirections("east_up", IrisDirection.EAST_POSITIVE_X, IrisDirection.UP_POSITIVE_Y);
|
||||
assertDirections("north_up", IrisDirection.NORTH_NEGATIVE_Z, IrisDirection.UP_POSITIVE_Y);
|
||||
assertDirections("south_up", IrisDirection.SOUTH_POSITIVE_Z, IrisDirection.UP_POSITIVE_Y);
|
||||
assertDirections("down_east", JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.EAST_POSITIVE_X);
|
||||
assertDirections("down_north", JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||
assertDirections("down_south", JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||
assertDirections("down_west", JigsawDirection.DOWN_NEGATIVE_Y, JigsawDirection.WEST_NEGATIVE_X);
|
||||
assertDirections("up_east", JigsawDirection.UP_POSITIVE_Y, JigsawDirection.EAST_POSITIVE_X);
|
||||
assertDirections("up_north", JigsawDirection.UP_POSITIVE_Y, JigsawDirection.NORTH_NEGATIVE_Z);
|
||||
assertDirections("up_south", JigsawDirection.UP_POSITIVE_Y, JigsawDirection.SOUTH_POSITIVE_Z);
|
||||
assertDirections("up_west", JigsawDirection.UP_POSITIVE_Y, JigsawDirection.WEST_NEGATIVE_X);
|
||||
assertDirections("west_up", JigsawDirection.WEST_NEGATIVE_X, JigsawDirection.UP_POSITIVE_Y);
|
||||
assertDirections("east_up", JigsawDirection.EAST_POSITIVE_X, JigsawDirection.UP_POSITIVE_Y);
|
||||
assertDirections("north_up", JigsawDirection.NORTH_NEGATIVE_Z, JigsawDirection.UP_POSITIVE_Y);
|
||||
assertDirections("south_up", JigsawDirection.SOUTH_POSITIVE_Z, JigsawDirection.UP_POSITIVE_Y);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -43,11 +43,11 @@ public class JigsawStudioMarkerParserTest {
|
||||
IrisJigsawConnector connector = JigsawStudioMarkerParser.parse(
|
||||
nbt, "north_up", 3, 5, 7);
|
||||
|
||||
assertEquals(3, connector.getPosition().getX());
|
||||
assertEquals(5, connector.getPosition().getY());
|
||||
assertEquals(7, connector.getPosition().getZ());
|
||||
assertEquals(IrisDirection.NORTH_NEGATIVE_Z, connector.getDirection());
|
||||
assertEquals(IrisDirection.UP_POSITIVE_Y, connector.getTop());
|
||||
assertEquals(3, connector.getPosition().x());
|
||||
assertEquals(5, connector.getPosition().y());
|
||||
assertEquals(7, connector.getPosition().z());
|
||||
assertEquals(JigsawDirection.NORTH_NEGATIVE_Z, connector.getDirection());
|
||||
assertEquals(JigsawDirection.UP_POSITIVE_Y, connector.getTop());
|
||||
assertEquals("fort/pool", connector.getPool());
|
||||
assertEquals("iris:door", connector.getName());
|
||||
assertEquals("iris:door", connector.getTargetName());
|
||||
@@ -98,8 +98,8 @@ public class JigsawStudioMarkerParserTest {
|
||||
|
||||
private static void assertDirections(
|
||||
String orientation,
|
||||
IrisDirection expectedFront,
|
||||
IrisDirection expectedTop
|
||||
JigsawDirection expectedFront,
|
||||
JigsawDirection expectedTop
|
||||
) {
|
||||
JigsawStudioMarkerParser.Directions directions = JigsawStudioMarkerParser.directions(orientation);
|
||||
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.object.structure.jigsaw.IrisJigsawPiece;
|
||||
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 com.volmit.ModuleLog;
|
||||
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 org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -35,9 +40,9 @@ public class JigsawStudioPreviewRendererTest {
|
||||
when(stone.key()).thenReturn("minecraft:stone");
|
||||
IrisObject object = new IrisObject(3, 3, 3);
|
||||
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(
|
||||
@@ -60,7 +65,7 @@ public class JigsawStudioPreviewRendererTest {
|
||||
object.setUnsigned(0, 0, 0, structureVoid);
|
||||
|
||||
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());
|
||||
assertFalse(plan.bounds().isEmpty());
|
||||
@@ -68,7 +73,7 @@ public class JigsawStudioPreviewRendererTest {
|
||||
|
||||
@Test
|
||||
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.bounds().isEmpty());
|
||||
@@ -81,7 +86,7 @@ public class JigsawStudioPreviewRendererTest {
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
ObjectTurn.of(0, 0, 0));
|
||||
PieceTurn.NONE);
|
||||
|
||||
PlacedStructurePiece planar = JigsawStudioService.alignPreviewPieces(
|
||||
List.of(source),
|
||||
@@ -134,19 +139,31 @@ public class JigsawStudioPreviewRendererTest {
|
||||
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(
|
||||
IrisObject object,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
ObjectTurn rotation
|
||||
PieceTurn rotation
|
||||
) {
|
||||
int minimumX = x - object.getW() / 2;
|
||||
int minimumY = y - object.getH() / 2;
|
||||
int minimumZ = z - object.getD() / 2;
|
||||
return new PlacedStructurePiece(
|
||||
new IrisJigsawPiece().setObject("preview"),
|
||||
object,
|
||||
"preview",
|
||||
new ObjectFrame(object.getW(), object.getH(), object.getD()),
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.JigsawStudioCompatibilityTarget;
|
||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioLayout;
|
||||
@@ -38,7 +38,7 @@ public class JigsawStudioRegistryTest {
|
||||
|
||||
@Test
|
||||
public void storesRequestAndSessionByNormalizedPackKey() {
|
||||
IrisData source = mock(IrisData.class);
|
||||
ToolPack source = StudioToolPacks.toolPack();
|
||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(11, 7, 11);
|
||||
JigsawStudioRequest request = registry.activate(
|
||||
"OverWorld",
|
||||
@@ -61,7 +61,7 @@ public class JigsawStudioRegistryTest {
|
||||
|
||||
@Test
|
||||
public void replacementGetsANewRequestScopedSession() {
|
||||
IrisData source = mock(IrisData.class);
|
||||
ToolPack source = StudioToolPacks.toolPack();
|
||||
JigsawStudioRequest first = registry.activate(
|
||||
"overworld",
|
||||
"village",
|
||||
@@ -90,7 +90,7 @@ public class JigsawStudioRegistryTest {
|
||||
|
||||
@Test
|
||||
public void staleRequestCannotDeactivateItsReplacement() {
|
||||
IrisData source = mock(IrisData.class);
|
||||
ToolPack source = StudioToolPacks.toolPack();
|
||||
JigsawStudioRequest first = registry.activate(
|
||||
"overworld",
|
||||
"village",
|
||||
@@ -116,7 +116,7 @@ public class JigsawStudioRegistryTest {
|
||||
|
||||
@Test
|
||||
public void acceptsExistingGraphLayoutAsCleanInitialState() {
|
||||
IrisData source = mock(IrisData.class);
|
||||
ToolPack source = StudioToolPacks.toolPack();
|
||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(9, 6, 9);
|
||||
JigsawStudioVariant variant = new JigsawStudioVariant(
|
||||
"stronghold/hall",
|
||||
@@ -154,7 +154,7 @@ public class JigsawStudioRegistryTest {
|
||||
|
||||
@Test
|
||||
public void stagedSamePackReplacementKeepsPriorActivationUntilCommit() {
|
||||
IrisData source = mock(IrisData.class);
|
||||
ToolPack source = StudioToolPacks.toolPack();
|
||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||
JigsawStudioLayout oldLayout = JigsawStudioLayout.create(
|
||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||
@@ -199,7 +199,7 @@ public class JigsawStudioRegistryTest {
|
||||
|
||||
@Test
|
||||
public void failedSamePackReplacementRollsBackWithoutReplacingPriorSession() {
|
||||
IrisData source = mock(IrisData.class);
|
||||
ToolPack source = StudioToolPacks.toolPack();
|
||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||
JigsawStudioLayout layout = JigsawStudioLayout.create(
|
||||
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.StructureWriteOptions;
|
||||
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.IrisJigsawPiece;
|
||||
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 com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -275,9 +275,9 @@ public class JigsawStudioResourceBundleAssemblerTest {
|
||||
|
||||
private static IrisJigsawConnector connector() {
|
||||
return new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(0, 0, 0))
|
||||
.setDirection(IrisDirection.NORTH_NEGATIVE_Z)
|
||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
||||
.setPosition(new BlockPosition(0, 0, 0))
|
||||
.setDirection(JigsawDirection.NORTH_NEGATIVE_Z)
|
||||
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||
.setPool("fort/start")
|
||||
.setName("iris:door")
|
||||
.setTargetName("iris:door")
|
||||
|
||||
+71
-71
@@ -1,6 +1,5 @@
|
||||
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.JigsawPlanarTopology;
|
||||
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.JigsawStudioWorkcellSpec;
|
||||
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.IrisJigsawPiece;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import art.arcane.iris.engine.platform.studio.generators.JigsawStudioGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
@@ -432,7 +431,7 @@ public class JigsawStudioServiceCaptureTest {
|
||||
JigsawStudioMode.PLANAR_JIGSAW,
|
||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||
dimensions,
|
||||
mock(IrisData.class),
|
||||
StudioToolPacks.toolPack(),
|
||||
initialLayout);
|
||||
JigsawStudioSession session = service.registry().getSession(request.requestId());
|
||||
JigsawStudioBay initialEnd = initialLayout.get("workcell/end");
|
||||
@@ -505,7 +504,7 @@ public class JigsawStudioServiceCaptureTest {
|
||||
JigsawStudioMode.PLANAR_JIGSAW,
|
||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||
dimensions,
|
||||
mock(IrisData.class),
|
||||
StudioToolPacks.toolPack(),
|
||||
layout,
|
||||
OWNER);
|
||||
service.registry().finishOpen(OWNER);
|
||||
@@ -601,8 +600,8 @@ public class JigsawStudioServiceCaptureTest {
|
||||
JigsawStudioMode.PLANAR_JIGSAW,
|
||||
dimensions,
|
||||
JigsawStudioVariantCatalog.empty());
|
||||
IrisJigsawConnector eastSource = connector().setDirection(IrisDirection.EAST_POSITIVE_X);
|
||||
IrisJigsawConnector southDisplayed = connector().setDirection(IrisDirection.SOUTH_POSITIVE_Z);
|
||||
IrisJigsawConnector eastSource = connector().setDirection(JigsawDirection.EAST_POSITIVE_X);
|
||||
IrisJigsawConnector southDisplayed = connector().setDirection(JigsawDirection.SOUTH_POSITIVE_Z);
|
||||
|
||||
JigsawStudioService.requireWorkcellTopology(
|
||||
layout.get("workcell/end"),
|
||||
@@ -637,15 +636,15 @@ public class JigsawStudioServiceCaptureTest {
|
||||
List<JigsawStudioService.ChunkCaptureArea> areas = JigsawStudioService.chunkIntersections(bounds);
|
||||
BlockState sourceState = BlockState.parse("minecraft:observer[facing=north]");
|
||||
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());
|
||||
IrisDirection displayedDirection = displayRotation.rotate(IrisDirection.NORTH_NEGATIVE_Z);
|
||||
JigsawDirection displayedDirection = JigsawDirection.NORTH_NEGATIVE_Z.turnedBy(displayRotation.quarterTurns());
|
||||
JigsawStudioService.CapturedConnector connector = new JigsawStudioService.CapturedConnector(
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
displayedDirection,
|
||||
IrisDirection.UP_POSITIVE_Y,
|
||||
JigsawDirection.UP_POSITIVE_Y,
|
||||
"test/pool",
|
||||
"door",
|
||||
"door",
|
||||
@@ -721,26 +720,26 @@ public class JigsawStudioServiceCaptureTest {
|
||||
@Test
|
||||
public void noOpTeeAndCrossCapturePreservesCreatorOrderForSeededAssembly() throws IOException {
|
||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||
List<List<IrisDirection>> authoredOrders = List.of(
|
||||
List<List<JigsawDirection>> authoredOrders = List.of(
|
||||
List.of(
|
||||
IrisDirection.NORTH_NEGATIVE_Z,
|
||||
IrisDirection.EAST_POSITIVE_X,
|
||||
IrisDirection.WEST_NEGATIVE_X),
|
||||
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||
JigsawDirection.EAST_POSITIVE_X,
|
||||
JigsawDirection.WEST_NEGATIVE_X),
|
||||
List.of(
|
||||
IrisDirection.NORTH_NEGATIVE_Z,
|
||||
IrisDirection.EAST_POSITIVE_X,
|
||||
IrisDirection.SOUTH_POSITIVE_Z,
|
||||
IrisDirection.WEST_NEGATIVE_X));
|
||||
List<List<IrisDirection>> captureOrders = List.of(
|
||||
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||
JigsawDirection.EAST_POSITIVE_X,
|
||||
JigsawDirection.SOUTH_POSITIVE_Z,
|
||||
JigsawDirection.WEST_NEGATIVE_X));
|
||||
List<List<JigsawDirection>> captureOrders = List.of(
|
||||
List.of(
|
||||
IrisDirection.WEST_NEGATIVE_X,
|
||||
IrisDirection.NORTH_NEGATIVE_Z,
|
||||
IrisDirection.EAST_POSITIVE_X),
|
||||
JigsawDirection.WEST_NEGATIVE_X,
|
||||
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||
JigsawDirection.EAST_POSITIVE_X),
|
||||
List.of(
|
||||
IrisDirection.WEST_NEGATIVE_X,
|
||||
IrisDirection.NORTH_NEGATIVE_Z,
|
||||
IrisDirection.SOUTH_POSITIVE_Z,
|
||||
IrisDirection.EAST_POSITIVE_X));
|
||||
JigsawDirection.WEST_NEGATIVE_X,
|
||||
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||
JigsawDirection.SOUTH_POSITIVE_Z,
|
||||
JigsawDirection.EAST_POSITIVE_X));
|
||||
|
||||
for (int index = 0; index < authoredOrders.size(); index++) {
|
||||
IrisJigsawPiece source = pieceWithPlanarConnectors(dimensions, authoredOrders.get(index));
|
||||
@@ -758,11 +757,11 @@ public class JigsawStudioServiceCaptureTest {
|
||||
public void connectorMetadataEditsAtTheSamePositionKeepAuthoredOrder() throws IOException {
|
||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||
IrisJigsawPiece source = pieceWithPlanarConnectors(dimensions, List.of(
|
||||
IrisDirection.NORTH_NEGATIVE_Z,
|
||||
IrisDirection.EAST_POSITIVE_X));
|
||||
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||
JigsawDirection.EAST_POSITIVE_X));
|
||||
IrisJigsawConnector capturedNorth = planarConnector(
|
||||
dimensions,
|
||||
IrisDirection.NORTH_NEGATIVE_Z)
|
||||
JigsawDirection.NORTH_NEGATIVE_Z)
|
||||
.setPool("changed/pool")
|
||||
.setName("changed:name")
|
||||
.setTargetName("changed:target")
|
||||
@@ -773,7 +772,7 @@ public class JigsawStudioServiceCaptureTest {
|
||||
.setPlacementPriority(-4);
|
||||
IrisJigsawConnector capturedEast = planarConnector(
|
||||
dimensions,
|
||||
IrisDirection.EAST_POSITIVE_X);
|
||||
JigsawDirection.EAST_POSITIVE_X);
|
||||
|
||||
List<IrisJigsawConnector> ordered = JigsawStudioService.preserveCapturedConnectorOrder(
|
||||
source,
|
||||
@@ -789,23 +788,23 @@ public class JigsawStudioServiceCaptureTest {
|
||||
public void removedConnectorsDisappearWithoutReorderingSurvivors() throws IOException {
|
||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||
IrisJigsawPiece source = pieceWithPlanarConnectors(dimensions, List.of(
|
||||
IrisDirection.NORTH_NEGATIVE_Z,
|
||||
IrisDirection.EAST_POSITIVE_X,
|
||||
IrisDirection.WEST_NEGATIVE_X));
|
||||
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||
JigsawDirection.EAST_POSITIVE_X,
|
||||
JigsawDirection.WEST_NEGATIVE_X));
|
||||
IrisJigsawConnector capturedWest = planarConnector(
|
||||
dimensions,
|
||||
IrisDirection.WEST_NEGATIVE_X);
|
||||
JigsawDirection.WEST_NEGATIVE_X);
|
||||
IrisJigsawConnector capturedNorth = planarConnector(
|
||||
dimensions,
|
||||
IrisDirection.NORTH_NEGATIVE_Z);
|
||||
JigsawDirection.NORTH_NEGATIVE_Z);
|
||||
|
||||
List<IrisJigsawConnector> ordered = JigsawStudioService.preserveCapturedConnectorOrder(
|
||||
source,
|
||||
List.of(capturedWest, capturedNorth));
|
||||
|
||||
assertEquals(List.of(
|
||||
IrisDirection.NORTH_NEGATIVE_Z,
|
||||
IrisDirection.WEST_NEGATIVE_X), connectorDirections(ordered));
|
||||
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||
JigsawDirection.WEST_NEGATIVE_X), connectorDirections(ordered));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -813,10 +812,10 @@ public class JigsawStudioServiceCaptureTest {
|
||||
JigsawStudioCellDimensions dimensions = new JigsawStudioCellDimensions(16, 16, 16);
|
||||
IrisJigsawPiece source = pieceWithPlanarConnectors(
|
||||
dimensions,
|
||||
List.of(IrisDirection.NORTH_NEGATIVE_Z));
|
||||
List.of(JigsawDirection.NORTH_NEGATIVE_Z));
|
||||
IrisJigsawConnector capturedNorth = planarConnector(
|
||||
dimensions,
|
||||
IrisDirection.NORTH_NEGATIVE_Z);
|
||||
JigsawDirection.NORTH_NEGATIVE_Z);
|
||||
IrisJigsawConnector highY = connectorAt(2, 5, 9);
|
||||
IrisJigsawConnector highZ = connectorAt(2, 3, 10);
|
||||
IrisJigsawConnector lowZ = connectorAt(2, 3, 4);
|
||||
@@ -835,7 +834,7 @@ public class JigsawStudioServiceCaptureTest {
|
||||
public void duplicateSourceOrCapturedConnectorPositionsAreRejected() {
|
||||
IrisJigsawConnector first = 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<>());
|
||||
duplicateSource.getConnectors().add(first);
|
||||
duplicateSource.getConnectors().add(second);
|
||||
@@ -858,16 +857,16 @@ public class JigsawStudioServiceCaptureTest {
|
||||
new JigsawStudioCellDimensions(5, 1, 3));
|
||||
List<JigsawStudioService.ChunkCaptureArea> areas = JigsawStudioService.chunkIntersections(bounds);
|
||||
IrisJigsawConnector sourceFirst = connectorAt(0, 0, 1)
|
||||
.setDirection(IrisDirection.NORTH_NEGATIVE_Z);
|
||||
.setDirection(JigsawDirection.NORTH_NEGATIVE_Z);
|
||||
IrisJigsawConnector sourceSecond = connectorAt(2, 0, 2)
|
||||
.setDirection(IrisDirection.EAST_POSITIVE_X);
|
||||
.setDirection(JigsawDirection.EAST_POSITIVE_X);
|
||||
IrisJigsawPiece source = new IrisJigsawPiece().setConnectors(new KList<>());
|
||||
source.getConnectors().add(sourceFirst);
|
||||
source.getConnectors().add(sourceSecond);
|
||||
BlockState sourceState = BlockState.parse("minecraft:observer[facing=north]");
|
||||
|
||||
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());
|
||||
JigsawStudioService.CapturedConnector displayedFirst = displayedConnector(
|
||||
sourceFirst,
|
||||
@@ -1248,7 +1247,8 @@ public class JigsawStudioServiceCaptureTest {
|
||||
mode,
|
||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||
dimensions,
|
||||
mock(IrisData.class),
|
||||
mock(com.volmit.tooling.ToolPack.class),
|
||||
java.nio.file.Path.of("pack"),
|
||||
null);
|
||||
}
|
||||
|
||||
@@ -1274,9 +1274,9 @@ public class JigsawStudioServiceCaptureTest {
|
||||
|
||||
private static IrisJigsawConnector connector() {
|
||||
return new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(0, 0, 0))
|
||||
.setDirection(IrisDirection.NORTH_NEGATIVE_Z)
|
||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
||||
.setPosition(new BlockPosition(0, 0, 0))
|
||||
.setDirection(JigsawDirection.NORTH_NEGATIVE_Z)
|
||||
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||
.setPool("fort/start")
|
||||
.setName("iris:door")
|
||||
.setTargetName("iris:door")
|
||||
@@ -1285,14 +1285,14 @@ public class JigsawStudioServiceCaptureTest {
|
||||
}
|
||||
|
||||
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(
|
||||
JigsawStudioCellDimensions dimensions,
|
||||
IrisDirection direction
|
||||
JigsawDirection direction
|
||||
) {
|
||||
IrisPosition size = new IrisPosition(
|
||||
BlockPosition size = new BlockPosition(
|
||||
dimensions.width(),
|
||||
dimensions.height(),
|
||||
dimensions.depth());
|
||||
@@ -1303,10 +1303,10 @@ public class JigsawStudioServiceCaptureTest {
|
||||
|
||||
private static List<IrisJigsawConnector> planarConnectors(
|
||||
JigsawStudioCellDimensions dimensions,
|
||||
List<IrisDirection> directions
|
||||
List<JigsawDirection> directions
|
||||
) {
|
||||
List<IrisJigsawConnector> connectors = new ArrayList<>(directions.size());
|
||||
for (IrisDirection direction : directions) {
|
||||
for (JigsawDirection direction : directions) {
|
||||
connectors.add(planarConnector(dimensions, direction));
|
||||
}
|
||||
return connectors;
|
||||
@@ -1314,15 +1314,15 @@ public class JigsawStudioServiceCaptureTest {
|
||||
|
||||
private static IrisJigsawPiece pieceWithPlanarConnectors(
|
||||
JigsawStudioCellDimensions dimensions,
|
||||
List<IrisDirection> directions
|
||||
List<JigsawDirection> directions
|
||||
) {
|
||||
IrisJigsawPiece piece = new IrisJigsawPiece().setConnectors(new KList<>());
|
||||
piece.getConnectors().addAll(planarConnectors(dimensions, directions));
|
||||
return piece;
|
||||
}
|
||||
|
||||
private static List<IrisDirection> connectorDirections(List<IrisJigsawConnector> connectors) {
|
||||
List<IrisDirection> directions = new ArrayList<>(connectors.size());
|
||||
private static List<JigsawDirection> connectorDirections(List<IrisJigsawConnector> connectors) {
|
||||
List<JigsawDirection> directions = new ArrayList<>(connectors.size());
|
||||
for (IrisJigsawConnector connector : connectors) {
|
||||
directions.add(connector.getDirection());
|
||||
}
|
||||
@@ -1333,19 +1333,19 @@ public class JigsawStudioServiceCaptureTest {
|
||||
IrisJigsawConnector source,
|
||||
JigsawStudioCellDimensions displayDimensions,
|
||||
int displayRotationQuarterTurns,
|
||||
ObjectTurn displayRotation,
|
||||
PieceTurn displayRotation,
|
||||
String finalState
|
||||
) {
|
||||
IrisPosition displayedPosition = displayedPosition(
|
||||
BlockPosition displayedPosition = displayedPosition(
|
||||
source.getPosition(),
|
||||
displayDimensions,
|
||||
displayRotationQuarterTurns);
|
||||
return new JigsawStudioService.CapturedConnector(
|
||||
displayedPosition.getX(),
|
||||
displayedPosition.getY(),
|
||||
displayedPosition.getZ(),
|
||||
displayRotation.rotate(source.getDirection()),
|
||||
displayRotation.rotate(source.getTop()),
|
||||
displayedPosition.x(),
|
||||
displayedPosition.y(),
|
||||
displayedPosition.z(),
|
||||
source.getDirection().turnedBy(displayRotation.quarterTurns()),
|
||||
source.getTop().turnedBy(displayRotation.quarterTurns()),
|
||||
source.getPool(),
|
||||
source.getName(),
|
||||
source.getTargetName(),
|
||||
@@ -1356,8 +1356,8 @@ public class JigsawStudioServiceCaptureTest {
|
||||
source.getPlacementPriority());
|
||||
}
|
||||
|
||||
private static IrisPosition displayedPosition(
|
||||
IrisPosition source,
|
||||
private static BlockPosition displayedPosition(
|
||||
BlockPosition source,
|
||||
JigsawStudioCellDimensions displayDimensions,
|
||||
int displayRotationQuarterTurns
|
||||
) {
|
||||
@@ -1370,12 +1370,12 @@ public class JigsawStudioServiceCaptureTest {
|
||||
: displayDimensions.width();
|
||||
return switch (quarterTurns) {
|
||||
case 0 -> source;
|
||||
case 1 -> new IrisPosition(sourceDepth - 1 - source.getZ(), source.getY(), source.getX());
|
||||
case 2 -> new IrisPosition(
|
||||
sourceWidth - 1 - source.getX(),
|
||||
source.getY(),
|
||||
sourceDepth - 1 - source.getZ());
|
||||
case 3 -> new IrisPosition(source.getZ(), source.getY(), sourceWidth - 1 - source.getX());
|
||||
case 1 -> new BlockPosition(sourceDepth - 1 - source.z(), source.y(), source.x());
|
||||
case 2 -> new BlockPosition(
|
||||
sourceWidth - 1 - source.x(),
|
||||
source.y(),
|
||||
sourceDepth - 1 - source.z());
|
||||
case 3 -> new BlockPosition(source.z(), source.y(), sourceWidth - 1 - source.x());
|
||||
default -> throw new IllegalStateException("Unreachable Jigsaw Studio test rotation");
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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.JigsawStudioBay;
|
||||
import art.arcane.iris.core.runtime.jigsaw.JigsawStudioCellDimensions;
|
||||
@@ -81,7 +80,7 @@ public class JigsawStudioWorldListenerTest {
|
||||
JigsawStudioMode.PLANAR_JIGSAW,
|
||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||
dimensions,
|
||||
mock(IrisData.class),
|
||||
StudioToolPacks.toolPack(),
|
||||
layout,
|
||||
OWNER);
|
||||
service.registry().finishOpen(OWNER);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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.runtime.StudioOpenCoordinator;
|
||||
import art.arcane.iris.core.runtime.StudioSlotOccupant;
|
||||
@@ -177,7 +176,7 @@ public class StudioSVCJigsawProtectionTest {
|
||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||
JigsawStudioCompatibilityTarget.IRIS_EXTENDED,
|
||||
dimensions,
|
||||
mock(IrisData.class),
|
||||
StudioToolPacks.toolPack(),
|
||||
JigsawStudioLayout.create(
|
||||
JigsawStudioMode.SPATIAL_JIGSAW,
|
||||
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.IrisJigsawPieceEntry;
|
||||
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.spi.PlatformBlockState;
|
||||
import com.volmit.block.BlockState;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.nbt.io.NBTUtil;
|
||||
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.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class VillageImporterConnectorRoundTripTest {
|
||||
private static final String FINAL_STATE =
|
||||
@@ -77,7 +76,8 @@ public class VillageImporterConnectorRoundTripTest {
|
||||
VanillaJigsawExportSource source = VanillaJigsawExportSource.forStructure(
|
||||
"metadata",
|
||||
graph.structure,
|
||||
graph
|
||||
graph,
|
||||
graph.objects::get
|
||||
);
|
||||
VanillaJigsawExportResult result = new VanillaJigsawDatapackExporter().export(
|
||||
VanillaJigsawExportRequest.builder(source, output)
|
||||
@@ -98,11 +98,8 @@ public class VillageImporterConnectorRoundTripTest {
|
||||
|
||||
private static TestGraph graph(IrisJigsawPiece piece, IrisJigsawConnector connector) {
|
||||
TestGraph graph = new TestGraph();
|
||||
IrisObject object = new IrisObject(3, 3, 3);
|
||||
PlatformBlockState finalState = mock(PlatformBlockState.class);
|
||||
when(finalState.key()).thenReturn(connector.getFinalState());
|
||||
object.setUnsigned(1, 1, 0, finalState);
|
||||
graph.objects.put("objects/start", object);
|
||||
graph.objects.put("objects/start", ObjectContents.plain(3, 3, 3,
|
||||
Map.of(new BlockPosition(1, 1, 0), BlockState.parse(connector.getFinalState())), Map.of()));
|
||||
graph.pieces.put("pieces/start", piece);
|
||||
graph.pools.put("pools/start", new IrisJigsawPool().setPieces(new KList<>(
|
||||
new IrisJigsawPieceEntry("pieces/start", 1)
|
||||
@@ -117,14 +114,13 @@ public class VillageImporterConnectorRoundTripTest {
|
||||
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH)
|
||||
.setCompatibility(IrisJigsawCompatibility.VANILLA_PORTABLE)
|
||||
.setPlaceMode(ObjectPlaceMode.STRUCTURE_PIECE);
|
||||
graph.structure.setLoadKey("metadata");
|
||||
return graph;
|
||||
}
|
||||
|
||||
private static final class TestGraph implements StructureGraphResolver {
|
||||
private final Map<String, IrisJigsawPool> pools = 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;
|
||||
|
||||
@Override
|
||||
@@ -138,8 +134,9 @@ public class VillageImporterConnectorRoundTripTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject loadObject(String key) {
|
||||
return objects.get(key);
|
||||
public ObjectFrame loadObject(String 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.blocks.ObjectReplace;
|
||||
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.IrisJigsawCompatibility;
|
||||
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.IrisJigsawPool;
|
||||
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.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.nbt.io.NBTUtil;
|
||||
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.ListTag;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
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.assertNotNull;
|
||||
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 {
|
||||
private static PlatformBlockState stone;
|
||||
private static final BlockState STONE = new BlockState("minecraft:stone");
|
||||
private static final BlockState AIR = new BlockState("minecraft:air");
|
||||
|
||||
@Rule
|
||||
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
|
||||
public void exportsComplete26_2DirectoryAndConnectorTemplate() throws Exception {
|
||||
TestGraph graph = connectorGraph();
|
||||
@@ -166,22 +144,21 @@ public class VanillaJigsawDatapackExporterTest {
|
||||
@Test
|
||||
public void preservesExplicitAirAndStructureVoidConnectorFinalStates() throws Exception {
|
||||
TestGraph graph = terminalGraph();
|
||||
PlatformBlockState air = blockState("minecraft:air");
|
||||
IrisObject object = graph.objects.get("objects/start");
|
||||
object.setUnsigned(0, 1, 1, air);
|
||||
graph.objects.put("objects/start", ObjectContents.plain(3, 3, 3,
|
||||
Map.of(new BlockPosition(1, 1, 1), STONE, new BlockPosition(0, 1, 1), AIR), Map.of()));
|
||||
IrisJigsawPiece piece = graph.pieces.get("pieces/start");
|
||||
piece.getConnectors().add(new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(0, 1, 1))
|
||||
.setDirection(IrisDirection.WEST_NEGATIVE_X)
|
||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
||||
.setPosition(new BlockPosition(0, 1, 1))
|
||||
.setDirection(JigsawDirection.WEST_NEGATIVE_X)
|
||||
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||
.setPool("pools/terminal")
|
||||
.setName("studio:air")
|
||||
.setTargetName("studio:door")
|
||||
.setFinalState("minecraft:air"));
|
||||
piece.getConnectors().add(new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(2, 1, 1))
|
||||
.setDirection(IrisDirection.EAST_POSITIVE_X)
|
||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
||||
.setPosition(new BlockPosition(2, 1, 1))
|
||||
.setDirection(JigsawDirection.EAST_POSITIVE_X)
|
||||
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||
.setPool("pools/terminal")
|
||||
.setName("studio:void")
|
||||
.setTargetName("studio:door")
|
||||
@@ -211,7 +188,8 @@ public class VanillaJigsawDatapackExporterTest {
|
||||
@Test
|
||||
public void rejectsTilePayloadWithoutPublishingPartialOutput() {
|
||||
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");
|
||||
|
||||
VanillaJigsawExportResult result = new VanillaJigsawDatapackExporter().export(
|
||||
@@ -310,18 +288,18 @@ public class VanillaJigsawDatapackExporterTest {
|
||||
VanillaJigsawExportSource source = VanillaJigsawExportSource.forStructure(
|
||||
"test_structure",
|
||||
graph.structure,
|
||||
graph);
|
||||
graph,
|
||||
graph.objects::get);
|
||||
return VanillaJigsawExportRequest.builder(source, output);
|
||||
}
|
||||
|
||||
private static TestGraph connectorGraph() {
|
||||
TestGraph graph = new TestGraph();
|
||||
IrisObject object = new IrisObject(3, 3, 3);
|
||||
object.setUnsigned(1, 1, 0, stone);
|
||||
ObjectContents object = ObjectContents.plain(3, 3, 3, Map.of(new BlockPosition(1, 1, 0), STONE), Map.of());
|
||||
IrisJigsawConnector connector = new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(1, 1, 0))
|
||||
.setDirection(IrisDirection.NORTH_NEGATIVE_Z)
|
||||
.setTop(IrisDirection.UP_POSITIVE_Y)
|
||||
.setPosition(new BlockPosition(1, 1, 0))
|
||||
.setDirection(JigsawDirection.NORTH_NEGATIVE_Z)
|
||||
.setTop(JigsawDirection.UP_POSITIVE_Y)
|
||||
.setPool("pools/terminal")
|
||||
.setName("studio:source")
|
||||
.setTargetName("studio:door")
|
||||
@@ -338,9 +316,7 @@ public class VanillaJigsawDatapackExporterTest {
|
||||
|
||||
private static TestGraph terminalGraph() {
|
||||
TestGraph graph = new TestGraph();
|
||||
IrisObject object = new IrisObject(3, 3, 3);
|
||||
object.setUnsigned(1, 1, 1, stone);
|
||||
graph.objects.put("objects/start", object);
|
||||
graph.objects.put("objects/start", ObjectContents.plain(3, 3, 3, Map.of(new BlockPosition(1, 1, 1), STONE), Map.of()));
|
||||
graph.pieces.put("pieces/start", piece("objects/start"));
|
||||
graph.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
graph.structure = structure("pools/start");
|
||||
@@ -349,7 +325,6 @@ public class VanillaJigsawDatapackExporterTest {
|
||||
|
||||
private static IrisStructure structure(String startPool) {
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setLoadKey("test_structure");
|
||||
structure.setStartPool(startPool);
|
||||
structure.setMaxDepth(4);
|
||||
structure.setMaxSizeChunks(4);
|
||||
@@ -377,13 +352,6 @@ public class VanillaJigsawDatapackExporterTest {
|
||||
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 {
|
||||
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 final Map<String, IrisJigsawPool> pools = 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;
|
||||
|
||||
@Override
|
||||
@@ -412,8 +380,9 @@ public class VanillaJigsawDatapackExporterTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject loadObject(String key) {
|
||||
return objects.get(key);
|
||||
public ObjectFrame loadObject(String 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.IrisStructureAdoptionStrategy;
|
||||
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.IrisJigsawPiece;
|
||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawDirection;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.tooling.Argument;
|
||||
import com.volmit.tooling.Command;
|
||||
@@ -270,8 +270,8 @@ public class JigsawCommandsContractTest {
|
||||
public void pieceAddUsesCanonicalAxesForRotatedRectangularPlanarWorkcells() {
|
||||
JigsawStudioLayout layout = nonuniformPlanarLayout();
|
||||
IrisJigsawPiece eastEnd = new IrisJigsawPiece();
|
||||
eastEnd.getConnectors().add(new IrisJigsawConnector().setDirection(IrisDirection.EAST_POSITIVE_X));
|
||||
IrisObject exactObject = new IrisObject(7, 5, 13);
|
||||
eastEnd.getConnectors().add(new IrisJigsawConnector().setDirection(JigsawDirection.EAST_POSITIVE_X));
|
||||
ObjectFrame exactObject = new ObjectFrame(7, 5, 13);
|
||||
|
||||
GraphMutations.PieceWorkcellResolution exact = GraphMutations.resolvePieceWorkcell(
|
||||
layout,
|
||||
@@ -280,13 +280,13 @@ public class JigsawCommandsContractTest {
|
||||
GraphMutations.PieceWorkcellResolution oversized = GraphMutations.resolvePieceWorkcell(
|
||||
layout,
|
||||
eastEnd,
|
||||
new IrisObject(8, 5, 13));
|
||||
new ObjectFrame(8, 5, 13));
|
||||
|
||||
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());
|
||||
assertTrue(exact.fits());
|
||||
assertTrue(exactObject.getD() > exact.workcell().capacity().depth());
|
||||
assertTrue(exactObject.depth() > exact.workcell().capacity().depth());
|
||||
assertFalse(oversized.fits());
|
||||
}
|
||||
|
||||
@@ -299,15 +299,15 @@ public class JigsawCommandsContractTest {
|
||||
JigsawStudioVariantCatalog.empty());
|
||||
IrisJigsawPiece spatialPiece = new IrisJigsawPiece();
|
||||
spatialPiece.getConnectors().add(
|
||||
new IrisJigsawConnector().setDirection(IrisDirection.EAST_POSITIVE_X));
|
||||
new IrisJigsawConnector().setDirection(JigsawDirection.EAST_POSITIVE_X));
|
||||
|
||||
GraphMutations.PieceWorkcellResolution resolution = GraphMutations.resolvePieceWorkcell(
|
||||
layout,
|
||||
spatialPiece,
|
||||
new IrisObject(7, 5, 13));
|
||||
new ObjectFrame(7, 5, 13));
|
||||
|
||||
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());
|
||||
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.engine.framework.structure.StructureResources;
|
||||
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.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.structure.jigsaw.IrisJigsawConnector;
|
||||
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.IrisJigsawPool;
|
||||
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.structure.IrisStructure;
|
||||
import art.arcane.iris.builtin.structure.StructureAnchorMode;
|
||||
@@ -46,7 +47,12 @@ import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.host.ModuleLogs;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
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 static art.arcane.iris.engine.framework.StructurePlacementFixtures.placement;
|
||||
@@ -118,8 +124,8 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void locatableIndexIncludesAliasesAndSeparatesEditableFromNativePlacements() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setLoadKey("test:city");
|
||||
structure.setVanillaSource("source:city");
|
||||
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.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));
|
||||
assertEquals(Set.of("test:city_definition", "test:city", "source:city"),
|
||||
assertEquals(Set.of("test:city_definition", "source:city"),
|
||||
IrisStructureLocator.locatableEditableKeys(engine));
|
||||
assertEquals(Set.of("source:native_city"), IrisStructureLocator.locatableNativeKeys(engine));
|
||||
assertTrue(IrisStructureLocator.hasLocatableEditablePlacement(engine, "SOURCE:CITY"));
|
||||
@@ -160,6 +166,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void nativeStructureReplacementSuppressesOnlyItsRegisteredSource() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
Engine engine = mock(Engine.class);
|
||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||
IrisDimension dimension = mock(IrisDimension.class);
|
||||
@@ -189,8 +196,8 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void vanillaSourceRequiresExplicitDimensionSuppression() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setLoadKey("test:city");
|
||||
structure.setVanillaSource("minecraft:ancient_city");
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||
registerSinglePieceGraph(data, structure, "test:city");
|
||||
@@ -220,8 +227,8 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void regionReplacementFailsInsteadOfFallingBackToNative() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setLoadKey("test:city");
|
||||
structure.setVanillaSource("minecraft:ancient_city");
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||
registerSinglePieceGraph(data, structure, "test:city");
|
||||
@@ -250,21 +257,21 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void geometryFailureFailsInsteadOfFallingBackToNative() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure()
|
||||
.setStartPool("test:start")
|
||||
.setMaxDepth(1)
|
||||
.setMaxSizeChunks(1)
|
||||
.setVanillaSource("minecraft:ancient_city");
|
||||
structure.setLoadKey("test:city");
|
||||
IrisJigsawConnector source = new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(0, 0, 0))
|
||||
.setDirection(IrisDirection.EAST_POSITIVE_X)
|
||||
.setPosition(new BlockPosition(0, 0, 0))
|
||||
.setDirection(JigsawDirection.EAST_POSITIVE_X)
|
||||
.setPool("test:target")
|
||||
.setName("source")
|
||||
.setTargetName("door");
|
||||
IrisJigsawConnector target = new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(50, 0, 0))
|
||||
.setDirection(IrisDirection.WEST_NEGATIVE_X)
|
||||
.setPosition(new BlockPosition(50, 0, 0))
|
||||
.setDirection(JigsawDirection.WEST_NEGATIVE_X)
|
||||
.setPool("test:target")
|
||||
.setName("door")
|
||||
.setTargetName("unused");
|
||||
@@ -276,22 +283,13 @@ public class IrisStructureLocatorContractTest {
|
||||
startPool.getPieces().add(new IrisJigsawPieceEntry("test:start-piece", 1));
|
||||
IrisJigsawPool targetPool = new IrisJigsawPool();
|
||||
targetPool.getPieces().add(new IrisJigsawPieceEntry("test:target-piece", 1));
|
||||
IrisObject startObject = mock(IrisObject.class);
|
||||
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).object("test:start-object", 1, 1, 1).object("test:target-object", 100, 1, 1);
|
||||
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:target", targetPool);
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, "test:start-piece", startPiece);
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, "test:target-piece", targetPiece);
|
||||
when(data.load(IrisObject.class, "test:start-object", false)).thenReturn(startObject);
|
||||
when(data.load(IrisObject.class, "test:target-object", false)).thenReturn(targetObject);
|
||||
assertFalse(StructureGraphCatalog.compile(data, structure, ModuleLogs.discarding()).isAssemblyViable());
|
||||
assertFalse(StructureGraphCatalog.compile(data.getPackResources(), "test:city", structure, ModuleLogs.discarding()).isAssemblyViable());
|
||||
|
||||
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||
withAdded(placement, "structures", "test:city");
|
||||
@@ -312,8 +310,8 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void missingVanillaSourceFailsInsteadOfFallingBackToNative() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setLoadKey("test:city");
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||
registerSinglePieceGraph(data, structure, "test:city");
|
||||
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||
@@ -335,6 +333,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void missingNonReplacementStructureFailsInsteadOfBeingSkipped() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serve(data);
|
||||
StructurePlacement placement = new StructurePlacement();
|
||||
withAdded(placement, "structures", "test:missing");
|
||||
@@ -512,6 +511,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void placementIndexIsKeptPerWorld() {
|
||||
IrisData sharedData = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(sharedData, new StructureModelModule(), new StructureModule());
|
||||
Engine firstEngine = emptyEngine(sharedData);
|
||||
Engine secondEngine = emptyEngine(sharedData);
|
||||
Set<String> firstIndex = IrisStructureLocator.placedKeys(firstEngine);
|
||||
@@ -524,15 +524,15 @@ public class IrisStructureLocatorContractTest {
|
||||
|
||||
@Test
|
||||
public void assembledBoundsMustFitVerticallyAndHorizontally() {
|
||||
KList<PlacedStructurePiece> fitting = new KList<>();
|
||||
KList<AssembledPiece> fitting = new KList<>();
|
||||
fitting.add(piece(-4, 1, -4, 4, 20, 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));
|
||||
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));
|
||||
assertFalse(IrisStructureLocator.fitsWorldBounds(outsideRadius, 0, 20, 0, 0, 4));
|
||||
}
|
||||
@@ -556,9 +556,7 @@ public class IrisStructureLocatorContractTest {
|
||||
String selectedKey = IrisStructureLocator.selectStructureKey(placement, selectsLast);
|
||||
assertEquals("test:second", selectedKey);
|
||||
|
||||
IrisStructure selected = new IrisStructure();
|
||||
selected.setLoadKey("test:second");
|
||||
selected.setVanillaSource("minecraft:second");
|
||||
StructureStamp selected = new StructureStamp(ObjectPlaceMode.STRUCTURE_PIECE, List.of(), List.of(), "minecraft:second");
|
||||
IrisStructureLocator.ResolvedPlacement resolved = new IrisStructureLocator.ResolvedPlacement(
|
||||
placement, selectedKey, selected, new KList<>(), selectsLast, 0, 64, 0, false);
|
||||
assertFalse(IrisStructureLocator.matchesResolved(resolved, "test:first"));
|
||||
@@ -573,40 +571,40 @@ public class IrisStructureLocatorContractTest {
|
||||
TestSettings.with(placement, "minHeight", -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));
|
||||
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));
|
||||
assertNull(IrisStructureLocator.resolveVerticalShift(tooTall, placement, 0, 0, 319));
|
||||
|
||||
TestSettings.with(placement, "underground", false);
|
||||
KList<PlacedStructurePiece> clippedSurface = new KList<>();
|
||||
KList<AssembledPiece> clippedSurface = new KList<>();
|
||||
clippedSurface.add(piece(-4, 300, -4, 4, 330, 4));
|
||||
assertNull(IrisStructureLocator.resolveVerticalShift(clippedSurface, placement, 300, -64, 319));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void caveAssemblyBoundsAlignToTheRequestedAnchorFace() {
|
||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
||||
KList<AssembledPiece> pieces = new KList<>();
|
||||
pieces.add(piece(-2, 10, -2, 2, 14, 2));
|
||||
StructurePlacement placement = new StructurePlacement();
|
||||
|
||||
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_FLOOR);
|
||||
KList<PlacedStructurePiece> floor = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||
assertEquals(40, floor.getFirst().getMinY());
|
||||
assertEquals(44, floor.getFirst().getMaxY());
|
||||
KList<AssembledPiece> floor = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||
assertEquals(40, floor.getFirst().minY());
|
||||
assertEquals(44, floor.getFirst().maxY());
|
||||
|
||||
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_CEILING);
|
||||
KList<PlacedStructurePiece> ceiling = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||
assertEquals(36, ceiling.getFirst().getMinY());
|
||||
assertEquals(40, ceiling.getFirst().getMaxY());
|
||||
KList<AssembledPiece> ceiling = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||
assertEquals(36, ceiling.getFirst().minY());
|
||||
assertEquals(40, ceiling.getFirst().maxY());
|
||||
|
||||
TestSettings.with(placement, "anchor", StructureAnchorMode.CAVE_CENTER);
|
||||
KList<PlacedStructurePiece> center = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||
assertEquals(38, center.getFirst().getMinY());
|
||||
assertEquals(42, center.getFirst().getMaxY());
|
||||
KList<AssembledPiece> center = IrisStructureLocator.alignCavePieces(pieces, placement, 40);
|
||||
assertEquals(38, center.getFirst().minY());
|
||||
assertEquals(42, center.getFirst().maxY());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -637,7 +635,7 @@ public class IrisStructureLocatorContractTest {
|
||||
TestSettings.with(placement, "underground", true);
|
||||
TestSettings.with(placement, "minHeight", -64);
|
||||
TestSettings.with(placement, "maxHeight", 100);
|
||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
||||
KList<AssembledPiece> pieces = new KList<>();
|
||||
pieces.add(piece(0, 60, 0, 1, 80, 0));
|
||||
|
||||
assertEquals(Integer.valueOf(-5), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||
@@ -660,7 +658,7 @@ public class IrisStructureLocatorContractTest {
|
||||
TestSettings.with(placement, "minHeight", -64);
|
||||
TestSettings.with(placement, "maxHeight", 100);
|
||||
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));
|
||||
|
||||
assertEquals(Integer.valueOf(-14), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||
@@ -686,7 +684,7 @@ public class IrisStructureLocatorContractTest {
|
||||
when(engine.getMinHeight()).thenReturn(-64);
|
||||
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"));
|
||||
KList<PlacedStructurePiece> pieces = new KList<>();
|
||||
KList<AssembledPiece> pieces = new KList<>();
|
||||
pieces.add(piece(4, 60, 7, 4, 80, 7));
|
||||
|
||||
assertEquals(Integer.valueOf(0), IrisStructureLocator.resolveUndergroundBurialShift(
|
||||
@@ -697,23 +695,19 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void exactYOnlyCoversPlacementPathsWithResolvedAbsoluteAnchors() {
|
||||
StructurePlacement placement = new StructurePlacement();
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||
KList<PlacedStructurePiece> onePiece = new KList<>();
|
||||
KList<AssembledPiece> onePiece = new KList<>();
|
||||
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, structure, onePiece));
|
||||
assertTrue(IrisStructureLocator.hasExactY(placement, stamp(ObjectPlaceMode.STRUCTURE_PIECE), onePiece));
|
||||
|
||||
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||
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);
|
||||
KList<PlacedStructurePiece> multiplePieces = new KList<>(onePiece);
|
||||
KList<AssembledPiece> multiplePieces = new KList<>(onePiece);
|
||||
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
|
||||
@@ -778,8 +772,12 @@ public class IrisStructureLocatorContractTest {
|
||||
return dx * dx + dz * dz;
|
||||
}
|
||||
|
||||
private PlacedStructurePiece 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);
|
||||
private AssembledPiece piece(int minX, int minY, int minZ, int maxX, int maxY, int 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) {
|
||||
@@ -797,8 +795,8 @@ public class IrisStructureLocatorContractTest {
|
||||
private Engine densityEngine(double density, boolean underground, int worldMin, int worldHeight,
|
||||
int placementMin, int placementMax) {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setLoadKey("test:density");
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:density", structure);
|
||||
registerSinglePieceGraph(data, structure, "test:density");
|
||||
|
||||
@@ -836,13 +834,9 @@ public class IrisStructureLocatorContractTest {
|
||||
pool.getPieces().add(new IrisJigsawPieceEntry().setPiece(pieceKey).setWeight(1));
|
||||
IrisJigsawPiece piece = new IrisJigsawPiece();
|
||||
piece.setObject(objectKey);
|
||||
IrisObject object = mock(IrisObject.class);
|
||||
when(object.getW()).thenReturn(1);
|
||||
when(object.getH()).thenReturn(1);
|
||||
when(object.getD()).thenReturn(1);
|
||||
ModuleResourceFixture.of(data).object(objectKey, 1, 1, 1);
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, poolKey, pool);
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, pieceKey, piece);
|
||||
when(data.load(IrisObject.class, objectKey, false)).thenReturn(object);
|
||||
}
|
||||
|
||||
private void assertReplacementFailure(Runnable operation, String expectedMessage) {
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.structure.MapStructureResolver;
|
||||
import art.arcane.iris.engine.framework.structure.ObjectFrame;
|
||||
import art.arcane.iris.engine.framework.structure.StructureAssemblyResult;
|
||||
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.IrisJigsawConnector;
|
||||
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.IrisJigsawPool;
|
||||
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.jigsaw.JigsawJoint;
|
||||
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.PlatformRegistries;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.host.ModuleLogs;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -77,16 +74,16 @@ public class StructureAssemblerTest {
|
||||
@Test
|
||||
public void attachedNonRotatablePieceKeepsItsAuthoredFacing() {
|
||||
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);
|
||||
IrisJigsawConnector candidateConnector = connector(IrisDirection.NORTH_NEGATIVE_Z, "", "door", "");
|
||||
IrisJigsawConnector candidateConnector = connector(JigsawDirection.NORTH_NEGATIVE_Z, "", "door", "");
|
||||
IrisJigsawPiece candidatePiece = piece("candidate-object", false, candidateConnector);
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("target", pool("", "candidate-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("candidate-piece", candidatePiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("candidate-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("candidate-object", new ObjectFrame(1, 1, 1));
|
||||
|
||||
StructureAssemblyResult fixed = fixture.assembler(
|
||||
structure("start", 1), 0, 0, 0).assemble(new RNG(11L));
|
||||
@@ -105,20 +102,20 @@ public class StructureAssemblerTest {
|
||||
public void fallbackCandidatesAreTriedAfterPrimaryCandidatesFail() {
|
||||
Fixture fixture = new Fixture();
|
||||
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,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||
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("branch", pool("fallback", "incompatible-piece"));
|
||||
fixture.pool("fallback", pool("", "fallback-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("incompatible-piece", incompatiblePiece);
|
||||
fixture.piece("fallback-piece", fallbackPiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("incompatible-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("fallback-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("incompatible-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("fallback-object", new ObjectFrame(1, 1, 1));
|
||||
|
||||
List<PlacedStructurePiece> placed = completedPieces(
|
||||
fixture.assembler(structure("start", 2), 0, 0, 0), new RNG(29L));
|
||||
@@ -139,21 +136,21 @@ public class StructureAssemblerTest {
|
||||
public void branchTerminationPolicyEndsOnlyAnUnmatchedOptionalBranch() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "target", "start", "door"),
|
||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "sibling", "start", "hall"));
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "target", "start", "door"),
|
||||
connector(JigsawDirection.SOUTH_POSITIVE_Z, "sibling", "start", "hall"));
|
||||
IrisJigsawPiece incompatiblePiece = piece("incompatible-object", false,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||
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("target", pool("", "incompatible-piece"));
|
||||
fixture.pool("sibling", pool("", "sibling-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("incompatible-piece", incompatiblePiece);
|
||||
fixture.piece("sibling-piece", siblingPiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("incompatible-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("sibling-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("incompatible-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("sibling-object", new ObjectFrame(1, 1, 1));
|
||||
|
||||
StructureAssemblyResult strict = fixture.assembler(
|
||||
structure("start", 2), 0, 0, 0).assemble(new RNG(17L));
|
||||
@@ -173,17 +170,17 @@ public class StructureAssemblerTest {
|
||||
public void requiredFallbackOverridesBranchTerminationPolicy() {
|
||||
Fixture fixture = new Fixture();
|
||||
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,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", "unused"));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", "unused"));
|
||||
capPiece.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("target", pool("caps"));
|
||||
fixture.pool("caps", pool("", "cap-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("cap-piece", capPiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("cap-object", new IrisObject(64, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("cap-object", new ObjectFrame(64, 1, 1));
|
||||
IrisStructure structure = structure("start", 2)
|
||||
.setMaxSizeChunks(1)
|
||||
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
||||
@@ -203,9 +200,9 @@ public class StructureAssemblerTest {
|
||||
public void explicitEmptyAndEmptyPrimaryPoolsCutOffDirectFallback() {
|
||||
Fixture fixture = new Fixture();
|
||||
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,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
IrisJigsawPool explicitEmpty = pool("fallback");
|
||||
explicitEmpty.getPieces().add(new IrisJigsawPieceEntry().setEmpty(true).setWeight(1));
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
@@ -213,8 +210,8 @@ public class StructureAssemblerTest {
|
||||
fixture.pool("fallback", pool("", "fallback-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("fallback-piece", fallbackPiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("fallback-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("fallback-object", new ObjectFrame(1, 1, 1));
|
||||
IrisStructure structure = structure("start", 2)
|
||||
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
||||
|
||||
@@ -233,25 +230,25 @@ public class StructureAssemblerTest {
|
||||
@Test
|
||||
public void alignedRuntimeConnectorsPreserveTopOrientation() {
|
||||
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)
|
||||
.setTop(IrisDirection.UP_POSITIVE_Y);
|
||||
IrisJigsawConnector target = connector(IrisDirection.WEST_NEGATIVE_X, "target", "door", "unused")
|
||||
.setTop(IrisDirection.DOWN_NEGATIVE_Y);
|
||||
.setTop(JigsawDirection.UP_POSITIVE_Y);
|
||||
IrisJigsawConnector target = connector(JigsawDirection.WEST_NEGATIVE_X, "target", "door", "unused")
|
||||
.setTop(JigsawDirection.DOWN_NEGATIVE_Y);
|
||||
IrisJigsawPiece startPiece = piece("start-object", false, source);
|
||||
IrisJigsawPiece targetPiece = piece("target-object", false, target);
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("target", pool("", "target-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("target-piece", targetPiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("target-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("target-object", new ObjectFrame(1, 1, 1));
|
||||
|
||||
assertEquals(StructureAssemblyStatus.FAILED_UNCAPPED,
|
||||
fixture.assembler(structure("start", 1), 0, 0, 0)
|
||||
.assemble(new RNG(13L)).status());
|
||||
|
||||
target.setTop(IrisDirection.UP_POSITIVE_Y);
|
||||
target.setTop(JigsawDirection.UP_POSITIVE_Y);
|
||||
List<PlacedStructurePiece> placed = completedPieces(
|
||||
fixture.assembler(structure("start", 1), 0, 0, 0), new RNG(13L));
|
||||
assertEquals(2, placed.size());
|
||||
@@ -261,31 +258,31 @@ public class StructureAssemblerTest {
|
||||
public void planarCanonicalSocketsPlaceEveryNeighborOnTheExactCellGrid() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawConnector northSource = connector(
|
||||
IrisDirection.NORTH_NEGATIVE_Z, "north", "start", "door")
|
||||
.setPosition(new IrisPosition(8, 4, 0));
|
||||
JigsawDirection.NORTH_NEGATIVE_Z, "north", "start", "door")
|
||||
.setPosition(new BlockPosition(8, 4, 0));
|
||||
IrisJigsawConnector eastSource = connector(
|
||||
IrisDirection.EAST_POSITIVE_X, "east", "start", "door")
|
||||
.setPosition(new IrisPosition(15, 4, 8));
|
||||
JigsawDirection.EAST_POSITIVE_X, "east", "start", "door")
|
||||
.setPosition(new BlockPosition(15, 4, 8));
|
||||
IrisJigsawConnector southSource = connector(
|
||||
IrisDirection.SOUTH_POSITIVE_Z, "south", "start", "door")
|
||||
.setPosition(new IrisPosition(8, 4, 15));
|
||||
JigsawDirection.SOUTH_POSITIVE_Z, "south", "start", "door")
|
||||
.setPosition(new BlockPosition(8, 4, 15));
|
||||
IrisJigsawConnector westSource = connector(
|
||||
IrisDirection.WEST_NEGATIVE_X, "west", "start", "door")
|
||||
.setPosition(new IrisPosition(0, 4, 8));
|
||||
JigsawDirection.WEST_NEGATIVE_X, "west", "start", "door")
|
||||
.setPosition(new BlockPosition(0, 4, 8));
|
||||
IrisJigsawPiece startPiece = piece(
|
||||
"start-object", false, northSource, eastSource, southSource, westSource);
|
||||
IrisJigsawPiece northPiece = piece("north-object", false,
|
||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "", "door", "")
|
||||
.setPosition(new IrisPosition(8, 4, 15)));
|
||||
connector(JigsawDirection.SOUTH_POSITIVE_Z, "", "door", "")
|
||||
.setPosition(new BlockPosition(8, 4, 15)));
|
||||
IrisJigsawPiece eastPiece = piece("east-object", false,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", "")
|
||||
.setPosition(new IrisPosition(0, 4, 8)));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", "")
|
||||
.setPosition(new BlockPosition(0, 4, 8)));
|
||||
IrisJigsawPiece southPiece = piece("south-object", false,
|
||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "", "door", "")
|
||||
.setPosition(new IrisPosition(8, 4, 0)));
|
||||
connector(JigsawDirection.NORTH_NEGATIVE_Z, "", "door", "")
|
||||
.setPosition(new BlockPosition(8, 4, 0)));
|
||||
IrisJigsawPiece westPiece = piece("west-object", false,
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "", "door", "")
|
||||
.setPosition(new IrisPosition(15, 4, 8)));
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "", "door", "")
|
||||
.setPosition(new BlockPosition(15, 4, 8)));
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("north", pool("", "north-piece"));
|
||||
fixture.pool("east", pool("", "east-piece"));
|
||||
@@ -296,14 +293,14 @@ public class StructureAssemblerTest {
|
||||
fixture.piece("east-piece", eastPiece);
|
||||
fixture.piece("south-piece", southPiece);
|
||||
fixture.piece("west-piece", westPiece);
|
||||
fixture.object("start-object", new IrisObject(16, 8, 16));
|
||||
fixture.object("north-object", new IrisObject(16, 8, 16));
|
||||
fixture.object("east-object", new IrisObject(16, 8, 16));
|
||||
fixture.object("south-object", new IrisObject(16, 8, 16));
|
||||
fixture.object("west-object", new IrisObject(16, 8, 16));
|
||||
fixture.object("start-object", new ObjectFrame(16, 8, 16));
|
||||
fixture.object("north-object", new ObjectFrame(16, 8, 16));
|
||||
fixture.object("east-object", new ObjectFrame(16, 8, 16));
|
||||
fixture.object("south-object", new ObjectFrame(16, 8, 16));
|
||||
fixture.object("west-object", new ObjectFrame(16, 8, 16));
|
||||
IrisStructure structure = structure("start", 1)
|
||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||
.setCellSize(new IrisPosition(16, 8, 16));
|
||||
.setCellSize(new BlockPosition(16, 8, 16));
|
||||
|
||||
List<PlacedStructurePiece> placed = completedPieces(
|
||||
fixture.assembler(structure, 32, 64, -48), new RNG(127L));
|
||||
@@ -336,23 +333,23 @@ public class StructureAssemblerTest {
|
||||
public void selectionPriorityProcessesHigherConnectorsFirstAndPreservesStableTies() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawConnector eastSource = connector(
|
||||
IrisDirection.EAST_POSITIVE_X, "east", "start", "door").setSelectionPriority(-20);
|
||||
JigsawDirection.EAST_POSITIVE_X, "east", "start", "door").setSelectionPriority(-20);
|
||||
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 eastPiece = piece("east-object", false,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
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("east", pool("", "east-piece"));
|
||||
fixture.pool("west", pool("", "west-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("east-piece", eastPiece);
|
||||
fixture.piece("west-piece", westPiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("east-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("west-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("east-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("west-object", new ObjectFrame(1, 1, 1));
|
||||
IrisStructure structure = structure("start", 1);
|
||||
|
||||
List<PlacedStructurePiece> prioritized = completedPieces(
|
||||
@@ -374,20 +371,20 @@ public class StructureAssemblerTest {
|
||||
public void selectionPriorityChoosesHigherCandidateConnectorAndPreservesStableTies() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawPiece startPiece = piece("start-object", false,
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "target", "start", "door"));
|
||||
IrisJigsawConnector low = connector(IrisDirection.WEST_NEGATIVE_X, "", "door", "")
|
||||
.setPosition(new IrisPosition(0, 0, 0))
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "target", "start", "door"));
|
||||
IrisJigsawConnector low = connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", "")
|
||||
.setPosition(new BlockPosition(0, 0, 0))
|
||||
.setSelectionPriority(-20);
|
||||
IrisJigsawConnector high = connector(IrisDirection.WEST_NEGATIVE_X, "", "door", "")
|
||||
.setPosition(new IrisPosition(0, 0, 2))
|
||||
IrisJigsawConnector high = connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", "")
|
||||
.setPosition(new BlockPosition(0, 0, 2))
|
||||
.setSelectionPriority(-10);
|
||||
IrisJigsawPiece targetPiece = piece("target-object", false, low, high);
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("target", pool("", "target-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("target-piece", targetPiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("target-object", new IrisObject(1, 1, 3));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("target-object", new ObjectFrame(1, 1, 3));
|
||||
IrisStructure structure = structure("start", 1);
|
||||
|
||||
List<PlacedStructurePiece> prioritized = completedPieces(
|
||||
@@ -406,20 +403,20 @@ public class StructureAssemblerTest {
|
||||
public void placementPrioritySchedulesChildExpansionAfterTheCurrentPieceAndPreservesStableTies() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawConnector eastSource = connector(
|
||||
IrisDirection.EAST_POSITIVE_X, "east", "start", "door").setPlacementPriority(-20);
|
||||
JigsawDirection.EAST_POSITIVE_X, "east", "start", "door").setPlacementPriority(-20);
|
||||
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 eastPiece = piece("east-object", false,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""),
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "east-leaf", "east", "leaf"));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""),
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "east-leaf", "east", "leaf"));
|
||||
IrisJigsawPiece westPiece = piece("west-object", false,
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "", "door", ""),
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "west-leaf", "west", "leaf"));
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "", "door", ""),
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "west-leaf", "west", "leaf"));
|
||||
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,
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "", "leaf", ""));
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "", "leaf", ""));
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("east", pool("", "east-piece"));
|
||||
fixture.pool("west", pool("", "west-piece"));
|
||||
@@ -430,11 +427,11 @@ public class StructureAssemblerTest {
|
||||
fixture.piece("west-piece", westPiece);
|
||||
fixture.piece("east-leaf-piece", eastLeaf);
|
||||
fixture.piece("west-leaf-piece", westLeaf);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("east-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("west-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("east-leaf-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("west-leaf-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("east-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("west-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("east-leaf-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("west-leaf-object", new ObjectFrame(1, 1, 1));
|
||||
IrisStructure structure = structure("start", 2);
|
||||
|
||||
List<PlacedStructurePiece> prioritized = completedPieces(
|
||||
@@ -458,17 +455,17 @@ public class StructureAssemblerTest {
|
||||
public void connectorChannelsMustMatchExactly() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawConnector source = connector(
|
||||
IrisDirection.EAST_POSITIVE_X, "target", "start", "door").setChannel("road");
|
||||
JigsawDirection.EAST_POSITIVE_X, "target", "start", "door").setChannel("road");
|
||||
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 targetPiece = piece("target-object", false, target);
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("target", pool("", "target-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("target-piece", targetPiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("target-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("target-object", new ObjectFrame(1, 1, 1));
|
||||
IrisStructure structure = structure("start", 1);
|
||||
|
||||
assertEquals(StructureAssemblyStatus.FAILED_UNCAPPED,
|
||||
@@ -493,15 +490,15 @@ public class StructureAssemblerTest {
|
||||
public void fallbackAtMaximumDepthDoesNotExpandAgain() {
|
||||
Fixture fixture = new Fixture();
|
||||
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,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""),
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "terminal", "branch", "door"));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""),
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "terminal", "branch", "door"));
|
||||
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,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""),
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "terminal", "terminal", "door"));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""),
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "terminal", "terminal", "door"));
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("branch", pool("", "branch-piece"));
|
||||
fixture.pool("terminal", pool("terminal-fallback", "primary-terminal-piece"));
|
||||
@@ -510,10 +507,10 @@ public class StructureAssemblerTest {
|
||||
fixture.piece("branch-piece", branchPiece);
|
||||
fixture.piece("primary-terminal-piece", primaryTerminal);
|
||||
fixture.piece("fallback-terminal-piece", fallbackTerminal);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("branch-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("primary-terminal-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("fallback-terminal-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("branch-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("primary-terminal-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("fallback-terminal-object", new ObjectFrame(1, 1, 1));
|
||||
IrisStructure structure = structure("start", 1);
|
||||
structure.setMaxSizeChunks(1);
|
||||
|
||||
@@ -529,17 +526,17 @@ public class StructureAssemblerTest {
|
||||
public void fallbackOfFallbackIsNotSelected() {
|
||||
Fixture fixture = new Fixture();
|
||||
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,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("branch", pool("terminators", "incompatible-piece"));
|
||||
fixture.pool("terminators", pool("empty", "incompatible-piece"));
|
||||
fixture.pool("empty", pool(""));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("incompatible-piece", incompatiblePiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("incompatible-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("incompatible-object", new ObjectFrame(1, 1, 1));
|
||||
|
||||
assertEquals(StructureAssemblyStatus.FAILED_UNCAPPED,
|
||||
fixture.assembler(structure("start", 2), 0, 0, 0)
|
||||
@@ -552,7 +549,7 @@ public class StructureAssemblerTest {
|
||||
IrisJigsawPiece startPiece = piece("start-object", false);
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
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(
|
||||
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);
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
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);
|
||||
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++) {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawConnector source = connector(
|
||||
IrisDirection.NORTH_NEGATIVE_Z, "target", "start", "door")
|
||||
.setPosition(new IrisPosition(2, 1, 0))
|
||||
JigsawDirection.NORTH_NEGATIVE_Z, "target", "start", "door")
|
||||
.setPosition(new BlockPosition(2, 1, 0))
|
||||
.setJoint(JigsawJoint.ALIGNED);
|
||||
IrisJigsawConnector target = connector(
|
||||
IrisDirection.SOUTH_POSITIVE_Z, "", "door", "unused")
|
||||
.setPosition(new IrisPosition(2, 1, 5))
|
||||
JigsawDirection.SOUTH_POSITIVE_Z, "", "door", "unused")
|
||||
.setPosition(new BlockPosition(2, 1, 5))
|
||||
.setJoint(JigsawJoint.ALIGNED);
|
||||
IrisJigsawPiece startPiece = piece("start-object", true, source);
|
||||
IrisJigsawPiece targetPiece = piece("target-object", true, target);
|
||||
@@ -592,11 +589,11 @@ public class StructureAssemblerTest {
|
||||
fixture.pool("target", pool("", "target-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("target-piece", targetPiece);
|
||||
fixture.object("start-object", new IrisObject(4, 2, 6));
|
||||
fixture.object("target-object", new IrisObject(4, 2, 6));
|
||||
fixture.object("start-object", new ObjectFrame(4, 2, 6));
|
||||
fixture.object("target-object", new ObjectFrame(4, 2, 6));
|
||||
IrisStructure structure = structure("start", 1)
|
||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||
.setCellSize(new IrisPosition(4, 2, 6));
|
||||
.setCellSize(new BlockPosition(4, 2, 6));
|
||||
|
||||
List<PlacedStructurePiece> pieces = completedPieces(
|
||||
fixture.assembler(structure, 10, 20, 30), rotationIndex(quarterTurn));
|
||||
@@ -662,18 +659,18 @@ public class StructureAssemblerTest {
|
||||
public void pillagerOutpostAirScaffoldAllowsTheWatchtowerToOverlapItsNativeBounds() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawConnector baseEntrance = connector(
|
||||
IrisDirection.NORTH_NEGATIVE_Z,
|
||||
JigsawDirection.NORTH_NEGATIVE_Z,
|
||||
"towers",
|
||||
"minecraft:entrance",
|
||||
"minecraft:entrance")
|
||||
.setPosition(new IrisPosition(8, 1, 14))
|
||||
.setPosition(new BlockPosition(8, 1, 14))
|
||||
.setJoint(JigsawJoint.ALIGNED);
|
||||
IrisJigsawConnector towerEntrance = connector(
|
||||
IrisDirection.SOUTH_POSITIVE_Z,
|
||||
JigsawDirection.SOUTH_POSITIVE_Z,
|
||||
"terminal",
|
||||
"minecraft:entrance",
|
||||
"minecraft:entrance")
|
||||
.setPosition(new IrisPosition(7, 1, 13))
|
||||
.setPosition(new BlockPosition(7, 1, 13))
|
||||
.setJoint(JigsawJoint.ALIGNED);
|
||||
IrisJigsawPiece basePlate = piece("base-plate-object", true, baseEntrance);
|
||||
IrisJigsawPiece watchtower = piece("watchtower-object", true, towerEntrance);
|
||||
@@ -681,8 +678,8 @@ public class StructureAssemblerTest {
|
||||
fixture.pool("towers", pool("terminal", "watchtower"));
|
||||
fixture.piece("base-plate", basePlate);
|
||||
fixture.piece("watchtower", watchtower);
|
||||
fixture.object("base-plate-object", new IrisObject(16, 30, 16));
|
||||
fixture.object("watchtower-object", new IrisObject(15, 21, 15));
|
||||
fixture.object("base-plate-object", new ObjectFrame(16, 30, 16));
|
||||
fixture.object("watchtower-object", new ObjectFrame(15, 21, 15));
|
||||
IrisStructure structure = structure("start", 1);
|
||||
|
||||
StructureAssemblyResult collidable = fixture.assembler(structure, 0, 0, 0)
|
||||
@@ -714,8 +711,8 @@ public class StructureAssemblerTest {
|
||||
fixture.pool("start", start);
|
||||
fixture.piece("first-piece", first);
|
||||
fixture.piece("second-piece", second);
|
||||
fixture.object("first-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("second-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("first-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("second-object", new ObjectFrame(1, 1, 1));
|
||||
|
||||
for (long seed = 0; seed < 32; seed++) {
|
||||
List<PlacedStructurePiece> placed = completedPieces(
|
||||
@@ -731,7 +728,7 @@ public class StructureAssemblerTest {
|
||||
startPiece.setConnectors(null);
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
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,
|
||||
() -> fixture.assembler(structure("start", 1), 0, 0, 0).assemble(new RNG(3L)));
|
||||
@@ -741,20 +738,20 @@ public class StructureAssemblerTest {
|
||||
public void corruptWeightedPeerFailsBeforeCandidateSelection() {
|
||||
Fixture fixture = new Fixture();
|
||||
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,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
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("branch", pool("fallback", "valid-piece", "missing-piece"));
|
||||
fixture.pool("fallback", pool("", "fallback-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("valid-piece", validPiece);
|
||||
fixture.piece("fallback-piece", fallbackPiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("valid-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("fallback-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("valid-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("fallback-object", new ObjectFrame(1, 1, 1));
|
||||
|
||||
IllegalStateException failure = assertThrows(IllegalStateException.class,
|
||||
() -> 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);
|
||||
fixture.pool("start", pool("", "valid-piece", "missing-piece"));
|
||||
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,
|
||||
() -> fixture.assembler(structure("start", 1), 0, 0, 0).assemble(new RNG(18L)));
|
||||
@@ -782,20 +779,20 @@ public class StructureAssemblerTest {
|
||||
public void malformedNestedConnectorDoesNotFallThroughToAuthoredFallback() {
|
||||
Fixture fixture = new Fixture();
|
||||
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);
|
||||
malformedPiece.getConnectors().add((IrisJigsawConnector) null);
|
||||
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("branch", pool("fallback", "malformed-piece"));
|
||||
fixture.pool("fallback", pool("", "fallback-piece"));
|
||||
fixture.piece("start-piece", startPiece);
|
||||
fixture.piece("malformed-piece", malformedPiece);
|
||||
fixture.piece("fallback-piece", fallbackPiece);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("malformed-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("fallback-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("malformed-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("fallback-object", new ObjectFrame(1, 1, 1));
|
||||
|
||||
assertThrows(IllegalStateException.class,
|
||||
() -> fixture.assembler(structure("start", 2), 0, 0, 0).assemble(new RNG(19L)));
|
||||
@@ -805,13 +802,13 @@ public class StructureAssemblerTest {
|
||||
public void emptyPoolChoiceTerminatesTheBranchWithoutPlacingAir() {
|
||||
Fixture fixture = new Fixture();
|
||||
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"));
|
||||
IrisJigsawPool terminal = new IrisJigsawPool();
|
||||
terminal.getPieces().add(new IrisJigsawPieceEntry().setEmpty(true).setWeight(1));
|
||||
fixture.pool("terminal", terminal);
|
||||
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(
|
||||
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.piece("first-piece", first);
|
||||
fixture.piece("second-piece", second);
|
||||
fixture.object("first-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("second-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("first-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("second-object", new ObjectFrame(1, 1, 1));
|
||||
IrisStructure structure = structure("start", 1);
|
||||
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-1", 1));
|
||||
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-2", 1));
|
||||
@@ -877,12 +874,12 @@ public class StructureAssemblerTest {
|
||||
public void unmetMinimumPlacementsTakePriorityWithinTheirPool() {
|
||||
Fixture fixture = new Fixture();
|
||||
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,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
required.setRules(new IrisJigsawPieceRules().setMinimumPlacements(1));
|
||||
IrisJigsawPiece common = piece("common-object", false,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
IrisJigsawPool branch = new IrisJigsawPool();
|
||||
branch.getPieces().add(new IrisJigsawPieceEntry("common-piece", 100));
|
||||
@@ -891,9 +888,9 @@ public class StructureAssemblerTest {
|
||||
fixture.piece("start-piece", start);
|
||||
fixture.piece("required-piece", required);
|
||||
fixture.piece("common-piece", common);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("required-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("common-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("required-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("common-object", new ObjectFrame(1, 1, 1));
|
||||
|
||||
StructureAssemblyResult result = fixture.assembler(structure("start", 2), 0, 0, 0)
|
||||
.assemble(new RNG(61L));
|
||||
@@ -906,16 +903,16 @@ public class StructureAssemblerTest {
|
||||
public void terminalPiecesNeverEnqueueTheirRemainingConnectors() {
|
||||
Fixture fixture = new Fixture();
|
||||
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));
|
||||
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("child", pool("", "child-piece"));
|
||||
fixture.piece("terminal-piece", terminal);
|
||||
fixture.piece("child-piece", child);
|
||||
fixture.object("terminal-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("child-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("terminal-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("child-object", new ObjectFrame(1, 1, 1));
|
||||
|
||||
StructureAssemblyResult result = fixture.assembler(structure("start", 2), 0, 0, 0)
|
||||
.assemble(new RNG(67L));
|
||||
@@ -928,11 +925,11 @@ public class StructureAssemblerTest {
|
||||
public void requiredCapsResolveThroughACompatibleTerminalFallback() {
|
||||
Fixture fixture = new Fixture();
|
||||
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,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "wrong", ""));
|
||||
IrisJigsawPiece cap = piece("cap-object", false,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "", "door", ""));
|
||||
cap.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("branch", pool("caps", "incompatible-piece"));
|
||||
@@ -940,9 +937,9 @@ public class StructureAssemblerTest {
|
||||
fixture.piece("start-piece", start);
|
||||
fixture.piece("incompatible-piece", incompatible);
|
||||
fixture.piece("cap-piece", cap);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("incompatible-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("cap-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("incompatible-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("cap-object", new ObjectFrame(1, 1, 1));
|
||||
IrisStructure structure = structure("start", 2).setRequireCaps(true);
|
||||
|
||||
StructureAssemblyResult result = fixture.assembler(structure, 0, 0, 0)
|
||||
@@ -957,20 +954,20 @@ public class StructureAssemblerTest {
|
||||
public void compatibleOpenConnectorsCloseAgainstAnAlreadyPlacedNeighbor() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawPiece start = piece("start-object", false,
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "east", "start-east", "door"),
|
||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "south", "start-south", "door"));
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "east", "start-east", "door"),
|
||||
connector(JigsawDirection.SOUTH_POSITIVE_Z, "south", "start-south", "door"));
|
||||
IrisJigsawPiece east = piece("east-object", false,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"),
|
||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "diagonal", "east-south", "door"));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"),
|
||||
connector(JigsawDirection.SOUTH_POSITIVE_Z, "diagonal", "east-south", "door"));
|
||||
IrisJigsawPiece south = piece("south-object", false,
|
||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused"),
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "diagonal", "south-east", "door"));
|
||||
connector(JigsawDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused"),
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "diagonal", "south-east", "door"));
|
||||
IrisJigsawPiece diagonal = piece("diagonal-object", false,
|
||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "loop", "door", "unused"),
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "loop", "door", "unused"));
|
||||
connector(JigsawDirection.NORTH_NEGATIVE_Z, "loop", "door", "unused"),
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "loop", "door", "unused"));
|
||||
IrisJigsawPiece cap = piece("cap-object", true,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"),
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "terminal", "unused", "unused"));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"),
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "terminal", "unused", "unused"));
|
||||
cap.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("east", pool("caps", "east-piece"));
|
||||
@@ -983,11 +980,11 @@ public class StructureAssemblerTest {
|
||||
fixture.piece("south-piece", south);
|
||||
fixture.piece("diagonal-piece", diagonal);
|
||||
fixture.piece("cap-piece", cap);
|
||||
fixture.object("start-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("east-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("south-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("diagonal-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("cap-object", new IrisObject(1, 1, 1));
|
||||
fixture.object("start-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("east-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("south-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("diagonal-object", new ObjectFrame(1, 1, 1));
|
||||
fixture.object("cap-object", new ObjectFrame(1, 1, 1));
|
||||
IrisStructure structure = structure("start", 2).setRequireCaps(true);
|
||||
|
||||
List<PlacedStructurePiece> placed = completedPieces(
|
||||
@@ -1001,26 +998,26 @@ public class StructureAssemblerTest {
|
||||
public void planarRequiredCapsRejectASecondOpenReservationForTheSameEmptyCell() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawPiece start = piece("start-object", false,
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "east", "start-east", "door")
|
||||
.setPosition(new IrisPosition(2, 0, 1)),
|
||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "south", "start-south", "door")
|
||||
.setPosition(new IrisPosition(1, 0, 2)));
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "east", "start-east", "door")
|
||||
.setPosition(new BlockPosition(2, 0, 1)),
|
||||
connector(JigsawDirection.SOUTH_POSITIVE_Z, "south", "start-south", "door")
|
||||
.setPosition(new BlockPosition(1, 0, 2)));
|
||||
IrisJigsawPiece east = piece("east-object", false,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "terminal", "door", "unused")
|
||||
.setPosition(new IrisPosition(0, 0, 1)),
|
||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "grow", "east-south", "door")
|
||||
.setPosition(new IrisPosition(1, 0, 2)));
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "terminal", "door", "unused")
|
||||
.setPosition(new BlockPosition(0, 0, 1)),
|
||||
connector(JigsawDirection.SOUTH_POSITIVE_Z, "grow", "east-south", "door")
|
||||
.setPosition(new BlockPosition(1, 0, 2)));
|
||||
IrisJigsawPiece conflicting = piece("conflicting-object", false,
|
||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
||||
.setPosition(new IrisPosition(1, 0, 0)),
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "grow", "south-east", "door")
|
||||
.setPosition(new IrisPosition(2, 0, 1)));
|
||||
connector(JigsawDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
||||
.setPosition(new BlockPosition(1, 0, 0)),
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "grow", "south-east", "door")
|
||||
.setPosition(new BlockPosition(2, 0, 1)));
|
||||
IrisJigsawPiece compatible = piece("compatible-object", false,
|
||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
||||
.setPosition(new IrisPosition(1, 0, 0)));
|
||||
connector(JigsawDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
||||
.setPosition(new BlockPosition(1, 0, 0)));
|
||||
IrisJigsawPiece cap = piece("cap-object", true,
|
||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
||||
.setPosition(new IrisPosition(1, 0, 0)));
|
||||
connector(JigsawDirection.NORTH_NEGATIVE_Z, "terminal", "door", "unused")
|
||||
.setPosition(new BlockPosition(1, 0, 0)));
|
||||
cap.setRules(new IrisJigsawPieceRules().setTerminal(true));
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("east", pool("caps", "east-piece"));
|
||||
@@ -1032,14 +1029,14 @@ public class StructureAssemblerTest {
|
||||
fixture.piece("conflicting-piece", conflicting);
|
||||
fixture.piece("compatible-piece", compatible);
|
||||
fixture.piece("cap-piece", cap);
|
||||
fixture.object("start-object", new IrisObject(3, 1, 3));
|
||||
fixture.object("east-object", new IrisObject(3, 1, 3));
|
||||
fixture.object("conflicting-object", new IrisObject(3, 1, 3));
|
||||
fixture.object("compatible-object", new IrisObject(3, 1, 3));
|
||||
fixture.object("cap-object", new IrisObject(3, 1, 3));
|
||||
fixture.object("start-object", new ObjectFrame(3, 1, 3));
|
||||
fixture.object("east-object", new ObjectFrame(3, 1, 3));
|
||||
fixture.object("conflicting-object", new ObjectFrame(3, 1, 3));
|
||||
fixture.object("compatible-object", new ObjectFrame(3, 1, 3));
|
||||
fixture.object("cap-object", new ObjectFrame(3, 1, 3));
|
||||
IrisStructure structure = structure("start", 2)
|
||||
.setMode(IrisJigsawMode.PLANAR_JIGSAW)
|
||||
.setCellSize(new IrisPosition(3, 1, 3))
|
||||
.setCellSize(new BlockPosition(3, 1, 3))
|
||||
.setRequireCaps(true);
|
||||
|
||||
List<PlacedStructurePiece> placed = completedPieces(
|
||||
@@ -1059,7 +1056,7 @@ public class StructureAssemblerTest {
|
||||
startPool.getPieces().getFirst().setChance(0D);
|
||||
fixture.pool("start", startPool);
|
||||
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)
|
||||
.assemble(new RNG(73L));
|
||||
@@ -1072,18 +1069,18 @@ public class StructureAssemblerTest {
|
||||
public void branchingGeometryReturnsATypedHardCapFailure() {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawConnector[] connectors = {
|
||||
connector(IrisDirection.NORTH_NEGATIVE_Z, "branch", "door", "door"),
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "branch", "door", "door"),
|
||||
connector(IrisDirection.SOUTH_POSITIVE_Z, "branch", "door", "door"),
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "branch", "door", "door"),
|
||||
connector(IrisDirection.UP_POSITIVE_Y, "branch", "door", "door"),
|
||||
connector(IrisDirection.DOWN_NEGATIVE_Y, "branch", "door", "door")
|
||||
connector(JigsawDirection.NORTH_NEGATIVE_Z, "branch", "door", "door"),
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "branch", "door", "door"),
|
||||
connector(JigsawDirection.SOUTH_POSITIVE_Z, "branch", "door", "door"),
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "branch", "door", "door"),
|
||||
connector(JigsawDirection.UP_POSITIVE_Y, "branch", "door", "door"),
|
||||
connector(JigsawDirection.DOWN_NEGATIVE_Y, "branch", "door", "door")
|
||||
};
|
||||
IrisJigsawPiece node = piece("node-object", false, connectors);
|
||||
fixture.pool("start", pool("", "node-piece"));
|
||||
fixture.pool("branch", pool("terminal", "node-piece"));
|
||||
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)
|
||||
.assemble(new RNG(83L));
|
||||
@@ -1093,9 +1090,9 @@ public class StructureAssemblerTest {
|
||||
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()
|
||||
.setPosition(new IrisPosition())
|
||||
.setPosition(new BlockPosition(0, 0, 0))
|
||||
.setDirection(direction)
|
||||
.setPool(pool == null || pool.isBlank() ? "terminal" : pool)
|
||||
.setName(name)
|
||||
@@ -1105,7 +1102,7 @@ public class StructureAssemblerTest {
|
||||
|
||||
private static IrisJigsawPiece piece(String object, boolean rotatable, IrisJigsawConnector... connectors) {
|
||||
IrisJigsawPiece piece = new IrisJigsawPiece().setObject(object).setRotatable(rotatable);
|
||||
piece.getConnectors().add(connectors);
|
||||
piece.getConnectors().addAll(List.of(connectors));
|
||||
return piece;
|
||||
}
|
||||
|
||||
@@ -1123,17 +1120,17 @@ public class StructureAssemblerTest {
|
||||
) {
|
||||
Fixture fixture = new Fixture();
|
||||
IrisJigsawPiece start = piece("start-object", false,
|
||||
connector(IrisDirection.EAST_POSITIVE_X, "target", "start", "door"))
|
||||
connector(JigsawDirection.EAST_POSITIVE_X, "target", "start", "door"))
|
||||
.setCollidable(placedCollidable);
|
||||
IrisJigsawPiece candidate = piece("candidate-object", false,
|
||||
connector(IrisDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"))
|
||||
connector(JigsawDirection.WEST_NEGATIVE_X, "terminal", "door", "unused"))
|
||||
.setCollidable(candidateCollidable);
|
||||
fixture.pool("start", pool("", "start-piece"));
|
||||
fixture.pool("target", pool("", "candidate-piece"));
|
||||
fixture.piece("start-piece", start);
|
||||
fixture.piece("candidate-piece", candidate);
|
||||
fixture.object("start-object", new IrisObject(3, 3, 3));
|
||||
fixture.object("candidate-object", new IrisObject(3, 3, 3));
|
||||
fixture.object("start-object", new ObjectFrame(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));
|
||||
}
|
||||
|
||||
@@ -1165,7 +1162,7 @@ public class StructureAssemblerTest {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -1195,26 +1192,26 @@ public class StructureAssemblerTest {
|
||||
}
|
||||
|
||||
private static final class Fixture {
|
||||
private final IrisData data = mock(IrisData.class);
|
||||
private final MapStructureResolver resolver = new MapStructureResolver();
|
||||
|
||||
private Fixture() {
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, "terminal", new IrisJigsawPool());
|
||||
resolver.pool("terminal", new IrisJigsawPool());
|
||||
}
|
||||
|
||||
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) {
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, key, piece);
|
||||
resolver.piece(key, piece);
|
||||
}
|
||||
|
||||
private void object(String key, IrisObject object) {
|
||||
when(data.load(IrisObject.class, key, false)).thenReturn(object);
|
||||
private void object(String key, ObjectFrame object) {
|
||||
resolver.object(key, object);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -15,14 +14,14 @@ import static org.junit.Assert.assertTrue;
|
||||
public class IrisObjectFrameReaderTest {
|
||||
@Test
|
||||
public void acceptsModernTileFrame() throws Exception {
|
||||
IrisObject object = readObject(tile -> {
|
||||
ObjectFrame object = readObject(tile -> {
|
||||
tile.writeUTF("minecraft:chest");
|
||||
tile.writeUTF("{}");
|
||||
});
|
||||
|
||||
assertEquals(1, object.getW());
|
||||
assertEquals(1, object.getH());
|
||||
assertEquals(1, object.getD());
|
||||
assertEquals(1, object.width());
|
||||
assertEquals(1, object.height());
|
||||
assertEquals(1, object.depth());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -146,7 +145,7 @@ public class IrisObjectFrameReaderTest {
|
||||
new ByteArrayInputStream(content), "objects/trailing.iob"));
|
||||
}
|
||||
|
||||
private IrisObject readObject(TileWriter tileWriter) throws Exception {
|
||||
private ObjectFrame readObject(TileWriter tileWriter) throws Exception {
|
||||
return IrisObjectFrameReader.readBounds(
|
||||
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;
|
||||
|
||||
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.IrisJigsawPiece;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcell;
|
||||
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 com.volmit.geometry.BlockPosition;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -19,14 +18,14 @@ import static org.junit.Assert.assertThrows;
|
||||
public class PlanarJigsawWorkcellResolverTest {
|
||||
@Test
|
||||
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 =
|
||||
PlanarJigsawWorkcellResolver.resolve(structure);
|
||||
|
||||
assertEquals(6, workcells.size());
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -60,13 +59,13 @@ public class PlanarJigsawWorkcellResolverTest {
|
||||
@Test
|
||||
public void canonicalDimensionsSwapRectangularRotatedVariants() {
|
||||
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,
|
||||
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,
|
||||
IrisJigsawWorkcellArchetype.fromPiece(eastEnd));
|
||||
assertFalse(IrisJigsawWorkcellArchetype.fromPiece(eastEnd)
|
||||
|
||||
+154
-152
@@ -1,6 +1,6 @@
|
||||
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.IrisJigsawCompatibility;
|
||||
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.IrisJigsawPool;
|
||||
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.jigsaw.JigsawJoint;
|
||||
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.PlatformRegistries;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -60,8 +59,8 @@ public class StructureGraphCompilerTest {
|
||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
IrisStructure structure = structure("pools/start");
|
||||
|
||||
StructureGraphCompilation first = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation second = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation first = compile(structure, resolver);
|
||||
StructureGraphCompilation second = compile(structure, resolver);
|
||||
|
||||
assertTrue(first.getDiagnostics().isEmpty());
|
||||
assertTrue(first.isAssemblyViable());
|
||||
@@ -84,7 +83,7 @@ public class StructureGraphCompilerTest {
|
||||
start.setFallback("pools/missing-fallback");
|
||||
resolver.pools.put("pools/start", start);
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure("pools/start"), resolver);
|
||||
StructureGraphCompilation result = compile(structure("pools/start"), resolver);
|
||||
|
||||
assertCodes(result,
|
||||
StructureGraphDiagnostic.Code.INVALID_WEIGHT,
|
||||
@@ -98,15 +97,15 @@ public class StructureGraphCompilerTest {
|
||||
@Test
|
||||
public void reportsEmptyPoolsAndConnectorFieldFailures() {
|
||||
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.pieces.put("pieces/start", piece("objects/start", connector));
|
||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
resolver.pools.put("pools/empty", pool());
|
||||
|
||||
StructureGraphCompilation invalidConnector = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation invalidConnector = compile(
|
||||
structure("pools/start"), resolver);
|
||||
StructureGraphCompilation emptyStart = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation emptyStart = compile(
|
||||
structure("pools/empty"), resolver);
|
||||
|
||||
assertCodes(invalidConnector,
|
||||
@@ -120,9 +119,9 @@ public class StructureGraphCompilerTest {
|
||||
|
||||
@Test
|
||||
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);
|
||||
|
||||
assertCodes(result,
|
||||
@@ -139,9 +138,9 @@ public class StructureGraphCompilerTest {
|
||||
|
||||
@Test
|
||||
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);
|
||||
|
||||
assertTrue(result.getDiagnostics().isEmpty());
|
||||
@@ -154,10 +153,10 @@ public class StructureGraphCompilerTest {
|
||||
|
||||
@Test
|
||||
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");
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation result = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertCodes(result,
|
||||
@@ -168,9 +167,9 @@ public class StructureGraphCompilerTest {
|
||||
|
||||
@Test
|
||||
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);
|
||||
|
||||
assertCodes(result,
|
||||
@@ -180,34 +179,34 @@ public class StructureGraphCompilerTest {
|
||||
|
||||
@Test
|
||||
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 target = resolver.pieces.get("pieces/target").getConnectors().getFirst();
|
||||
source.setJoint(JigsawJoint.ALIGNED);
|
||||
source.setTop(IrisDirection.UP_POSITIVE_Y);
|
||||
target.setTop(IrisDirection.DOWN_NEGATIVE_Y);
|
||||
source.setTop(JigsawDirection.UP_POSITIVE_Y);
|
||||
target.setTop(JigsawDirection.DOWN_NEGATIVE_Y);
|
||||
|
||||
StructureGraphCompilation aligned = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation aligned = compile(
|
||||
structure("pools/start"), resolver);
|
||||
assertCodes(aligned,
|
||||
StructureGraphDiagnostic.Code.NO_COMPATIBLE_CONNECTOR,
|
||||
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
||||
|
||||
source.setJoint(JigsawJoint.ROLLABLE);
|
||||
StructureGraphCompilation rollable = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation rollable = compile(
|
||||
structure("pools/start"), resolver);
|
||||
assertTrue(rollable.isAssemblyViable());
|
||||
}
|
||||
|
||||
@Test
|
||||
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 target = resolver.pieces.get("pieces/target").getConnectors().getFirst();
|
||||
source.setChannel("roads");
|
||||
target.setChannel("rooms");
|
||||
|
||||
StructureGraphCompilation mismatched = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation mismatched = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertCodes(mismatched,
|
||||
@@ -215,7 +214,7 @@ public class StructureGraphCompilerTest {
|
||||
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
||||
|
||||
target.setChannel("Roads");
|
||||
StructureGraphCompilation mismatchedCase = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation mismatchedCase = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertCodes(mismatchedCase,
|
||||
@@ -223,7 +222,7 @@ public class StructureGraphCompilerTest {
|
||||
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
||||
|
||||
target.setChannel(" roads");
|
||||
StructureGraphCompilation mismatchedWhitespace = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation mismatchedWhitespace = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertCodes(mismatchedWhitespace,
|
||||
@@ -231,7 +230,7 @@ public class StructureGraphCompilerTest {
|
||||
StructureGraphDiagnostic.Code.UNREACHABLE_PIECE);
|
||||
|
||||
target.setChannel("roads");
|
||||
StructureGraphCompilation matched = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation matched = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertTrue(matched.isAssemblyViable());
|
||||
@@ -239,7 +238,7 @@ public class StructureGraphCompilerTest {
|
||||
IrisStructure portable = structure("pools/start")
|
||||
.setCompatibility(IrisJigsawCompatibility.VANILLA_PORTABLE)
|
||||
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
||||
StructureGraphCompilation rejectedPortable = StructureGraphCompiler.compile(portable, resolver);
|
||||
StructureGraphCompilation rejectedPortable = compile(portable, resolver);
|
||||
|
||||
assertCodes(rejectedPortable, StructureGraphDiagnostic.Code.NON_PORTABLE_CONNECTOR);
|
||||
assertTrue(rejectedPortable.hasErrors());
|
||||
@@ -249,7 +248,7 @@ public class StructureGraphCompilerTest {
|
||||
public void validatesPlanarCellSizeAndConnectorMetadata() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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")
|
||||
.setFinalState("")
|
||||
.setSelectionPriority(-1);
|
||||
@@ -259,9 +258,9 @@ public class StructureGraphCompilerTest {
|
||||
resolver.pools.put("pools/terminal", pool());
|
||||
IrisStructure structure = structure("pools/start")
|
||||
.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,
|
||||
StructureGraphDiagnostic.Code.INVALID_PLANAR_CELL_SIZE,
|
||||
@@ -272,14 +271,14 @@ public class StructureGraphCompilerTest {
|
||||
@Test
|
||||
public void acceptsRectangularPlanarCellSize() {
|
||||
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.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
IrisStructure structure = structure("pools/start")
|
||||
.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));
|
||||
assertTrue(result.isAssemblyViable());
|
||||
@@ -288,24 +287,24 @@ public class StructureGraphCompilerTest {
|
||||
@Test
|
||||
public void allowsSmallerPlanarObjectsAndRejectsObjectsOutsideTheirWorkcell() {
|
||||
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.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
IrisStructure structure = structure("pools/start")
|
||||
.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));
|
||||
|
||||
resolver.objects.put("objects/start", new IrisObject(4, 2, 4));
|
||||
StructureGraphCompilation smaller = StructureGraphCompiler.compile(structure, resolver);
|
||||
resolver.objects.put("objects/start", new ObjectFrame(4, 2, 4));
|
||||
StructureGraphCompilation smaller = compile(structure, resolver);
|
||||
|
||||
assertFalse(hasCode(smaller, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE));
|
||||
|
||||
resolver.objects.put("objects/start", new IrisObject(5, 3, 4));
|
||||
StructureGraphCompilation oversized = StructureGraphCompiler.compile(structure, resolver);
|
||||
resolver.objects.put("objects/start", new ObjectFrame(5, 3, 4));
|
||||
StructureGraphCompilation oversized = compile(structure, resolver);
|
||||
|
||||
assertCodes(oversized, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE);
|
||||
assertTrue(oversized.getDiagnostics().stream().anyMatch(
|
||||
@@ -316,22 +315,22 @@ public class StructureGraphCompilerTest {
|
||||
public void ignoresPlanarObjectSizeForPiecesThatCannotBeReached() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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");
|
||||
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");
|
||||
resolver.objects.put("objects/start", new IrisObject(4, 3, 4));
|
||||
resolver.objects.put("objects/target", new IrisObject(4, 2, 4));
|
||||
resolver.objects.put("objects/start", new ObjectFrame(4, 3, 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/target", piece("objects/target", target).setRotatable(false));
|
||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
resolver.pools.put("pools/target", pool(entry("pieces/target", 1)));
|
||||
IrisStructure structure = structure("pools/start")
|
||||
.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(hasCode(result, StructureGraphDiagnostic.Code.INVALID_PLANAR_OBJECT_SIZE));
|
||||
@@ -341,26 +340,26 @@ public class StructureGraphCompilerTest {
|
||||
public void acceptsAllCanonicalPlanarFaceCenterSockets() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
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.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
resolver.pools.put("pools/terminal", pool());
|
||||
IrisStructure structure = structure("pools/start")
|
||||
.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.isAssemblyViable());
|
||||
@@ -370,24 +369,24 @@ public class StructureGraphCompilerTest {
|
||||
public void rejectsOffsetVerticalAndTiltedPlanarConnectors() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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");
|
||||
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");
|
||||
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")
|
||||
.setTop(IrisDirection.DOWN_NEGATIVE_Y);
|
||||
resolver.objects.put("objects/start", new IrisObject(4, 3, 4));
|
||||
.setTop(JigsawDirection.DOWN_NEGATIVE_Y);
|
||||
resolver.objects.put("objects/start", new ObjectFrame(4, 3, 4));
|
||||
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/terminal", pool());
|
||||
IrisStructure structure = structure("pools/start")
|
||||
.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<>();
|
||||
for (StructureGraphDiagnostic diagnostic : result.getDiagnostics()) {
|
||||
if (diagnostic.code() == StructureGraphDiagnostic.Code.INVALID_PLANAR_CONNECTOR) {
|
||||
@@ -406,18 +405,18 @@ public class StructureGraphCompilerTest {
|
||||
public void spatialGraphsIgnoreThePlanarGeometryContract() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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")
|
||||
.setTop(IrisDirection.DOWN_NEGATIVE_Y);
|
||||
resolver.objects.put("objects/start", new IrisObject(2, 5, 3));
|
||||
.setTop(JigsawDirection.DOWN_NEGATIVE_Y);
|
||||
resolver.objects.put("objects/start", new ObjectFrame(2, 5, 3));
|
||||
resolver.pieces.put("pieces/start", piece("objects/start", vertical));
|
||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
resolver.pools.put("pools/terminal", pool());
|
||||
IrisStructure structure = structure("pools/start")
|
||||
.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_OBJECT_SIZE));
|
||||
@@ -429,20 +428,20 @@ public class StructureGraphCompilerTest {
|
||||
public void deterministicSamplesHonorSelectionPriorityAndStableTies() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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);
|
||||
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);
|
||||
resolver.objects.put("objects/start", object());
|
||||
resolver.objects.put("objects/east", object());
|
||||
resolver.objects.put("objects/west", object());
|
||||
resolver.pieces.put("pieces/start", piece("objects/start", east, west));
|
||||
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")));
|
||||
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")));
|
||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
resolver.pools.put("pools/east", pool(entry("pieces/east", 1)));
|
||||
@@ -450,7 +449,7 @@ public class StructureGraphCompilerTest {
|
||||
resolver.pools.put("pools/terminal", pool());
|
||||
IrisStructure structure = structure("pools/start");
|
||||
|
||||
StructureGraphCompilation prioritized = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation prioritized = compile(structure, resolver);
|
||||
|
||||
for (StructureGraphAssemblySample sample : prioritized.getAssemblySamples()) {
|
||||
assertEquals(List.of("pieces/start", "pieces/west", "pieces/east"),
|
||||
@@ -458,7 +457,7 @@ public class StructureGraphCompilerTest {
|
||||
}
|
||||
|
||||
east.setSelectionPriority(-10);
|
||||
StructureGraphCompilation tied = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation tied = compile(structure, resolver);
|
||||
|
||||
for (StructureGraphAssemblySample sample : tied.getAssemblySamples()) {
|
||||
assertEquals(List.of("pieces/start", "pieces/east", "pieces/west"),
|
||||
@@ -470,22 +469,22 @@ public class StructureGraphCompilerTest {
|
||||
public void deterministicSamplesScheduleChildExpansionBySourcePlacementPriority() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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);
|
||||
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);
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
resolver.objects.put("objects/start", 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/west", piece("objects/west", westTarget, westBranch));
|
||||
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")));
|
||||
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")));
|
||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
resolver.pools.put("pools/east", pool(entry("pieces/east", 1)));
|
||||
@@ -509,7 +508,7 @@ public class StructureGraphCompilerTest {
|
||||
resolver.pools.put("pools/terminal", pool());
|
||||
IrisStructure structure = structure("pools/start");
|
||||
|
||||
StructureGraphCompilation prioritized = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation prioritized = compile(structure, resolver);
|
||||
|
||||
for (StructureGraphAssemblySample sample : prioritized.getAssemblySamples()) {
|
||||
assertEquals(List.of(
|
||||
@@ -519,7 +518,7 @@ public class StructureGraphCompilerTest {
|
||||
}
|
||||
|
||||
westSource.setPlacementPriority(-20);
|
||||
StructureGraphCompilation tied = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation tied = compile(structure, resolver);
|
||||
|
||||
for (StructureGraphAssemblySample sample : tied.getAssemblySamples()) {
|
||||
assertEquals(List.of(
|
||||
@@ -533,25 +532,25 @@ public class StructureGraphCompilerTest {
|
||||
public void deterministicSamplesUseSelectionPriorityForCandidateConnectors() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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");
|
||||
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);
|
||||
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);
|
||||
resolver.objects.put("objects/start", new IrisObject(1, 3, 1));
|
||||
resolver.objects.put("objects/target", new IrisObject(1, 3, 3));
|
||||
resolver.objects.put("objects/low-leaf", new IrisObject(1, 3, 1));
|
||||
resolver.objects.put("objects/high-leaf", new IrisObject(1, 3, 1));
|
||||
resolver.objects.put("objects/start", new ObjectFrame(1, 3, 1));
|
||||
resolver.objects.put("objects/target", new ObjectFrame(1, 3, 3));
|
||||
resolver.objects.put("objects/low-leaf", new ObjectFrame(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/target", piece("objects/target", low, high).setRotatable(false));
|
||||
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));
|
||||
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));
|
||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
resolver.pools.put("pools/target", pool(entry("pieces/target", 1)));
|
||||
@@ -560,7 +559,7 @@ public class StructureGraphCompilerTest {
|
||||
resolver.pools.put("pools/terminal", pool());
|
||||
IrisStructure structure = structure("pools/start");
|
||||
|
||||
StructureGraphCompilation prioritized = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation prioritized = compile(structure, resolver);
|
||||
|
||||
for (StructureGraphAssemblySample sample : prioritized.getAssemblySamples()) {
|
||||
assertEquals(List.of("pieces/start", "pieces/target", "pieces/low-leaf"),
|
||||
@@ -568,7 +567,7 @@ public class StructureGraphCompilerTest {
|
||||
}
|
||||
|
||||
low.setSelectionPriority(-10);
|
||||
StructureGraphCompilation tied = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation tied = compile(structure, resolver);
|
||||
|
||||
for (StructureGraphAssemblySample sample : tied.getAssemblySamples()) {
|
||||
assertEquals(List.of("pieces/start", "pieces/target", "pieces/high-leaf"),
|
||||
@@ -580,16 +579,16 @@ public class StructureGraphCompilerTest {
|
||||
public void deterministicSamplingUsesFallbackAtTheMaximumDepth() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
resolver.objects.put("objects/start", object());
|
||||
resolver.objects.put("objects/primary", object());
|
||||
@@ -605,7 +604,7 @@ public class StructureGraphCompilerTest {
|
||||
IrisStructure structure = structure("pools/start");
|
||||
structure.setMaxDepth(1);
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation result = compile(structure, resolver);
|
||||
|
||||
assertTrue(result.getDiagnostics().isEmpty());
|
||||
assertTrue(result.isAssemblyViable());
|
||||
@@ -620,13 +619,13 @@ public class StructureGraphCompilerTest {
|
||||
public void deterministicSamplingDoesNotSelectFallbackOfFallback() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
resolver.objects.put("objects/start", object());
|
||||
resolver.objects.put("objects/incompatible", object());
|
||||
@@ -643,7 +642,7 @@ public class StructureGraphCompilerTest {
|
||||
resolver.pools.put("pools/direct", direct);
|
||||
resolver.pools.put("pools/nested", pool(entry("pieces/nested", 1)));
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation result = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertFalse(result.getGraph().getReachablePools().contains("pools/nested"));
|
||||
@@ -671,7 +670,7 @@ public class StructureGraphCompilerTest {
|
||||
resolver.pools.put("pools/first", first);
|
||||
resolver.pools.put("pools/second", second);
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation result = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertCodes(result,
|
||||
@@ -694,7 +693,7 @@ public class StructureGraphCompilerTest {
|
||||
resolver.pools.put("pools/chain-" + index, pool);
|
||||
}
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation result = compile(
|
||||
structure("pools/chain-0"), resolver);
|
||||
|
||||
assertTrue(result.getDiagnostics().stream().noneMatch(
|
||||
@@ -705,14 +704,14 @@ public class StructureGraphCompilerTest {
|
||||
@Test
|
||||
public void reportsMissingObjectsAndInvalidObjectBounds() {
|
||||
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/empty-object", piece("objects/empty"));
|
||||
resolver.pools.put("pools/start", pool(
|
||||
entry("pieces/missing-object", 1),
|
||||
entry("pieces/empty-object", 1)));
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation result = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertCodes(result,
|
||||
@@ -730,15 +729,15 @@ public class StructureGraphCompilerTest {
|
||||
nullListResolver.pieces.put("pieces/start", nullListPiece);
|
||||
nullListResolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
|
||||
StructureGraphCompilation nullList = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation nullList = compile(
|
||||
structure("pools/start"), nullListResolver);
|
||||
|
||||
assertCodes(nullList, StructureGraphDiagnostic.Code.INVALID_CONNECTOR);
|
||||
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);
|
||||
StructureGraphCompilation nullNames = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation nullNames = compile(
|
||||
structure("pools/start"), nullNamesResolver);
|
||||
|
||||
assertCodes(nullNames, StructureGraphDiagnostic.Code.INVALID_CONNECTOR);
|
||||
@@ -759,11 +758,11 @@ public class StructureGraphCompilerTest {
|
||||
IrisStructure overflowing = structure("pools/start");
|
||||
overflowing.setMaxSizeChunks(Integer.MAX_VALUE);
|
||||
|
||||
assertCodes(StructureGraphCompiler.compile(deep, resolver),
|
||||
assertCodes(compile(deep, resolver),
|
||||
StructureGraphDiagnostic.Code.INVALID_MAX_DEPTH);
|
||||
assertCodes(StructureGraphCompiler.compile(wide, resolver),
|
||||
assertCodes(compile(wide, resolver),
|
||||
StructureGraphDiagnostic.Code.INVALID_MAX_SIZE);
|
||||
assertCodes(StructureGraphCompiler.compile(overflowing, resolver),
|
||||
assertCodes(compile(overflowing, resolver),
|
||||
StructureGraphDiagnostic.Code.INVALID_MAX_SIZE);
|
||||
}
|
||||
|
||||
@@ -771,14 +770,14 @@ public class StructureGraphCompilerTest {
|
||||
public void emptyPoolChoiceTerminatesABranchWithoutAPlaceholderPiece() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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");
|
||||
resolver.objects.put("objects/start", object());
|
||||
resolver.pieces.put("pieces/start", piece("objects/start", source));
|
||||
resolver.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
resolver.pools.put("pools/terminal", pool(emptyEntry(4)));
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation result = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertTrue(result.getDiagnostics().isEmpty());
|
||||
@@ -794,7 +793,7 @@ public class StructureGraphCompilerTest {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
resolver.pools.put("pools/start", pool(emptyEntry(1)));
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation result = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertTrue(result.isAssemblyViable());
|
||||
@@ -815,7 +814,7 @@ public class StructureGraphCompilerTest {
|
||||
resolver.pools.put("pools/start", pool(
|
||||
entry("pieces/start", Integer.MAX_VALUE), emptyEntry(1)));
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation result = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertTrue(result.isAssemblyViable());
|
||||
@@ -827,11 +826,11 @@ public class StructureGraphCompilerTest {
|
||||
@Test
|
||||
public void oversizedStartPreventsGuaranteedReplacementOutput() {
|
||||
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.pools.put("pools/start", pool(entry("pieces/start", 1)));
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation result = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertTrue(result.isAssemblyViable());
|
||||
@@ -840,9 +839,9 @@ public class StructureGraphCompilerTest {
|
||||
|
||||
@Test
|
||||
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);
|
||||
|
||||
assertTrue(unbounded.isAssemblyViable());
|
||||
@@ -850,7 +849,7 @@ public class StructureGraphCompilerTest {
|
||||
|
||||
resolver.pools.get("pools/target").setFallback("pools/empty");
|
||||
resolver.pools.put("pools/empty", pool());
|
||||
StructureGraphCompilation terminated = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation terminated = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertTrue(terminated.isAssemblyViable());
|
||||
@@ -859,13 +858,13 @@ public class StructureGraphCompilerTest {
|
||||
|
||||
@Test
|
||||
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 terminatingStructure = structure("pools/start")
|
||||
.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
||||
|
||||
StructureGraphCompilation strict = StructureGraphCompiler.compile(strictStructure, resolver);
|
||||
StructureGraphCompilation terminating = StructureGraphCompiler.compile(terminatingStructure, resolver);
|
||||
StructureGraphCompilation strict = compile(strictStructure, resolver);
|
||||
StructureGraphCompilation terminating = compile(terminatingStructure, resolver);
|
||||
|
||||
assertCodes(strict,
|
||||
StructureGraphDiagnostic.Code.NO_COMPATIBLE_CONNECTOR,
|
||||
@@ -892,9 +891,9 @@ public class StructureGraphCompilerTest {
|
||||
IrisStructure structure = structure("pools/start")
|
||||
.setCompatibility(IrisJigsawCompatibility.VANILLA_PORTABLE);
|
||||
|
||||
StructureGraphCompilation strict = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation strict = compile(structure, resolver);
|
||||
structure.setBranchFailurePolicy(IrisJigsawBranchFailurePolicy.TERMINATE_BRANCH);
|
||||
StructureGraphCompilation terminating = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation terminating = compile(structure, resolver);
|
||||
|
||||
assertCodes(strict, StructureGraphDiagnostic.Code.NON_PORTABLE_METADATA);
|
||||
assertTrue(strict.hasErrors());
|
||||
@@ -906,16 +905,16 @@ public class StructureGraphCompilerTest {
|
||||
public void authoritativeGeometrySamplingDoesNotReportTopologyOnlyPieceCaps() {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
resolver.objects.put("objects/start", object());
|
||||
resolver.objects.put("objects/recursive", object());
|
||||
@@ -931,7 +930,7 @@ public class StructureGraphCompilerTest {
|
||||
structure.setMaxDepth(30);
|
||||
structure.setMaxSizeChunks(8);
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation result = compile(structure, resolver);
|
||||
|
||||
assertFalse(hasCode(result, StructureGraphDiagnostic.Code.ASSEMBLY_PIECE_CAP_REACHED));
|
||||
assertTrue(result.isAssemblyViable());
|
||||
@@ -955,7 +954,7 @@ public class StructureGraphCompilerTest {
|
||||
IrisStructure structure = structure("pools/start");
|
||||
structure.getThemeSets().add(new IrisJigsawThemeSet("variant-1", 1));
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation result = compile(structure, resolver);
|
||||
|
||||
assertCodes(result,
|
||||
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-2", 1));
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(structure, resolver);
|
||||
StructureGraphCompilation result = compile(structure, resolver);
|
||||
|
||||
assertCodes(result, StructureGraphDiagnostic.Code.UNSATISFIABLE_PIECE_RULE);
|
||||
}
|
||||
|
||||
@Test
|
||||
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(
|
||||
new IrisJigsawPieceRules().setTerminal(true));
|
||||
|
||||
StructureGraphCompilation result = StructureGraphCompiler.compile(
|
||||
StructureGraphCompilation result = compile(
|
||||
structure("pools/start"), resolver);
|
||||
|
||||
assertTrue(result.getGraph().getReachablePieces().contains("pieces/start"));
|
||||
@@ -997,20 +996,20 @@ public class StructureGraphCompilerTest {
|
||||
|
||||
@Test
|
||||
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.put("pools/fallback", pool(entry("pieces/target", 1)));
|
||||
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);
|
||||
}
|
||||
|
||||
private static InMemoryResolver connectorGraph(boolean rotatable, IrisDirection targetDirection) {
|
||||
private static InMemoryResolver connectorGraph(boolean rotatable, JigsawDirection targetDirection) {
|
||||
InMemoryResolver resolver = new InMemoryResolver();
|
||||
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");
|
||||
IrisJigsawConnector target = connector(
|
||||
canonicalPosition(targetDirection), targetDirection,
|
||||
@@ -1030,25 +1029,24 @@ public class StructureGraphCompilerTest {
|
||||
|
||||
private static IrisStructure structure(String startPool) {
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setLoadKey("structures/test");
|
||||
structure.setStartPool(startPool);
|
||||
structure.setMaxDepth(3);
|
||||
structure.setMaxSizeChunks(4);
|
||||
return structure;
|
||||
}
|
||||
|
||||
private static IrisObject object() {
|
||||
return new IrisObject(3, 3, 3);
|
||||
private static ObjectFrame object() {
|
||||
return new ObjectFrame(3, 3, 3);
|
||||
}
|
||||
|
||||
private static IrisPosition canonicalPosition(IrisDirection direction) {
|
||||
private static BlockPosition canonicalPosition(JigsawDirection direction) {
|
||||
return switch (direction) {
|
||||
case NORTH_NEGATIVE_Z -> new IrisPosition(1, 1, 0);
|
||||
case EAST_POSITIVE_X -> new IrisPosition(2, 1, 1);
|
||||
case SOUTH_POSITIVE_Z -> new IrisPosition(1, 1, 2);
|
||||
case WEST_NEGATIVE_X -> new IrisPosition(0, 1, 1);
|
||||
case UP_POSITIVE_Y -> new IrisPosition(1, 2, 1);
|
||||
case DOWN_NEGATIVE_Y -> new IrisPosition(1, 0, 1);
|
||||
case NORTH_NEGATIVE_Z -> new BlockPosition(1, 1, 0);
|
||||
case EAST_POSITIVE_X -> new BlockPosition(2, 1, 1);
|
||||
case SOUTH_POSITIVE_Z -> new BlockPosition(1, 1, 2);
|
||||
case WEST_NEGATIVE_X -> new BlockPosition(0, 1, 1);
|
||||
case UP_POSITIVE_Y -> new BlockPosition(1, 2, 1);
|
||||
case DOWN_NEGATIVE_Y -> new BlockPosition(1, 0, 1);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1073,7 +1071,7 @@ public class StructureGraphCompilerTest {
|
||||
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) {
|
||||
return new IrisJigsawConnector()
|
||||
.setPosition(position)
|
||||
@@ -1104,10 +1102,14 @@ public class StructureGraphCompilerTest {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static StructureGraphCompilation compile(IrisStructure structure, StructureGraphResolver resolver) {
|
||||
return StructureGraphCompiler.compile("test", structure, resolver);
|
||||
}
|
||||
|
||||
private static final class InMemoryResolver implements StructureGraphResolver {
|
||||
private final Map<String, IrisJigsawPool> pools = 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
|
||||
public IrisJigsawPool loadPool(String key) {
|
||||
@@ -1120,7 +1122,7 @@ public class StructureGraphCompilerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject loadObject(String key) {
|
||||
public ObjectFrame loadObject(String key) {
|
||||
return objects.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-4
@@ -45,7 +45,7 @@ public class StructureGraphValidationTest {
|
||||
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}]}");
|
||||
"{\"pieces\":[{\"piece\":\"castle/start\",\"weight\":1}]}");
|
||||
write(pack, "jigsaw-pieces/castle/start.json",
|
||||
"{\"object\":\"castle/start\",\"connectors\":[{\"position\":{\"x\":2,\"y\":0,\"z\":0},"
|
||||
+ "\"direction\":\"NORTH_NEGATIVE_Z\",\"pool\":\"castle/start\",\"name\":\"path\",\"targetName\":\"path\"}]}");
|
||||
@@ -53,8 +53,22 @@ public class StructureGraphValidationTest {
|
||||
|
||||
StructureGraphValidation.Validation validation = validate(pack, null);
|
||||
|
||||
assertTrue(validation.errors().stream().anyMatch(message -> message.contains("non-positive weight 0")));
|
||||
assertTrue(validation.errors().stream().anyMatch(message -> message.contains("outside object bounds")));
|
||||
assertTrue(validation.errors().toString(), 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
|
||||
@@ -322,7 +336,7 @@ public class StructureGraphValidationTest {
|
||||
private static StructureGraphValidation.Validation validate(Path pack, Set<String> activeStructureKeys) {
|
||||
IrisData data = IrisData.openValidation(pack.toFile());
|
||||
try {
|
||||
return StructureGraphValidation.validate(data, activeStructureKeys);
|
||||
return StructureGraphValidation.validate(data.getPackResources(), pack.toFile(), activeStructureKeys);
|
||||
} finally {
|
||||
data.close();
|
||||
}
|
||||
|
||||
+1
-2
@@ -78,7 +78,6 @@ public class StructureResourcesTest {
|
||||
|
||||
assertEquals("castle/start", castle.getStartPool());
|
||||
assertEquals(5, castle.getMaxDepth());
|
||||
assertEquals("castle", castle.getLoadKey());
|
||||
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.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());
|
||||
JSONObject structures = new JSONObject(Files.readString(pack.resolve(".iris/schema/structures-schema.json")));
|
||||
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\"]",
|
||||
structures.getJSONObject("definitions").getJSONObject("erzjigsaw-pools").getJSONArray("enum").toString());
|
||||
} finally {
|
||||
|
||||
+71
-59
@@ -1,30 +1,31 @@
|
||||
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.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.iris.engine.framework.structure.assembly.AssembledPiece;
|
||||
import art.arcane.iris.engine.framework.structure.assembly.PieceTurn;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.resource.ResourceId;
|
||||
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.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class StructureCarvingFootprintTest {
|
||||
@Test
|
||||
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, 1), block(0, 0, 2));
|
||||
|
||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 0);
|
||||
StructureCarvingFootprint footprint = footprintOf(pieces(piece), 0);
|
||||
|
||||
assertNotNull(footprint);
|
||||
assertEquals(10, footprint.minX());
|
||||
@@ -39,11 +40,11 @@ public class StructureCarvingFootprintTest {
|
||||
|
||||
@Test
|
||||
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(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 tied = footprint.sample(2, 0);
|
||||
|
||||
@@ -59,12 +60,12 @@ public class StructureCarvingFootprintTest {
|
||||
|
||||
@Test
|
||||
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));
|
||||
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));
|
||||
|
||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(
|
||||
StructureCarvingFootprint footprint = footprintOf(
|
||||
pieces(rotated, overlapping), 0);
|
||||
|
||||
assertNotNull(footprint);
|
||||
@@ -82,18 +83,18 @@ public class StructureCarvingFootprintTest {
|
||||
int[][] sourceBlocks = new int[][]{
|
||||
block(0, 2, 0), block(3, 4, 1), block(1, 6, 4), block(5, 8, 5)
|
||||
};
|
||||
PlacedStructurePiece piece = piece(
|
||||
-8, 30, 11, ObjectTurn.of(0, 0, 0), sourceBlocks);
|
||||
Piece piece = piece(
|
||||
-8, 30, 11, PieceTurn.NONE, sourceBlocks);
|
||||
|
||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 3);
|
||||
StructureCarvingFootprint footprint = footprintOf(pieces(piece), 3);
|
||||
|
||||
assertNotNull(footprint);
|
||||
for (int z = footprint.minZ(); z <= footprint.maxZ(); z++) {
|
||||
for (int x = footprint.minX(); x <= footprint.maxX(); x++) {
|
||||
long expected = Long.MAX_VALUE;
|
||||
for (int[] source : sourceBlocks) {
|
||||
long deltaX = (long) x - (piece.getX() + source[0]);
|
||||
long deltaZ = (long) z - (piece.getZ() + source[2]);
|
||||
long deltaX = (long) x - (piece.assembled.x() + source[0]);
|
||||
long deltaZ = (long) z - (piece.assembled.z() + source[2]);
|
||||
expected = Math.min(expected, deltaX * deltaX + deltaZ * deltaZ);
|
||||
}
|
||||
assertEquals(expected, footprint.distanceSquaredAt(x, z));
|
||||
@@ -103,23 +104,22 @@ public class StructureCarvingFootprintTest {
|
||||
|
||||
@Test
|
||||
public void returnsNullForEmptyInvalidOrOversizedInputs() {
|
||||
assertNull(StructureCarvingFootprint.from(null, 0));
|
||||
assertNull(StructureCarvingFootprint.from(new KList<>(), 0));
|
||||
assertNull(footprintOf(null, 0));
|
||||
assertNull(footprintOf(new ArrayList<>(), 0));
|
||||
|
||||
KList<PlacedStructurePiece> invalidPieces = new KList<>();
|
||||
invalidPieces.add((PlacedStructurePiece) null);
|
||||
invalidPieces.add(new PlacedStructurePiece(
|
||||
null, null, 0, 0, 0, null, 0, 0, 0, 0, 0, 0));
|
||||
assertNull(StructureCarvingFootprint.from(invalidPieces, 0));
|
||||
List<Piece> invalidPieces = new ArrayList<>();
|
||||
invalidPieces.add(null);
|
||||
invalidPieces.add(new Piece(piece(0, 0, 0, PieceTurn.NONE).assembled, null));
|
||||
assertNull(footprintOf(invalidPieces, 0));
|
||||
|
||||
PlacedStructurePiece piece = piece(0, 0, 0, ObjectTurn.of(0, 0, 0), block(0, 0, 0));
|
||||
assertNull(StructureCarvingFootprint.from(pieces(piece), 2, 24));
|
||||
PlacedStructurePiece overflowing = piece(
|
||||
Integer.MAX_VALUE, 0, 0, ObjectTurn.of(0, 0, 0), block(1, 0, 0));
|
||||
assertNull(StructureCarvingFootprint.from(pieces(overflowing), 0));
|
||||
Piece piece = piece(0, 0, 0, PieceTurn.NONE, block(0, 0, 0));
|
||||
assertNull(footprintOf(pieces(piece), 2, 24));
|
||||
Piece overflowing = piece(
|
||||
Integer.MAX_VALUE, 0, 0, PieceTurn.NONE, block(1, 0, 0));
|
||||
assertNull(footprintOf(pieces(overflowing), 0));
|
||||
|
||||
try {
|
||||
StructureCarvingFootprint.from(pieces(piece), -1);
|
||||
footprintOf(pieces(piece), -1);
|
||||
fail("Expected negative padding to fail");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("padding must be non-negative", e.getMessage());
|
||||
@@ -128,9 +128,9 @@ public class StructureCarvingFootprintTest {
|
||||
|
||||
@Test
|
||||
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);
|
||||
assertEquals(5, footprint.minX());
|
||||
@@ -148,17 +148,12 @@ public class StructureCarvingFootprintTest {
|
||||
|
||||
@Test
|
||||
public void explicitAirDoesNotExpandTheExteriorFootprint() {
|
||||
IrisObject object = new IrisObject(1, 1, 1);
|
||||
PlatformBlockState solid = mock(PlatformBlockState.class);
|
||||
PlatformBlockState air = mock(PlatformBlockState.class);
|
||||
when(air.isAir()).thenReturn(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);
|
||||
Piece piece = new Piece(new AssembledPiece(new ResourceId("test", "piece"), 10, 20, 30, PieceTurn.NONE,
|
||||
10, 20, 30, 18, 24, 38), List.of(
|
||||
new StructurePieceColumns.PieceBlock(new BlockPosition(0, 0, 0), false),
|
||||
new StructurePieceColumns.PieceBlock(new BlockPosition(8, 4, 8), true)));
|
||||
|
||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 0);
|
||||
StructureCarvingFootprint footprint = footprintOf(pieces(piece), 0);
|
||||
|
||||
assertNotNull(footprint);
|
||||
assertEquals(10, footprint.minX());
|
||||
@@ -167,23 +162,40 @@ public class StructureCarvingFootprintTest {
|
||||
assertEquals(30, footprint.maxZ());
|
||||
}
|
||||
|
||||
private static PlacedStructurePiece piece(int x, int y, int z, ObjectTurn rotation,
|
||||
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 record Piece(AssembledPiece assembled, List<StructurePieceColumns.PieceBlock> blocks) {
|
||||
}
|
||||
|
||||
private static KList<PlacedStructurePiece> pieces(PlacedStructurePiece... pieces) {
|
||||
KList<PlacedStructurePiece> result = new KList<>();
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
result.add(piece);
|
||||
private static StructureCarvingFootprint footprintOf(List<Piece> pieces, int padding) {
|
||||
return footprintOf(pieces, padding, StructureCarvingFootprint.DEFAULT_MAX_CELLS);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
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