From 74b129e105b6628036ce1060edd6e840374249bc Mon Sep 17 00:00:00 2001 From: piexel Date: Tue, 27 Oct 2026 00:59:48 +0100 Subject: [PATCH] Batch 7 stage 1: jigsaw definitions from the module build The jigsaw definitions, StructureResources and IrisDirection now come from IrisModule. Iris registers iris:structure (StructureModule) with its own modules; iris:structure-model keeps the validator and the locator and vanilla structure services. StructureResources lookups take the pack's PackResources, so callers pass data.getPackResources(); the Bukkit plugin compiles against the API for that. IrisRegistrant extends the module's KeyedResource, which holds the load key. A structure's loot placement is StructurePlacing.lootPlacement. Studio maps an API object reference (GeneratedObject) to Iris's object loader. --- adapters/bukkit/plugin/build.gradle | 2 + .../iris/core/commands/CommandJigsaw.java | 8 +- .../iris/core/commands/CommandStructure.java | 4 +- .../command/ModdedStructureCommands.java | 6 +- .../iris/core/loader/IrisRegistrant.java | 10 +- .../iris/core/modules/IrisModuleHost.java | 11 +- .../core/modules/ModuleResourceFiles.java | 18 +- .../core/modules/StructureModelModule.java | 10 +- .../iris/core/project/SchemaBuilder.java | 13 +- .../jigsaw/JigsawStudioGraphMapper.java | 6 +- .../core/service/JigsawStudioService.java | 10 +- .../export/VanillaJigsawExportSource.java | 2 +- .../arcane/iris/engine/framework/Engine.java | 5 +- .../framework/IrisStructureLocator.java | 8 +- .../structure/StructureGraphResolver.java | 4 +- .../structure/StructureGraphValidation.java | 6 +- .../structure/StructureLocating.java | 2 +- .../structure/StructureResources.java | 104 ----- .../mantle/components/StructurePlacing.java | 21 +- .../object/structure/IrisStructure.java | 156 ------- .../structure/jigsaw/IrisJigsawConnector.java | 96 ----- .../structure/jigsaw/IrisJigsawPiece.java | 94 ----- .../jigsaw/IrisJigsawPieceEntry.java | 66 --- .../structure/jigsaw/IrisJigsawPool.java | 63 --- .../structure/jigsaw/IrisJigsawWorkcell.java | 40 -- .../jigsaw/IrisJigsawWorkcellArchetype.java | 88 ---- .../engine/object/value/IrisDirection.java | 392 ------------------ .../generators/JigsawStudioGenerator.java | 2 +- .../specialhandlers/IrisStructureHandler.java | 2 +- .../arcane/iris/core/modules/BuiltInPack.java | 3 +- .../structure/StructureResourcesTest.java | 36 +- .../IrisStructureLootPlacementTest.java | 5 +- 32 files changed, 112 insertions(+), 1181 deletions(-) delete mode 100644 core/src/main/java/art/arcane/iris/engine/framework/structure/StructureResources.java delete mode 100644 core/src/main/java/art/arcane/iris/engine/object/structure/IrisStructure.java delete mode 100644 core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawConnector.java delete mode 100644 core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPiece.java delete mode 100644 core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPieceEntry.java delete mode 100644 core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPool.java delete mode 100644 core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawWorkcell.java delete mode 100644 core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawWorkcellArchetype.java delete mode 100644 core/src/main/java/art/arcane/iris/engine/object/value/IrisDirection.java diff --git a/adapters/bukkit/plugin/build.gradle b/adapters/bukkit/plugin/build.gradle index d18e8ec11..098e84cfc 100644 --- a/adapters/bukkit/plugin/build.gradle +++ b/adapters/bukkit/plugin/build.gradle @@ -8,6 +8,8 @@ String volmLibCoordinate = providers.gradleProperty('volmLibCoordinate') dependencies { compileOnly(project(':core')) + // The structure commands look up structures through the module's PackResources lookups; core shades the API. + compileOnly('com.volmit:iris-api') compileOnly(libs.lombok) annotationProcessor(libs.lombok) compileOnly(volmLibCoordinate) { diff --git a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandJigsaw.java b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandJigsaw.java index 5a5da4e0b..a9a217ed2 100644 --- a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandJigsaw.java +++ b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandJigsaw.java @@ -263,7 +263,7 @@ public class CommandJigsaw implements DirectorExecutor { if (data == null) { return; } - IrisStructure irisStructure = StructureResources.structure(data, structure); + IrisStructure irisStructure = StructureResources.structure(data.getPackResources(), structure); if (irisStructure == null) { sendError(commandSender, "No Iris jigsaw structure '" + structure + "' exists in this pack."); return; @@ -1216,7 +1216,7 @@ public class CommandJigsaw implements DirectorExecutor { static JigsawStudioLayout loadPersistedLayout(ActiveContext context) throws IOException { IrisData source = context.request().source(); source.invalidateStructureResources(); - IrisStructure structure = StructureResources.structure(source, context.request().structureKey()); + IrisStructure structure = StructureResources.structure(source.getPackResources(), context.request().structureKey()); if (structure == null) { throw new IOException("The structure could not be reloaded after the graph transaction"); } @@ -1276,7 +1276,7 @@ public class CommandJigsaw implements DirectorExecutor { static String nextThemeKey(ActiveContext context) throws IOException { IrisStructure structure = StructureResources.structure( - context.request().source(), + context.request().source().getPackResources(), context.request().structureKey()); if (structure == null) { throw new IOException("The active jigsaw structure could not be loaded"); @@ -1749,7 +1749,7 @@ public class CommandJigsaw implements DirectorExecutor { sendError(this, "Open a Jigsaw Studio project first."); return; } - IrisJigsawPiece piece = StructureResources.piece(context.request().source(), pieceKey); + IrisJigsawPiece piece = StructureResources.piece(context.request().source().getPackResources(), pieceKey); if (piece == null) { sendError(this, "No jigsaw piece '" + pieceKey + "' exists in this pack."); return; diff --git a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandStructure.java b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandStructure.java index f1796df2f..a2fdc4b2a 100644 --- a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandStructure.java +++ b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandStructure.java @@ -301,7 +301,7 @@ public class CommandStructure implements DirectorExecutor { sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STRUCTURE_COULD_NOT_RESOLVE_PACK_DIMENSION_4, MessageArgument.untrusted("value", dimension.getLoadKey()))); return; } - IrisStructure s = StructureResources.structure(data, structure); + IrisStructure s = StructureResources.structure(data.getPackResources(), structure); if (s == null) { sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STRUCTURE_NO_IRIS_STRUCTURE_THIS_PACK, MessageArgument.untrusted("structure", structure))); return; @@ -339,7 +339,7 @@ public class CommandStructure implements DirectorExecutor { sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STRUCTURE_COULD_NOT_RESOLVE_PACK_DIMENSION_5, MessageArgument.untrusted("value", dimension.getLoadKey()))); return; } - IrisStructure s = StructureResources.structure(data, structure); + IrisStructure s = StructureResources.structure(data.getPackResources(), structure); if (s == null) { sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STRUCTURE_NO_IRIS_STRUCTURE_THIS_PACK_2, MessageArgument.untrusted("structure", structure))); return; diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStructureCommands.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStructureCommands.java index 568d1aa34..1948c81fe 100644 --- a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStructureCommands.java +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStructureCommands.java @@ -141,7 +141,7 @@ public final class ModdedStructureCommands { return 0; } String key = keyRaw.trim(); - IrisStructure structure = StructureResources.structure(data, key); + IrisStructure structure = StructureResources.structure(data.getPackResources(), key); if (structure == null) { IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STRUCTURE_COMMANDS_NO_IRIS_STRUCTURE_THIS_PACK, MessageArgument.untrusted("key", key))); return 0; @@ -181,7 +181,7 @@ public final class ModdedStructureCommands { return 0; } String key = keyRaw.trim(); - IrisStructure structure = StructureResources.structure(data, key); + IrisStructure structure = StructureResources.structure(data.getPackResources(), key); if (structure == null) { IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STRUCTURE_COMMANDS_NO_IRIS_STRUCTURE_THIS_PACK_2, MessageArgument.untrusted("key", key))); return 0; @@ -227,7 +227,7 @@ public final class ModdedStructureCommands { try { Engine engine = IrisModdedCommands.engineFor(context.getSource().getLevel()); if (engine != null) { - return SharedSuggestionProvider.suggest(StructureResources.structureKeys(engine.getData()), builder); + return SharedSuggestionProvider.suggest(StructureResources.structureKeys(engine.getData().getPackResources()), builder); } } catch (Throwable ignored) { } diff --git a/core/src/main/java/art/arcane/iris/core/loader/IrisRegistrant.java b/core/src/main/java/art/arcane/iris/core/loader/IrisRegistrant.java index 782818ba2..2231ec9d5 100644 --- a/core/src/main/java/art/arcane/iris/core/loader/IrisRegistrant.java +++ b/core/src/main/java/art/arcane/iris/core/loader/IrisRegistrant.java @@ -20,6 +20,7 @@ package art.arcane.iris.core.loader; import com.google.gson.GsonBuilder; import art.arcane.iris.core.modules.ModuleSettings; +import art.arcane.iris.engine.object.KeyedResource; import art.arcane.iris.spi.IrisLogging; import lombok.Data; import lombok.EqualsAndHashCode; @@ -28,19 +29,14 @@ import java.awt.Desktop; import java.io.File; @Data -public abstract class IrisRegistrant { +@EqualsAndHashCode(callSuper = false) +public abstract class IrisRegistrant extends KeyedResource { @EqualsAndHashCode.Exclude private transient IrisData loader; - private transient String loadKey; - private transient File loadFile; private transient ModuleSettings moduleSettings = ModuleSettings.NONE; - public abstract String getFolderName(); - - public abstract String getTypeName(); - public void registerTypeAdapters(GsonBuilder builder) { } diff --git a/core/src/main/java/art/arcane/iris/core/modules/IrisModuleHost.java b/core/src/main/java/art/arcane/iris/core/modules/IrisModuleHost.java index 6979856c5..32c295f81 100644 --- a/core/src/main/java/art/arcane/iris/core/modules/IrisModuleHost.java +++ b/core/src/main/java/art/arcane/iris/core/modules/IrisModuleHost.java @@ -19,6 +19,7 @@ package art.arcane.iris.core.modules; import art.arcane.iris.core.loader.IrisData; +import art.arcane.iris.engine.mantle.components.StructureModule; import art.arcane.iris.spi.IrisPlatforms; import com.volmit.IrisModule; import com.volmit.ModuleLog; @@ -61,7 +62,7 @@ public final class IrisModuleHost { public static final List JAR_MODULE_IDS = List.of("iris:post", "iris:perfection", "iris:matter", "iris:loot", "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:structure"); + "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"; private static final String[] JAR_COPY_FOLDER = {"cache", "module-jars"}; @@ -81,9 +82,13 @@ public final class IrisModuleHost { return hostModules(); } - /** Modules that are Iris itself, not features: they write the layout's platform biomes, record the platform's custom blocks and serve Iris's structure model. A pack never replaces them and the built-ins jar does not hold them. */ + /** + * Modules Iris registers itself, not from the built-ins jar: those that are Iris (they write the layout's platform + * biomes, record the platform's custom blocks and answer for Iris's structure model) and {@code iris:structure}, whose + * resources Iris's jigsaw studio reads as the same classes. A pack never replaces them. + */ private static List hostModules() { - return List.of(new BiomeModule(), new CustomModule(), new StructureModelModule()); + return List.of(new BiomeModule(), new CustomModule(), new StructureModule(), new StructureModelModule()); } /** Iris's own log, labelled {@code [iris]}, for host code that calls module classes outside any module's stage, service or hook. */ diff --git a/core/src/main/java/art/arcane/iris/core/modules/ModuleResourceFiles.java b/core/src/main/java/art/arcane/iris/core/modules/ModuleResourceFiles.java index a07439752..d2207150b 100644 --- a/core/src/main/java/art/arcane/iris/core/modules/ModuleResourceFiles.java +++ b/core/src/main/java/art/arcane/iris/core/modules/ModuleResourceFiles.java @@ -20,6 +20,7 @@ package art.arcane.iris.core.modules; import art.arcane.iris.core.loader.IrisData; import art.arcane.iris.core.loader.IrisRegistrant; +import art.arcane.iris.engine.object.KeyedResource; import art.arcane.iris.core.loader.JsonSchemaValidator; import art.arcane.volmlib.util.json.JSONObject; import com.volmit.resource.ResourceKind; @@ -117,21 +118,22 @@ public final class ModuleResourceFiles { } private void describeOrigin(T resource, String key, File file) { - if (!(resource instanceof IrisRegistrant registrant)) { - return; + if (resource instanceof KeyedResource keyed) { + keyed.setLoadKey(key); + } + if (resource instanceof IrisRegistrant registrant) { + registrant.setLoadFile(file); + registrant.setLoader(data); } - registrant.setLoadKey(key); - registrant.setLoadFile(file); - registrant.setLoader(data); } - /** What load reports and studio call a resource of {@code kind}: an Iris registrant's own type name, such as Structure, or else the kind's id. */ + /** What load reports and studio call a resource of {@code kind}: the type name of one of Iris's own resource classes, such as Structure, or else the kind's id. */ public static String typeName(ResourceKind kind) { - if (!IrisRegistrant.class.isAssignableFrom(kind.type())) { + if (!KeyedResource.class.isAssignableFrom(kind.type())) { return kind.id().toString(); } try { - return ((IrisRegistrant) kind.type().getConstructor().newInstance()).getTypeName(); + return ((KeyedResource) kind.type().getConstructor().newInstance()).getTypeName(); } catch (ReflectiveOperationException failure) { return kind.id().toString(); } diff --git a/core/src/main/java/art/arcane/iris/core/modules/StructureModelModule.java b/core/src/main/java/art/arcane/iris/core/modules/StructureModelModule.java index 3478255ca..33af51654 100644 --- a/core/src/main/java/art/arcane/iris/core/modules/StructureModelModule.java +++ b/core/src/main/java/art/arcane/iris/core/modules/StructureModelModule.java @@ -29,12 +29,11 @@ import com.volmit.service.StructureLocator; import com.volmit.service.VanillaStructures; /** - * Module {@code iris:structure-model}: Iris's jigsaw structure model, which the structure placements of - * {@code iris:structure} build from and the jigsaw studio, importers and exporters edit. + * Module {@code iris:structure-model}: the parts of Iris's jigsaw structures that still need Iris itself. The structures, + * jigsaw pools and jigsaw pieces are resource kinds of {@code iris:structure} ({@link StructureResources}). *

- * It owns the pack's structures, jigsaw pools and jigsaw pieces as resource kinds ({@link StructureResources}), read - * from the folders packs have always used, and checks them with {@link StructureValidator} wherever Iris validates a - * pack. It lets Iris find its structures through {@link StructureLocating}; a world's structure index lives in the + * It checks them with {@link StructureValidator} wherever Iris validates a pack. It lets Iris find its structures + * through {@link StructureLocating}; a world's structure index lives in the * world's state, so a reload of the pack's structure files, which starts a new world, builds it again. *

* It decides over the platform's own structures through its {@link VanillaStructures} provider @@ -53,7 +52,6 @@ public final class StructureModelModule implements IrisModule { @Override public void setup(ModuleSetup setup) { var registry = setup.registry(); - StructureResources.kinds().forEach(registry::registerResourceKind); registry.registerValidator(new StructureValidator()); registry.registerService(StructureLocator.class, new StructureLocating()); registry.registerService(VanillaStructures.class, new StructureVanillaStructures()); diff --git a/core/src/main/java/art/arcane/iris/core/project/SchemaBuilder.java b/core/src/main/java/art/arcane/iris/core/project/SchemaBuilder.java index 47abde3da..922a551cd 100644 --- a/core/src/main/java/art/arcane/iris/core/project/SchemaBuilder.java +++ b/core/src/main/java/art/arcane/iris/core/project/SchemaBuilder.java @@ -84,6 +84,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.Function; import java.util.function.Supplier; +import java.util.stream.Stream; public class SchemaBuilder { private static final String SYMBOL_LIMIT__N = "*"; @@ -490,7 +491,7 @@ public class SchemaBuilder { * the module resource kind read into it; null when the pack has neither. */ private PackResourceList putPackResourceRef(JSONObject property, Class type) { - ResourceLoader loader = data.getLoaders().get(type); + ResourceLoader loader = data.getLoaders().get(irisTypeOf(type)); if (loader != null) { return putResourceKeys(property, new PackResourceList(loader.getFolderName(), loader.getResourceTypeName()), Arrays.asList(loader.getPossibleKeys())); @@ -502,6 +503,16 @@ public class SchemaBuilder { .orElse(null); } + /** The Iris class a host kind reads into, for the API type the kind serves (IrisObject for GeneratedObject); else {@code type}. */ + private static Class irisTypeOf(Class type) { + return Stream.of(PackResources.BIOMES, PackResources.REGIONS, PackResources.OBJECTS, PackResources.EXPRESSIONS, + PackResources.IMAGE_MAPS) + .filter(kind -> kind.type() == type) + .findFirst() + .>map(kind -> IRIS_TYPES_OF_HOST_KINDS.get(kind.id())) + .orElse(type); + } + /** Completion for a module option naming a resource of the host or module resource kind {@code kindId}. */ private void completeResourceReference(JSONObject property, ResourceId kindId) { Class irisType = IRIS_TYPES_OF_HOST_KINDS.get(kindId); diff --git a/core/src/main/java/art/arcane/iris/core/runtime/jigsaw/JigsawStudioGraphMapper.java b/core/src/main/java/art/arcane/iris/core/runtime/jigsaw/JigsawStudioGraphMapper.java index f118cf4eb..f9c1bb1e2 100644 --- a/core/src/main/java/art/arcane/iris/core/runtime/jigsaw/JigsawStudioGraphMapper.java +++ b/core/src/main/java/art/arcane/iris/core/runtime/jigsaw/JigsawStudioGraphMapper.java @@ -166,7 +166,7 @@ public final class JigsawStudioGraphMapper { if (!visitedPools.add(poolKey)) { continue; } - IrisJigsawPool pool = StructureResources.pool(data, poolKey); + IrisJigsawPool pool = StructureResources.pool(data.getPackResources(), poolKey); if (pool == null) { continue; } @@ -180,7 +180,7 @@ public final class JigsawStudioGraphMapper { continue; } String pieceKey = entry.getPiece(); - IrisJigsawPiece piece = StructureResources.piece(data, pieceKey); + IrisJigsawPiece piece = StructureResources.piece(data.getPackResources(), pieceKey); if (piece == null || piece.getObject() == null || piece.getObject().isBlank()) { continue; } @@ -211,7 +211,7 @@ public final class JigsawStudioGraphMapper { if (variants.containsKey(pieceKey)) { return; } - IrisJigsawPiece piece = StructureResources.piece(data, pieceKey); + IrisJigsawPiece piece = StructureResources.piece(data.getPackResources(), pieceKey); if (piece == null || piece.getObject() == null || piece.getObject().isBlank()) { return; } diff --git a/core/src/main/java/art/arcane/iris/core/service/JigsawStudioService.java b/core/src/main/java/art/arcane/iris/core/service/JigsawStudioService.java index 534e6d76f..38eb8a96e 100644 --- a/core/src/main/java/art/arcane/iris/core/service/JigsawStudioService.java +++ b/core/src/main/java/art/arcane/iris/core/service/JigsawStudioService.java @@ -2473,7 +2473,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC J.a(() -> { try { IrisStructure structure = StructureResources.structure( - request.source(), request.structureKey()); + request.source().getPackResources(), request.structureKey()); if (structure == null) { throw new IOException("The active structure resource no longer exists"); } @@ -2601,7 +2601,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC try { JigsawStudioActivation.Request request = studio.generator().getRequest(); IrisStructure structure = StructureResources.structure( - request.source(), + request.source().getPackResources(), request.structureKey()); if (structure == null) { throw new IOException("The active structure resource no longer exists"); @@ -2802,7 +2802,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC private static IrisStructure loadStudioStructure(ActiveStudio studio) { JigsawStudioActivation.Request request = studio.generator().getRequest(); - return StructureResources.structure(request.source(), request.structureKey()); + return StructureResources.structure(request.source().getPackResources(), request.structureKey()); } private static boolean canResizeVariantToCapacity( @@ -3798,7 +3798,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC JigsawStudioActivation.Request request = studio.generator().getRequest(); IrisData source = request.source(); source.invalidateStructureResources(); - IrisStructure structure = StructureResources.structure(source, request.structureKey()); + IrisStructure structure = StructureResources.structure(source.getPackResources(), request.structureKey()); if (structure == null) { throw new IOException("The structure could not be reloaded after the graph transaction"); } @@ -7070,7 +7070,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC throw new IOException("variant '" + activeVariant.pieceKey() + "' does not belong to workcell '" + currentBay.stableId() + "'"); } - IrisJigsawPiece piece = StructureResources.piece(source, activeVariant.pieceKey()); + IrisJigsawPiece piece = StructureResources.piece(source.getPackResources(), activeVariant.pieceKey()); if (piece == null || piece.getObject() == null || piece.getObject().isBlank()) { throw new IOException("piece '" + activeVariant.pieceKey() + "' is missing or has no object"); } diff --git a/core/src/main/java/art/arcane/iris/core/structure/export/VanillaJigsawExportSource.java b/core/src/main/java/art/arcane/iris/core/structure/export/VanillaJigsawExportSource.java index 9ba533b1e..dffe0b0db 100644 --- a/core/src/main/java/art/arcane/iris/core/structure/export/VanillaJigsawExportSource.java +++ b/core/src/main/java/art/arcane/iris/core/structure/export/VanillaJigsawExportSource.java @@ -53,7 +53,7 @@ public final class VanillaJigsawExportSource { if (structure != null) { return structure; } - return StructureResources.structure(data, structureKey); + return StructureResources.structure(data.getPackResources(), structureKey); } public StructureGraphResolver resolver() { diff --git a/core/src/main/java/art/arcane/iris/engine/framework/Engine.java b/core/src/main/java/art/arcane/iris/engine/framework/Engine.java index 40961387d..b5655a51c 100644 --- a/core/src/main/java/art/arcane/iris/engine/framework/Engine.java +++ b/core/src/main/java/art/arcane/iris/engine/framework/Engine.java @@ -37,6 +37,7 @@ import art.arcane.iris.engine.IrisComplex; import art.arcane.iris.engine.UpperDimensionContext; import art.arcane.iris.engine.data.chunk.TerrainChunk; import art.arcane.iris.engine.mantle.EngineMantle; +import art.arcane.iris.engine.mantle.components.StructurePlacing; import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.value.IrisColor; import art.arcane.iris.engine.object.world.dimension.IrisDimension; @@ -459,10 +460,10 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer, if (marker.structureAware()) { IrisObject placedObject = getData().getObjectLoader().load(object); - IrisStructure structure = StructureResources.structure(getData(), marker.structureKey()); + IrisStructure structure = StructureResources.structure(getData().getPackResources(), marker.structureKey()); IrisObjectPlacement placement = placedObject == null || structure == null ? null - : structure.createLootPlacement(object); + : StructurePlacing.lootPlacement(structure, object); return new PlacedObject(placement, placedObject, id, x, z); } diff --git a/core/src/main/java/art/arcane/iris/engine/framework/IrisStructureLocator.java b/core/src/main/java/art/arcane/iris/engine/framework/IrisStructureLocator.java index f9b7df408..ee3217df1 100644 --- a/core/src/main/java/art/arcane/iris/engine/framework/IrisStructureLocator.java +++ b/core/src/main/java/art/arcane/iris/engine/framework/IrisStructureLocator.java @@ -516,7 +516,7 @@ 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(), selectedKey); + IrisStructure structure = StructureResources.structure(engine.getData().getPackResources(), selectedKey); if (structure == null) { throw new IllegalStateException("Iris structure placement references missing structure '" + selectedKey + "'"); @@ -1030,7 +1030,7 @@ public final class IrisStructureLocator { if (structureKey == null || structureKey.isBlank()) { continue; } - IrisStructure structure = StructureResources.structure(data, structureKey); + IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey); if (structure == null) { continue; } @@ -1091,7 +1091,7 @@ public final class IrisStructureLocator { continue; } for (String structureKey : placement.structures()) { - IrisStructure structure = StructureResources.structure(data, structureKey); + IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey); if (structure == null) { throw new IllegalStateException( "Iris structure placement references missing structure '" + structureKey + "'"); @@ -1209,7 +1209,7 @@ 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, structureKey); + IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey); if (structure == null) { throw new IllegalStateException((replacesNative ? "REPLACE_SOURCE references missing Iris structure '" diff --git a/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphResolver.java b/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphResolver.java index 5b96dd060..4e6fcc23c 100644 --- a/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphResolver.java +++ b/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphResolver.java @@ -32,12 +32,12 @@ final class IrisDataStructureGraphResolver implements StructureGraphResolver { @Override public IrisJigsawPool loadPool(String key) { - return StructureResources.pool(data, key); + return StructureResources.pool(data.getPackResources(), key); } @Override public IrisJigsawPiece loadPiece(String key) { - return StructureResources.piece(data, key); + return StructureResources.piece(data.getPackResources(), key); } @Override diff --git a/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphValidation.java b/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphValidation.java index a44bba695..9e6d8572c 100644 --- a/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphValidation.java +++ b/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphValidation.java @@ -82,7 +82,7 @@ public final class StructureGraphValidation { if (structureKey.equals(LEGACY_INDEX_KEY) || (activeStructureKeys != null && !activeStructureKeys.contains(structureKey))) { continue; } - IrisStructure structure = StructureResources.structure(data, structureKey); + IrisStructure structure = StructureResources.structure(data.getPackResources(), structureKey); if (structure == null) { continue; } @@ -270,12 +270,12 @@ public final class StructureGraphValidation { @Override public IrisJigsawPool loadPool(String key) { - return StructureResources.pool(data, key); + return StructureResources.pool(data.getPackResources(), key); } @Override public IrisJigsawPiece loadPiece(String key) { - return StructureResources.piece(data, key); + return StructureResources.piece(data.getPackResources(), key); } @Override diff --git a/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureLocating.java b/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureLocating.java index 01f1cf2f6..a2de3f091 100644 --- a/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureLocating.java +++ b/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureLocating.java @@ -47,7 +47,7 @@ public final class StructureLocating implements StructureLocator { @Override public Set structures(PackResources pack) { - return idsOf(pack, StructureResources.structureKeysOf(pack)); + return idsOf(pack, StructureResources.structureKeys(pack)); } @Override diff --git a/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureResources.java b/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureResources.java deleted file mode 100644 index a5504fa6c..000000000 --- a/core/src/main/java/art/arcane/iris/engine/framework/structure/StructureResources.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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 . - */ - -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.object.structure.IrisStructure; -import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece; -import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool; -import com.volmit.resource.PackResources; -import com.volmit.resource.ResourceId; -import com.volmit.resource.ResourceKind; - -import java.util.List; - -/** - * The resource kinds of Iris's module {@code iris:structure-model}, which keep the folders and files Iris packs have always used, - * and lookups by pack key for code that still names structures, pools and pieces by key. Every lookup goes through - * the pack's {@link com.volmit.resource.PackResources}, so it sees the pack's current snapshot: a hotload, or - * {@link IrisData#invalidateStructureResources()} after a tool rewrote the files, reads them again. - *

- * Lookups answer null where Iris's loaders did: for a blank key, a key the pack has no file for, and a file that - * fails to load, which was reported when it was read. - */ -public final class StructureResources { - /** Jigsaw structures, in {@code structures/}. */ - public static final ResourceKind STRUCTURES = ResourceKind.of("iris:structure-model/structure", "structures", IrisStructure.class); - /** Jigsaw pools a structure starts from and connectors lead to, in {@code jigsaw-pools/}. */ - public static final ResourceKind POOLS = ResourceKind.of("iris:structure-model/pool", "jigsaw-pools", IrisJigsawPool.class); - /** Jigsaw pieces pools hold, each an object with connectors, in {@code jigsaw-pieces/}. */ - public static final ResourceKind PIECES = ResourceKind.of("iris:structure-model/piece", "jigsaw-pieces", IrisJigsawPiece.class); - - private StructureResources() { - } - - /** Every resource kind of the structure model. */ - public static List> kinds() { - return List.of(STRUCTURES, POOLS, PIECES); - } - - public static IrisStructure structure(IrisData data, String key) { - return find(data, STRUCTURES, key); - } - - public static IrisJigsawPool pool(IrisData data, String key) { - return find(data, POOLS, key); - } - - public static IrisJigsawPiece piece(IrisData data, String key) { - return find(data, PIECES, key); - } - - /** The key of every structure of the pack, in key order. */ - public static List structureKeys(IrisData data) { - return structureKeysOf(data.getPackResources()); - } - - /** The key of every structure of the pack snapshot {@code pack}, in key order. */ - public static List structureKeysOf(PackResources pack) { - return keys(pack, STRUCTURES); - } - - /** The key of every jigsaw piece of the pack, in key order. */ - public static List pieceKeys(IrisData data) { - return keys(data, PIECES); - } - - private static T find(IrisData data, ResourceKind kind, String key) { - if (key == null || key.isBlank()) { - return null; - } - IrisPackResources resources = data.getPackResources(); - try { - return resources.find(kind, resources.idOf(key)).orElse(null); - } catch (IllegalStateException failedToLoad) { - return null; - } - } - - /** A key's id has the key as its path, so the path names the resource again wherever a key is expected. */ - private static List keys(IrisData data, ResourceKind kind) { - return keys(data.getPackResources(), kind); - } - - private static List keys(PackResources pack, ResourceKind kind) { - return pack.ids(kind).stream().map(ResourceId::path).toList(); - } -} diff --git a/core/src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java b/core/src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java index 06d241f91..04f69ee90 100644 --- a/core/src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java +++ b/core/src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java @@ -30,6 +30,7 @@ import art.arcane.iris.engine.framework.StructurePlacementScope; import art.arcane.iris.builtin.structure.StructurePlacementMarker; import art.arcane.iris.engine.framework.TreeBlockMaterial; import art.arcane.iris.engine.framework.Engine; +import art.arcane.iris.builtin.loot.ObjectLoot; import art.arcane.iris.engine.mantle.MantleWriter; import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.world.dimension.IrisDimension; @@ -536,12 +537,28 @@ public class StructurePlacing { 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 IrisObjectPlacement lootPlacement(IrisStructure structure, String objectKey) { + IrisObjectPlacement placement = new IrisObjectPlacement(); + placement.getPlace().add(objectKey); + placement.setOverrideGlobalLoot(false); + if (structure.getLoot() == null) { + return placement; + } + for (String lootTable : structure.getLoot()) { + if (lootTable != null && !lootTable.isBlank()) { + placement.getLoot().add(new ObjectLoot(lootTable, 1)); + } + } + return placement; + } + private int placeObject(MantleWriter writer, IrisStructure structure, PlacedStructurePiece p, ObjectPlaceMode mode, int y, RNG rng, Long2IntOpenHashMap foundationColumns, boolean supportNonOccluding) { IrisObject object = p.getObject(); String objectKey = object.getLoadKey(); - IrisObjectPlacement config = structure.createLootPlacement(objectKey); + IrisObjectPlacement config = lootPlacement(structure, objectKey); config.setMode(mode); config.setRotation(p.getRotation()); if (!structure.getEdit().isEmpty()) { @@ -612,7 +629,7 @@ public class StructurePlacing { || terrain.resolvedMode() == StructureTerrainMode.BORE ? Math.max(0, terrain.horizontalPadding()) : 0; for (String key : placement.structures()) { - IrisStructure structure = StructureResources.structure(engine.getData(), key); + IrisStructure structure = StructureResources.structure(engine.getData().getPackResources(), key); if (structure != null) { max = Math.max(max, Math.max(1, structure.getMaxSizeChunks()) * 16 + carvePadding); } diff --git a/core/src/main/java/art/arcane/iris/engine/object/structure/IrisStructure.java b/core/src/main/java/art/arcane/iris/engine/object/structure/IrisStructure.java deleted file mode 100644 index 9c14ab28b..000000000 --- a/core/src/main/java/art/arcane/iris/engine/object/structure/IrisStructure.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 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 . - */ - -package art.arcane.iris.engine.object.structure; - -import art.arcane.iris.builtin.anchor.PlaceTrait; -import art.arcane.iris.builtin.anchor.ObjectPlaceMode; -import art.arcane.iris.builtin.blocks.ObjectReplace; -import art.arcane.iris.builtin.loot.LootTable; -import art.arcane.iris.builtin.loot.ObjectLoot; -import art.arcane.iris.engine.object.placement.IrisObjectPlacement; -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.IrisJigsawMode; -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.value.IrisPosition; -import art.arcane.iris.core.loader.IrisRegistrant; -import art.arcane.iris.engine.object.annotations.ArrayType; -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.iris.engine.object.annotations.MaxNumber; -import art.arcane.iris.engine.object.annotations.MinNumber; -import art.arcane.iris.engine.object.annotations.RegistryListResource; -import art.arcane.iris.engine.object.annotations.RegistryListVanillaStructure; -import art.arcane.iris.engine.object.annotations.Required; -import art.arcane.volmlib.util.collection.KList; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Desc("A jigsaw structure. Starting from a pool, the assembler places a start piece and recursively attaches more pieces through matching connectors until it reaches the max depth or size. Pieces are Iris objects, so they carry the full object placement and block-control feature set.") -@Data -@EqualsAndHashCode(callSuper = false) -public class IrisStructure extends IrisRegistrant { - @Required - @RegistryListResource(IrisJigsawPool.class) - @Desc("The pool the assembler draws the start piece from.") - private String startPool = ""; - - @MinNumber(1) - @MaxNumber(30) - @Desc("The maximum jigsaw recursion depth. Larger values allow larger structures (e.g. villages) at the cost of generation time.") - private int maxDepth = 7; - - @MinNumber(1) - @MaxNumber(32) - @Desc("The maximum radius of the structure in chunks from its start piece. Acts as a hard bound on assembly size and collision checks.") - private int maxSizeChunks = 8; - - @Desc("Assembly topology. SPATIAL_JIGSAW preserves the existing freeform connector graph; PLANAR_JIGSAW declares a cell-aligned planar graph.") - private IrisJigsawMode mode = IrisJigsawMode.SPATIAL_JIGSAW; - - @Desc("Target compatibility contract for this structure. IRIS_EXTENDED permits Iris-only metadata; VANILLA_PORTABLE requires a graph that can be represented by vanilla jigsaw resources.") - private IrisJigsawCompatibility compatibility = IrisJigsawCompatibility.IRIS_EXTENDED; - - @Desc("How unresolved optional connector branches affect assembly. FAIL_ASSEMBLY preserves strict Iris behavior; TERMINATE_BRANCH matches vanilla jigsaw branch termination.") - private IrisJigsawBranchFailurePolicy branchFailurePolicy = IrisJigsawBranchFailurePolicy.FAIL_ASSEMBLY; - - @Desc("Default Studio cell dimensions. Legacy planar structures use this value for every workcell when planarWorkcells is empty.") - private IrisPosition cellSize = new IrisPosition(15, 15, 15); - - @Desc("Optional author-facing name for the single spatial Jigsaw Studio workcell. Spatial is shown when this is blank.") - private String spatialWorkcellDisplayName = ""; - - @ArrayType(type = IrisJigsawWorkcell.class) - @Desc("The six persistent planar Studio workcells. Leave empty only for the legacy cellSize fallback.") - private KList planarWorkcells = new KList<>(); - - @ArrayType(type = IrisJigsawThemeSet.class, min = 1) - @Desc("Weighted themes available to an assembly. Leave empty for one implicit unthemed assembly path.") - private KList themeSets = new KList<>(); - - @Desc("Whether every open connector must close with a real terminal piece through a mandatory direct fallback.") - private boolean requireCaps = false; - - @Desc("The place mode used when stamping each piece object into the world.") - private ObjectPlaceMode placeMode = ObjectPlaceMode.STRUCTURE_PIECE; - - @ArrayType(min = 1, type = ObjectReplace.class) - @Desc("Find-and-replace block edits applied to every piece of this structure, using the exact same syntax as an object's 'edit'. For example, replace stone bricks with obsidian.") - private KList edit = new KList<>(); - - @ArrayType(type = String.class, min = 1) - @RegistryListResource(LootTable.class) - @Desc("Loot tables applied to containers placed by this structure's pieces.") - private KList loot = new KList<>(); - - @RegistryListVanillaStructure - @Desc("If this structure was generated by importing a vanilla or datapack structure, this is that structure's key (provenance). Empty for hand-authored structures.") - private String vanillaSource = ""; - - /** Whether the structure's pieces are stamped where the assembler put them, as a vanilla jigsaw places them. */ - public boolean stampsPiecesWhereAssembled() { - return placeMode != null && placeMode.placeMode().has(PlaceTrait.RAW_STAMP); - } - - public IrisJigsawMode resolvedMode() { - return mode == null ? IrisJigsawMode.SPATIAL_JIGSAW : mode; - } - - public IrisJigsawCompatibility resolvedCompatibility() { - return compatibility == null ? IrisJigsawCompatibility.IRIS_EXTENDED : compatibility; - } - - public IrisJigsawBranchFailurePolicy resolvedBranchFailurePolicy() { - return branchFailurePolicy == null - ? IrisJigsawBranchFailurePolicy.FAIL_ASSEMBLY - : branchFailurePolicy; - } - - public IrisObjectPlacement createLootPlacement(String objectKey) { - IrisObjectPlacement placement = new IrisObjectPlacement(); - placement.getPlace().add(objectKey); - placement.setOverrideGlobalLoot(false); - if (loot == null) { - return placement; - } - for (String lootTable : loot) { - if (lootTable != null && !lootTable.isBlank()) { - placement.getLoot().add(new ObjectLoot(lootTable, 1)); - } - } - return placement; - } - - @Override - public String getFolderName() { - return "structures"; - } - - @Override - public String getTypeName() { - return "Structure"; - } -} diff --git a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawConnector.java b/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawConnector.java deleted file mode 100644 index dc99b49cc..000000000 --- a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawConnector.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 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 . - */ - -package art.arcane.iris.engine.object.structure.jigsaw; - -import art.arcane.iris.engine.object.value.IrisDirection; -import art.arcane.iris.engine.object.value.IrisPosition; -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.iris.engine.object.annotations.RegistryListResource; -import art.arcane.iris.engine.object.annotations.Required; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import java.util.Objects; - -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Desc("A jigsaw connection point on a piece. When two connectors face each other and their names match, the assembler may join the pieces.") -@Data -public class IrisJigsawConnector { - public static IrisPosition canonicalPlanarPosition(IrisPosition cellSize, IrisDirection direction) { - IrisPosition dimensions = Objects.requireNonNull(cellSize, "Planar jigsaw cell size"); - IrisDirection face = Objects.requireNonNull(direction, "Planar jigsaw connector direction"); - if (dimensions.getX() < 1 || dimensions.getY() < 1 || dimensions.getZ() < 1) { - throw new IllegalArgumentException("Planar jigsaw cell dimensions must be positive"); - } - int centerX = dimensions.getX() / 2; - int centerY = dimensions.getY() / 2; - int centerZ = dimensions.getZ() / 2; - return switch (face) { - case NORTH_NEGATIVE_Z -> new IrisPosition(centerX, centerY, 0); - case EAST_POSITIVE_X -> new IrisPosition(dimensions.getX() - 1, centerY, centerZ); - case SOUTH_POSITIVE_Z -> new IrisPosition(centerX, centerY, dimensions.getZ() - 1); - case WEST_NEGATIVE_X -> new IrisPosition(0, centerY, centerZ); - case UP_POSITIVE_Y, DOWN_NEGATIVE_Y -> throw new IllegalArgumentException( - "Planar jigsaw connector direction must be horizontal"); - }; - } - - @Required - @Desc("The position of this connector relative to the piece object's origin (0,0,0 is the lowest-corner of the object).") - private IrisPosition position = new IrisPosition(); - - @Required - @Desc("The direction this connector faces. The connecting piece is placed on this side.") - private IrisDirection direction = IrisDirection.NORTH_NEGATIVE_Z; - - @Required - @Desc("The connector's authored top direction, used to preserve aligned vanilla jigsaw orientation.") - private IrisDirection top = IrisDirection.UP_POSITIVE_Y; - - @Required - @RegistryListResource(IrisJigsawPool.class) - @Desc("The jigsaw pool to draw the connecting piece from.") - private String pool = ""; - - @Desc("The identity exposed by this connector. Another connector can attach when its targetName equals this name, matching Minecraft's jigsaw target-to-name contract.") - private String name = ""; - - @Desc("The name this connector wants to connect to on the other piece.") - private String targetName = ""; - - @Desc("Optional Iris-only connection channel. Matching is exact, case-sensitive, and whitespace-sensitive; empty channels match only other empty channels.") - private String channel = ""; - - @Desc("How the connecting piece may be rotated relative to this connector.") - private JigsawJoint joint = JigsawJoint.ROLLABLE; - - @Required - @Desc("Block state placed where this jigsaw marker was authored after assembly. Used when exporting or capturing Mojang-style jigsaw templates.") - private String finalState = "minecraft:air"; - - @Desc("Signed priority for selecting this connector within its piece. Higher values are processed before lower values; equal priorities preserve authored order.") - private int selectionPriority = 0; - - @Desc("Signed priority assigned to a child piece attached through this connector. Higher-priority child pieces expand first; equal priorities preserve attachment order.") - private int placementPriority = 0; -} diff --git a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPiece.java b/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPiece.java deleted file mode 100644 index 4e2c03202..000000000 --- a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPiece.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 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 . - */ - -package art.arcane.iris.engine.object.structure.jigsaw; - -import art.arcane.iris.engine.object.prefab.IrisObject; -import art.arcane.iris.core.loader.IrisRegistrant; -import art.arcane.iris.engine.object.annotations.ArrayType; -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.iris.engine.object.annotations.RegistryListResource; -import art.arcane.iris.engine.object.annotations.Required; -import art.arcane.volmlib.util.collection.KList; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Desc("A jigsaw piece. A piece is a single Iris object plus the connection points (connectors) that let the assembler attach other pieces to it.") -@Data -@EqualsAndHashCode(callSuper = false) -public class IrisJigsawPiece extends IrisRegistrant { - @Desc("Optional author-facing name shown by Jigsaw Studio. The resource key is shown when this is blank.") - private String displayName = ""; - - @Required - @RegistryListResource(IrisObject.class) - @Desc("The object (schematic) that makes up this piece.") - private String object = ""; - - @ArrayType(type = IrisJigsawConnector.class, min = 1) - @Desc("The jigsaw connection points on this piece.") - private KList connectors = new KList<>(); - - @Desc("If true, this piece may be rotated around the Y axis when placed so the assembler can match its connectors. Disable for pieces that must keep a fixed orientation.") - private boolean rotatable = true; - - @Desc("If true, this piece's object bounds block overlapping jigsaw pieces. Disable for connector-only scaffolds whose stored volume is intentionally shared with physical pieces.") - private boolean collidable = true; - - @ArrayType(type = String.class, min = 1) - @Desc("Theme keys that may select this piece. An empty list makes the piece available to every selected theme.") - private KList themes = new KList<>(); - - @Desc("Deterministic depth, placement-count, and terminal-role rules for this piece.") - private IrisJigsawPieceRules rules = new IrisJigsawPieceRules(); - - public boolean supportsTheme(String selectedTheme) { - if (themes == null || themes.isEmpty()) { - return true; - } - if (selectedTheme == null || selectedTheme.isBlank()) { - return false; - } - for (String theme : themes) { - if (selectedTheme.equals(theme)) { - return true; - } - } - return false; - } - - public IrisJigsawPieceRules resolvedRules() { - return rules == null ? new IrisJigsawPieceRules() : rules; - } - - @Override - public String getFolderName() { - return "jigsaw-pieces"; - } - - @Override - public String getTypeName() { - return "Jigsaw Piece"; - } -} diff --git a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPieceEntry.java b/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPieceEntry.java deleted file mode 100644 index c022d4de8..000000000 --- a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPieceEntry.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 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 . - */ - -package art.arcane.iris.engine.object.structure.jigsaw; - -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.iris.engine.object.annotations.MaxNumber; -import art.arcane.iris.engine.object.annotations.MinNumber; -import art.arcane.iris.engine.object.annotations.RegistryListResource; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Desc("A weighted reference to a jigsaw piece inside a jigsaw pool.") -@Data -public class IrisJigsawPieceEntry { - @RegistryListResource(IrisJigsawPiece.class) - @Desc("The jigsaw piece this entry refers to. Omit when empty is true.") - private String piece; - - @MinNumber(1) - @Desc("The relative weight of this piece within its pool. Higher weights are chosen more often.") - private int weight = 1; - - @MinNumber(0) - @MaxNumber(1) - @Desc("The independent eligibility chance applied to this exact pool membership before weighted selection. Zero never passes and one always passes.") - private double chance = 1D; - - @Desc("When true, choosing this entry successfully terminates the current branch without placing a piece.") - private boolean empty = false; - - public IrisJigsawPieceEntry(String piece, int weight) { - this(piece, weight, 1D, false); - } - - public boolean requiresChanceRoll() { - return chance > 0D && chance < 1D; - } - - public boolean passesChance(double roll) { - if (!Double.isFinite(roll) || roll < 0D || roll >= 1D) { - throw new IllegalArgumentException("Jigsaw chance roll must be finite and within 0 inclusive and 1 exclusive"); - } - return chance >= 1D || chance > 0D && roll < chance; - } -} diff --git a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPool.java b/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPool.java deleted file mode 100644 index f20ae5e0d..000000000 --- a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawPool.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 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 . - */ - -package art.arcane.iris.engine.object.structure.jigsaw; - -import art.arcane.iris.core.loader.IrisRegistrant; -import art.arcane.iris.engine.object.annotations.ArrayType; -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.iris.engine.object.annotations.RegistryListResource; -import art.arcane.volmlib.util.collection.KList; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Desc("A jigsaw pool. A pool is a weighted set of pieces the assembler chooses from when a connector targets this pool.") -@Data -@EqualsAndHashCode(callSuper = false) -public class IrisJigsawPool extends IrisRegistrant { - @ArrayType(type = IrisJigsawPieceEntry.class, min = 1) - @Desc("The weighted pieces in this pool.") - private KList pieces = new KList<>(); - - @RegistryListResource(IrisJigsawPool.class) - @Desc("The direct fallback pool tried after this pool, or used alone at maximum depth. The fallback pool's own fallback is not part of the same selection. Leave empty to stop expanding at maximum depth.") - private String fallback = ""; - - @Desc("Whether failure to place from this pool must be resolved through its direct fallback even when the structure does not require every branch to be capped.") - private boolean mandatoryFallback = false; - - public boolean requiresFallback(boolean structureRequiresCaps) { - return structureRequiresCaps || mandatoryFallback; - } - - @Override - public String getFolderName() { - return "jigsaw-pools"; - } - - @Override - public String getTypeName() { - return "Jigsaw Pool"; - } -} diff --git a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawWorkcell.java b/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawWorkcell.java deleted file mode 100644 index e998e142e..000000000 --- a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawWorkcell.java +++ /dev/null @@ -1,40 +0,0 @@ -package art.arcane.iris.engine.object.structure.jigsaw; - -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.iris.engine.object.annotations.MaxNumber; -import art.arcane.iris.engine.object.annotations.MinNumber; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Data -@Desc("Persistent authoring bounds and runtime availability for one planar jigsaw workcell.") -public class IrisJigsawWorkcell { - @Desc("Optional author-facing name shown by Jigsaw Studio. The canonical archetype name is shown when this is blank.") - private String displayName = ""; - - @Desc("The orientation-independent planar connector shape configured by this workcell.") - private IrisJigsawWorkcellArchetype archetype = IrisJigsawWorkcellArchetype.BLANK; - - @MinNumber(3) - @MaxNumber(128) - @Desc("The maximum canonical variant width that this workcell can contain, in blocks.") - private int width = 16; - - @MinNumber(1) - @MaxNumber(192) - @Desc("The maximum variant height that this workcell can contain, in blocks.") - private int height = 16; - - @MinNumber(3) - @MaxNumber(128) - @Desc("The maximum canonical variant depth that this workcell can contain, in blocks.") - private int depth = 16; - - @Desc("Whether pieces with this planar connector shape participate in assembly and vanilla export.") - private boolean enabled = true; -} diff --git a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawWorkcellArchetype.java b/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawWorkcellArchetype.java deleted file mode 100644 index 4275be726..000000000 --- a/core/src/main/java/art/arcane/iris/engine/object/structure/jigsaw/IrisJigsawWorkcellArchetype.java +++ /dev/null @@ -1,88 +0,0 @@ -package art.arcane.iris.engine.object.structure.jigsaw; - -import art.arcane.iris.engine.object.annotations.Desc; - -@Desc("The orientation-independent connector shape represented by a planar jigsaw workcell.") -public enum IrisJigsawWorkcellArchetype { - @Desc("Pieces with no horizontal connectors: sealed filler cells that terminate nothing and are excluded from the default piece pool.") - BLANK(0), - - @Desc("One-connector dead-end pieces; the Studio bay seeds a single north connector and new projects mark these as terminal caps.") - END(1), - - @Desc("Two-connector pass-through pieces with openings on opposite sides; the Studio bay seeds north and south connectors.") - STRAIGHT(5), - - @Desc("Two-connector right-angle pieces with openings on adjacent sides; the Studio bay seeds north and east connectors.") - CORNER(3), - - @Desc("Three-connector junction pieces; the Studio bay seeds north, east, and west connectors.") - TEE(11), - - @Desc("Four-connector pieces open on all sides; new projects use this archetype as the structure's start piece.") - CROSS(15); - - private final int canonicalMask; - - IrisJigsawWorkcellArchetype(int canonicalMask) { - this.canonicalMask = canonicalMask; - } - - public static IrisJigsawWorkcellArchetype fromPiece(IrisJigsawPiece piece) { - if (piece == null || piece.getConnectors() == null) { - return BLANK; - } - return fromMask(horizontalMask(piece)); - } - - public static IrisJigsawWorkcellArchetype fromMask(int mask) { - if (mask < 0 || mask > 15) { - throw new IllegalArgumentException("Planar jigsaw topology mask must be between 0 and 15"); - } - int connections = Integer.bitCount(mask); - return switch (connections) { - case 0 -> BLANK; - case 1 -> END; - case 2 -> mask == 5 || mask == 10 ? STRAIGHT : CORNER; - case 3 -> TEE; - case 4 -> CROSS; - default -> throw new IllegalStateException("Unreachable planar jigsaw topology"); - }; - } - - public static int horizontalMask(IrisJigsawPiece piece) { - if (piece == null || piece.getConnectors() == null) { - return 0; - } - int mask = 0; - for (IrisJigsawConnector connector : piece.getConnectors()) { - if (connector == null || connector.getDirection() == null) { - continue; - } - mask |= switch (connector.getDirection()) { - case NORTH_NEGATIVE_Z -> 1; - case EAST_POSITIVE_X -> 2; - case SOUTH_POSITIVE_Z -> 4; - case WEST_NEGATIVE_X -> 8; - case UP_POSITIVE_Y, DOWN_NEGATIVE_Y -> 0; - }; - } - return mask; - } - - public int sourceToCanonicalQuarterTurns(IrisJigsawPiece piece) { - int sourceMask = horizontalMask(piece); - if (fromMask(sourceMask) != this) { - throw new IllegalArgumentException("Jigsaw piece does not match workcell archetype " + name()); - } - for (int quarterTurns = 0; quarterTurns < 4; quarterTurns++) { - int rotated = quarterTurns == 0 - ? sourceMask - : ((sourceMask << quarterTurns) | (sourceMask >>> (4 - quarterTurns))) & 15; - if (rotated == canonicalMask) { - return quarterTurns; - } - } - throw new IllegalStateException("No canonical rotation exists for planar jigsaw piece"); - } -} diff --git a/core/src/main/java/art/arcane/iris/engine/object/value/IrisDirection.java b/core/src/main/java/art/arcane/iris/engine/object/value/IrisDirection.java deleted file mode 100644 index c386de231..000000000 --- a/core/src/main/java/art/arcane/iris/engine/object/value/IrisDirection.java +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 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 . - */ - -package art.arcane.iris.engine.object.value; - -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.volmlib.util.collection.GBiset; -import art.arcane.volmlib.util.collection.KList; -import art.arcane.volmlib.util.collection.KMap; -import art.arcane.volmlib.util.data.Cuboid.CuboidDirection; -import art.arcane.volmlib.util.math.DOP; -import art.arcane.volmlib.util.math.VectorMath; -import org.bukkit.Axis; -import org.bukkit.block.BlockFace; -import org.bukkit.util.Vector; - -import java.util.Map; - -/** - * Directions - * - * @author cyberpwn - */ -@Desc("A direction object") -public enum IrisDirection { - @Desc("0, 1, 0") - UP_POSITIVE_Y(0, 1, 0, CuboidDirection.Up), - @Desc("0, -1, 0") - DOWN_NEGATIVE_Y(0, -1, 0, CuboidDirection.Down), - @Desc("0, 0, -1") - NORTH_NEGATIVE_Z(0, 0, -1, CuboidDirection.North), - @Desc("0, 0, 1") - SOUTH_POSITIVE_Z(0, 0, 1, CuboidDirection.South), - @Desc("1, 0, 0") - EAST_POSITIVE_X(1, 0, 0, CuboidDirection.East), - @Desc("-1, 0, 0") - WEST_NEGATIVE_X(-1, 0, 0, CuboidDirection.West); - - private static KMap, DOP> permute = null; - - private final int x; - private final int y; - private final int z; - private final CuboidDirection f; - - IrisDirection(int x, int y, int z, CuboidDirection f) { - this.x = x; - this.y = y; - this.z = z; - this.f = f; - } - - public static IrisDirection getDirection(BlockFace f) { - return switch (f) { - case DOWN -> DOWN_NEGATIVE_Y; - case EAST, EAST_NORTH_EAST, EAST_SOUTH_EAST -> EAST_POSITIVE_X; - case NORTH, NORTH_NORTH_WEST, NORTH_EAST, NORTH_NORTH_EAST, NORTH_WEST -> NORTH_NEGATIVE_Z; - case SELF, UP -> UP_POSITIVE_Y; - case SOUTH, SOUTH_EAST, SOUTH_SOUTH_EAST, SOUTH_SOUTH_WEST, SOUTH_WEST -> SOUTH_POSITIVE_Z; - case WEST, WEST_NORTH_WEST, WEST_SOUTH_WEST -> WEST_NEGATIVE_X; - }; - - } - - public static IrisDirection closest(Vector v) { - double m = Double.MAX_VALUE; - IrisDirection s = null; - - for (IrisDirection i : values()) { - Vector x = i.toVector(); - double g = x.distance(v); - - if (g < m) { - m = g; - s = i; - } - } - - return s; - } - - public static IrisDirection closest(Vector v, IrisDirection... d) { - double m = Double.MAX_VALUE; - IrisDirection s = null; - - for (IrisDirection i : d) { - Vector x = i.toVector(); - double g = x.distance(v); - - if (g < m) { - m = g; - s = i; - } - } - - return s; - } - - public static IrisDirection closest(Vector v, KList d) { - double m = Double.MAX_VALUE; - IrisDirection s = null; - - for (IrisDirection i : d) { - Vector x = i.toVector(); - double g = x.distance(v); - - if (g < m) { - m = g; - s = i; - } - } - - return s; - } - - public static KList news() { - return new KList().add(NORTH_NEGATIVE_Z, EAST_POSITIVE_X, WEST_NEGATIVE_X, SOUTH_POSITIVE_Z); - } - - public static IrisDirection getDirection(Vector v) { - Vector k = VectorMath.triNormalize(v.clone().normalize()); - - for (IrisDirection i : udnews()) { - if (i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) { - return i; - } - } - - return IrisDirection.NORTH_NEGATIVE_Z; - } - - public static KList udnews() { - return new KList().add(UP_POSITIVE_Y, DOWN_NEGATIVE_Y, NORTH_NEGATIVE_Z, EAST_POSITIVE_X, WEST_NEGATIVE_X, SOUTH_POSITIVE_Z); - } - - /** - * Get the directional value from the given byte from common directional blocks - * (MUST BE BETWEEN 0 and 5 INCLUSIVE) - * - * @param b the byte - * @return the direction or null if the byte is outside of the inclusive range - * 0-5 - */ - public static IrisDirection fromByte(byte b) { - if (b > 5 || b < 0) { - return null; - } - - if (b == 0) { - return DOWN_NEGATIVE_Y; - } else if (b == 1) { - return UP_POSITIVE_Y; - } else if (b == 2) { - return NORTH_NEGATIVE_Z; - } else if (b == 3) { - return SOUTH_POSITIVE_Z; - } else if (b == 4) { - return WEST_NEGATIVE_X; - } else { - return EAST_POSITIVE_X; - } - } - - public static void calculatePermutations() { - if (permute != null) { - return; - } - - permute = new KMap<>(); - - for (IrisDirection i : udnews()) { - for (IrisDirection j : udnews()) { - GBiset b = new GBiset<>(i, j); - - if (i.equals(j)) { - permute.put(b, new DOP("DIRECT") { - @Override - public Vector op(Vector v) { - return v; - } - }); - } else if (i.reverse().equals(j)) { - if (i.isVertical()) { - permute.put(b, new DOP("R180CCZ") { - @Override - public Vector op(Vector v) { - return VectorMath.rotate90CCZ(VectorMath.rotate90CCZ(v)); - } - }); - } else { - permute.put(b, new DOP("R180CCY") { - @Override - public Vector op(Vector v) { - return VectorMath.rotate90CCY(VectorMath.rotate90CCY(v)); - } - }); - } - } else if (getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) { - permute.put(b, new DOP("R90CX") { - @Override - public Vector op(Vector v) { - return VectorMath.rotate90CX(v); - } - }); - } else if (getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) { - permute.put(b, new DOP("R90CCX") { - @Override - public Vector op(Vector v) { - return VectorMath.rotate90CCX(v); - } - }); - } else if (getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) { - permute.put(b, new DOP("R90CY") { - @Override - public Vector op(Vector v) { - return VectorMath.rotate90CY(v); - } - }); - } else if (getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) { - permute.put(b, new DOP("R90CCY") { - @Override - public Vector op(Vector v) { - return VectorMath.rotate90CCY(v); - } - }); - } else if (getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) { - permute.put(b, new DOP("R90CZ") { - @Override - public Vector op(Vector v) { - return VectorMath.rotate90CZ(v); - } - }); - } else if (getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) { - permute.put(b, new DOP("R90CCZ") { - @Override - public Vector op(Vector v) { - return VectorMath.rotate90CCZ(v); - } - }); - } else { - permute.put(b, new DOP("FAIL") { - @Override - public Vector op(Vector v) { - return v; - } - }); - } - } - } - } - - @Override - public String toString() { - return switch (this) { - case DOWN_NEGATIVE_Y -> "Down"; - case EAST_POSITIVE_X -> "East"; - case NORTH_NEGATIVE_Z -> "North"; - case SOUTH_POSITIVE_Z -> "South"; - case UP_POSITIVE_Y -> "Up"; - case WEST_NEGATIVE_X -> "West"; - }; - - } - - public boolean isVertical() { - return equals(DOWN_NEGATIVE_Y) || equals(UP_POSITIVE_Y); - } - - public Vector toVector() { - return new Vector(x, y, z); - } - - public boolean isCrooked(IrisDirection to) { - if (equals(to.reverse())) { - return false; - } - - return !equals(to); - } - - public Vector angle(Vector initial, IrisDirection d) { - calculatePermutations(); - - for (Map.Entry, DOP> entry : permute.entrySet()) { - GBiset i = entry.getKey(); - if (i.getA().equals(this) && i.getB().equals(d)) { - return entry.getValue().op(initial); - } - } - - return initial; - } - - public IrisDirection reverse() { - switch (this) { - case DOWN_NEGATIVE_Y: - return UP_POSITIVE_Y; - case EAST_POSITIVE_X: - return WEST_NEGATIVE_X; - case NORTH_NEGATIVE_Z: - return SOUTH_POSITIVE_Z; - case SOUTH_POSITIVE_Z: - return NORTH_NEGATIVE_Z; - case UP_POSITIVE_Y: - return DOWN_NEGATIVE_Y; - case WEST_NEGATIVE_X: - return EAST_POSITIVE_X; - default: - break; - } - - return EAST_POSITIVE_X; - } - - public int x() { - return x; - } - - public int y() { - return y; - } - - public int z() { - return z; - } - - public CuboidDirection f() { - return f; - } - - /** - * Get the byte value represented in some directional blocks - * - * @return the byte value - */ - public byte byteValue() { - switch (this) { - case DOWN_NEGATIVE_Y: - return 0; - case EAST_POSITIVE_X: - return 5; - case NORTH_NEGATIVE_Z: - return 2; - case SOUTH_POSITIVE_Z: - return 3; - case UP_POSITIVE_Y: - return 1; - case WEST_NEGATIVE_X: - return 4; - default: - break; - } - - return -1; - } - - public BlockFace getFace() { - return switch (this) { - case DOWN_NEGATIVE_Y -> BlockFace.DOWN; - case EAST_POSITIVE_X -> BlockFace.EAST; - case NORTH_NEGATIVE_Z -> BlockFace.NORTH; - case SOUTH_POSITIVE_Z -> BlockFace.SOUTH; - case UP_POSITIVE_Y -> BlockFace.UP; - case WEST_NEGATIVE_X -> BlockFace.WEST; - }; - - } - - public Axis getAxis() { - return switch (this) { - case DOWN_NEGATIVE_Y, UP_POSITIVE_Y -> Axis.Y; - case EAST_POSITIVE_X, WEST_NEGATIVE_X -> Axis.X; - case NORTH_NEGATIVE_Z, SOUTH_POSITIVE_Z -> Axis.Z; - }; - - } -} diff --git a/core/src/main/java/art/arcane/iris/engine/platform/studio/generators/JigsawStudioGenerator.java b/core/src/main/java/art/arcane/iris/engine/platform/studio/generators/JigsawStudioGenerator.java index 0eab62c67..b8c256d3b 100644 --- a/core/src/main/java/art/arcane/iris/engine/platform/studio/generators/JigsawStudioGenerator.java +++ b/core/src/main/java/art/arcane/iris/engine/platform/studio/generators/JigsawStudioGenerator.java @@ -425,7 +425,7 @@ public final class JigsawStudioGenerator extends EnginedStudioGenerator { } private RenderedBay buildRenderedBay(JigsawStudioBay workcell, JigsawStudioVariant variant) { - IrisJigsawPiece piece = StructureResources.piece(request.source(), variant.pieceKey()); + IrisJigsawPiece piece = StructureResources.piece(request.source().getPackResources(), variant.pieceKey()); if (piece == null) { return RenderedBay.invalid( workcell.bounds().dimensions(), diff --git a/core/src/main/java/art/arcane/iris/util/common/director/specialhandlers/IrisStructureHandler.java b/core/src/main/java/art/arcane/iris/util/common/director/specialhandlers/IrisStructureHandler.java index fb44936aa..faac8e8e7 100644 --- a/core/src/main/java/art/arcane/iris/util/common/director/specialhandlers/IrisStructureHandler.java +++ b/core/src/main/java/art/arcane/iris/util/common/director/specialhandlers/IrisStructureHandler.java @@ -51,7 +51,7 @@ public final class IrisStructureHandler implements DirectorParameterHandler keys, IrisData data) { try { - keys.addAll(StructureResources.structureKeys(data)); + keys.addAll(StructureResources.structureKeys(data.getPackResources())); } catch (PackModulesException ignored) { } } diff --git a/core/src/test/java/art/arcane/iris/core/modules/BuiltInPack.java b/core/src/test/java/art/arcane/iris/core/modules/BuiltInPack.java index 877aebf4d..efccf8141 100644 --- a/core/src/test/java/art/arcane/iris/core/modules/BuiltInPack.java +++ b/core/src/test/java/art/arcane/iris/core/modules/BuiltInPack.java @@ -30,7 +30,6 @@ import art.arcane.iris.engine.actuator.TerrainModule; import art.arcane.iris.engine.framework.vanillafeatures.VanillaFeaturesModule; import art.arcane.iris.engine.loot.LootModule; import art.arcane.iris.engine.modifier.CarveModule; -import art.arcane.iris.engine.mantle.components.StructureModule; import art.arcane.iris.engine.modifier.DepositModule; import art.arcane.iris.engine.modifier.FloatingModule; import art.arcane.iris.engine.modifier.MatterModule; @@ -77,7 +76,7 @@ public final class BuiltInPack { return List.of(new PostModule(), new PerfectionModule(), new MatterModule(), new LootModule(), new SpawnModule(), new PrepareModule(), new AnchorModule(), new ValidateModule(), new BoreModule(), new BlocksModule(), new StiltModule(), new VacuumModule(), new SnowModule(), new VanillaFeaturesModule(), new CarveModule(), - new DepositModule(), new DecorantModule(), new TerrainModule(), new ObjectModule(), new FloatingModule(), new StructureModule()); + new DepositModule(), new DecorantModule(), new TerrainModule(), new ObjectModule(), new FloatingModule()); } /** Every built-in module: Iris's own and the compiled-in copies of the jar's ({@link #jarModules()}). */ diff --git a/core/src/test/java/art/arcane/iris/engine/framework/structure/StructureResourcesTest.java b/core/src/test/java/art/arcane/iris/engine/framework/structure/StructureResourcesTest.java index 07eabd0eb..3b4820195 100644 --- a/core/src/test/java/art/arcane/iris/engine/framework/structure/StructureResourcesTest.java +++ b/core/src/test/java/art/arcane/iris/engine/framework/structure/StructureResourcesTest.java @@ -45,8 +45,8 @@ public class StructureResourcesTest { var catalog = data.getModules().pack().catalog(); var kinds = catalog.resourceKinds().stream().map(ResourceKindRegistration::kind) - .filter(kind -> kind.id().toString().startsWith("iris:structure-model/")).toList(); - assertEquals(List.of("iris:structure-model/piece", "iris:structure-model/pool", "iris:structure-model/structure"), + .filter(kind -> kind.id().toString().startsWith("iris:structure/")).toList(); + assertEquals(List.of("iris:structure/piece", "iris:structure/pool", "iris:structure/structure"), kinds.stream().map(kind -> kind.id().toString()).toList()); assertEquals(List.of("jigsaw-pieces", "jigsaw-pools", "structures"), kinds.stream().map(kind -> kind.folder()).toList()); assertTrue(catalog.validators().stream().map(ValidatorRegistration::validator).anyMatch(StructureValidator.class::isInstance)); @@ -74,20 +74,18 @@ public class StructureResourcesTest { Path pack = castlePack("castles"); IrisData data = IrisData.openValidation(pack.toFile()); try { - IrisStructure castle = StructureResources.structure(data, "castle"); + IrisStructure castle = StructureResources.structure(data.getPackResources(),"castle"); assertEquals("castle/start", castle.getStartPool()); assertEquals(5, castle.getMaxDepth()); assertEquals("castle", castle.getLoadKey()); - assertEquals(pack.resolve("structures/castle.json").toFile(), castle.getLoadFile()); - assertSame(data, castle.getLoader()); assertSame(castle, data.getPackResources().find(StructureResources.STRUCTURES, new ResourceId("castles", "castle")).orElseThrow()); - assertEquals("castle/start", StructureResources.pool(data, "castle/start").getPieces().getFirst().getPiece()); - assertEquals("castle/start", StructureResources.piece(data, "castle/start").getObject()); - assertEquals(List.of("castle"), StructureResources.structureKeys(data)); - assertEquals(List.of("castle/start"), StructureResources.pieceKeys(data)); - assertNull(StructureResources.structure(data, "missing")); - assertNull(StructureResources.structure(data, " ")); + assertEquals("castle/start", StructureResources.pool(data.getPackResources(), "castle/start").getPieces().getFirst().getPiece()); + assertEquals("castle/start", StructureResources.piece(data.getPackResources(), "castle/start").getObject()); + assertEquals(List.of("castle"), StructureResources.structureKeys(data.getPackResources())); + assertEquals(List.of("castle/start"), StructureResources.pieceKeys(data.getPackResources())); + assertNull(StructureResources.structure(data.getPackResources(),"missing")); + assertNull(StructureResources.structure(data.getPackResources()," ")); } finally { data.close(); } @@ -99,7 +97,7 @@ public class StructureResourcesTest { write(pack, "structures/ruin.json", "{\"maxDepth\":"); IrisData data = IrisData.openValidation(pack.toFile()); try { - assertNull(StructureResources.structure(data, "ruin")); + assertNull(StructureResources.structure(data.getPackResources(),"ruin")); assertThrows(IllegalStateException.class, () -> data.getPackResources().find(StructureResources.STRUCTURES, new ResourceId("broken", "ruin"))); } finally { @@ -112,28 +110,28 @@ public class StructureResourcesTest { Path pack = castlePack("reloaded"); IrisData data = IrisData.openValidation(pack.toFile()); try { - assertEquals(5, StructureResources.structure(data, "castle").getMaxDepth()); + assertEquals(5, StructureResources.structure(data.getPackResources(),"castle").getMaxDepth()); write(pack, "structures/castle.json", "{\"startPool\":\"castle/start\",\"maxDepth\":9}"); write(pack, "structures/tower.json", "{\"startPool\":\"castle/start\"}"); - assertEquals("a snapshot keeps what it read", 5, StructureResources.structure(data, "castle").getMaxDepth()); + assertEquals("a snapshot keeps what it read", 5, StructureResources.structure(data.getPackResources(),"castle").getMaxDepth()); data.invalidateStructureResources(); - assertEquals(9, StructureResources.structure(data, "castle").getMaxDepth()); - assertEquals(List.of("castle", "tower"), StructureResources.structureKeys(data)); + assertEquals(9, StructureResources.structure(data.getPackResources(),"castle").getMaxDepth()); + assertEquals(List.of("castle", "tower"), StructureResources.structureKeys(data.getPackResources())); write(pack, "structures/castle.json", "{\"startPool\":\"castle/start\",\"maxDepth\":3}"); data.dump(); - assertEquals(3, StructureResources.structure(data, "castle").getMaxDepth()); + assertEquals(3, StructureResources.structure(data.getPackResources(),"castle").getMaxDepth()); } finally { data.close(); } IrisData runtime = IrisData.openRuntime(pack.toFile()); try { - assertEquals(3, StructureResources.structure(runtime, "castle").getMaxDepth()); + assertEquals(3, StructureResources.structure(runtime.getPackResources(),"castle").getMaxDepth()); write(pack, "structures/castle.json", "{\"startPool\":\"castle/start\",\"maxDepth\":2}"); runtime.hotloaded(); - assertEquals(2, StructureResources.structure(runtime, "castle").getMaxDepth()); + assertEquals(2, StructureResources.structure(runtime.getPackResources(),"castle").getMaxDepth()); } finally { runtime.close(); } diff --git a/core/src/test/java/art/arcane/iris/engine/object/structure/IrisStructureLootPlacementTest.java b/core/src/test/java/art/arcane/iris/engine/object/structure/IrisStructureLootPlacementTest.java index 96a4d6aa4..0c831db73 100644 --- a/core/src/test/java/art/arcane/iris/engine/object/structure/IrisStructureLootPlacementTest.java +++ b/core/src/test/java/art/arcane/iris/engine/object/structure/IrisStructureLootPlacementTest.java @@ -1,5 +1,6 @@ package art.arcane.iris.engine.object.structure; +import art.arcane.iris.engine.mantle.components.StructurePlacing; import art.arcane.iris.engine.object.placement.IrisObjectPlacement; import art.arcane.iris.engine.object.structure.IrisStructure; import org.junit.Test; @@ -15,7 +16,7 @@ public class IrisStructureLootPlacementTest { structure.getLoot().add("village_common"); structure.getLoot().add("village_rare"); - IrisObjectPlacement placement = structure.createLootPlacement("pieces/village_house"); + IrisObjectPlacement placement = StructurePlacing.lootPlacement(structure, "pieces/village_house"); assertEquals(1, placement.getPlace().size()); assertEquals("pieces/village_house", placement.getPlace().get(0)); @@ -31,7 +32,7 @@ public class IrisStructureLootPlacementTest { @Test public void createsEmptyLootPlacementWhenStructureHasNoLoot() { - IrisObjectPlacement placement = new IrisStructure().createLootPlacement("pieces/empty_house"); + IrisObjectPlacement placement = StructurePlacing.lootPlacement(new IrisStructure(), "pieces/empty_house"); assertEquals("pieces/empty_house", placement.getPlace().get(0)); assertTrue(placement.getLoot().isEmpty());