mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Move structure placement and jigsaw into the built-in modules jar
iris:structure places and locates structures and owns the structure commands; iris:jigsaw owns the model, the assembler, the importers, the studio and the jigsaw commands. Both load from the jar, and the studio now lives with its tool world: it is created by the first jigsaw command and closes with the world. The host's structure host, model module, assemblies seam and studio host are gone. A datapack's structures are imported through the new DatapackStructureImport service.
This commit is contained in:
1 parent
ba8429952a
commit
543e8c615e
235 files changed
+1199
-1006
No files matched your search
+2
-1
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.iris.engine.framework.NativeStartMemo;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.engine.framework.NativeStructureReach;
|
||||
import art.arcane.iris.engine.framework.nativefit.NativeFitPiece;
|
||||
import art.arcane.iris.engine.framework.nativefit.NativeStructureFitting;
|
||||
@@ -1032,7 +1033,7 @@ public class NativeStructureFitBridgeTest {
|
||||
}
|
||||
|
||||
private static final class BuiltInFitting {
|
||||
private static final NativeStructureFitting FITTING = NativeStructureFitting.builtInModules();
|
||||
private static final NativeStructureFitting FITTING = NativeStructureFitting.ofModules(new StructureModule());
|
||||
}
|
||||
|
||||
private static PoolElementStructurePiece rigidTemplatePiece(
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.iris.engine.framework.NativeStartMemo;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.engine.framework.nativefit.NativeStructureFitting;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -140,7 +141,7 @@ public class NativeStructureFitPinTest {
|
||||
|
||||
/** The built-in modules load once for every scenario. */
|
||||
private static final class BuiltInFitting {
|
||||
private static final NativeStructureFitting FITTING = NativeStructureFitting.builtInModules();
|
||||
private static final NativeStructureFitting FITTING = NativeStructureFitting.ofModules(new StructureModule());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,14 +66,15 @@ tasks.named('jar', Jar).configure {
|
||||
|
||||
tasks.named('test').configure {
|
||||
systemProperty('iris.commandFindSource', file('src/main/java/art/arcane/iris/core/commands/CommandFind.java').absolutePath)
|
||||
systemProperty('iris.importCommandsSource', rootProject.file('core/src/main/java/art/arcane/iris/core/structure/tooling/ImportCommands.java').absolutePath)
|
||||
systemProperty('iris.studioLifecycleCommandsSource', rootProject.file('core/src/main/java/art/arcane/iris/core/structure/tooling/StudioLifecycleCommands.java').absolutePath)
|
||||
systemProperty('iris.importCommandsSource', rootProject.file('module/src/main/java/art/arcane/iris/core/structure/tooling/ImportCommands.java').absolutePath)
|
||||
systemProperty('iris.studioLifecycleCommandsSource', rootProject.file('module/src/main/java/art/arcane/iris/core/structure/tooling/StudioLifecycleCommands.java').absolutePath)
|
||||
systemProperty('iris.commandIrisSource', file('src/main/java/art/arcane/iris/core/commands/CommandIris.java').absolutePath)
|
||||
systemProperty('iris.bukkitChunkGeneratorSource', rootProject.file('core/src/main/java/art/arcane/iris/engine/platform/BukkitChunkGenerator.java').absolutePath)
|
||||
systemProperty('iris.pregeneratorJobSource', rootProject.file('core/src/main/java/art/arcane/iris/core/gui/PregeneratorJob.java').absolutePath)
|
||||
systemProperty('iris.bukkitEnginePlatformHooksSource', file('src/main/java/art/arcane/iris/core/runtime/BukkitEnginePlatformHooks.java').absolutePath)
|
||||
systemProperty('iris.engineSvcSource', file('src/main/java/art/arcane/iris/core/service/IrisEngineSVC.java').absolutePath)
|
||||
systemProperty('iris.jigsawStudioSvcSource', rootProject.file('core/src/main/java/art/arcane/iris/core/service/JigsawStudioService.java').absolutePath)
|
||||
systemProperty('iris.jigsawStudioSvcSource', rootProject.file('module/src/main/java/art/arcane/iris/core/service/JigsawStudioService.java').absolutePath)
|
||||
systemProperty('iris.toolWorldServiceSource', file('src/main/java/art/arcane/iris/core/toolworld/BukkitToolWorldService.java').absolutePath)
|
||||
systemProperty('iris.studioSvcSource', rootProject.file('core/src/main/java/art/arcane/iris/core/service/StudioSVC.java').absolutePath)
|
||||
systemProperty('iris.terrainSvcSource', file('src/main/java/art/arcane/iris/core/service/IrisTerrainSVC.java').absolutePath)
|
||||
systemProperty('iris.apiEventSvcSource', file('src/main/java/art/arcane/iris/core/service/IrisApiEventSVC.java').absolutePath)
|
||||
|
||||
@@ -47,9 +47,7 @@ import art.arcane.iris.core.runtime.BukkitEnginePlatformHooks;
|
||||
import art.arcane.iris.core.runtime.WorldDeletionQueue;
|
||||
import art.arcane.iris.core.runtime.WorldRuntimeControlService;
|
||||
import art.arcane.iris.core.toolworld.BukkitToolWorldService;
|
||||
import art.arcane.iris.core.structure.BukkitJigsawStudioHost;
|
||||
import art.arcane.iris.core.structure.BukkitPlatformStructures;
|
||||
import art.arcane.iris.core.structure.tooling.JigsawStudioHost;
|
||||
import art.arcane.iris.core.tooling.ToolWorldsHost;
|
||||
import com.volmit.tooling.PlatformStructures;
|
||||
import art.arcane.iris.api.terrain.IrisTerrainService;
|
||||
@@ -73,8 +71,6 @@ import art.arcane.iris.core.service.IrisEngineSVC;
|
||||
import art.arcane.iris.core.service.IrisIntegrationService;
|
||||
import art.arcane.iris.core.service.IrisProtocolService;
|
||||
import art.arcane.iris.core.service.IrisTerrainSVC;
|
||||
import art.arcane.iris.core.modules.IrisModuleHost;
|
||||
import art.arcane.iris.core.service.JigsawStudioService;
|
||||
import art.arcane.iris.core.service.LogFilterSVC;
|
||||
import art.arcane.iris.core.service.MultiverseSVC;
|
||||
import art.arcane.iris.core.service.ObjectSVC;
|
||||
@@ -200,7 +196,6 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
|
||||
private volatile IrisPapiListener papiListener;
|
||||
private volatile IrisPapiState papiState;
|
||||
private KMap<Class<? extends IrisService>, IrisService> services;
|
||||
private volatile JigsawStudioService jigsawStudio;
|
||||
// Copy-on-write: mutated on the main thread during enable() and iterated by the JVM
|
||||
// shutdown-hook thread during teardown; a plain list would CME and abort the teardown.
|
||||
private final List<IrisService> enabledServices = new CopyOnWriteArrayList<>();
|
||||
@@ -225,11 +220,6 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
|
||||
return (T) instance.services.get(c);
|
||||
}
|
||||
|
||||
/** The Jigsaw Studio of this plugin instance; there is one, created when the plugin enables. */
|
||||
public static JigsawStudioService jigsawStudio() {
|
||||
return instance.jigsawStudio;
|
||||
}
|
||||
|
||||
public static void callEvent(Event e) {
|
||||
Runnable dispatcher = () -> {
|
||||
try {
|
||||
@@ -620,7 +610,6 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
|
||||
PaperLibBootstrap.install();
|
||||
SimdSupport.install();
|
||||
services = new KMap<>();
|
||||
jigsawStudio = new JigsawStudioService(IrisModuleHost.hostLog());
|
||||
BukkitPlatform.hostHud(new HudActionBar(this), new HudBossBarLane());
|
||||
// Explicit, ordered service list: the previous reflective jar scan gave hash-ordered
|
||||
// enable/disable and paid a full-jar class sweep at boot. Infrastructure first,
|
||||
@@ -656,7 +645,6 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
|
||||
}
|
||||
IrisServices.register(ToolWorldsHost.class, services.get(BukkitToolWorldService.class));
|
||||
IrisServices.register(PlatformStructures.class, new BukkitPlatformStructures());
|
||||
IrisServices.register(JigsawStudioHost.class, new BukkitJigsawStudioHost());
|
||||
IrisServices.register(BlockEditAccess.class, services.get(EditSVC.class));
|
||||
IrisServices.register(PreservationRegistry.class, services.get(PreservationSVC.class));
|
||||
compat = IrisCompat.configured(getDataFile("compat.json"));
|
||||
@@ -952,7 +940,6 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
|
||||
if (services != null && servicesDisabled.compareAndSet(false, true)) {
|
||||
// Only services whose onEnable actually completed; disabling a service that
|
||||
// never initialized runs teardown against uninitialized state.
|
||||
quiesceJigsawStudio("Failed to disable Jigsaw Studio.");
|
||||
for (IrisService service : enabledServices) {
|
||||
try {
|
||||
service.onDisable();
|
||||
@@ -973,21 +960,8 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
|
||||
}
|
||||
}
|
||||
|
||||
private void quiesceJigsawStudio(String failureMessage) {
|
||||
JigsawStudioService studio = jigsawStudio;
|
||||
if (studio == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
studio.quiesceForServerShutdown();
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(failureMessage, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void quiesceRuntimeForServerShutdown(String reason) {
|
||||
serverStopTeardownDeferred.set(true);
|
||||
quiesceJigsawStudio("Failed to quiesce Jigsaw Studio before server shutdown.");
|
||||
StudioSVC studioService = IrisServices.getOrNull(StudioSVC.class);
|
||||
if (studioService != null) {
|
||||
studioService.quiesceDownloadsForShutdown();
|
||||
|
||||
-79
@@ -1,79 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.structure;
|
||||
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.core.pack.BrokenPackException;
|
||||
import art.arcane.iris.core.runtime.StudioOpenCoordinator;
|
||||
import art.arcane.iris.core.service.JigsawStudioService;
|
||||
import art.arcane.iris.core.service.StudioSVC;
|
||||
import art.arcane.iris.core.structure.tooling.JigsawStudioHost;
|
||||
import art.arcane.iris.core.tooling.IrisToolPack;
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
import art.arcane.iris.util.common.plugin.VolmitSender;
|
||||
import com.volmit.tooling.Sender;
|
||||
import com.volmit.tooling.ToolPack;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
|
||||
/** The Jigsaw Studio of this plugin, and the Bukkit server services the jigsaw commands need around it. */
|
||||
public final class BukkitJigsawStudioHost implements JigsawStudioHost {
|
||||
static final StudioOpenCoordinator.StudioOpenKind STUDIO_OPEN_KIND = StudioOpenCoordinator.StudioOpenKind.TOOL;
|
||||
private static final String UNKNOWN_CLOSE_FAILURE = "unknown failure";
|
||||
|
||||
@Override
|
||||
public JigsawStudioService studio() {
|
||||
return Iris.jigsawStudio();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String packKey(ToolPack pack) {
|
||||
return IrisToolPack.dataOf(pack).getDataFolder().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Throwable> reportAdmissionFailure(Sender sender, String packKey) {
|
||||
VolmitSender messages = sender.extension(CommandSender.class).map(VolmitSender::new).orElseGet(BukkitPlatform::console);
|
||||
return Optional.ofNullable(StudioSVC.reportPackAdmissionFailure(messages, packKey, STUDIO_OPEN_KIND));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpectedOpenDenial(Throwable failure) {
|
||||
return unwrapCompletionFailure(failure) instanceof BrokenPackException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Optional<Throwable>> closeStudio() {
|
||||
return Iris.service(StudioSVC.class).close().thenApply(result -> {
|
||||
Throwable failure = result == null ? new IllegalStateException(UNKNOWN_CLOSE_FAILURE) : result.failureCause();
|
||||
return Optional.ofNullable(failure);
|
||||
});
|
||||
}
|
||||
|
||||
private static Throwable unwrapCompletionFailure(Throwable failure) {
|
||||
Throwable current = failure;
|
||||
while (current instanceof CompletionException && current.getCause() != null) {
|
||||
current = current.getCause();
|
||||
}
|
||||
return current;
|
||||
}
|
||||
}
|
||||
+27
-1
@@ -20,6 +20,7 @@ package art.arcane.iris.core.toolworld;
|
||||
|
||||
import art.arcane.iris.core.tooling.ToolWorldsHost;
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.util.common.plugin.IrisService;
|
||||
import com.volmit.tooling.world.ToolPlayer;
|
||||
import com.volmit.tooling.world.ToolWorlds;
|
||||
@@ -27,12 +28,21 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
/**
|
||||
* Tool worlds on Bukkit: the platform side of {@code com.volmit.tooling.world}. It keeps the open tool worlds and the
|
||||
* tool players, listens for the events that concern them ({@link ToolWorldEvents}), and hands each pack its
|
||||
* {@link ToolWorlds} through {@link ToolWorldsHost}, which core reaches it by.
|
||||
*/
|
||||
public final class BukkitToolWorldService implements IrisService, ToolWorldsHost {
|
||||
private static final long CLOSING_WAIT_SECONDS = 30L;
|
||||
|
||||
private final OpenToolWorlds worlds = new OpenToolWorlds();
|
||||
private final ToolPlayers players = new ToolPlayers(worlds);
|
||||
private final ToolWorldEvents events = new ToolWorldEvents(worlds, players);
|
||||
@@ -45,7 +55,23 @@ public final class BukkitToolWorldService implements IrisService, ToolWorldsHost
|
||||
@Override
|
||||
public void onDisable() {
|
||||
HandlerList.unregisterAll(events);
|
||||
worlds.all().forEach(BukkitToolWorld::unloaded);
|
||||
List<BukkitToolWorld> open = worlds.all();
|
||||
awaitClosing(open);
|
||||
open.forEach(BukkitToolWorld::unloaded);
|
||||
}
|
||||
|
||||
/** Lets every tool hear that its world is closing, as a replacement does, so it can save what it holds before the world is gone. */
|
||||
private static void awaitClosing(List<BukkitToolWorld> open) {
|
||||
CompletableFuture<?>[] closing = open.stream()
|
||||
.map(world -> world.prepareReplacement(Optional.empty()))
|
||||
.toArray(CompletableFuture[]::new);
|
||||
try {
|
||||
CompletableFuture.allOf(closing).get(CLOSING_WAIT_SECONDS, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException interrupted) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (ExecutionException | TimeoutException notReady) {
|
||||
IrisLogging.reportError("A tool world was not ready to close when Iris stopped.", notReady);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
@@ -23,6 +23,7 @@ import art.arcane.iris.core.runtime.StudioPainterSlots;
|
||||
import art.arcane.iris.core.service.StudioSVC;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
import com.volmit.tooling.world.ToolWorld;
|
||||
import com.volmit.tooling.world.ToolWorldDenied;
|
||||
import com.volmit.tooling.world.ToolWorldSpec;
|
||||
import com.volmit.tooling.world.ToolWorlds;
|
||||
import org.bukkit.World;
|
||||
@@ -52,6 +53,10 @@ final class BukkitToolWorlds implements ToolWorlds {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<ToolWorld> open(ToolWorldSpec spec) {
|
||||
Optional<String> denial = StudioSVC.packAdmissionDenial(packName, StudioOpenCoordinator.StudioOpenKind.TOOL);
|
||||
if (denial.isPresent()) {
|
||||
return CompletableFuture.failedFuture(new ToolWorldDenied(denial.get()));
|
||||
}
|
||||
PendingBlockEntities pending = new PendingBlockEntities();
|
||||
StudioPainterSlots.Slot slot = new StudioPainterSlots.Slot(spec.painter(), pending::add);
|
||||
String storageName = STORAGE_NAME_PREFIX + UUID.randomUUID();
|
||||
|
||||
+13
-25
@@ -57,7 +57,6 @@ public class IrisShutdownOrderingTest {
|
||||
assertTrue("Server-stop quiescence must leave queued Paper generation admitted",
|
||||
quiesce.contains("generator.quiesceForServerShutdown()"));
|
||||
assertOrdered(quiesce,
|
||||
"quiesceJigsawStudio(\"Failed to quiesce Jigsaw Studio before server shutdown.\")",
|
||||
"PregeneratorJob.shutdownAndWait",
|
||||
"generator.quiesceForServerShutdown()");
|
||||
assertOrdered(onDisable,
|
||||
@@ -114,32 +113,21 @@ public class IrisShutdownOrderingTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jigsawStudio_quiescesOnceBeforeDeferredServiceTeardown() throws Exception {
|
||||
String source = Files.readString(Path.of(System.getProperty("iris.jigsawStudioSvcSource")));
|
||||
public void jigsawStudio_quiescesThroughItsToolWorldBeforeTheWorldIsUnloaded() throws Exception {
|
||||
String startup = Files.readString(Path.of(System.getProperty("iris.startupSource")));
|
||||
String teardown = section(startup, "private void teardownRuntime", "private void quiesceJigsawStudio");
|
||||
String quiesceStudio = section(startup, "private void quiesceJigsawStudio", "private void quiesceRuntimeForServerShutdown");
|
||||
String quiesce = section(source, "public void quiesceForServerShutdown()", "public CompletableFuture<ToolWorld> open(");
|
||||
String register = section(source, "void register(", "private void replayChunksLoadedBeforeRegistration(");
|
||||
String activation = section(source, "public void activationCommitted(", "private void markChunkAvailable(");
|
||||
String toolWorlds = Files.readString(Path.of(System.getProperty("iris.toolWorldServiceSource")));
|
||||
String studio = Files.readString(Path.of(System.getProperty("iris.jigsawStudioSvcSource")));
|
||||
String disable = section(toolWorlds, "public void onDisable()", "public ToolWorlds worldsOf");
|
||||
String closing = section(studio, "CompletableFuture<Void> closing(", "private boolean markDirty(");
|
||||
|
||||
assertOrdered(teardown,
|
||||
"quiesceJigsawStudio(\"Failed to disable Jigsaw Studio.\")",
|
||||
"service.onDisable()");
|
||||
assertTrue("Deferred service teardown must reuse the idempotent early quiesce",
|
||||
quiesceStudio.contains("studio.quiesceForServerShutdown()"));
|
||||
assertOrdered(quiesce,
|
||||
"disableStarted.compareAndSet(false, true)",
|
||||
"finalizeAllJigsawTileWatches()",
|
||||
"drainAutosavesBeforeDisable()",
|
||||
"enabled = false",
|
||||
"activeMenuController.closeAll()",
|
||||
"previewRenderer.removeAll()",
|
||||
"studios.clear()");
|
||||
assertTrue("Registration must reject work after shutdown begins",
|
||||
occurrences(register, "!enabled || disableStarted.get()") >= 2);
|
||||
assertTrue("Activation must reject work after shutdown begins",
|
||||
activation.contains("!enabled || disableStarted.get()"));
|
||||
assertFalse("Iris no longer holds or quiesces a studio itself", startup.contains("JigsawStudio"));
|
||||
assertOrdered(disable,
|
||||
"awaitClosing(open)",
|
||||
"open.forEach(BukkitToolWorld::unloaded)");
|
||||
assertTrue("The host asks every tool world to get ready to close", toolWorlds.contains("world.prepareReplacement(Optional.empty())"));
|
||||
assertOrdered(closing,
|
||||
"drainAutosavesBeforeRemoval(studios.get(worldId))",
|
||||
"awaitCloseForReplacement(");
|
||||
}
|
||||
|
||||
private static String section(String source, String startMarker, String endMarker) {
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
package art.arcane.iris.core.structure;
|
||||
|
||||
import art.arcane.iris.core.pack.BrokenPackException;
|
||||
import art.arcane.iris.core.runtime.StudioOpenCoordinator;
|
||||
import art.arcane.iris.core.tools.IrisCreator;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletionException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BukkitJigsawStudioHostTest {
|
||||
private final BukkitJigsawStudioHost host = new BukkitJigsawStudioHost();
|
||||
|
||||
@Test
|
||||
public void jigsawStudioUsesItsDedicatedOpenLifecycle() {
|
||||
assertEquals(
|
||||
StudioOpenCoordinator.StudioOpenKind.TOOL,
|
||||
BukkitJigsawStudioHost.STUDIO_OPEN_KIND);
|
||||
assertFalse(BukkitJigsawStudioHost.STUDIO_OPEN_KIND.openWorkspace());
|
||||
assertFalse(BukkitJigsawStudioHost.STUDIO_OPEN_KIND.teleportThroughStandardEntry());
|
||||
assertEquals(
|
||||
IrisCreator.DatapackPreparation.REUSE_LOADED_RUNTIME_IF_READY,
|
||||
BukkitJigsawStudioHost.STUDIO_OPEN_KIND.datapackPreparation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void packValidationDenialsAreExpectedOpenFailures() {
|
||||
BrokenPackException failure = new BrokenPackException(
|
||||
"overworld", List.of("Biome 'broken' has no resolvable regions."));
|
||||
|
||||
assertTrue(host.isExpectedOpenDenial(failure));
|
||||
assertTrue(host.isExpectedOpenDenial(new CompletionException(failure)));
|
||||
assertFalse(host.isExpectedOpenDenial(new IllegalStateException("Unexpected Studio failure")));
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.iris.engine.framework.NativeStartMemo;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.engine.framework.nativefit.NativeStructureFitting;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -55,7 +56,7 @@ public class NativeStructureVacuumParityTest {
|
||||
Map<BlockPos, BlockState> blocks = flatTerrain(area);
|
||||
Map<BlockPos, BlockState> original = new HashMap<>(blocks);
|
||||
|
||||
NativeStructureFitting.builtInModules().beforePieces(NativeStructureFitBridge.chunk(world(blocks), area,
|
||||
NativeStructureFitting.ofModules(new StructureModule()).beforePieces(NativeStructureFitBridge.chunk(world(blocks), area,
|
||||
List.of(new NativeStructureFitBridge.FitTarget("test:vacuum", start,
|
||||
new NativeStartMemo("{\"terrain\":{\"mode\":\"VACUUM\"}}"))), (x, z) -> SURFACE_Y));
|
||||
|
||||
|
||||
@@ -69,6 +69,13 @@ public interface PackResources {
|
||||
return ResourceId.ofPackKey(packId().namespace(), key);
|
||||
}
|
||||
|
||||
/** The providers of {@code service} that the pack's modules registered, in module id order, so a module that holds only the
|
||||
* resources, such as a locator listing structures, can ask the modules that own the kinds. Empty by default.
|
||||
*/
|
||||
default <S> List<S> services(Class<S> service) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
/** {@link #find} for a resource that must exist: a missing one throws NoSuchElementException naming kind and id. */
|
||||
default <T> T require(ResourceKind<T> kind, ResourceId id) {
|
||||
return find(kind, id).orElseThrow(() -> new NoSuchElementException("Missing " + kind.id() + " resource: " + id));
|
||||
|
||||
@@ -117,6 +117,15 @@ public final class Argument<T> {
|
||||
});
|
||||
}
|
||||
|
||||
/** One word that {@code reader} turns into the value, for a value only the command's module can check, such as a resource
|
||||
* of a kind its module's neighbour registers. {@code reader} fails with an IllegalArgumentException that says why; the
|
||||
* argument completes nothing until {@link #suggesting} gives it candidates.
|
||||
*/
|
||||
public static <T> Argument<T> reading(String name, Reader<T> reader) {
|
||||
Objects.requireNonNull(reader, "reader");
|
||||
return of(name, false, reader::read, (partial, context) -> List.of());
|
||||
}
|
||||
|
||||
/** An id registered in the platform's {@code registry}, such as {@link Reference#STRUCTURE}; completes
|
||||
* {@link PlatformRegistries#ids}. Written as the platform writes it, {@code minecraft:village_plains}, or without the
|
||||
* {@code minecraft:} namespace.
|
||||
@@ -244,6 +253,12 @@ public final class Argument<T> {
|
||||
return registry.name().toLowerCase(Locale.ROOT).replace('_', ' ');
|
||||
}
|
||||
|
||||
/** Turns the word a sender typed into the argument's value. */
|
||||
@FunctionalInterface
|
||||
public interface Reader<T> {
|
||||
T read(String text, CommandContext context);
|
||||
}
|
||||
|
||||
private interface Parser<T> {
|
||||
T parse(String text, CommandContext context);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.volmit.tooling;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/** What {@link DatapackStructureImport#importAll} did.
|
||||
*
|
||||
* @param total the sources it tried
|
||||
* @param imported the sources it imported
|
||||
* @param skipped the sources it left as they were
|
||||
* @param failed the sources it could not import
|
||||
* @param importedBundles the bundle each fully imported source ended up as, by bundle name
|
||||
* @param retryRequired whether a failure may pass when the import runs again, as opposed to the source being invalid
|
||||
*/
|
||||
public record DatapackImportReport(int total, int imported, int skipped, int failed, Map<String, ResourceId> importedBundles,
|
||||
boolean retryRequired) {
|
||||
public DatapackImportReport {
|
||||
Objects.requireNonNull(importedBundles, "importedBundles");
|
||||
importedBundles = java.util.Collections.unmodifiableMap(new TreeMap<>(importedBundles));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.volmit.tooling;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.Providers;
|
||||
import com.volmit.service.Service;
|
||||
import java.util.Collection;
|
||||
|
||||
/** Turns the structures and templates a datapack brought into editable resources of the pack, once the host installed the
|
||||
* datapack. A module that owns a kind of structure provides it; the host asks the pack's first provider and, when the pack has
|
||||
* none, leaves the datapack's structures pending. Re-importing a source replaces what an earlier import made of it.
|
||||
*/
|
||||
@Service(Providers.FIRST)
|
||||
public interface DatapackStructureImport {
|
||||
/** Imports {@code structures} (ids of the platform's registered structures) and {@code templates} (ids of its structure
|
||||
* templates) into {@code pack}, reporting progress to {@code sender}. A source that fails does not stop the others.
|
||||
*/
|
||||
DatapackImportReport importAll(ToolPack pack, PlatformStructures platform, Sender sender,
|
||||
Collection<ResourceId> structures, Collection<ResourceId> templates);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.volmit.tooling.world;
|
||||
|
||||
/** A host refused to open a tool world for a reason its message tells the user and the pack's author can fix, such as a pack
|
||||
* with blocking errors. {@link ToolWorlds#open} completes with it; it is not a fault, so a tool reports the message and logs no
|
||||
* stack trace.
|
||||
*/
|
||||
public final class ToolWorldDenied extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ToolWorldDenied(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,10 @@ public interface ToolWorlds {
|
||||
/**
|
||||
* Opens a world whose chunks come only from {@code spec.painter()}. The future completes, on a host thread, when
|
||||
* players can enter the world. It fails with {@link IllegalStateException} when a tool world of that name is open
|
||||
* already, and with the cause when the platform cannot create the world; a failed open leaves no world behind.
|
||||
* The host closes every tool world it still has open when it shuts down.
|
||||
* already, with {@link ToolWorldDenied} when the host refuses the pack a world (its message says why), and with the
|
||||
* cause when the platform cannot create the world; a failed open leaves no world behind.
|
||||
* The host closes every tool world it still has open when it shuts down: it hears {@link ToolWorldListener#closing}
|
||||
* of each and waits for it before {@link ToolWorldListener#closed}.
|
||||
*
|
||||
* <p>A tool world has no natural mob spawning, weather, daylight cycle, portals, vanilla structures or features.
|
||||
*/
|
||||
|
||||
@@ -116,6 +116,7 @@ nmsBindings.each { key, value ->
|
||||
compileOnly(rootProject.libs.byteBuddy.core)
|
||||
testImplementation('junit:junit:4.13.2')
|
||||
testImplementation(project(':core'))
|
||||
testCompileOnly('com.volmit:iris-api')
|
||||
// The runtime contract of the host's reflection over template pools runs against this binding's own classes.
|
||||
testImplementation(project(':adapters:bukkit:plugin'))
|
||||
testCompileOnly(volmLibCoordinate) {
|
||||
|
||||
+2
-1
@@ -321,7 +321,8 @@ List<String> dependencyBuildMetadata = [
|
||||
// what its own Bukkit jar leaves out of VolmLib, which only Iris knows.
|
||||
String builtinModulesJarName = 'iris-builtins.jar'
|
||||
// The packages pack modules may use besides the IrisApi; IrisModuleHost.EXPOSED_PACKAGES lists the same.
|
||||
List<String> builtinExposedPackages = ['art.arcane.iris.builtin', 'art.arcane.volmlib', 'com.google.gson']
|
||||
List<String> builtinExposedPackages = ['art.arcane.iris.builtin', 'art.arcane.iris.core.structure.authoring', 'art.arcane.volmlib',
|
||||
'com.google.gson']
|
||||
Provider<RegularFile> bundledBuiltinModulesJar = layout.buildDirectory.file("builtin-modules/${builtinModulesJarName}")
|
||||
|
||||
configurations {
|
||||
|
||||
@@ -31,11 +31,14 @@ import art.arcane.iris.core.nms.MinecraftVersion;
|
||||
import art.arcane.iris.core.project.IrisProject;
|
||||
import art.arcane.iris.core.project.IrisCodeWorkspace;
|
||||
import art.arcane.iris.core.modules.IrisModuleHost;
|
||||
import art.arcane.iris.core.structure.BulkStructureImporter;
|
||||
import art.arcane.iris.core.modules.PackServices;
|
||||
import art.arcane.iris.core.tooling.IrisToolPack;
|
||||
import art.arcane.iris.core.tooling.VolmitToolSender;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.tooling.DatapackImportReport;
|
||||
import com.volmit.tooling.DatapackStructureImport;
|
||||
import com.volmit.tooling.PlatformStructures;
|
||||
import art.arcane.iris.core.structure.StructureImporter;
|
||||
import art.arcane.iris.core.structure.authoring.StructureBundleNames;
|
||||
import art.arcane.iris.core.structure.authoring.StructureKey;
|
||||
import art.arcane.iris.core.structure.authoring.StructureSource;
|
||||
import art.arcane.iris.core.structure.authoring.StructureTransactionWriter;
|
||||
@@ -81,6 +84,7 @@ import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
@@ -101,6 +105,7 @@ import java.util.stream.Stream;
|
||||
|
||||
public final class DatapackIngestService {
|
||||
private static final String USER_AGENT = "VolmitSoftware/Iris (datapack-ingest)";
|
||||
private static final String NO_STRUCTURE_IMPORT_KEY = "datapack-structure-import-missing:";
|
||||
private static final String FINDER_METADATA = ".DS_Store";
|
||||
private static final String OVERRIDES_STRIPPED_MARKER = ".iris-overrides-stripped";
|
||||
private static final String OWNERSHIP_MARKER = ".iris-managed.json";
|
||||
@@ -3182,20 +3187,30 @@ public final class DatapackIngestService {
|
||||
}
|
||||
attemptedPacks++;
|
||||
try {
|
||||
BulkStructureImporter.Report report = BulkStructureImporter.importManagedDatapackStructures(
|
||||
Optional<DatapackStructureImport> structureImport = PackServices.of(data)
|
||||
.providers(DatapackStructureImport.class).stream().findFirst();
|
||||
if (structureImport.isEmpty()) {
|
||||
IrisLogging.warnOnce(NO_STRUCTURE_IMPORT_KEY + data.getDataFolder().getAbsolutePath(),
|
||||
"Pack '%s' has no module that imports datapack structures; they stay pending until it has one.",
|
||||
data.getDataFolder().getPath());
|
||||
failedUrls.addAll(pendingUrls);
|
||||
reconcileFailedImportInventories(root, manifest, data, targetId, pendingUrls, entriesByUrl);
|
||||
continue;
|
||||
}
|
||||
DatapackImportReport report = structureImport.get().importAll(
|
||||
new IrisToolPack(data, IrisModuleHost.hostLog()),
|
||||
IrisServices.get(PlatformStructures.class),
|
||||
StructureImporter.Mode.OVERWRITE,
|
||||
new VolmitToolSender(BukkitPlatform.console()),
|
||||
structureKeys,
|
||||
templateKeys
|
||||
resourceIds(structureKeys),
|
||||
resourceIds(templateKeys)
|
||||
);
|
||||
Map<String, String> importedBundles = bundleKeys(report);
|
||||
Set<String> successfulPendingUrls = new HashSet<>(pendingUrls);
|
||||
Set<String> incompleteUrls = new HashSet<>();
|
||||
for (String pendingUrl : pendingUrls) {
|
||||
Entry entry = entriesByUrl.get(pendingUrl);
|
||||
Map<String, String> desired = importBundleInventory(entry);
|
||||
if (!report.successfulBundles().entrySet().containsAll(desired.entrySet())) {
|
||||
if (!importedBundles.entrySet().containsAll(desired.entrySet())) {
|
||||
successfulPendingUrls.remove(pendingUrl);
|
||||
incompleteUrls.add(pendingUrl);
|
||||
failedUrls.add(pendingUrl);
|
||||
@@ -3497,13 +3512,23 @@ public final class DatapackIngestService {
|
||||
return bundles;
|
||||
}
|
||||
|
||||
private static List<ResourceId> resourceIds(Collection<String> keys) {
|
||||
return keys.stream().map(ResourceId::ofPlatformKey).toList();
|
||||
}
|
||||
|
||||
private static Map<String, String> bundleKeys(DatapackImportReport report) {
|
||||
Map<String, String> bundles = new TreeMap<>();
|
||||
report.importedBundles().forEach((bundle, source) -> bundles.put(bundle, source.toString()));
|
||||
return bundles;
|
||||
}
|
||||
|
||||
static Map<String, String> importBundleInventory(Entry entry) {
|
||||
Map<String, String> bundles = new TreeMap<>();
|
||||
for (String structureKey : copyList(entry.structureKeys)) {
|
||||
bundles.put("iris:" + StructureImporter.deriveName(structureKey), structureKey);
|
||||
bundles.put(StructureBundleNames.ofStructure(structureKey), structureKey);
|
||||
}
|
||||
for (String templateKey : copyList(entry.templateKeys)) {
|
||||
bundles.put("iris:" + BulkStructureImporter.templateNameFor(templateKey), templateKey);
|
||||
bundles.put(StructureBundleNames.ofTemplate(templateKey), templateKey);
|
||||
}
|
||||
return bundles;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
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;
|
||||
@@ -52,8 +51,14 @@ public final class IrisModuleHost {
|
||||
* and Gson, which every platform Iris runs on provides.
|
||||
*/
|
||||
public static final List<String> SHARED_LIBRARY_PACKAGES = List.of("art.arcane.volmlib", "com.google.gson");
|
||||
/**
|
||||
* The structure file transactions Iris's datapack ingest and the jigsaw module's tools both run, which each would
|
||||
* otherwise see as a copy of its own; exposed with its subpackages.
|
||||
*/
|
||||
public static final String STRUCTURE_FILES_PACKAGE = "art.arcane.iris.core.structure.authoring";
|
||||
/** Every package pack modules may use besides the IrisApi. {@code exposedHostPackages} in IrisModule's build lists the same. */
|
||||
public static final List<String> EXPOSED_PACKAGES = Stream.concat(Stream.of(BUILT_IN_API_PACKAGE), SHARED_LIBRARY_PACKAGES.stream()).toList();
|
||||
public static final List<String> EXPOSED_PACKAGES = Stream.concat(Stream.of(BUILT_IN_API_PACKAGE, STRUCTURE_FILES_PACKAGE),
|
||||
SHARED_LIBRARY_PACKAGES.stream()).toList();
|
||||
/**
|
||||
* The ids of the built-in modules that ship in the built-ins jar ({@code iris-builtins.jar}, listed in
|
||||
* {@code IrisModule/builtin-modules.txt}) instead of being compiled into Iris. Every pack loads them from the jar Iris
|
||||
@@ -62,7 +67,7 @@ public final class IrisModuleHost {
|
||||
public static final List<String> 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:floating", "iris:structure", "iris:jigsaw");
|
||||
/**
|
||||
* 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.
|
||||
@@ -90,11 +95,10 @@ public final class IrisModuleHost {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* biomes and record the platform's custom blocks). A pack never replaces them.
|
||||
*/
|
||||
private static List<IrisModule> hostModules() {
|
||||
return List.of(new BiomeModule(), new CustomModule(), new StructureModule(), new StructureModelModule());
|
||||
return List.of(new BiomeModule(), new CustomModule());
|
||||
}
|
||||
|
||||
/** Iris's own log, labelled {@code [iris]}, for host code that calls module classes outside any module's stage, service or hook. */
|
||||
|
||||
@@ -165,6 +165,11 @@ public final class IrisPackResources implements PackResources {
|
||||
return kindOf(kind).ids();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S> List<S> services(Class<S> service) {
|
||||
return PackServices.of(data).providers(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ids of the resources of the kind {@code kindId} names, for Iris's own tools that list a module's resources
|
||||
* without the module's class for them, which the plugin's classes cannot reach when the kind ships in a module jar.
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.builtin.structure.StructureHost;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
@@ -40,8 +39,8 @@ import java.util.Optional;
|
||||
/**
|
||||
* The settings an engine's pack declares, for working out mantle stage reaches when the pack loads and for vanilla
|
||||
* structure hooks: the engine's dimension, then every region it can reach, then every biome. Iris's built-in modules
|
||||
* decide from Iris's own pack data instead of module settings; they reach it through the object, floating and structure
|
||||
* hosts the settings offer as {@linkplain #extension extensions}.
|
||||
* decide from Iris's own pack data instead of module settings; they reach it through the engine the settings offer as an
|
||||
* {@linkplain #extension extension}.
|
||||
*/
|
||||
public final class IrisPackSettings implements PackSettings {
|
||||
static final String DIMENSION = "dimension";
|
||||
@@ -71,15 +70,9 @@ public final class IrisPackSettings implements PackSettings {
|
||||
return HostExtensions.as(type, offered(type));
|
||||
}
|
||||
|
||||
/** The engine is offered only for the structure built-ins, which drive Iris's structure locator themselves. */
|
||||
/** The engine is offered only for the built-ins that read Iris's own pack data. */
|
||||
private Object offered(Class<?> type) {
|
||||
if (type == Engine.class) {
|
||||
return engine;
|
||||
}
|
||||
if (type == StructureHost.class) {
|
||||
return new IrisStructureHost(engine, IrisApiLogger.hostLog());
|
||||
}
|
||||
return null;
|
||||
return type == Engine.class ? engine : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.structure.StructureHost;
|
||||
import art.arcane.iris.builtin.structure.StructureVerifier;
|
||||
import art.arcane.iris.builtin.structure.StructureSeeds;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import com.volmit.ModuleLog;
|
||||
@@ -36,7 +36,7 @@ import java.util.function.Function;
|
||||
* One Iris world as modules see it: an engine runtime generating with one snapshot of its pack's resources, and the
|
||||
* state modules keep for it. {@link ModuleWorlds} makes one when the runtime is built and a new one whenever the
|
||||
* pack's resources reload under it. Iris's built-in modules reach what they need of Iris through its
|
||||
* {@linkplain #extension extensions}: the structure host.
|
||||
* {@linkplain #extension extensions}: the engine and the structure verifier.
|
||||
*/
|
||||
public final class IrisPackWorld implements PackWorld {
|
||||
private final Engine engine;
|
||||
@@ -45,7 +45,7 @@ public final class IrisPackWorld implements PackWorld {
|
||||
private final ModuleLog log;
|
||||
private final IrisRunningWorld running;
|
||||
private final Placements placements;
|
||||
private final IrisStructureHost structureHost;
|
||||
private final StructureVerifier structureVerifier;
|
||||
|
||||
IrisPackWorld(Engine engine) {
|
||||
this.engine = engine;
|
||||
@@ -54,7 +54,7 @@ public final class IrisPackWorld implements PackWorld {
|
||||
this.log = IrisApiLogger.hostLog();
|
||||
this.placements = new IrisPlacements(engine.getData(), engine, () -> this);
|
||||
this.running = new IrisRunningWorld(engine, log);
|
||||
this.structureHost = new IrisStructureHost(engine, log);
|
||||
this.structureVerifier = (context, radiusChunks) -> StructureVerification.run(engine, context, radiusChunks);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,8 +131,8 @@ public final class IrisPackWorld implements PackWorld {
|
||||
if (type == Engine.class) {
|
||||
return engine;
|
||||
}
|
||||
if (type == StructureHost.class) {
|
||||
return structureHost;
|
||||
if (type == StructureVerifier.class) {
|
||||
return structureVerifier;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,69 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.structure.StructureHost;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.engine.mantle.components.StructurePlacing;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** Iris's {@link StructureHost}: the engine's {@link StructurePlacing}, one per engine runtime, places and sizes its structures. */
|
||||
final class IrisStructureHost implements StructureHost {
|
||||
private final Engine engine;
|
||||
private final ModuleLog log;
|
||||
|
||||
IrisStructureHost(Engine engine, ModuleLog log) {
|
||||
this.engine = engine;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeChunk(MantleStageContext context) {
|
||||
placing().place(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int reach() {
|
||||
return placing().reach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<List<String>> lootTables(ResourceId structureId) {
|
||||
IrisPackResources resources = engine.getData().getPackResources();
|
||||
IrisStructure structure = StructureResources.structure(resources, resources.keyOf(structureId));
|
||||
if (structure == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
if (structure.getLoot() == null) {
|
||||
return Optional.of(List.of());
|
||||
}
|
||||
return Optional.of(structure.getLoot().stream().filter(table -> table != null && !table.isBlank()).toList());
|
||||
}
|
||||
|
||||
private StructurePlacing placing() {
|
||||
return engine.getGeneration().world().state(StructurePlacing.class, generating -> new StructurePlacing(generating, log));
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import art.arcane.iris.engine.framework.nativefit.NativeFitStart;
|
||||
import art.arcane.iris.engine.framework.nativefit.NativeFitTrait;
|
||||
import art.arcane.iris.engine.framework.nativefit.NativeStructureFitting;
|
||||
import art.arcane.iris.engine.framework.nativefit.NativeTemplateCells;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.host.DiscoveredModule;
|
||||
@@ -62,6 +63,7 @@ import java.util.Optional;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* The pack's {@link VanillaStructures} providers fitting the platform's starts into a chunk: the platform code's view
|
||||
@@ -92,10 +94,14 @@ public final class ModuleStructureFitting implements NativeStructureFitting {
|
||||
() -> engine.getGeneration().world());
|
||||
}
|
||||
|
||||
/** The built-in modules' registrations only: their stage graph needs the modules of the built-ins jar too. */
|
||||
public static NativeStructureFitting builtInModules() {
|
||||
/**
|
||||
* Iris's own modules' and {@code modules}' registrations only, whose classes the caller names because they ship in the
|
||||
* built-ins jar: their stage graph needs the rest of the jar too.
|
||||
*/
|
||||
public static NativeStructureFitting ofModules(IrisModule... modules) {
|
||||
ModuleRegistry registry = new ModuleRegistry();
|
||||
IrisModuleHost.builtInModules().forEach(module -> ModuleSetups.run(DiscoveredModule.builtIn(module), new StageGraphBuilder(), registry));
|
||||
Stream.concat(IrisModuleHost.builtInModules().stream(), Stream.of(modules))
|
||||
.forEach(module -> ModuleSetups.run(DiscoveredModule.builtIn(module), new StageGraphBuilder(), registry));
|
||||
FitlessWorld fitless = new FitlessWorld();
|
||||
return new ModuleStructureFitting(registry.freeze().registrations(VanillaStructures.class), () -> fitless);
|
||||
}
|
||||
|
||||
@@ -1,38 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.engine.framework.StructureAssembler;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
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
|
||||
* log as Iris itself.
|
||||
*/
|
||||
public final class StructureAssemblies {
|
||||
private StructureAssemblies() {
|
||||
}
|
||||
|
||||
/** 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());
|
||||
}
|
||||
}
|
||||
@@ -1,101 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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.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.volmlib.util.math.RNG;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.tooling.Argument;
|
||||
import com.volmit.tooling.Command;
|
||||
import com.volmit.tooling.CommandContext;
|
||||
import com.volmit.tooling.PlatformStructures;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** The {@code /iris module structure} commands of {@link StructureModelModule}: the index, one structure's graph, and the verification of a world's structures. */
|
||||
final class StructureCommands {
|
||||
private static final String ROOT_NAME = "structure";
|
||||
private static final long INFO_SAMPLE_SEED = 1234L;
|
||||
private static final int INFO_ORIGIN_Y = 64;
|
||||
|
||||
private static final Argument<ResourceId> STRUCTURE = Argument.resource("structure", StructureResources.STRUCTURES)
|
||||
.describe("The Iris structure to inspect");
|
||||
|
||||
private StructureCommands() {
|
||||
}
|
||||
|
||||
static Command root() {
|
||||
return Command.named(ROOT_NAME).alias("struct", "str")
|
||||
.describe("Iris structure tools")
|
||||
.child(Command.named("list").alias("ls")
|
||||
.describe("Write the index of every vanilla, datapack and Iris structure of the pack")
|
||||
.runs(StructureCommands::list))
|
||||
.child(Command.named("info")
|
||||
.describe("Resolve an Iris structure's jigsaw graph and report its piece count and footprint")
|
||||
.argument(STRUCTURE)
|
||||
.runs(StructureCommands::info))
|
||||
.child(Command.named("verify").alias("locateall")
|
||||
.describe("Verify native structure eligibility and locate Iris-placed structures in the world you stand in")
|
||||
.argument(StructureVerification.RADIUS)
|
||||
.runs(StructureVerification::run));
|
||||
}
|
||||
|
||||
private static void list(CommandContext context) throws IOException {
|
||||
Optional<PlatformStructures> platform = PlatformStructuresAccess.require(context);
|
||||
if (platform.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
File index = StructureIndexService.write(context.pack(), platform.get());
|
||||
context.sender().success("Wrote the structure index: " + index.getPath());
|
||||
}
|
||||
|
||||
private static void info(CommandContext context) {
|
||||
ResourceId id = context.get(STRUCTURE);
|
||||
IrisStructure structure = context.pack().resources().require(StructureResources.STRUCTURES, id);
|
||||
StructureAssemblyResult assembly = StructureAssemblies
|
||||
.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() + "')");
|
||||
return;
|
||||
}
|
||||
List<PlacedStructurePiece> pieces = assembly.pieces();
|
||||
int minX = Integer.MAX_VALUE;
|
||||
int minZ = Integer.MAX_VALUE;
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int maxZ = Integer.MIN_VALUE;
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
minX = Math.min(minX, piece.getMinX());
|
||||
minZ = Math.min(minZ, piece.getMinZ());
|
||||
maxX = Math.max(maxX, piece.getMaxX());
|
||||
maxZ = Math.max(maxZ, piece.getMaxZ());
|
||||
}
|
||||
context.sender().success("Structure " + id + ": " + pieces.size() + " pieces, footprint " + (maxX - minX + 1) + "x"
|
||||
+ (maxZ - minZ + 1) + " blocks (sample seed " + INFO_SAMPLE_SEED + ")");
|
||||
}
|
||||
}
|
||||
@@ -1,72 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleSetup;
|
||||
import com.volmit.service.StructureLocator;
|
||||
import com.volmit.service.VanillaStructures;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 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}).
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* It decides over the platform's own structures through its {@link VanillaStructures} provider
|
||||
* ({@link StructureVanillaStructures}): the dimension's {@code importedStructures} settings disable, move, fit and set
|
||||
* them up, and the pack's structure placements replace them, place them alongside, start them where their
|
||||
* {@code nativeStructures} grids say and fit them into the terrain.
|
||||
* <p>
|
||||
* It mounts {@code /iris module structure list|info|verify} ({@link StructureCommands}) and the Jigsaw Studio tree
|
||||
* {@code /iris module jigsaw ...} ({@link JigsawCommands}) through the tooling api.
|
||||
*/
|
||||
public final class StructureModelModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("iris:structure-model", "Structure model", VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
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());
|
||||
setup.tooling().registerCommand(JigsawCommands.root(() -> Optional.ofNullable(IrisServices.getOrNull(JigsawStudioHost.class))));
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,13 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.structure.StructureVerifier;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
|
||||
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
||||
import art.arcane.iris.engine.framework.StructureReachability;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.tooling.Argument;
|
||||
import com.volmit.tooling.CommandContext;
|
||||
import com.volmit.tooling.Sender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -36,17 +35,12 @@ import java.util.TreeSet;
|
||||
/**
|
||||
* {@code /iris module structure verify}: for every structure the platform registers and every structure the pack's modules place,
|
||||
* whether it can generate in the world the sender stands in, searching around the world origin for those the pack places.
|
||||
* Native eligibility is decided without the platform's blocking locate.
|
||||
* Native eligibility is decided without the platform's blocking locate. The command is {@code iris:structure}'s; the world
|
||||
* offers this to it as its {@link StructureVerifier}.
|
||||
*/
|
||||
final class StructureVerification {
|
||||
private static final long DEFAULT_RADIUS_CHUNKS = 48L;
|
||||
private static final long MAX_RADIUS_CHUNKS = 1000L;
|
||||
private static final int ORIGIN_BLOCK = 0;
|
||||
|
||||
static final Argument<Long> RADIUS = Argument.integer("radius", 1, MAX_RADIUS_CHUNKS)
|
||||
.orElse(DEFAULT_RADIUS_CHUNKS)
|
||||
.describe("Search radius in chunks around the world origin (larger is much slower)");
|
||||
|
||||
private final Engine engine;
|
||||
private final CommandContext context;
|
||||
private final int radiusChunks;
|
||||
@@ -64,15 +58,8 @@ final class StructureVerification {
|
||||
this.radiusChunks = radiusChunks;
|
||||
}
|
||||
|
||||
static void run(CommandContext context) {
|
||||
Sender sender = context.sender();
|
||||
Engine engine = context.world().flatMap(world -> world.extension(Engine.class)).orElse(null);
|
||||
if (engine == null) {
|
||||
sender.error("Stand in a world generated with this pack: verify reads the running world");
|
||||
return;
|
||||
}
|
||||
int radiusChunks = Math.toIntExact(context.get(RADIUS));
|
||||
sender.info("Verifying structures within " + radiusChunks + " chunks of the world origin...");
|
||||
static void run(Engine engine, CommandContext context, int radiusChunks) {
|
||||
context.sender().info("Verifying structures within " + radiusChunks + " chunks of the world origin...");
|
||||
new StructureVerification(engine, context, radiusChunks).report();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,19 +18,18 @@
|
||||
|
||||
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;
|
||||
import art.arcane.iris.core.modules.IrisPackResources;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.volmlib.util.io.IO;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.config.ResourceRef;
|
||||
import com.volmit.host.ResourceKindRegistration;
|
||||
import com.volmit.object.GeneratedObject;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.resource.ResourceKind;
|
||||
|
||||
import java.io.File;
|
||||
@@ -61,24 +60,23 @@ 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 Class<?> structureType;
|
||||
private final Map<ResourceKind<?>, Map<String, Object>> found = new LinkedHashMap<>();
|
||||
private final Set<Object> visited = java.util.Collections.newSetFromMap(new IdentityHashMap<>());
|
||||
private final Set<String> objectKeys = new TreeSet<>();
|
||||
|
||||
public ModuleResourceClosure(IrisData data) {
|
||||
this.data = data;
|
||||
Class<?> structures = null;
|
||||
for (ResourceKindRegistration registration : data.getModules().pack().catalog().resourceKinds()) {
|
||||
kindsByType.put(registration.kind().type(), registration.kind());
|
||||
if (registration.kind().id().equals(IrisStructureRef.KIND)) {
|
||||
structures = registration.kind().type();
|
||||
}
|
||||
}
|
||||
this.structureType = structures;
|
||||
}
|
||||
|
||||
/** Adds the resources that the module settings of {@code owner} reference, and those they reference. */
|
||||
@@ -126,6 +124,15 @@ public final class ModuleResourceClosure {
|
||||
return kind == null || !found.containsKey(kind) ? List.of() : new ArrayList<>(new TreeMap<>(found.get(kind)).keySet());
|
||||
}
|
||||
|
||||
/** The keys of the resources found of the kind {@code kindId}, in key order, for a kind whose class Iris cannot name. */
|
||||
public List<String> keysOf(ResourceId kindId) {
|
||||
return kindsByType.values().stream()
|
||||
.filter(kind -> kind.id().equals(kindId))
|
||||
.findFirst()
|
||||
.map(kind -> found.containsKey(kind) ? new ArrayList<>(new TreeMap<>(found.get(kind)).keySet()) : new ArrayList<String>())
|
||||
.orElseGet(ArrayList::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* The keys of the pack objects that what was found references, in key order. Objects are Iris's own files, not a
|
||||
* module kind, so the export copies them itself.
|
||||
@@ -172,25 +179,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) {
|
||||
private Class<?> referencedType(Field field) {
|
||||
ResourceRef reference = field.getAnnotation(ResourceRef.class);
|
||||
if (reference != null) {
|
||||
return reference.value();
|
||||
}
|
||||
if (field.isAnnotationPresent(IrisStructureRef.class)) {
|
||||
return IrisStructure.class;
|
||||
}
|
||||
if (field.equals(STRUCTURE_LOOT_FIELD)) {
|
||||
return LootTable.class;
|
||||
return structureType;
|
||||
}
|
||||
RegistryListResource registry = field.getAnnotation(RegistryListResource.class);
|
||||
return registry == null ? null : registry.value();
|
||||
|
||||
@@ -33,7 +33,6 @@ import art.arcane.iris.engine.object.image.IrisImageMap;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.noise.expression.IrisExpression;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.framework.ListFunction;
|
||||
@@ -470,7 +469,7 @@ public class SchemaBuilder {
|
||||
if (field.isEmpty() || !field.get().isAnnotationPresent(IrisStructureRef.class)) {
|
||||
return;
|
||||
}
|
||||
putPackResourceRef(property, IrisStructure.class);
|
||||
completeResourceReference(property, IrisStructureRef.KIND);
|
||||
}
|
||||
|
||||
private static Optional<Field> declaredField(String typeName, String fieldName) {
|
||||
|
||||
@@ -525,6 +525,23 @@ public class StudioSVC implements IrisService {
|
||||
String dimm,
|
||||
StudioOpenCoordinator.StudioOpenKind openKind
|
||||
) {
|
||||
PackAdmission admission = admitPack(dimm, openKind);
|
||||
admission.messages().forEach(sender::sendMessage);
|
||||
return admission.failure();
|
||||
}
|
||||
|
||||
/** Why a studio of the pack {@code dimm} may not open, as the lines {@link #reportPackAdmissionFailure} would send; empty when it may. */
|
||||
public static Optional<String> packAdmissionDenial(String dimm, StudioOpenCoordinator.StudioOpenKind openKind) {
|
||||
PackAdmission admission = admitPack(dimm, openKind);
|
||||
return admission.failure() == null ? Optional.empty() : Optional.of(String.join("\n", admission.messages()));
|
||||
}
|
||||
|
||||
/** Whether the pack may open a studio, and the messages that tell its sender so; {@code failure} is null when it may. */
|
||||
private record PackAdmission(BrokenPackException failure, List<String> messages) {
|
||||
}
|
||||
|
||||
private static PackAdmission admitPack(String dimm, StudioOpenCoordinator.StudioOpenKind openKind) {
|
||||
List<String> messages = new ArrayList<>();
|
||||
boolean force = openKind == StudioOpenCoordinator.StudioOpenKind.FORCED_STANDARD;
|
||||
Optional<String> unforcedStartupDenial = ServerConfigurator.worldCreationDenialReason(false);
|
||||
Optional<String> startupDenial = ServerConfigurator.worldCreationDenialReason(force);
|
||||
@@ -537,20 +554,20 @@ public class StudioSVC implements IrisService {
|
||||
packName, startupDenial, validation);
|
||||
if (failure == null) {
|
||||
if (force && unforcedStartupDenial.isPresent()) {
|
||||
sender.sendMessage("Force-opening Studio with the currently loaded registry state. The open may fail; restart remains required.");
|
||||
messages.add("Force-opening Studio with the currently loaded registry state. The open may fail; restart remains required.");
|
||||
}
|
||||
return null;
|
||||
return new PackAdmission(null, messages);
|
||||
}
|
||||
if (startupDenial.isPresent()) {
|
||||
sender.sendMessage(startupDenial.get());
|
||||
return failure;
|
||||
messages.add(startupDenial.get());
|
||||
return new PackAdmission(failure, messages);
|
||||
}
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_CANNOT_OPEN_STUDIO_PACK_HAS_BLOCKING_ERRORS, MessageArgument.untrusted("dimm", String.valueOf(dimm))));
|
||||
messages.add(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_CANNOT_OPEN_STUDIO_PACK_HAS_BLOCKING_ERRORS, MessageArgument.untrusted("dimm", String.valueOf(dimm))));
|
||||
for (String reason : failure.getReasons()) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_MESSAGE, MessageArgument.untrusted("reason", String.valueOf(reason))));
|
||||
messages.add(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_MESSAGE, MessageArgument.untrusted("reason", String.valueOf(reason))));
|
||||
}
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_FIX_PACK_RUN_IRIS_PACK_VALIDATE_REVALIDATE, MessageArgument.untrusted("dimm", String.valueOf(packName))));
|
||||
return failure;
|
||||
messages.add(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_FIX_PACK_RUN_IRIS_PACK_VALIDATE_REVALIDATE, MessageArgument.untrusted("dimm", String.valueOf(packName))));
|
||||
return new PackAdmission(failure, messages);
|
||||
}
|
||||
|
||||
static void retainPackRestartRequirement(PackDownloader.PackInstallResult result) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import art.arcane.iris.core.ServerConfigurator;
|
||||
import art.arcane.iris.core.WorldCreatorCompat;
|
||||
import art.arcane.iris.core.lifecycle.LifecycleOperationCoordinator;
|
||||
import art.arcane.iris.core.lifecycle.WorldLifecycleService;
|
||||
import art.arcane.iris.core.structure.authoring.StructureBundleNames;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.nms.INMS;
|
||||
import art.arcane.iris.core.pack.AtomicDirectoryPublisher;
|
||||
@@ -189,7 +190,7 @@ public final class FeatureImporter {
|
||||
if (key.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
rows.add(new Row(group, key, BulkStructureImporter.templateNameFor(key)));
|
||||
rows.add(new Row(group, key, StructureBundleNames.templateName(key)));
|
||||
}
|
||||
rows.sort(Comparator.comparing(r -> r.group() + "/" + r.safeName()));
|
||||
return rows;
|
||||
|
||||
@@ -1,48 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.structure.tooling;
|
||||
|
||||
import art.arcane.iris.core.service.JigsawStudioService;
|
||||
import com.volmit.tooling.Sender;
|
||||
import com.volmit.tooling.ToolPack;
|
||||
|
||||
import java.util.Optional;
|
||||
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, 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 key the studio files {@code pack} under. */
|
||||
String packKey(ToolPack pack);
|
||||
|
||||
/** Tells {@code sender} why {@code packKey} may not open a studio; empty, and silent, when it may. */
|
||||
Optional<Throwable> reportAdmissionFailure(Sender sender, String packKey);
|
||||
|
||||
/** Whether {@code failure} is the pack's validation denying the studio, which is the pack author's to fix and not an error of Iris. */
|
||||
boolean isExpectedOpenDenial(Throwable failure);
|
||||
|
||||
/** Closes the studio the server has open; completes with why it failed, or empty when it closed. */
|
||||
CompletableFuture<Optional<Throwable>> closeStudio();
|
||||
}
|
||||
@@ -20,7 +20,7 @@ package art.arcane.iris.core.tooling;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisModuleHost;
|
||||
import art.arcane.iris.core.structure.StructureIndexService;
|
||||
import art.arcane.iris.core.structure.authoring.StructureIndexService;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
import com.volmit.tooling.PlatformStructures;
|
||||
|
||||
+4
-3
@@ -2,6 +2,7 @@ package art.arcane.iris.engine.framework.nativefit;
|
||||
|
||||
import art.arcane.iris.core.modules.ModuleStructureFitting;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import com.volmit.IrisModule;
|
||||
|
||||
/**
|
||||
* The pack's modules fitting a chunk's structure starts into the terrain, around the platform placing their pieces:
|
||||
@@ -17,11 +18,11 @@ public interface NativeStructureFitting {
|
||||
}
|
||||
|
||||
/**
|
||||
* Iris's built-in modules outside any world, for starts whose fit their memo records and whose fit uses no palette;
|
||||
* Iris's own modules and {@code modules} outside any world, for starts whose fit their memo records and whose fit uses no palette;
|
||||
* a fit that needs the world or the pack's resources fails. For tools and tests that drive the platform side alone.
|
||||
*/
|
||||
static NativeStructureFitting builtInModules() {
|
||||
return ModuleStructureFitting.builtInModules();
|
||||
static NativeStructureFitting ofModules(IrisModule... modules) {
|
||||
return ModuleStructureFitting.ofModules(modules);
|
||||
}
|
||||
|
||||
/** One chunk's fit, between its starts' placements. */
|
||||
|
||||
@@ -45,6 +45,14 @@ public final class BuiltInModulesJar {
|
||||
return entryClasses(jar);
|
||||
}
|
||||
|
||||
/** {@link #writeInto} unless the pack has the jar already, for a test that writes a pack file by file. */
|
||||
public static void installInto(Path pack) throws IOException {
|
||||
if (Files.exists(pack.resolve("modules").resolve(JAR_NAME))) {
|
||||
return;
|
||||
}
|
||||
writeInto(pack);
|
||||
}
|
||||
|
||||
private static List<String> entryClasses(Path jar) throws IOException {
|
||||
try (JarFile file = new JarFile(jar.toFile())) {
|
||||
String entries = new String(file.getInputStream(file.getJarEntry(SERVICE_ENTRY)).readAllBytes(), StandardCharsets.UTF_8);
|
||||
|
||||
@@ -31,7 +31,9 @@ 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.modifier.DepositModule;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.engine.modifier.FloatingModule;
|
||||
import art.arcane.iris.modules.jigsaw.JigsawModule;
|
||||
import art.arcane.iris.engine.modifier.MatterModule;
|
||||
import art.arcane.iris.engine.modifier.PerfectionModule;
|
||||
import art.arcane.iris.engine.mantle.components.ObjectModule;
|
||||
@@ -78,7 +80,8 @@ 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 DepositModule(), new DecorantModule(), new TerrainModule(), new ObjectModule(), new FloatingModule(),
|
||||
new StructureModule(), new JigsawModule());
|
||||
}
|
||||
|
||||
/** Every built-in module: Iris's own and the compiled-in copies of the jar's ({@link #jarModules()}). */
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* A pack opened for validation whose built-in modules are the classes of the test class path, not the built-ins jar.
|
||||
* Tests that call a built-in module's classes directly need this: a jar loads its own copy of every class, so what
|
||||
* the pack serves would not be the classes the test names.
|
||||
*/
|
||||
public final class ClasspathPack {
|
||||
private ClasspathPack() {
|
||||
}
|
||||
|
||||
/** {@code pack} opened for validation with {@link BuiltInPack#allBuiltIns()} as its modules; close it after the test. */
|
||||
public static IrisData open(File pack, TemporaryFolder folder) throws IOException {
|
||||
return withClasspathModules(IrisData.openValidation(pack), pack, folder);
|
||||
}
|
||||
|
||||
/** Like {@link #open}, opened for a running world as {@link IrisData#openRuntime} does. */
|
||||
public static IrisData openRuntime(File pack, TemporaryFolder folder) throws IOException {
|
||||
return withClasspathModules(IrisData.openRuntime(pack), pack, folder);
|
||||
}
|
||||
|
||||
private static IrisData withClasspathModules(IrisData opened, File pack, TemporaryFolder folder) throws IOException {
|
||||
IrisData data = spy(opened);
|
||||
LoadedPack loaded = LoadedPack.load(pack.toPath(), ModuleHost.of(BuiltInPack.allBuiltIns())
|
||||
.exposing(IrisModuleHost.EXPOSED_PACKAGES.toArray(String[]::new))
|
||||
.reservingFields(ModuleTargets.reservedFields())
|
||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGES)
|
||||
.copyingJarsTo(folder.newFolder().toPath()));
|
||||
PackModuleSet modules = mock(PackModuleSet.class);
|
||||
when(modules.pack()).thenReturn(loaded);
|
||||
when(modules.settings()).thenReturn(new ModuleSettingsDecoder(loaded.catalog(), pack.toPath(), opened::getGson));
|
||||
doReturn(modules).when(data).getModules();
|
||||
data.invalidateStructureResources();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.structure.StructureHost;
|
||||
import art.arcane.iris.builtin.structure.StructureVerifier;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import com.volmit.world.PackWorld;
|
||||
@@ -32,8 +32,8 @@ public class IrisPackWorldConcurrencyTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void concurrentFirstCallersShareOneStructureHost() throws Exception {
|
||||
assertEveryCallerGetsOneInstance(world -> world.extension(StructureHost.class).orElseThrow());
|
||||
public void concurrentFirstCallersShareOneStructureVerifier() throws Exception {
|
||||
assertEveryCallerGetsOneInstance(world -> world.extension(StructureVerifier.class).orElseThrow());
|
||||
}
|
||||
|
||||
private static void assertEveryCallerGetsOneInstance(Function<PackWorld, Object> ask) throws Exception {
|
||||
|
||||
@@ -49,6 +49,7 @@ public final class ModuleResourceFixture {
|
||||
IrisPackResources resources = mock(IrisPackResources.class);
|
||||
when(data.getPackResources()).thenReturn(resources);
|
||||
when(resources.objects()).thenReturn(mock(PackObjects.class));
|
||||
when(resources.services(any())).thenAnswer(invocation -> PackServices.of(data).providers((Class<?>) invocation.getArgument(0)));
|
||||
when(resources.idOf(anyString())).thenAnswer(invocation -> idOf(invocation.getArgument(0)));
|
||||
when(resources.keyOf(any(ResourceId.class))).thenAnswer(invocation -> keyOf(invocation.getArgument(0)));
|
||||
when(resources.keyOf(any(ResourceKind.class), any(ResourceId.class))).thenAnswer(invocation -> keyOf(invocation.getArgument(1)));
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ public class PackModuleJarNextToBuiltInsTest {
|
||||
|
||||
@Test
|
||||
public void aJarModuleWithTheIdOfACompiledInBuiltInFailsAsADuplicate() throws IOException {
|
||||
String builtInId = new StructureModelModule().info().id().toString();
|
||||
String builtInId = new BiomeModule().info().id().toString();
|
||||
Path packFolder = BuiltInPack.newPackFolder(folder);
|
||||
PackModuleJar.write(packFolder, "carve.jar", "pack.ported.Ported",
|
||||
Map.of("pack.ported.Ported", module("ported", "Ported", builtInId)));
|
||||
@@ -88,7 +88,7 @@ public class PackModuleJarNextToBuiltInsTest {
|
||||
() -> BuiltInPack.serve(mock(IrisData.class), folder, packFolder, List.of()));
|
||||
|
||||
assertEquals("Duplicate module " + builtInId + " from " + Path.of("modules", "carve.jar") + " (pack.ported.Ported); already loaded from host classpath ("
|
||||
+ StructureModelModule.class.getName() + ")", failure.getMessage());
|
||||
+ BiomeModule.class.getName() + ")", failure.getMessage());
|
||||
}
|
||||
|
||||
private static String module(String packageName, String className, String moduleId) {
|
||||
|
||||
@@ -203,6 +203,7 @@ public class PackModuleResourceKindTest {
|
||||
|
||||
private Path castlePack(String name) throws Exception {
|
||||
File pack = temporaryFolder.newFolder(name);
|
||||
BuiltInModulesJar.installInto(pack.toPath());
|
||||
write(pack.toPath(), "dimensions/main.json", "{\"regions\":[\"region\"]}");
|
||||
write(pack.toPath(), "regions/region.json", "{\"landBiomes\":[\"biome\"]}");
|
||||
write(pack.toPath(), "biomes/biome.json", "{\"name\":\"Biome\"}");
|
||||
|
||||
@@ -180,9 +180,9 @@ public class ExportClosureComparisonTest {
|
||||
biomes.forEach(closure::followSettingsOf);
|
||||
closure.follow(placements);
|
||||
Exported generic = new Exported(
|
||||
new TreeSet<>(closure.keysOf(IrisStructure.class)),
|
||||
new TreeSet<>(closure.keysOf(IrisJigsawPool.class)),
|
||||
new TreeSet<>(closure.keysOf(IrisJigsawPiece.class)),
|
||||
new TreeSet<>(closure.keysOf(StructureResources.STRUCTURES.id())),
|
||||
new TreeSet<>(closure.keysOf(StructureResources.POOLS.id())),
|
||||
new TreeSet<>(closure.keysOf(StructureResources.PIECES.id())),
|
||||
new TreeSet<>(closure.keysOf(LootTable.class)),
|
||||
new TreeSet<>(closure.objectKeys()), true, List.of());
|
||||
|
||||
|
||||
+1
@@ -84,6 +84,7 @@ public class PackValidatorImportedStructurePolicyTest {
|
||||
}
|
||||
|
||||
private void write(File root, String relative, String content) throws Exception {
|
||||
art.arcane.iris.core.modules.BuiltInModulesJar.installInto(root.toPath());
|
||||
Path target = new File(root, relative).toPath();
|
||||
Files.createDirectories(target.getParent());
|
||||
Files.writeString(target, content, StandardCharsets.UTF_8);
|
||||
|
||||
@@ -569,6 +569,7 @@ public class PackValidatorStructureGraphTest {
|
||||
}
|
||||
|
||||
private void write(File root, String relative, String content) throws Exception {
|
||||
art.arcane.iris.core.modules.BuiltInModulesJar.installInto(root.toPath());
|
||||
Path path = root.toPath().resolve(relative);
|
||||
Files.createDirectories(path.getParent());
|
||||
Files.writeString(path, content, StandardCharsets.UTF_8);
|
||||
|
||||
+1
@@ -89,6 +89,7 @@ public class PackValidatorStructureTerrainBackendTest {
|
||||
}
|
||||
|
||||
private void write(File root, String relativePath, String content) throws Exception {
|
||||
art.arcane.iris.core.modules.BuiltInModulesJar.installInto(root.toPath());
|
||||
Path path = root.toPath().resolve(relativePath);
|
||||
Files.createDirectories(path.getParent());
|
||||
Files.writeString(path, content, StandardCharsets.UTF_8);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package art.arcane.iris.core.project;
|
||||
|
||||
import art.arcane.iris.core.modules.StructureModelModule;
|
||||
import art.arcane.iris.modules.jigsaw.JigsawModule;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
@@ -71,7 +71,7 @@ public class IrisImageMapSchemaTest {
|
||||
IrisData data = mock(IrisData.class);
|
||||
LoadedPack pack = mock(LoadedPack.class);
|
||||
PackModuleSet modules = mock(PackModuleSet.class);
|
||||
when(pack.catalog()).thenReturn(ModuleResourceFixture.catalogOf(new StructureModelModule(), new StructureModule()));
|
||||
when(pack.catalog()).thenReturn(ModuleResourceFixture.catalogOf(new JigsawModule(), new StructureModule()));
|
||||
when(modules.pack()).thenReturn(pack);
|
||||
when(data.getModules()).thenReturn(modules);
|
||||
ModuleResourceFixture.serve(data);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.core.project;
|
||||
|
||||
import art.arcane.iris.builtin.structure.StructureSettings;
|
||||
import art.arcane.iris.core.modules.StructureModelModule;
|
||||
import art.arcane.iris.modules.jigsaw.JigsawModule;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
@@ -516,7 +516,7 @@ public class SchemaBuilderParityTest {
|
||||
LoadedPack pack = mock(LoadedPack.class);
|
||||
PackModuleSet moduleSet = mock(PackModuleSet.class);
|
||||
when(pack.schema()).thenReturn(modules);
|
||||
when(pack.catalog()).thenReturn(ModuleResourceFixture.catalogOf(new StructureModelModule(), new StructureModule()));
|
||||
when(pack.catalog()).thenReturn(ModuleResourceFixture.catalogOf(new JigsawModule(), new StructureModule()));
|
||||
when(moduleSet.pack()).thenReturn(pack);
|
||||
when(data.getModules()).thenReturn(moduleSet);
|
||||
ModuleResourceFixture.serve(data);
|
||||
|
||||
@@ -46,7 +46,6 @@ public class JigsawStudioLifecycleTest {
|
||||
registry.finishOpen(OWNER);
|
||||
registry.finishOpen(OTHER_OWNER);
|
||||
registry.deactivate("overworld");
|
||||
service.quiesceForServerShutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-12
@@ -38,11 +38,6 @@ public class JigsawStudioMenuControllerTest {
|
||||
private static final UUID REQUEST_ID = UUID.fromString("77777777-7777-7777-7777-777777777777");
|
||||
private static final JigsawStudioPieceRules RULES = new JigsawStudioPieceRules(1, 12, 2, 8, false);
|
||||
|
||||
@After
|
||||
public void stopScheduler() {
|
||||
scheduler.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pagesVariantsAndClampsStalePageIndexes() {
|
||||
List<Integer> values = new ArrayList<>();
|
||||
@@ -541,14 +536,10 @@ public class JigsawStudioMenuControllerTest {
|
||||
menuField.setAccessible(true);
|
||||
menuField.set(service, menu);
|
||||
|
||||
try {
|
||||
service.playerLeft(player);
|
||||
service.playerLeft(player);
|
||||
|
||||
verify(menu).close(player);
|
||||
assertEquals(1, player.sidebarsHidden);
|
||||
} finally {
|
||||
service.quiesceForServerShutdown();
|
||||
}
|
||||
verify(menu).close(player);
|
||||
assertEquals(1, player.sidebarsHidden);
|
||||
}
|
||||
|
||||
private JigsawStudioMenuState state(
|
||||
|
||||
@@ -82,24 +82,6 @@ public class JigsawStudioServiceCaptureTest {
|
||||
public void stopService() {
|
||||
service.registry().finishOpen(OWNER);
|
||||
service.registry().deactivate("overworld");
|
||||
service.quiesceForServerShutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shutdownQuiesceIsIdempotent() throws Exception {
|
||||
Field disableStartedField = JigsawStudioService.class.getDeclaredField("disableStarted");
|
||||
Field enabledField = JigsawStudioService.class.getDeclaredField("enabled");
|
||||
disableStartedField.setAccessible(true);
|
||||
enabledField.setAccessible(true);
|
||||
AtomicBoolean disableStarted = (AtomicBoolean) disableStartedField.get(service);
|
||||
assertFalse(disableStarted.get());
|
||||
assertTrue(enabledField.getBoolean(service));
|
||||
|
||||
service.quiesceForServerShutdown();
|
||||
service.quiesceForServerShutdown();
|
||||
|
||||
assertTrue(disableStarted.get());
|
||||
assertFalse(enabledField.getBoolean(service));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -114,7 +114,6 @@ public class JigsawStudioWorldListenerTest {
|
||||
@After
|
||||
public void closeStudio() {
|
||||
service.registry().deactivate("overworld");
|
||||
service.quiesceForServerShutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -49,7 +49,6 @@ public class StudioSVCJigsawProtectionTest {
|
||||
public void clearLifecycle() {
|
||||
jigsawService.registry().finishOpen(OWNER);
|
||||
jigsawService.registry().deactivate("overworld");
|
||||
jigsawService.quiesceForServerShutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-3
@@ -1,13 +1,14 @@
|
||||
package art.arcane.iris.core.structure;
|
||||
package art.arcane.iris.core.structure.authoring;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisModuleHost;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import art.arcane.iris.core.modules.StructureModelModule;
|
||||
import art.arcane.iris.core.structure.FakePlatformStructures;
|
||||
import art.arcane.iris.core.tooling.IrisToolPack;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.modules.jigsaw.JigsawModule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
@@ -41,7 +42,7 @@ public class StructureIndexServiceTest {
|
||||
public void writeListsPlatformStructuresAndTheStructuresOfThePack() throws Exception {
|
||||
File pack = temporaryFolder.newFolder("pack");
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new StructureModule(), new JigsawModule());
|
||||
when(data.getDataFolder()).thenReturn(pack);
|
||||
ModuleResourceFixture.serve(data).resource(StructureResources.STRUCTURES, "castle", new IrisStructure());
|
||||
FakePlatformStructures platform = new FakePlatformStructures()
|
||||
+2
-2
@@ -55,7 +55,7 @@ public class JigsawCommandsContractTest {
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
private final Command root = JigsawCommands.root(Optional::empty);
|
||||
private final Command root = JigsawCommands.root(new JigsawStudios());
|
||||
|
||||
@Test
|
||||
public void theJigsawRootAnswersToItsShortNamesAndHoldsTheWholeTree() {
|
||||
@@ -456,7 +456,7 @@ public class JigsawCommandsContractTest {
|
||||
}
|
||||
|
||||
private static String source(String fileName) throws Exception {
|
||||
return Files.readString(Path.of("src/main/java/art/arcane/iris/core/structure/tooling", fileName))
|
||||
return Files.readString(Path.of("../module/src/main/java/art/arcane/iris/core/structure/tooling", fileName))
|
||||
.replace("\r\n", "\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package art.arcane.iris.core.tooling;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import art.arcane.iris.core.modules.StructureModelModule;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleSetup;
|
||||
@@ -37,21 +37,21 @@ public class CommandRootCollisionTest {
|
||||
@Test
|
||||
public void aModuleCannotTakeTheRootNameOfTheStructureModule() {
|
||||
var collision = assertThrows(IllegalArgumentException.class, () -> ModuleResourceFixture.catalogOf(
|
||||
new StructureModelModule(), registering("test:rival", Command.named("structure"))));
|
||||
new StructureModule(), registering("test:rival", Command.named("structure"))));
|
||||
|
||||
assertTrue(collision.getMessage(), collision.getMessage().contains("Command root structure is registered by module"));
|
||||
assertTrue(collision.getMessage(), collision.getMessage().contains("iris:structure-model"));
|
||||
assertTrue(collision.getMessage(), collision.getMessage().contains("iris:structure"));
|
||||
assertTrue(collision.getMessage(), collision.getMessage().contains("test:rival"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aModuleCannotTakeAnAliasOfTheStructureModule() {
|
||||
var collision = assertThrows(IllegalArgumentException.class, () -> ModuleResourceFixture.catalogOf(
|
||||
registering("test:rival", Command.named("shapes").alias("str")), new StructureModelModule()));
|
||||
registering("test:rival", Command.named("shapes").alias("str")), new StructureModule()));
|
||||
|
||||
assertTrue(collision.getMessage(), collision.getMessage().contains("Command root str is registered by module"));
|
||||
assertTrue(collision.getMessage(), collision.getMessage().contains("test:rival"));
|
||||
assertTrue(collision.getMessage(), collision.getMessage().contains("iris:structure-model"));
|
||||
assertTrue(collision.getMessage(), collision.getMessage().contains("iris:structure"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -2,7 +2,7 @@ package art.arcane.iris.core.tooling;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import art.arcane.iris.core.modules.StructureModelModule;
|
||||
import art.arcane.iris.modules.jigsaw.JigsawModule;
|
||||
import art.arcane.iris.core.structure.FakePlatformStructures;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
@@ -52,7 +52,7 @@ public class StructureCommandsTest {
|
||||
|
||||
packFolder = temporaryFolder.newFolder("overworld");
|
||||
data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
when(data.getDataFolder()).thenReturn(packFolder);
|
||||
IrisStructure emptyCastle = new IrisStructure();
|
||||
emptyCastle.setStartPool("ghost-pool");
|
||||
|
||||
@@ -2,7 +2,7 @@ package art.arcane.iris.core.tooling;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import art.arcane.iris.core.modules.StructureModelModule;
|
||||
import art.arcane.iris.modules.jigsaw.JigsawModule;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
@@ -41,7 +41,7 @@ public class StructureIndexOnStartTest {
|
||||
File pack = temporaryFolder.newFolder("pack");
|
||||
IrisData data = mock(IrisData.class);
|
||||
PlatformStructures platform = mock(PlatformStructures.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
when(data.getDataFolder()).thenReturn(pack);
|
||||
ModuleResourceFixture.serve(data).resource(StructureResources.STRUCTURES, "castle", new IrisStructure());
|
||||
when(platform.structures()).thenReturn(List.of(ResourceId.parse("minecraft:village"), ResourceId.parse("example:castle")));
|
||||
|
||||
+10
-10
@@ -24,7 +24,7 @@ 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.modules.jigsaw.JigsawModule;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.structure.StructureGraphCatalog;
|
||||
@@ -123,7 +123,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void locatableIndexIncludesAliasesAndSeparatesEditableFromNativePlacements() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setVanillaSource("source:city");
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city_definition", structure);
|
||||
@@ -153,7 +153,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void nativeStructureReplacementSuppressesOnlyItsRegisteredSource() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
StructurePlacement placement = placement("nativeSuppression", NativeStructureSuppression.REPLACE_SOURCE);
|
||||
withAdded(placement, "nativeStructures", nativeSource("minecraft:ancient_city"));
|
||||
StructureTestWorld engine = jigsawWorld(data).dimension(placement);
|
||||
@@ -173,7 +173,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void vanillaSourceRequiresExplicitDimensionSuppression() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setVanillaSource("minecraft:ancient_city");
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||
@@ -193,7 +193,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void regionReplacementFailsInsteadOfFallingBackToNative() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure();
|
||||
structure.setVanillaSource("minecraft:ancient_city");
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||
@@ -212,7 +212,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void geometryFailureFailsInsteadOfFallingBackToNative() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure()
|
||||
.setStartPool("test:start")
|
||||
.setMaxDepth(1)
|
||||
@@ -258,7 +258,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void missingVanillaSourceFailsInsteadOfFallingBackToNative() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure();
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:city", structure);
|
||||
registerSinglePieceGraph(data, structure, "test:city");
|
||||
@@ -274,7 +274,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void missingNonReplacementStructureFailsInsteadOfBeingSkipped() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
ModuleResourceFixture.serve(data);
|
||||
StructurePlacement placement = new StructurePlacement();
|
||||
withAdded(placement, "structures", "test:missing");
|
||||
@@ -439,7 +439,7 @@ public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void placementIndexIsKeptPerWorld() {
|
||||
IrisData sharedData = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(sharedData, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(sharedData, new JigsawModule(), new StructureModule());
|
||||
StructureTestWorld firstWorld = emptyWorld(sharedData);
|
||||
StructureTestWorld secondWorld = emptyWorld(sharedData);
|
||||
Set<String> firstIndex = IrisStructureLocator.placedKeys(firstWorld);
|
||||
@@ -717,7 +717,7 @@ public class IrisStructureLocatorContractTest {
|
||||
private StructureTestWorld densityWorld(double density, boolean underground, int worldMin, int worldHeight,
|
||||
int placementMin, int placementMax) {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
IrisStructure structure = new IrisStructure();
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "test:density", structure);
|
||||
registerSinglePieceGraph(data, structure, "test:density");
|
||||
|
||||
+4
-3
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.engine.framework.structure;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.ClasspathPack;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
@@ -62,7 +63,7 @@ public class StructureGraphValidationTest {
|
||||
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());
|
||||
IrisData data = ClasspathPack.open(pack.toFile(), temporaryFolder);
|
||||
try {
|
||||
assertThrows(IllegalStateException.class, () -> data.getPackResources().find(
|
||||
StructureResources.POOLS, data.getPackResources().idOf("castle/start")));
|
||||
@@ -333,8 +334,8 @@ public class StructureGraphValidationTest {
|
||||
&& message.contains("seed 0")));
|
||||
}
|
||||
|
||||
private static StructureGraphValidation.Validation validate(Path pack, Set<String> activeStructureKeys) {
|
||||
IrisData data = IrisData.openValidation(pack.toFile());
|
||||
private StructureGraphValidation.Validation validate(Path pack, Set<String> activeStructureKeys) throws Exception {
|
||||
IrisData data = ClasspathPack.open(pack.toFile(), temporaryFolder);
|
||||
try {
|
||||
return StructureGraphValidation.validate(data.getPackResources(), pack.toFile(), activeStructureKeys);
|
||||
} finally {
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package art.arcane.iris.engine.framework.structure;
|
||||
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.validation.Problem;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
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 StructureReferenceValidationTest {
|
||||
private static final String KNOWN_BLOCK = "minecraft:structure_void";
|
||||
private static final String UNKNOWN_BLOCK = "example:not_a_block";
|
||||
private static final ResourceId PIECE = new ResourceId("test", "castle/keep");
|
||||
private static final ResourceId OBJECT = new ResourceId("test", "castle/keep");
|
||||
|
||||
@Test
|
||||
public void aConnectorWhoseFinalStateIsNoBlockOfThePlatformIsAnError() {
|
||||
List<Problem> problems = StructureReferenceValidation.validate(
|
||||
packWithAPieceWhoseConnectorBecomes(UNKNOWN_BLOCK), Optional.of(blocksKnowing(KNOWN_BLOCK)));
|
||||
|
||||
assertEquals(problems.toString(), 1, problems.size());
|
||||
assertTrue(problems.get(0).message(), problems.get(0).message().contains(
|
||||
"Jigsaw piece 'castle/keep' connectors[0] finalState '" + UNKNOWN_BLOCK + "' is not a block."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aConnectorWhoseFinalStateIsABlockOfThePlatformIsAccepted() {
|
||||
List<Problem> problems = StructureReferenceValidation.validate(
|
||||
packWithAPieceWhoseConnectorBecomes(KNOWN_BLOCK), Optional.of(blocksKnowing(KNOWN_BLOCK)));
|
||||
|
||||
assertTrue(problems.toString(), problems.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withoutAPlatformNoFinalStateIsChecked() {
|
||||
List<Problem> problems = StructureReferenceValidation.validate(
|
||||
packWithAPieceWhoseConnectorBecomes(UNKNOWN_BLOCK), Optional.empty());
|
||||
|
||||
assertTrue(problems.toString(), problems.isEmpty());
|
||||
}
|
||||
|
||||
private static BlockRegistry blocksKnowing(String known) {
|
||||
BlockRegistry blocks = mock(BlockRegistry.class);
|
||||
when(blocks.find(known)).thenReturn(Optional.of(BlockState.parse(known)));
|
||||
when(blocks.find(UNKNOWN_BLOCK)).thenReturn(Optional.empty());
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private static PackResources packWithAPieceWhoseConnectorBecomes(String finalState) {
|
||||
PackResources pack = mock(PackResources.class);
|
||||
IrisJigsawPiece piece = new IrisJigsawPiece().setObject("castle/keep")
|
||||
.setConnectors(List.of(new IrisJigsawConnector().setFinalState(finalState)));
|
||||
when(pack.ids(StructureResources.STRUCTURES)).thenReturn(List.of());
|
||||
when(pack.ids(StructureResources.POOLS)).thenReturn(List.of());
|
||||
when(pack.ids(StructureResources.PIECES)).thenReturn(List.of(PIECE));
|
||||
when(pack.ids(PackResources.OBJECTS)).thenReturn(List.of(OBJECT));
|
||||
when(pack.find(StructureResources.PIECES, PIECE)).thenReturn(Optional.of(piece));
|
||||
return pack;
|
||||
}
|
||||
}
|
||||
+12
-11
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.engine.framework.structure;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.ClasspathPack;
|
||||
import art.arcane.iris.core.modules.ModuleServices;
|
||||
import art.arcane.iris.core.modules.IrisModuleHost;
|
||||
import art.arcane.iris.core.project.ModuleResourceSchemas;
|
||||
@@ -39,17 +40,17 @@ public class StructureResourcesTest {
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void theStructureModuleOwnsTheKindsAndTheirValidator() throws Exception {
|
||||
IrisData data = IrisData.openValidation(castlePack("owned").toFile());
|
||||
public void theJigsawModuleOwnsTheKindsAndTheirValidator() throws Exception {
|
||||
IrisData data = ClasspathPack.open(castlePack("owned").toFile(), temporaryFolder);
|
||||
try {
|
||||
var catalog = data.getModules().pack().catalog();
|
||||
|
||||
var kinds = catalog.resourceKinds().stream().map(ResourceKindRegistration::kind)
|
||||
.filter(kind -> kind.id().toString().startsWith("iris:structure/")).toList();
|
||||
assertEquals(List.of("iris:structure/piece", "iris:structure/pool", "iris:structure/structure"),
|
||||
.filter(kind -> kind.id().toString().startsWith("iris:jigsaw/")).toList();
|
||||
assertEquals(List.of("iris:jigsaw/piece", "iris:jigsaw/pool", "iris:jigsaw/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));
|
||||
assertTrue(catalog.validators().stream().map(ValidatorRegistration::validator).anyMatch(JigsawValidator.class::isInstance));
|
||||
assertFalse(data.getLoaders().containsKey(IrisStructure.class));
|
||||
assertFalse(data.getLoaders().containsKey(IrisJigsawPool.class));
|
||||
assertFalse(data.getLoaders().containsKey(IrisJigsawPiece.class));
|
||||
@@ -60,7 +61,7 @@ public class StructureResourcesTest {
|
||||
|
||||
@Test
|
||||
public void theStructureModuleListsThePacksStructuresForIrissIndexThroughItsLocator() throws Exception {
|
||||
IrisData data = IrisData.openValidation(castlePack("listed").toFile());
|
||||
IrisData data = ClasspathPack.open(castlePack("listed").toFile(), temporaryFolder);
|
||||
try {
|
||||
assertEquals(Set.of(new ResourceId("listed", "castle")), new StructureLocating().structures(data.getPackResources()));
|
||||
assertEquals(Set.of("castle"), ModuleServices.structureKeys(data));
|
||||
@@ -72,7 +73,7 @@ public class StructureResourcesTest {
|
||||
@Test
|
||||
public void structuresPoolsAndPiecesAreReadThroughPackResources() throws Exception {
|
||||
Path pack = castlePack("castles");
|
||||
IrisData data = IrisData.openValidation(pack.toFile());
|
||||
IrisData data = ClasspathPack.open(pack.toFile(), temporaryFolder);
|
||||
try {
|
||||
IrisStructure castle = StructureResources.structure(data.getPackResources(),"castle");
|
||||
|
||||
@@ -94,7 +95,7 @@ public class StructureResourcesTest {
|
||||
public void aBrokenStructureIsAbsentToLookupsButAnErrorToPackResources() throws Exception {
|
||||
Path pack = castlePack("broken");
|
||||
write(pack, "structures/ruin.json", "{\"maxDepth\":");
|
||||
IrisData data = IrisData.openValidation(pack.toFile());
|
||||
IrisData data = ClasspathPack.open(pack.toFile(), temporaryFolder);
|
||||
try {
|
||||
assertNull(StructureResources.structure(data.getPackResources(),"ruin"));
|
||||
assertThrows(IllegalStateException.class,
|
||||
@@ -107,7 +108,7 @@ public class StructureResourcesTest {
|
||||
@Test
|
||||
public void rewrittenFilesAreReadAgainAfterInvalidationDumpAndHotload() throws Exception {
|
||||
Path pack = castlePack("reloaded");
|
||||
IrisData data = IrisData.openValidation(pack.toFile());
|
||||
IrisData data = ClasspathPack.open(pack.toFile(), temporaryFolder);
|
||||
try {
|
||||
assertEquals(5, StructureResources.structure(data.getPackResources(),"castle").getMaxDepth());
|
||||
write(pack, "structures/castle.json", "{\"startPool\":\"castle/start\",\"maxDepth\":9}");
|
||||
@@ -125,7 +126,7 @@ public class StructureResourcesTest {
|
||||
data.close();
|
||||
}
|
||||
|
||||
IrisData runtime = IrisData.openRuntime(pack.toFile());
|
||||
IrisData runtime = ClasspathPack.openRuntime(pack.toFile(), temporaryFolder);
|
||||
try {
|
||||
assertEquals(3, StructureResources.structure(runtime.getPackResources(),"castle").getMaxDepth());
|
||||
write(pack, "structures/castle.json", "{\"startPool\":\"castle/start\",\"maxDepth\":2}");
|
||||
@@ -139,7 +140,7 @@ public class StructureResourcesTest {
|
||||
@Test
|
||||
public void studioDescribesStructuresAsIrisDoesAndCompletesTheirPools() throws Exception {
|
||||
Path pack = castlePack("studio");
|
||||
IrisData data = IrisData.openValidation(pack.toFile());
|
||||
IrisData data = ClasspathPack.open(pack.toFile(), temporaryFolder);
|
||||
try (SchemaTestPlatform ignored = SchemaTestPlatform.bind(temporaryFolder.getRoot())) {
|
||||
List<JSONObject> entries = ModuleResourceSchemas.entries(data, true);
|
||||
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@ import art.arcane.iris.builtin.structure.StructureSettings;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
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.modules.jigsaw.JigsawModule;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
@@ -105,11 +105,11 @@ public class StructureHandlerTest {
|
||||
|
||||
IrisStructure custom = new IrisStructure();
|
||||
IrisStructure collision = new IrisStructure();
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "iris:custom_definition", custom);
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "iris:collision_definition", collision);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getWorld()).thenReturn(world);
|
||||
@@ -173,11 +173,11 @@ public class StructureHandlerTest {
|
||||
placements.add(editablePlacement("iris:replacement_definition"));
|
||||
placements.add(nativePlacement("minecraft:explicit", StructureDistribution.RANDOM_SPREAD, 1.0));
|
||||
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "iris:editable_definition", editable);
|
||||
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, "iris:replacement_definition", replacement);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
ModuleResourceFixture.serveModules(data, new StructureModelModule(), new StructureModule());
|
||||
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
|
||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getWorld()).thenReturn(world);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import org.gradle.api.tasks.bundling.ZipEntryCompression
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
@@ -54,7 +55,8 @@ val builtinModulesJarName = "iris-builtins.jar"
|
||||
val builtinModuleEntryFile = "com.volmit.IrisModule"
|
||||
val builtinModulesFile = layout.projectDirectory.file("builtin-modules.txt").asFile
|
||||
// The packages an Iris host exposes to pack modules besides the API (Iris's IrisModuleHost.EXPOSED_PACKAGES).
|
||||
val exposedHostPackages = listOf("art.arcane.iris.builtin", "art.arcane.volmlib", "com.google.gson")
|
||||
val exposedHostPackages = listOf("art.arcane.iris.builtin", "art.arcane.iris.core.structure.authoring", "art.arcane.volmlib",
|
||||
"com.google.gson")
|
||||
|
||||
data class BuiltinModulesList(val moduleClasses: List<String>, val classPatterns: List<String>)
|
||||
|
||||
@@ -101,6 +103,8 @@ val packageBuiltinModules = tasks.register<Jar>("packageBuiltinModules") {
|
||||
description = "Packages the listed built-in modules and classes before they are checked."
|
||||
archiveFileName.set(builtinModulesJarName)
|
||||
destinationDirectory.set(builtinModulesBuild.map { it.dir("unchecked") })
|
||||
// Iris's own jar compresses this one as a whole, which squeezes more out of the classes than compressing them twice.
|
||||
entryCompression = ZipEntryCompression.STORED
|
||||
inputs.file(builtinModulesFile)
|
||||
from(sourceSets.main.map { it.java.classesDirectory }) {
|
||||
include(builtinPackagedPatterns)
|
||||
|
||||
@@ -98,5 +98,52 @@ include art/arcane/iris/engine/mantle/components/FloatingPlacer*.class
|
||||
include art/arcane/iris/engine/mantle/components/FloatingIslandSampleResolver*.class
|
||||
include art/arcane/iris/engine/mantle/components/IslandFace*.class
|
||||
include art/arcane/iris/engine/mantle/components/UndersideTurn*.class
|
||||
# iris:structure (art.arcane.iris.engine.mantle.components.StructureModule) is not here: Iris registers it with its own
|
||||
# modules, because its jigsaw studio reads the structure resources the module registers.
|
||||
module art.arcane.iris.engine.mantle.components.StructureModule
|
||||
include art/arcane/iris/engine/mantle/components/StructurePlacing*.class
|
||||
include art/arcane/iris/engine/mantle/components/StructureCarvingFootprint*.class
|
||||
include art/arcane/iris/engine/mantle/components/StructureCarveEnvelope*.class
|
||||
include art/arcane/iris/engine/mantle/components/StructureFoundationPlanner*.class
|
||||
include art/arcane/iris/engine/mantle/components/StructurePieceColumns*.class
|
||||
include art/arcane/iris/engine/framework/IrisStructureLocator*.class
|
||||
include art/arcane/iris/engine/framework/StructureCaveAnchorResolver*.class
|
||||
include art/arcane/iris/engine/framework/StructurePlacementScope*.class
|
||||
include art/arcane/iris/engine/framework/StructurePlacementGrid*.class
|
||||
include art/arcane/iris/engine/framework/structure/fit/**
|
||||
include art/arcane/iris/engine/framework/structure/assembly/**
|
||||
include art/arcane/iris/engine/framework/structure/ColumnHeights*.class
|
||||
include art/arcane/iris/engine/framework/structure/ImportedStructures*.class
|
||||
include art/arcane/iris/engine/framework/structure/NativeStartPlanner*.class
|
||||
include art/arcane/iris/engine/framework/structure/NativeStructureFit*.class
|
||||
include art/arcane/iris/engine/framework/structure/StructureAssemblyStatus*.class
|
||||
include art/arcane/iris/engine/framework/structure/StructureLocating*.class
|
||||
include art/arcane/iris/engine/framework/structure/StructurePlacementValidation*.class
|
||||
include art/arcane/iris/engine/framework/structure/StructureValidator*.class
|
||||
include art/arcane/iris/engine/framework/structure/StructureVanillaStructures*.class
|
||||
include art/arcane/iris/engine/framework/structure/StructureWorld*.class
|
||||
include art/arcane/iris/core/modules/StructureCommands*.class
|
||||
module art.arcane.iris.modules.jigsaw.JigsawModule
|
||||
include art/arcane/iris/engine/object/structure/**
|
||||
include art/arcane/iris/engine/framework/StructureAssembler*.class
|
||||
include art/arcane/iris/engine/framework/PlacedStructurePiece*.class
|
||||
include art/arcane/iris/engine/framework/structure/CompiledStructureGraph*.class
|
||||
include art/arcane/iris/engine/framework/structure/IrisObjectFrameReader*.class
|
||||
include art/arcane/iris/engine/framework/structure/JigsawPoolSelection*.class
|
||||
include art/arcane/iris/engine/framework/structure/JigsawStructureAssembly*.class
|
||||
include art/arcane/iris/engine/framework/structure/JigsawValidator*.class
|
||||
include art/arcane/iris/engine/framework/structure/NativeReplacementValidation*.class
|
||||
include art/arcane/iris/engine/framework/structure/ObjectFrame*.class
|
||||
include art/arcane/iris/engine/framework/structure/PackJsonFiles*.class
|
||||
include art/arcane/iris/engine/framework/structure/PackStructureGraphResolver*.class
|
||||
include art/arcane/iris/engine/framework/structure/PlanarJigsawWorkcellResolver*.class
|
||||
include art/arcane/iris/engine/framework/structure/StructureAssemblyResult*.class
|
||||
include art/arcane/iris/engine/framework/structure/StructureGraph*.class
|
||||
include art/arcane/iris/engine/framework/structure/StructureReferenceValidation*.class
|
||||
include art/arcane/iris/engine/framework/structure/StructureResource*.class
|
||||
include art/arcane/iris/core/runtime/jigsaw/**
|
||||
include art/arcane/iris/core/service/JigsawStudio*.class
|
||||
include art/arcane/iris/engine/platform/studio/generators/JigsawStudioGenerator*.class
|
||||
include art/arcane/iris/core/structure/*.class
|
||||
include art/arcane/iris/core/structure/conversion/**
|
||||
include art/arcane/iris/core/structure/export/**
|
||||
include art/arcane/iris/core/structure/tooling/**
|
||||
include art/arcane/iris/core/pack/StructurePackageClosure*.class
|
||||
@@ -18,17 +18,22 @@
|
||||
|
||||
package art.arcane.iris.builtin.structure;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Iris extension: says that a text option names structures of Iris's structure model by key, which Iris completes in
|
||||
* studio and carries along when it exports the pack. The structure model is Iris's own resource kind, whose class a
|
||||
* module cannot see, so {@code @ResourceRef} cannot name it; to another host the option is plain text.
|
||||
* Iris extension: says that a text option names structures of the pack's jigsaw module by key, which Iris completes in
|
||||
* studio and carries along when it exports the pack. It stands for {@code @ResourceRef} of the structure kind, whose class
|
||||
* lives in the module jar and so cannot be named from this exposed package; Iris resolves it by the kind's id, {@link #KIND}.
|
||||
* To another host the option is plain text.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface IrisStructureRef {
|
||||
/** The id of the resource kind of the structures, which {@code iris:jigsaw} registers. */
|
||||
ResourceId KIND = ResourceId.parse("iris:jigsaw/structure");
|
||||
}
|
||||
@@ -1,41 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.structure;
|
||||
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* What {@code iris:structure} asks of Iris: Iris places its jigsaw structures itself. The structure model (structures,
|
||||
* pools, pieces), the assembler that builds a structure from them and the locator that spreads them over the world are
|
||||
* Iris's, shared with the jigsaw studio and the structure importers and exporters. Iris offers it as an extension of its
|
||||
* worlds and of the settings of the pack it loads: {@code world.extension(StructureHost.class)}.
|
||||
*/
|
||||
public interface StructureHost {
|
||||
/** Places the structures that start in the chunk whose mantle the mantle invocation {@code context} generates. */
|
||||
void placeChunk(MantleStageContext context);
|
||||
|
||||
/** How far, in blocks along X and Z, a structure may write beyond the chunk it starts in. */
|
||||
int reach();
|
||||
|
||||
/** The loot tables the structure gives its pieces' containers; empty when the pack has no such structure. */
|
||||
Optional<List<String>> lootTables(ResourceId structure);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.builtin.structure;
|
||||
|
||||
import com.volmit.tooling.CommandContext;
|
||||
|
||||
/**
|
||||
* What Iris's running worlds offer {@code iris:structure}'s {@code verify} command: whether each structure can generate
|
||||
* in the world, which needs the world's native structure policy and biome reachability that only Iris itself reads.
|
||||
* Ask for it with {@code world.extension(StructureVerifier.class)}.
|
||||
*/
|
||||
public interface StructureVerifier {
|
||||
/** Reports to the sender of {@code context}, for every structure the platform registers and every structure the pack places, whether it can generate within {@code radiusChunks} of the world origin. */
|
||||
void verify(CommandContext context, int radiusChunks);
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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.modules;
|
||||
|
||||
import art.arcane.iris.builtin.structure.StructureVerifier;
|
||||
import art.arcane.iris.core.structure.authoring.StructureIndexService;
|
||||
import art.arcane.iris.core.structure.tooling.PlatformStructuresAccess;
|
||||
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.volmlib.util.math.RNG;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.tooling.Argument;
|
||||
import com.volmit.tooling.Command;
|
||||
import com.volmit.tooling.CommandContext;
|
||||
import com.volmit.tooling.PlatformStructures;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/** The {@code /iris module structure} commands of {@code iris:structure}: the index, one structure's graph, and the verification of a world's structures. */
|
||||
public final class StructureCommands {
|
||||
private static final String ROOT_NAME = "structure";
|
||||
private static final long INFO_SAMPLE_SEED = 1234L;
|
||||
private static final int INFO_ORIGIN_Y = 64;
|
||||
private static final long DEFAULT_RADIUS_CHUNKS = 48L;
|
||||
private static final long MAX_RADIUS_CHUNKS = 1000L;
|
||||
private static final char NAMESPACE_SEPARATOR = ':';
|
||||
private static final String STRUCTURES_FOLDER = "structures";
|
||||
|
||||
private static final Argument<ResourceId> STRUCTURE = Argument.reading("structure", StructureCommands::readStructure)
|
||||
.describe("The Iris structure to inspect")
|
||||
.suggesting(StructureCommands::structureKeys);
|
||||
private static final Argument<Long> RADIUS = Argument.integer("radius", 1, MAX_RADIUS_CHUNKS)
|
||||
.orElse(DEFAULT_RADIUS_CHUNKS)
|
||||
.describe("Search radius in chunks around the world origin (larger is much slower)");
|
||||
|
||||
private StructureCommands() {
|
||||
}
|
||||
|
||||
public static Command root() {
|
||||
return Command.named(ROOT_NAME).alias("struct", "str")
|
||||
.describe("Iris structure tools")
|
||||
.child(Command.named("list").alias("ls")
|
||||
.describe("Write the index of every vanilla, datapack and Iris structure of the pack")
|
||||
.runs(StructureCommands::list))
|
||||
.child(Command.named("info")
|
||||
.describe("Resolve an Iris structure's jigsaw graph and report its piece count and footprint")
|
||||
.argument(STRUCTURE)
|
||||
.runs(StructureCommands::info))
|
||||
.child(Command.named("verify").alias("locateall")
|
||||
.describe("Verify native structure eligibility and locate Iris-placed structures in the world you stand in")
|
||||
.argument(RADIUS)
|
||||
.runs(StructureCommands::verify));
|
||||
}
|
||||
|
||||
private static void list(CommandContext context) throws IOException {
|
||||
Optional<PlatformStructures> platform = PlatformStructuresAccess.require(context);
|
||||
if (platform.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
File index = StructureIndexService.write(context.pack(), platform.get());
|
||||
context.sender().success("Wrote the structure index: " + index.getPath());
|
||||
}
|
||||
|
||||
private static void info(CommandContext context) {
|
||||
ResourceId id = context.get(STRUCTURE);
|
||||
Assembly assembly = sampleAssembly(context, id).orElseThrow();
|
||||
if (!assembly.hasOutput()) {
|
||||
context.sender().error("Structure " + id + " assembled 0 pieces" + (assembly.detail().isBlank() ? "" : " (" + assembly.detail() + ")"));
|
||||
return;
|
||||
}
|
||||
List<AssembledPiece> pieces = assembly.pieces();
|
||||
int minX = Integer.MAX_VALUE;
|
||||
int minZ = Integer.MAX_VALUE;
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int maxZ = Integer.MIN_VALUE;
|
||||
for (AssembledPiece piece : pieces) {
|
||||
minX = Math.min(minX, piece.minX());
|
||||
minZ = Math.min(minZ, piece.minZ());
|
||||
maxX = Math.max(maxX, piece.maxX());
|
||||
maxZ = Math.max(maxZ, piece.maxZ());
|
||||
}
|
||||
context.sender().success("Structure " + id + ": " + pieces.size() + " pieces, footprint " + (maxX - minX + 1) + "x"
|
||||
+ (maxZ - minZ + 1) + " blocks (sample seed " + INFO_SAMPLE_SEED + ")");
|
||||
}
|
||||
|
||||
private static Optional<Assembly> sampleAssembly(CommandContext context, ResourceId id) {
|
||||
PackResources resources = context.pack().resources();
|
||||
BlockPosition origin = new BlockPosition(0, INFO_ORIGIN_Y, 0);
|
||||
for (StructureAssembly provider : context.pack().services(StructureAssembly.class)) {
|
||||
Optional<Assembly> assembly = provider.assemble(resources, id, origin, new RNG(INFO_SAMPLE_SEED));
|
||||
if (assembly.isPresent()) {
|
||||
return assembly;
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private static void verify(CommandContext context) {
|
||||
Optional<StructureVerifier> verifier = context.world().flatMap(world -> world.extension(StructureVerifier.class));
|
||||
if (verifier.isEmpty()) {
|
||||
context.sender().error("Stand in a world generated with this pack: verify reads the running world");
|
||||
return;
|
||||
}
|
||||
verifier.get().verify(context, Math.toIntExact(context.get(RADIUS)));
|
||||
}
|
||||
|
||||
private static ResourceId readStructure(String written, CommandContext context) {
|
||||
PackResources resources = context.pack().resources();
|
||||
ResourceId id = written.indexOf(NAMESPACE_SEPARATOR) < 0 ? resources.idOf(written) : ResourceId.parse(written);
|
||||
boolean known = context.pack().services(StructureAssembly.class).stream().anyMatch(provider -> provider.knows(resources, id));
|
||||
if (!known) {
|
||||
throw new IllegalArgumentException("No " + STRUCTURES_FOLDER + " resource '" + written + "' in this pack");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
private static List<String> structureKeys(CommandContext context) {
|
||||
PackResources resources = context.pack().resources();
|
||||
Set<String> keys = new LinkedHashSet<>();
|
||||
for (StructureAssembly provider : context.pack().services(StructureAssembly.class)) {
|
||||
provider.structures(resources).forEach(id -> keys.add(resources.idOf(id.path()).equals(id) ? id.path() : id.toString()));
|
||||
}
|
||||
return List.copyOf(keys);
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 235 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user