mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Replace world modes with one generation path through the module pipelines
EngineGeneration replaces the engine mode: it generates the mantle around a chunk, then runs the pack's chunk graph, Iris's built-in stages included, and keeps the per-runtime state built-in stages need. IrisChunk carries the biome hunk and multicore flag, IrisMantleChunk gives built-in mantle stages Iris's mantle writer, and the module mantle component now runs as the first pass, where carving ran. Built-in modules are loaded with Iris's pack object model as host types.
This commit is contained in:
1 parent
fb348d26c8
commit
0f63a3c59a
34 files changed
+546
-569
No files matched your search
+2
-2
@@ -30,7 +30,7 @@ import art.arcane.iris.core.service.IrisApiEventSVC;
|
||||
import art.arcane.iris.core.tools.IrisToolbelt;
|
||||
import art.arcane.iris.core.tools.WorldMaintenance;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineMode;
|
||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||
import art.arcane.iris.engine.framework.EnginePlatformHooks;
|
||||
import art.arcane.iris.engine.framework.NativeStructureVolume;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
@@ -137,7 +137,7 @@ public final class BukkitEnginePlatformHooks implements EnginePlatformHooks {
|
||||
return false;
|
||||
}
|
||||
boolean maintenanceActive = WorldMaintenance.isWorldMaintenanceActive(world.identity());
|
||||
return EngineMode.shouldDisableContextCacheForMaintenance(maintenanceActive, isPregeneratorActive(engine));
|
||||
return EngineGeneration.shouldDisableContextCacheForMaintenance(maintenanceActive, isPregeneratorActive(engine));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,17 +19,18 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.spi.PlatformBiome;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Iris's own view of the chunk whose module stages are running: the engine, Iris's block hunk and the
|
||||
* chunk's sampled context. Iris's built-in chunk stages read them through {@link #current()}, bound on the
|
||||
* generating thread while the chunk graph runs, and work on Iris's block states directly; pack modules
|
||||
* cannot see this class.
|
||||
* Iris's own view of the chunk whose module stages are running: the engine, Iris's block and biome hunks and
|
||||
* the chunk's sampled context. Iris's built-in chunk stages read them through {@link #current()}, bound on the
|
||||
* generating thread while the chunk graph runs, and work on Iris's types directly; pack modules cannot see
|
||||
* this class.
|
||||
*/
|
||||
public final class IrisChunk {
|
||||
private static final ScopedValue<IrisChunk> CURRENT = ScopedValue.newInstance();
|
||||
@@ -38,13 +39,18 @@ public final class IrisChunk {
|
||||
private final int originX;
|
||||
private final int originZ;
|
||||
private final Hunk<PlatformBlockState> blocks;
|
||||
private final Hunk<PlatformBiome> biomes;
|
||||
private final boolean multicore;
|
||||
private final ChunkContext context;
|
||||
|
||||
IrisChunk(Engine engine, int originX, int originZ, Hunk<PlatformBlockState> blocks, ChunkContext context) {
|
||||
IrisChunk(Engine engine, int originX, int originZ, Hunk<PlatformBlockState> blocks, Hunk<PlatformBiome> biomes,
|
||||
boolean multicore, ChunkContext context) {
|
||||
this.engine = engine;
|
||||
this.originX = originX;
|
||||
this.originZ = originZ;
|
||||
this.blocks = blocks;
|
||||
this.biomes = biomes;
|
||||
this.multicore = multicore;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@@ -79,8 +85,28 @@ public final class IrisChunk {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/** The chunk's biomes, indexed like {@link #blocks()}. */
|
||||
public Hunk<PlatformBiome> biomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
/** Whether stages may spread their work over threads. */
|
||||
public boolean multicore() {
|
||||
return multicore;
|
||||
}
|
||||
|
||||
/** What the engine sampled for this chunk, such as its biomes and heights. */
|
||||
public ChunkContext context() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/** The {@code type} state of this engine runtime, such as an actuator; see {@link art.arcane.iris.engine.framework.EngineGeneration#state}. */
|
||||
public <T> T state(Class<T> type, Function<Engine, T> create) {
|
||||
return engine.getGeneration().state(type, create);
|
||||
}
|
||||
|
||||
/** Whether stages backed by the mantle skip this chunk, as maintenance regeneration on Folia requires. */
|
||||
public boolean bypassesMantleStages() {
|
||||
return engine.getGeneration().bypassesMantleStages();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.Engine;
|
||||
import art.arcane.iris.engine.mantle.MantleWriter;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Iris's own view of the chunk whose mantle stages are running: the engine, the mantle writer prepared around
|
||||
* the chunk and the generating chunk's sampled context. Iris's built-in mantle stages read them through
|
||||
* {@link #current()}, bound on the thread running the mantle graph, and write Iris's own mantle data; pack
|
||||
* modules cannot see this class.
|
||||
*/
|
||||
public final class IrisMantleChunk {
|
||||
private static final ScopedValue<IrisMantleChunk> CURRENT = ScopedValue.newInstance();
|
||||
|
||||
private final Engine engine;
|
||||
private final MantleWriter writer;
|
||||
private final int chunkX;
|
||||
private final int chunkZ;
|
||||
private final ChunkContext context;
|
||||
|
||||
IrisMantleChunk(Engine engine, MantleWriter writer, int chunkX, int chunkZ, ChunkContext context) {
|
||||
this.engine = engine;
|
||||
this.writer = writer;
|
||||
this.chunkX = chunkX;
|
||||
this.chunkZ = chunkZ;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/** The mantle chunk whose stages run on this thread. */
|
||||
public static IrisMantleChunk current() {
|
||||
if (!CURRENT.isBound()) {
|
||||
throw new IllegalStateException("No Iris mantle chunk is generating on this thread");
|
||||
}
|
||||
return CURRENT.get();
|
||||
}
|
||||
|
||||
void runBound(Runnable generation) {
|
||||
ScopedValue.where(CURRENT, this).run(generation);
|
||||
}
|
||||
|
||||
public Engine engine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
/** Iris's mantle around the chunk, as far as the mantle pipeline reaches. */
|
||||
public MantleWriter writer() {
|
||||
return writer;
|
||||
}
|
||||
|
||||
public int chunkX() {
|
||||
return chunkX;
|
||||
}
|
||||
|
||||
public int chunkZ() {
|
||||
return chunkZ;
|
||||
}
|
||||
|
||||
/** What the engine sampled for the chunk whose generation asked for this mantle, not necessarily this chunk. */
|
||||
public ChunkContext context() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/** The {@code type} state of this engine runtime; see {@link art.arcane.iris.engine.framework.EngineGeneration#state}. */
|
||||
public <T> T state(Class<T> type, Function<Engine, T> create) {
|
||||
return engine.getGeneration().state(type, create);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,16 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.engine.actuator.BiomeModule;
|
||||
import art.arcane.iris.engine.actuator.DecorantModule;
|
||||
import art.arcane.iris.engine.actuator.TerrainModule;
|
||||
import art.arcane.iris.engine.modifier.CarveModule;
|
||||
import art.arcane.iris.engine.modifier.CustomModule;
|
||||
import art.arcane.iris.engine.modifier.DepositModule;
|
||||
import art.arcane.iris.engine.modifier.FloatingModule;
|
||||
import art.arcane.iris.engine.modifier.MatterModule;
|
||||
import art.arcane.iris.engine.modifier.PerfectionModule;
|
||||
import art.arcane.iris.engine.modifier.PostModule;
|
||||
import art.arcane.iris.engine.object.placement.PlacementModules;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import com.volmit.IrisModule;
|
||||
@@ -50,9 +59,14 @@ public final class IrisModuleHost {
|
||||
return Holder.HOST;
|
||||
}
|
||||
|
||||
/** The modules every pack loads before its own: Iris's built-in features. */
|
||||
/** The modules every pack loads before its own: Iris's built-in features, placement and the chunk generation every world runs. */
|
||||
public static List<IrisModule> builtInModules() {
|
||||
return Stream.concat(PlacementModules.all().stream(), Stream.of(new PerfectionModule())).toList();
|
||||
return Stream.concat(PlacementModules.all().stream(), generationModules().stream()).toList();
|
||||
}
|
||||
|
||||
private static List<IrisModule> generationModules() {
|
||||
return List.of(new BiomeModule(), new TerrainModule(), new CarveModule(), new PostModule(), new FloatingModule(),
|
||||
new DepositModule(), new MatterModule(), new DecorantModule(), new PerfectionModule(), new CustomModule());
|
||||
}
|
||||
|
||||
/** Whether {@code type} is one of Iris's own classes that built-in settings may hold. */
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.spi.PlatformBiome;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
@@ -30,7 +31,8 @@ import com.volmit.host.ResolvedGraph;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Runs the pack's resolved chunk graph on a chunk. A stage is active where any column of the chunk has its
|
||||
* Runs the pack's resolved chunk graph on a chunk, Iris's built-in stages included: this is how every chunk
|
||||
* generates. A stage is active where any column of the chunk has its
|
||||
* settings at the dimension, the column's region or its biome (see {@link ChunkModuleSettings}). A failing
|
||||
* stage fails the chunk.
|
||||
* <p>
|
||||
@@ -43,13 +45,14 @@ public final class ModuleChunkGeneration {
|
||||
private ModuleChunkGeneration() {
|
||||
}
|
||||
|
||||
/** {@code x} and {@code z} are the chunk's first block, as engine stages receive them. */
|
||||
public static void generate(Engine engine, int x, int z, Hunk<PlatformBlockState> blocks, ChunkContext context) {
|
||||
generate(engine.getData().getModules().pack(), engine, x, z, blocks, context, B::getState);
|
||||
/** {@code x} and {@code z} are the chunk's first block. */
|
||||
public static void generate(Engine engine, int x, int z, Hunk<PlatformBlockState> blocks, Hunk<PlatformBiome> biomes,
|
||||
boolean multicore, ChunkContext context) {
|
||||
generate(engine.getData().getModules().pack(), engine, x, z, blocks, biomes, multicore, context, B::getState);
|
||||
}
|
||||
|
||||
static void generate(LoadedPack pack, Engine engine, int x, int z, Hunk<PlatformBlockState> blocks, ChunkContext context,
|
||||
Function<String, PlatformBlockState> platformStates) {
|
||||
static void generate(LoadedPack pack, Engine engine, int x, int z, Hunk<PlatformBlockState> blocks, Hunk<PlatformBiome> biomes,
|
||||
boolean multicore, ChunkContext context, Function<String, PlatformBlockState> platformStates) {
|
||||
ResolvedGraph chunk = pack.chunk();
|
||||
if (chunk.stages().isEmpty()) {
|
||||
return;
|
||||
@@ -60,7 +63,7 @@ public final class ModuleChunkGeneration {
|
||||
try (PinnedMantleChunk mantle = new PinnedMantleChunk(engine, chunkX, chunkZ)) {
|
||||
IrisGenerationContext inputs = new IrisGenerationContext(engine, x, z, new BlockStateHunk(blocks, platformStates), mantle,
|
||||
pack.catalog().mantle());
|
||||
new IrisChunk(engine, x, z, blocks, context).runBound(() -> new ChunkRunner(chunk).generate(inputs, seed));
|
||||
new IrisChunk(engine, x, z, blocks, biomes, multicore, context).runBound(() -> new ChunkRunner(chunk).generate(inputs, seed));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,15 +29,16 @@ import com.volmit.host.MantleRunner;
|
||||
import com.volmit.host.ResolvedGraph;
|
||||
|
||||
/**
|
||||
* Runs the pack's mantle pipeline as one of Iris's mantle components: once for every chunk the mantle prepares
|
||||
* around a generating chunk, as far as the pipeline's declared reach. It is the last pass, so its stages see what
|
||||
* Iris's own components wrote, and it is disabled while the pack has no mantle stages.
|
||||
* Runs the pack's mantle pipeline, Iris's built-in mantle stages included, as one of Iris's mantle components:
|
||||
* once for every chunk the mantle prepares around a generating chunk, as far as the pipeline's declared reach.
|
||||
* It is the first pass, where carving has always run, so Iris's object, floating object and structure passes
|
||||
* see the caves and whatever else mantle stages wrote. It is disabled while the pack has no mantle stages.
|
||||
*/
|
||||
public final class ModuleMantleComponent extends IrisMantleComponent {
|
||||
/** Marks a mantle chunk whose module stages have run. */
|
||||
public static final MantleFlag FLAG = MantleFlag.of(MantleFlag.MIN_ORDINAL);
|
||||
/** After every Iris component, whatever priority they use. */
|
||||
private static final int PRIORITY = Integer.MAX_VALUE;
|
||||
/** The first pass: the carving stage it runs had priority 0 as a component of its own. */
|
||||
private static final int PRIORITY = 0;
|
||||
|
||||
/** Whether the pack has mantle stages; asked on every chunk, so kept until the next hotload. */
|
||||
private volatile Boolean hasStages;
|
||||
@@ -65,7 +66,8 @@ public final class ModuleMantleComponent extends IrisMantleComponent {
|
||||
@Override
|
||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||
Engine engine = getEngineMantle().getEngine();
|
||||
generate(engine.getData().getModules().pack(), engine, x, z, getRadius(), writer::acquireChunk);
|
||||
IrisMantleChunk chunk = new IrisMantleChunk(engine, writer, x, z, context);
|
||||
chunk.runBound(() -> generate(engine.getData().getModules().pack(), engine, x, z, getRadius(), writer::acquireChunk));
|
||||
}
|
||||
|
||||
/** Runs the mantle stages of chunk {@code x}, {@code z}, with the mantle chunks within {@code reachBlocks} of it. */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.engine;
|
||||
|
||||
import art.arcane.iris.engine.framework.EngineEffects;
|
||||
import art.arcane.iris.engine.framework.EngineMode;
|
||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||
import art.arcane.iris.engine.framework.EngineTarget;
|
||||
import art.arcane.iris.engine.framework.EngineWorldManager;
|
||||
|
||||
@@ -35,7 +35,7 @@ record EngineRuntime(
|
||||
IrisComplex complex,
|
||||
UpperDimensionContext upperContext,
|
||||
EngineEffects effects,
|
||||
EngineMode mode,
|
||||
EngineGeneration generation,
|
||||
EngineWorldManager worldManager,
|
||||
CompletableFuture<Long> hash32,
|
||||
BiomeMaxes biomeMaxes
|
||||
@@ -52,7 +52,7 @@ record EngineRuntime(
|
||||
nextComplex,
|
||||
nextUpperContext,
|
||||
effects,
|
||||
mode,
|
||||
generation,
|
||||
worldManager,
|
||||
hash32,
|
||||
nextBiomeMaxes);
|
||||
|
||||
@@ -25,7 +25,7 @@ import art.arcane.iris.engine.EngineRuntime.BiomeMaxes;
|
||||
import art.arcane.iris.engine.IrisEngine.LifecycleState;
|
||||
import art.arcane.iris.engine.framework.EngineEffects;
|
||||
import art.arcane.iris.engine.framework.EngineEffectsProvider;
|
||||
import art.arcane.iris.engine.framework.EngineMode;
|
||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||
import art.arcane.iris.engine.framework.EngineTarget;
|
||||
import art.arcane.iris.engine.framework.EngineWorldManager;
|
||||
import art.arcane.iris.engine.framework.EngineWorldManagerProvider;
|
||||
@@ -33,8 +33,6 @@ import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.terrain.IrisBiomePaletteLayer;
|
||||
import art.arcane.iris.engine.object.decoration.IrisDecorator;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimensionMode;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimensionModeType;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
import art.arcane.iris.util.project.context.IrisContext;
|
||||
@@ -86,8 +84,7 @@ final class EngineRuntimeBuilder {
|
||||
engine.getMantle().hotload();
|
||||
IrisLogging.debug("[IrisEngine timing] mantle.hotload=" + (M.ms() - started) + "ms");
|
||||
started = M.ms();
|
||||
assembly.mode = createMode();
|
||||
IrisLogging.debug("[IrisEngine timing] setupMode=" + (M.ms() - started) + "ms");
|
||||
assembly.generation = new EngineGeneration(engine);
|
||||
started = M.ms();
|
||||
assembly.worldManager = IrisServices.get(EngineWorldManagerProvider.class).create(engine);
|
||||
if (assembly.worldManager == null) {
|
||||
@@ -201,39 +198,6 @@ final class EngineRuntimeBuilder {
|
||||
return null;
|
||||
}
|
||||
|
||||
private EngineMode createMode() {
|
||||
Throwable configuredFailure = null;
|
||||
try {
|
||||
IrisDimensionMode configuredMode = engine.getDimension().getMode();
|
||||
if (configuredMode == null) {
|
||||
configuredMode = new IrisDimensionMode();
|
||||
engine.getDimension().setMode(configuredMode);
|
||||
}
|
||||
EngineMode configured = configuredMode.create(engine);
|
||||
if (configured == null) {
|
||||
throw new IllegalStateException("Dimension mode factory returned null");
|
||||
}
|
||||
return configured;
|
||||
} catch (Throwable e) {
|
||||
configuredFailure = e;
|
||||
IrisLogging.reportError(e);
|
||||
if (engine.getModeFallbackLogged().compareAndSet(false, true)) {
|
||||
IrisLogging.warn("Failed to initialize configured dimension mode for " + engine.getDimension().getLoadKey() + ", falling back to OVERWORLD mode.");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
EngineMode fallback = IrisDimensionModeType.OVERWORLD.create(engine);
|
||||
if (fallback == null) {
|
||||
throw new IllegalStateException("OVERWORLD mode factory returned null");
|
||||
}
|
||||
return fallback;
|
||||
} catch (Throwable fallbackFailure) {
|
||||
fallbackFailure.addSuppressed(configuredFailure);
|
||||
throw new IllegalStateException("Both configured and fallback Iris engine modes failed.", fallbackFailure);
|
||||
}
|
||||
}
|
||||
|
||||
BiomeMaxes computeBiomeMaxes() {
|
||||
double objectDensity = 0D;
|
||||
double layerDensity = 0D;
|
||||
@@ -297,7 +261,7 @@ final class EngineRuntimeBuilder {
|
||||
IrisComplex complex;
|
||||
UpperDimensionContext upperContext;
|
||||
EngineEffects effects;
|
||||
EngineMode mode;
|
||||
EngineGeneration generation;
|
||||
EngineWorldManager worldManager;
|
||||
CompletableFuture<Long> hash32;
|
||||
|
||||
@@ -307,7 +271,7 @@ final class EngineRuntimeBuilder {
|
||||
}
|
||||
|
||||
EngineRuntime freeze(BiomeMaxes biomeMaxes) {
|
||||
if (complex == null || effects == null || mode == null || worldManager == null || hash32 == null) {
|
||||
if (complex == null || effects == null || generation == null || worldManager == null || hash32 == null) {
|
||||
throw new IllegalStateException("Cannot publish an incomplete Iris engine runtime.");
|
||||
}
|
||||
return new EngineRuntime(
|
||||
@@ -316,7 +280,7 @@ final class EngineRuntimeBuilder {
|
||||
complex,
|
||||
upperContext,
|
||||
effects,
|
||||
mode,
|
||||
generation,
|
||||
worldManager,
|
||||
hash32,
|
||||
biomeMaxes);
|
||||
|
||||
@@ -218,8 +218,8 @@ final class EngineShutdownSequence {
|
||||
}
|
||||
});
|
||||
failure = runCleanup(failure, () -> {
|
||||
if (assembly.mode != null) {
|
||||
assembly.mode.close();
|
||||
if (assembly.generation != null) {
|
||||
assembly.generation.close();
|
||||
}
|
||||
});
|
||||
failure = runCleanup(failure, () -> {
|
||||
@@ -241,7 +241,7 @@ final class EngineShutdownSequence {
|
||||
}
|
||||
failure = runCleanup(failure, engineRuntime.worldManager()::close);
|
||||
failure = runCleanup(failure, engineRuntime.effects()::close);
|
||||
failure = runCleanup(failure, engineRuntime.mode()::close);
|
||||
failure = runCleanup(failure, engineRuntime.generation()::close);
|
||||
failure = runCleanup(failure, engineRuntime.complex()::close);
|
||||
failure = runCleanup(failure, () -> engineRuntime.hash32().cancel(true));
|
||||
return failure;
|
||||
|
||||
@@ -23,7 +23,7 @@ import art.arcane.iris.engine.EngineRuntimeBuilder.RuntimeAssembly;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineEffects;
|
||||
import art.arcane.iris.engine.framework.EngineMetrics;
|
||||
import art.arcane.iris.engine.framework.EngineMode;
|
||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||
import art.arcane.iris.engine.framework.EnginePlatformHooks;
|
||||
import art.arcane.iris.engine.framework.NativeStructureVolume;
|
||||
import art.arcane.iris.engine.framework.NativeStructureVolumeMemo;
|
||||
@@ -148,7 +148,6 @@ public class IrisEngine implements Engine {
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
volatile LifecycleState lifecycleState;
|
||||
private final AtomicBoolean modeFallbackLogged;
|
||||
private final AtomicBoolean prefetchSaveStarted;
|
||||
|
||||
/**
|
||||
@@ -201,7 +200,6 @@ public class IrisEngine implements Engine {
|
||||
mantle = new IrisEngineMantle(this);
|
||||
IrisLogging.debug("[IrisEngine timing] new IrisEngineMantle=" + (M.ms() - _t0) + "ms");
|
||||
cleaning = new AtomicBoolean(false);
|
||||
modeFallbackLogged = new AtomicBoolean(false);
|
||||
prefetchSaveStarted = new AtomicBoolean(false);
|
||||
sealInitialGenerationSession();
|
||||
|
||||
@@ -511,13 +509,13 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EngineMode getMode() {
|
||||
public EngineGeneration getGeneration() {
|
||||
RuntimeAssembly assembly = runtimeAssembly.get();
|
||||
if (assembly != null && assembly.mode != null) {
|
||||
return assembly.mode;
|
||||
if (assembly != null && assembly.generation != null) {
|
||||
return assembly.generation;
|
||||
}
|
||||
EngineRuntime current = runtimeBuilder.requireRuntime("access the engine mode");
|
||||
return current.mode();
|
||||
EngineRuntime current = runtimeBuilder.requireRuntime("access the engine generation");
|
||||
return current.generation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -635,8 +633,7 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
EngineMode activeMode = getMode();
|
||||
activeMode.generate(x, z, blocks, vbiomes, multicore, lease.sessionId());
|
||||
getGeneration().generate(x, z, blocks, vbiomes, multicore, lease.sessionId());
|
||||
}
|
||||
|
||||
boolean skipRealFlag = platformHooks.shouldBypassMantleStages(this);
|
||||
|
||||
@@ -27,7 +27,6 @@ import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.engine.mantle.MantleComponent;
|
||||
import art.arcane.iris.engine.mantle.MantlePass;
|
||||
import art.arcane.iris.engine.mantle.components.MantleCarvingComponent;
|
||||
import art.arcane.iris.engine.mantle.components.MantleFloatingObjectComponent;
|
||||
import art.arcane.iris.engine.mantle.components.MantleObjectComponent;
|
||||
import art.arcane.iris.engine.mantle.components.IrisStructureComponent;
|
||||
@@ -46,7 +45,6 @@ import art.arcane.volmlib.util.mantle.runtime.MantleDataAdapter;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleHooks;
|
||||
import art.arcane.volmlib.util.mantle.runtime.TectonicPlate;
|
||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
||||
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
||||
import art.arcane.iris.util.common.format.C;
|
||||
import art.arcane.volmlib.util.matter.IrisMatter;
|
||||
@@ -86,7 +84,6 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
this.engine = engine;
|
||||
this.mantle = createMantle(engine);
|
||||
components = new KMap<>();
|
||||
registerComponent(new MantleCarvingComponent(this));
|
||||
object = new MantleObjectComponent(this);
|
||||
registerComponent(object);
|
||||
registerComponent(new MantleFloatingObjectComponent(this));
|
||||
@@ -173,9 +170,6 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
return disabledFlags.aquire(() -> {
|
||||
KList<MantleFlag> disabled = new KList<>();
|
||||
disabled.addAll(getDimension().getDisabledComponents());
|
||||
if (!getDimension().isCarvingEnabled()) {
|
||||
disabled.addIfMissing(ReservedFlag.CARVED);
|
||||
}
|
||||
return Set.copyOf(disabled);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
||||
return null;
|
||||
}
|
||||
|
||||
EngineMode getMode();
|
||||
EngineGeneration getGeneration();
|
||||
|
||||
EnginePlatformHooks getPlatformHooks();
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import art.arcane.iris.core.modules.ModuleChunkGeneration;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBiome;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.iris.util.project.context.IrisContext;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* How every Iris world generates a chunk: the mantle around it first, then the pack's chunk pipeline, Iris's
|
||||
* built-in stages included. It also keeps the state built-in stages hold per engine runtime, such as an
|
||||
* actuator's caches, so a hotload, which builds a new runtime, starts them fresh.
|
||||
*/
|
||||
public final class EngineGeneration {
|
||||
private static final int CHUNK_SHIFT = 4;
|
||||
private static final long MAINTENANCE_LOG_INTERVAL_MILLIS = 5000L;
|
||||
private static final AtomicLong lastMaintenanceBypassLog = new AtomicLong(0L);
|
||||
|
||||
private final Engine engine;
|
||||
private final Map<Class<?>, Object> states = new ConcurrentHashMap<>();
|
||||
|
||||
public EngineGeneration(Engine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* The one {@code type} instance of this runtime, created by {@code create} the first time a stage asks.
|
||||
* {@code create} must not ask for other state.
|
||||
*/
|
||||
public <T> T state(Class<T> type, Function<Engine, T> create) {
|
||||
return type.cast(states.computeIfAbsent(type, ignored -> create.apply(engine)));
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
public void generate(int x, int z, Hunk<PlatformBlockState> blocks, Hunk<PlatformBiome> biomes, boolean multicore, long generationSessionId) {
|
||||
boolean cacheContext = !engine.getPlatformHooks().shouldDisableChunkContextCache(engine);
|
||||
ChunkContext.PrefillPlan prefillPlan = cacheContext ? ChunkContext.PrefillPlan.NO_CAVE : ChunkContext.PrefillPlan.NONE;
|
||||
ChunkContext context = new ChunkContext(x, z, engine.getComplex(), generationSessionId, cacheContext, prefillPlan, engine.getMetrics());
|
||||
try (IrisContext.Scope chunkScope = IrisContext.open(engine, generationSessionId, context)) {
|
||||
generateMantle(x, z, multicore, context);
|
||||
ModuleChunkGeneration.generate(engine, x, z, blocks, biomes, multicore, context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether stages backed by the mantle skip this chunk: on Folia, maintenance regeneration runs without the
|
||||
* mantle to stay region-safe.
|
||||
*/
|
||||
public boolean bypassesMantleStages() {
|
||||
boolean bypass = engine.getPlatformHooks().shouldBypassMantleStages(engine);
|
||||
if (bypass) {
|
||||
logMaintenanceBypass();
|
||||
}
|
||||
return bypass;
|
||||
}
|
||||
|
||||
/** Closes the state stages kept, such as actuators that hold engine resources. */
|
||||
public void close() {
|
||||
states.values().forEach(state -> {
|
||||
if (state instanceof EngineComponent component) {
|
||||
component.close();
|
||||
}
|
||||
});
|
||||
states.clear();
|
||||
}
|
||||
|
||||
public static boolean shouldDisableContextCacheForMaintenance(boolean maintenanceActive, boolean pregeneratorTargetsWorld) {
|
||||
return maintenanceActive && !pregeneratorTargetsWorld;
|
||||
}
|
||||
|
||||
private void generateMantle(int x, int z, boolean multicore, ChunkContext context) {
|
||||
if (bypassesMantleStages()) {
|
||||
return;
|
||||
}
|
||||
engine.getMantle().generateMatter(x >> CHUNK_SHIFT, z >> CHUNK_SHIFT, multicore || engine.isStudio(), context);
|
||||
}
|
||||
|
||||
private static void logMaintenanceBypass() {
|
||||
long now = System.currentTimeMillis();
|
||||
long last = lastMaintenanceBypassLog.get();
|
||||
if (now - last >= MAINTENANCE_LOG_INTERVAL_MILLIS && lastMaintenanceBypassLog.compareAndSet(last, now)) {
|
||||
IrisLogging.info("Maintenance regen bypass: skipping mantle-backed stages for Folia safety.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.core.modules.ModuleChunkGeneration;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.iris.util.project.context.IrisContext;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.iris.util.common.parallel.BurstExecutor;
|
||||
import art.arcane.iris.util.common.parallel.MultiBurst;
|
||||
import art.arcane.iris.spi.PlatformBiome;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
|
||||
public interface EngineMode extends Staged {
|
||||
void close();
|
||||
|
||||
Engine getEngine();
|
||||
|
||||
default MultiBurst burst() {
|
||||
return getEngine().burst();
|
||||
}
|
||||
|
||||
default EngineStage burst(EngineStage... stages) {
|
||||
return (x, z, blocks, biomes, multicore, ctx) -> {
|
||||
BurstExecutor e = burst().burst(stages.length);
|
||||
e.setMulticore(multicore);
|
||||
// BurstExecutor.complete() logs-and-swallows stage failures; without re-propagation
|
||||
// a multicore run would commit a half-written chunk that the inline (production)
|
||||
// path correctly aborts.
|
||||
java.util.concurrent.atomic.AtomicReference<Throwable> failure = new java.util.concurrent.atomic.AtomicReference<>();
|
||||
|
||||
for (EngineStage i : stages) {
|
||||
e.queue(() -> {
|
||||
if (failure.get() != null) {
|
||||
return;
|
||||
}
|
||||
try (IrisContext.Scope stageScope = IrisContext.open(getEngine(), ctx.getGenerationSessionId(), ctx)) {
|
||||
i.generate(x, z, blocks, biomes, multicore, ctx);
|
||||
} catch (Throwable t) {
|
||||
failure.compareAndSet(null, t);
|
||||
// Rethrow so the inline (multicore=false) path still aborts out of
|
||||
// queue() on the first failure, exactly as before.
|
||||
if (t instanceof Error error) {
|
||||
throw error;
|
||||
}
|
||||
if (t instanceof RuntimeException runtimeException) {
|
||||
throw runtimeException;
|
||||
}
|
||||
throw new IllegalStateException(t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
e.complete();
|
||||
|
||||
Throwable t = failure.get();
|
||||
if (t != null) {
|
||||
if (t instanceof Error error) {
|
||||
throw error;
|
||||
}
|
||||
if (t instanceof RuntimeException runtimeException) {
|
||||
throw runtimeException;
|
||||
}
|
||||
throw new IllegalStateException("Burst stage failure during chunk generation", t);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
default IrisComplex getComplex() {
|
||||
return getEngine().getComplex();
|
||||
}
|
||||
|
||||
default EngineMantle getMantle() {
|
||||
return getEngine().getMantle();
|
||||
}
|
||||
|
||||
default void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
|
||||
getMantle().generateMatter(x, z, multicore, context);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default void generate(int x, int z, Hunk<PlatformBlockState> blocks, Hunk<PlatformBiome> biomes, boolean multicore, long generationSessionId) {
|
||||
boolean cacheContext = !getEngine().getPlatformHooks().shouldDisableChunkContextCache(getEngine());
|
||||
ChunkContext.PrefillPlan prefillPlan = cacheContext ? ChunkContext.PrefillPlan.NO_CAVE : ChunkContext.PrefillPlan.NONE;
|
||||
ChunkContext ctx = new ChunkContext(x, z, getComplex(), generationSessionId, cacheContext, prefillPlan, getEngine().getMetrics());
|
||||
|
||||
EngineStage[] stages = getStages().toArray(new EngineStage[0]);
|
||||
try (IrisContext.Scope chunkScope = IrisContext.open(getEngine(), generationSessionId, ctx)) {
|
||||
for (EngineStage i : stages) {
|
||||
i.generate(x, z, blocks, biomes, multicore, ctx);
|
||||
}
|
||||
ModuleChunkGeneration.generate(getEngine(), x, z, blocks, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean shouldDisableContextCacheForMaintenance(boolean maintenanceActive, boolean pregeneratorTargetsWorld) {
|
||||
return maintenanceActive && !pregeneratorTargetsWorld;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import art.arcane.iris.spi.PlatformBiome;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
|
||||
public interface EngineStage {
|
||||
@BlockCoordinates
|
||||
void generate(int x, int z, Hunk<PlatformBlockState> blocks, Hunk<PlatformBiome> biomes, boolean multicore, ChunkContext context);
|
||||
|
||||
default void close() {
|
||||
if (this instanceof EngineComponent c) {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
public abstract class IrisEngineMode implements EngineMode {
|
||||
private final Engine engine;
|
||||
private final KList<EngineStage> stages;
|
||||
private boolean closed;
|
||||
|
||||
public IrisEngineMode(Engine engine) {
|
||||
this.engine = engine;
|
||||
this.stages = new KList<>();
|
||||
this.closed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
|
||||
closed = true;
|
||||
dump();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Engine getEngine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KList<EngineStage> getStages() {
|
||||
return stages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStage(EngineStage stage) {
|
||||
stages.add(stage);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
public interface Staged {
|
||||
KList<EngineStage> getStages();
|
||||
|
||||
void registerStage(EngineStage stage);
|
||||
|
||||
default void dump() {
|
||||
getStages().forEach(EngineStage::close);
|
||||
getStages().clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.loader.IrisData;
|
||||
import art.arcane.iris.builtin.deposit.DepositSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ResolvedGraph;
|
||||
import com.volmit.host.schema.FeatureSchema;
|
||||
import com.volmit.host.schema.ValueKind;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/** Every world generates through the built-in modules' stages, in the order the old overworld mode ran them. */
|
||||
public class BuiltInGenerationGraphTest {
|
||||
private static final List<String> EXPECTED_CHUNK_ORDER = List.of(
|
||||
"iris:biome/write", "iris:terrain/shape", "iris:carve/apply", "iris:post/smooth", "iris:floating/solids",
|
||||
"iris:deposit/ores", "iris:matter/insert", "iris:decorant/decorate", "iris:floating/decorate",
|
||||
"iris:perfection/surface", "iris:custom/blocks");
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void chunkStagesRunInTheOverworldOrder() throws IOException {
|
||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
ResolvedGraph chunk = pack.chunk();
|
||||
|
||||
assertEquals(chunk.describe(), EXPECTED_CHUNK_ORDER, ids(chunk));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cavesArePlannedInTheMantleOneBlockIntoEachNeighbor() throws IOException {
|
||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
ResolvedGraph mantle = pack.mantle();
|
||||
|
||||
assertEquals(List.of("iris:carve/caves"), ids(mantle));
|
||||
assertEquals(1, mantle.reach().blocks());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void depositsAreSettingsOfEveryLevelWrittenAsTheirOldList() throws IOException {
|
||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
for (Target level : List.of(Target.DIMENSION, Target.REGION, Target.BIOME)) {
|
||||
FeatureSchema deposits = pack.schema().fields(level).stream()
|
||||
.filter(feature -> feature.settings().name().equals(DepositSettings.class.getName()))
|
||||
.findFirst().orElseThrow();
|
||||
assertEquals("deposits", deposits.alias().orElseThrow());
|
||||
ValueKind generators = deposits.shorthand().orElseThrow().kind();
|
||||
assertTrue(generators.toString(), generators instanceof ValueKind.ListKind list
|
||||
&& list.element() instanceof ValueKind.HostKind host
|
||||
&& host.type().equals("art.arcane.iris.engine.object.terrain.deposit.IrisDepositGenerator"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> ids(ResolvedGraph graph) {
|
||||
return graph.stages().stream().map(stage -> stage.stage().id().toString()).toList();
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -33,15 +33,17 @@ import java.util.stream.Stream;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** Test packs whose placement graph is Iris's built-in modules followed by the given pack modules. */
|
||||
public final class BuiltInPlacementPack {
|
||||
private BuiltInPlacementPack() {
|
||||
/** Test packs of Iris's built-in modules followed by the given pack modules, loaded as Iris's module host loads them. */
|
||||
public final class BuiltInPack {
|
||||
private BuiltInPack() {
|
||||
}
|
||||
|
||||
/** Loads the pack and lets the mocked {@code data} serve it, as a pack's data serves its modules. Close it after the test. */
|
||||
public static LoadedPack serve(IrisData data, TemporaryFolder folder, List<IrisModule> packModules) throws IOException {
|
||||
List<IrisModule> modules = Stream.concat(IrisModuleHost.builtInModules().stream(), packModules.stream()).toList();
|
||||
LoadedPack pack = LoadedPack.load(folder.newFolder().toPath(), ModuleHost.of(modules).copyingJarsTo(folder.newFolder().toPath()));
|
||||
LoadedPack pack = LoadedPack.load(folder.newFolder().toPath(), ModuleHost.of(modules)
|
||||
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE)
|
||||
.copyingJarsTo(folder.newFolder().toPath()));
|
||||
PackModuleSet moduleSet = mock(PackModuleSet.class);
|
||||
when(moduleSet.pack()).thenReturn(pack);
|
||||
when(data.getModules()).thenReturn(moduleSet);
|
||||
@@ -43,7 +43,7 @@ public class BuiltInPlacementGraphTest {
|
||||
|
||||
@Test
|
||||
public void writesTheObjectAndFindsItsStiltLayersInOneBlockPass() throws IOException {
|
||||
try (LoadedPack pack = BuiltInPlacementPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
ResolvedGraph graph = pack.placement();
|
||||
|
||||
assertEquals(graph.describe(), EXPECTED_ORDER, graph.stages().stream().map(stage -> stage.stage().id().toString()).toList());
|
||||
|
||||
@@ -135,7 +135,7 @@ public class ModuleChunkGenerationTest {
|
||||
IrisBiome pillared = configured(new IrisBiome(), pillar(3));
|
||||
when(engine.getSurfaceBiome(anyInt(), anyInt())).thenAnswer(call -> call.getArgument(0, Integer.class) == 15 ? pillared : plain);
|
||||
|
||||
ModuleChunkGeneration.generate(pack, engine, 0, 0, blocks, null, ModuleChunkGenerationTest::platformState);
|
||||
ModuleChunkGeneration.generate(pack, engine, 0, 0, blocks, null, false, null, ModuleChunkGenerationTest::platformState);
|
||||
|
||||
assertEquals("minecraft:oak_log[axis=y]", blocks.get(3, 2, 0).key());
|
||||
}
|
||||
@@ -175,7 +175,7 @@ public class ModuleChunkGenerationTest {
|
||||
private void generate(IrisBiome biome) {
|
||||
when(engine.getRegion(anyInt(), anyInt())).thenReturn(new IrisRegion());
|
||||
when(engine.getSurfaceBiome(anyInt(), anyInt())).thenReturn(biome);
|
||||
ModuleChunkGeneration.generate(pack, engine, 0, 0, blocks, null, ModuleChunkGenerationTest::platformState);
|
||||
ModuleChunkGeneration.generate(pack, engine, 0, 0, blocks, null, false, null, ModuleChunkGenerationTest::platformState);
|
||||
}
|
||||
|
||||
private static PillarSettings pillar(int x) {
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ public class ObjectPlacementModuleSettingsTest {
|
||||
IrisPlatforms.bind(platform);
|
||||
|
||||
data = mock(IrisData.class);
|
||||
pack = BuiltInPlacementPack.serve(data, folder, List.of(new GlowModule()));
|
||||
pack = BuiltInPack.serve(data, folder, List.of(new GlowModule()));
|
||||
ModuleSettingsDecoder decoder = new ModuleSettingsDecoder(pack.catalog(), folder.getRoot().toPath(), Gson::new);
|
||||
gson = new GsonBuilder().registerTypeAdapterFactory(new ObjectPlacementSettingsReader(() -> decoder)).create();
|
||||
}
|
||||
|
||||
@@ -18,19 +18,23 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.floating.FloatingStages;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineMetrics;
|
||||
import art.arcane.iris.engine.framework.SeedManager;
|
||||
import art.arcane.iris.engine.modifier.PerfectionModule;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimensionModeType;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.spi.PlatformRegistries;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import com.volmit.stage.StageGraph;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -38,6 +42,7 @@ import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
@@ -69,7 +74,7 @@ public class PerfectionModuleTest {
|
||||
when(platform.registries()).thenReturn(registries);
|
||||
IrisPlatforms.bind(platform);
|
||||
pack = LoadedPack.load(folder.newFolder("pack").toPath(),
|
||||
ModuleHost.of(IrisModuleHost.builtInModules()).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||
ModuleHost.of(List.of(new PerfectionModule(), new FloatingDecorationStub())).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||
engine = mock(Engine.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
SeedManager seeds = mock(SeedManager.class);
|
||||
@@ -92,7 +97,7 @@ public class PerfectionModuleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overworldChunksLoseDecorationsTheirGroundCannotHold() {
|
||||
public void chunksLoseDecorationsTheirGroundCannotHold() {
|
||||
PlatformBlockState floating = decorant(false);
|
||||
PlatformBlockState rooted = decorant(true);
|
||||
blocks.set(0, 1, 0, floating);
|
||||
@@ -105,19 +110,22 @@ public class PerfectionModuleTest {
|
||||
assertSame(ground, blocks.get(0, 0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void otherWorldModesKeepEveryDecoration() {
|
||||
dimension.getMode().setType(IrisDimensionModeType.SUPERFLAT);
|
||||
PlatformBlockState floating = decorant(false);
|
||||
blocks.set(0, 1, 0, floating);
|
||||
|
||||
generate();
|
||||
|
||||
assertSame(floating, blocks.get(0, 1, 0));
|
||||
private void generate() {
|
||||
ModuleChunkGeneration.generate(pack, engine, 0, 0, blocks, null, false, null, key -> block(key, false));
|
||||
}
|
||||
|
||||
private void generate() {
|
||||
ModuleChunkGeneration.generate(pack, engine, 0, 0, blocks, null, key -> block(key, false));
|
||||
/** The stage perfection runs after; perfection needs it installed, not doing anything. */
|
||||
private static final class FloatingDecorationStub implements IrisModule {
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("iris:floating", "Floating islands", "test");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
graph.define(FloatingStages.DECORATE).run(context -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static PlatformBlockState decorant(boolean held) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package art.arcane.iris.engine;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineMode;
|
||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.engine.mode.ModeOverworld;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -25,7 +24,7 @@ public class IrisEnginePlatformHookIsolationTest {
|
||||
"art/arcane/iris/platform/bukkit/",
|
||||
"org/bukkit/"
|
||||
);
|
||||
private static final List<String> BUKKIT_MODE_CLASSES = List.of(
|
||||
private static final List<String> BUKKIT_GENERATION_CLASSES = List.of(
|
||||
"art/arcane/iris/core/tools/IrisToolbelt",
|
||||
"art/arcane/iris/spi/IrisServices",
|
||||
"art/arcane/iris/util/common/scheduling/J",
|
||||
@@ -59,9 +58,9 @@ public class IrisEnginePlatformHookIsolationTest {
|
||||
assertNoClassLinks(IrisEngineMantle.class, BUKKIT_ENGINE_CLASSES);
|
||||
assertNoClassLinks(Class.forName(IrisEngineMantle.class.getName() + "$1"), BUKKIT_ENGINE_CLASSES);
|
||||
assertNoClassLinks(Engine.class, ENGINE_POLICY_CLASSES);
|
||||
assertNoClassLinks(EngineMode.class, PLATFORM_POLICY_CLASSES);
|
||||
assertNoClassLinks(EngineGeneration.class, PLATFORM_POLICY_CLASSES);
|
||||
assertNoClassLinks(EngineMantle.class, PLATFORM_POLICY_CLASSES);
|
||||
assertNoClassLinks(ModeOverworld.class, BUKKIT_MODE_CLASSES);
|
||||
assertNoClassLinks(EngineGeneration.class, BUKKIT_GENERATION_CLASSES);
|
||||
}
|
||||
|
||||
private static void assertNoClassLinks(Class<?> type, List<String> forbiddenClasses) throws IOException {
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@ import static org.mockito.ArgumentMatchers.same;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisBiomeActuatorCoordinateTest {
|
||||
public class BiomeModuleCoordinateTest {
|
||||
@After
|
||||
public void unbindPlatform() {
|
||||
IrisPlatforms.unbind();
|
||||
@@ -43,7 +43,7 @@ public class IrisBiomeActuatorCoordinateTest {
|
||||
public void derivativeScatterUsesEachWorldColumnCoordinate() {
|
||||
bindPlatform();
|
||||
Engine engine = engine();
|
||||
IrisBiomeActuator actuator = new IrisBiomeActuator(engine);
|
||||
BiomeModule.BiomeWriter writer = new BiomeModule.BiomeWriter(engine);
|
||||
Hunk<PlatformBiome> output = mock(Hunk.class);
|
||||
when(output.getWidth()).thenReturn(2);
|
||||
when(output.getDepth()).thenReturn(2);
|
||||
@@ -64,7 +64,7 @@ public class IrisBiomeActuatorCoordinateTest {
|
||||
ChunkContext context = mock(ChunkContext.class);
|
||||
when(context.getBiome()).thenReturn(biomeCache);
|
||||
|
||||
actuator.onActuate(100, -200, output, false, context);
|
||||
writer.write(100, -200, output, context);
|
||||
|
||||
assertEquals(List.of("100,-200", "100,-199", "101,-200", "101,-199"), samples);
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class EngineGenerationMaintenanceTest {
|
||||
@Test
|
||||
public void maintenanceDisablesContextCacheWithoutActivePregen() {
|
||||
assertTrue(EngineGeneration.shouldDisableContextCacheForMaintenance(true, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maintenanceKeepsContextCacheForActivePregenWorld() {
|
||||
assertFalse(EngineGeneration.shouldDisableContextCacheForMaintenance(true, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noMaintenanceKeepsContextCacheEnabled() {
|
||||
assertFalse(EngineGeneration.shouldDisableContextCacheForMaintenance(false, false));
|
||||
assertFalse(EngineGeneration.shouldDisableContextCacheForMaintenance(false, true));
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class EngineModeMaintenanceTest {
|
||||
@Test
|
||||
public void maintenanceDisablesContextCacheWithoutActivePregen() {
|
||||
assertTrue(EngineMode.shouldDisableContextCacheForMaintenance(true, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maintenanceKeepsContextCacheForActivePregenWorld() {
|
||||
assertFalse(EngineMode.shouldDisableContextCacheForMaintenance(true, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noMaintenanceKeepsContextCacheEnabled() {
|
||||
assertFalse(EngineMode.shouldDisableContextCacheForMaintenance(false, false));
|
||||
assertFalse(EngineMode.shouldDisableContextCacheForMaintenance(false, true));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -15,7 +15,7 @@ import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MantleCarvingComponentTop2BlendTest {
|
||||
public class CaveCarvingTop2BlendTest {
|
||||
private static Constructor<?> weightedProfileConstructor;
|
||||
private static Method limitMethod;
|
||||
private static Field profileField;
|
||||
@@ -23,10 +23,10 @@ public class MantleCarvingComponentTop2BlendTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception {
|
||||
Class<?> weightedProfileClass = Class.forName("art.arcane.iris.engine.mantle.components.MantleCarvingComponent$WeightedProfile");
|
||||
Class<?> weightedProfileClass = Class.forName("art.arcane.iris.engine.mantle.components.CaveCarving$WeightedProfile");
|
||||
weightedProfileConstructor = weightedProfileClass.getDeclaredConstructor(IrisCaveProfile.class, double[].class, double.class, Class.forName("art.arcane.iris.engine.object.value.IrisRange"), int.class);
|
||||
weightedProfileConstructor.setAccessible(true);
|
||||
limitMethod = MantleCarvingComponent.class.getDeclaredMethod("limitAndMergeBlendedProfiles", List.class, int.class, int.class);
|
||||
limitMethod = CaveCarving.class.getDeclaredMethod("limitAndMergeBlendedProfiles", List.class, int.class, int.class);
|
||||
limitMethod.setAccessible(true);
|
||||
profileField = weightedProfileClass.getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.mantle.MantleComponent;
|
||||
import art.arcane.iris.engine.mantle.MantlePass;
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.engine.mantle.MatterGenerator;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.spi.PlatformRegistries;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class MantleCarvingComponentBoundaryRadiusTest {
|
||||
@Before
|
||||
public void bindPlatform() {
|
||||
IrisPlatforms.unbind();
|
||||
PlatformBlockState block = mock(PlatformBlockState.class);
|
||||
PlatformRegistries registries = mock(PlatformRegistries.class);
|
||||
when(registries.block(anyString())).thenReturn(block);
|
||||
IrisPlatform platform = mock(IrisPlatform.class);
|
||||
when(platform.registries()).thenReturn(registries);
|
||||
IrisPlatforms.bind(platform);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unbindPlatform() {
|
||||
IrisPlatforms.unbind();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void boundaryWallResolutionSchedulesAdjacentCarvingChunks() {
|
||||
EngineMantle engineMantle = mock(EngineMantle.class);
|
||||
MantleCarvingComponent component = new MantleCarvingComponent(engineMantle);
|
||||
|
||||
assertEquals(1, component.getRadius());
|
||||
assertEquals(1, Math.ceilDiv(component.getRadius(), 16));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void matterGenerationRunsCarvingForAllAdjacentChunks() {
|
||||
IrisDimension dimension = mock(IrisDimension.class);
|
||||
when(dimension.isUseMantle()).thenReturn(true);
|
||||
Mantle<Matter> mantle = mock(Mantle.class);
|
||||
MantleChunk<Matter> chunk = mock(MantleChunk.class);
|
||||
when(mantle.getChunk(anyInt(), anyInt())).thenReturn(chunk);
|
||||
when(chunk.use()).thenReturn(chunk);
|
||||
doAnswer(invocation -> {
|
||||
Runnable task = invocation.getArgument(1);
|
||||
task.run();
|
||||
return null;
|
||||
}).when(chunk).raiseFlagSuspend(any(), any(Runnable.class));
|
||||
|
||||
EngineMantle engineMantle = mock(EngineMantle.class);
|
||||
Engine engine = mock(Engine.class);
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getMantle()).thenReturn(engineMantle);
|
||||
when(engineMantle.getEngine()).thenReturn(engine);
|
||||
|
||||
List<String> generatedChunks = new ArrayList<>();
|
||||
MantleCarvingComponent component = spy(new MantleCarvingComponent(engineMantle));
|
||||
doAnswer(invocation -> {
|
||||
int chunkX = invocation.getArgument(1);
|
||||
int chunkZ = invocation.getArgument(2);
|
||||
generatedChunks.add(chunkX + "," + chunkZ);
|
||||
return null;
|
||||
}).when(component).generateLayer(any(), anyInt(), anyInt(), any());
|
||||
|
||||
TestMatterGenerator generator = new TestMatterGenerator(engine, mantle, component);
|
||||
generator.generateMatter(4, -7, false, mock(ChunkContext.class));
|
||||
|
||||
assertEquals(List.of(
|
||||
"3,-8", "3,-7", "3,-6",
|
||||
"4,-8", "4,-7", "4,-6",
|
||||
"5,-8", "5,-7", "5,-6"
|
||||
), generatedChunks);
|
||||
}
|
||||
|
||||
private static final class TestMatterGenerator implements MatterGenerator {
|
||||
private final Engine engine;
|
||||
private final Mantle<Matter> mantle;
|
||||
private final List<MantlePass> components;
|
||||
|
||||
private TestMatterGenerator(Engine engine, Mantle<Matter> mantle, MantleComponent component) {
|
||||
this.engine = engine;
|
||||
this.mantle = mantle;
|
||||
this.components = List.of(new MantlePass(List.of(component), 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Engine getEngine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mantle<Matter> getMantle() {
|
||||
return mantle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRadius() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRealRadius() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MantlePass> getComponents() {
|
||||
return components;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.deposit.DepositSettings;
|
||||
import art.arcane.iris.engine.object.terrain.deposit.IrisDepositGenerator;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DepositModuleTest {
|
||||
private static final int CENTRE = 7;
|
||||
|
||||
@Test
|
||||
public void everyLevelAtTheCentreColumnStacksInLevelOrder() {
|
||||
IrisDepositGenerator dimension = new IrisDepositGenerator();
|
||||
IrisDepositGenerator region = new IrisDepositGenerator();
|
||||
IrisDepositGenerator biome = new IrisDepositGenerator();
|
||||
IrisDepositGenerator elsewhere = new IrisDepositGenerator();
|
||||
FeatureSettings settings = new FeatureSettings() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <F extends IrisFeature> List<Entry<F>> at(Class<F> type, int worldX, int worldZ) {
|
||||
if (worldX != 32 + CENTRE || worldZ != -16 + CENTRE) {
|
||||
return List.of((Entry<F>) entry(Target.BIOME, "biome/other", elsewhere));
|
||||
}
|
||||
return List.of((Entry<F>) entry(Target.DIMENSION, "dimension/overworld", dimension),
|
||||
(Entry<F>) entry(Target.REGION, "region/hot", region),
|
||||
(Entry<F>) entry(Target.BIOME, "biome/desert", biome));
|
||||
}
|
||||
};
|
||||
|
||||
assertEquals(List.of(dimension, region, biome), DepositModule.generatorsAtCentre(settings, 32, -16));
|
||||
}
|
||||
|
||||
private static FeatureSettings.Entry<DepositSettings> entry(Target level, String source, IrisDepositGenerator generator) {
|
||||
return new FeatureSettings.Entry<>(level, ResourceId.parse("pack:" + source), new DepositSettings(List.of(generator)));
|
||||
}
|
||||
}
|
||||
+37
-37
@@ -31,34 +31,34 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisDepositModifierContainmentTest {
|
||||
public class DepositPlacerContainmentTest {
|
||||
@Test
|
||||
public void depositSurfaceLimitKeepsEveryColumnSevenBlocksBuried() {
|
||||
assertEquals(73, IrisDepositModifier.depositSurfaceLimit(80));
|
||||
assertEquals(24, IrisDepositModifier.depositSurfaceLimit(31));
|
||||
assertEquals(80, IrisDepositModifier.depositSurfaceLimit(80, 0));
|
||||
assertEquals(73, DepositPlacer.depositSurfaceLimit(80));
|
||||
assertEquals(24, DepositPlacer.depositSurfaceLimit(31));
|
||||
assertEquals(80, DepositPlacer.depositSurfaceLimit(80, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void placementScopeSeparatesTerrainFromFloatingSolids() {
|
||||
assertTrue(IrisDepositModifier.placementSurfaceAllows(
|
||||
assertTrue(DepositPlacer.placementSurfaceAllows(
|
||||
IrisDepositPlacementScope.TERRAIN, 70, 80, 7));
|
||||
assertFalse(IrisDepositModifier.placementSurfaceAllows(
|
||||
assertFalse(DepositPlacer.placementSurfaceAllows(
|
||||
IrisDepositPlacementScope.TERRAIN, 74, 80, 7));
|
||||
assertFalse(IrisDepositModifier.placementSurfaceAllows(
|
||||
assertFalse(DepositPlacer.placementSurfaceAllows(
|
||||
IrisDepositPlacementScope.ABOVE_TERRAIN, 80, 80, 0));
|
||||
assertTrue(IrisDepositModifier.placementSurfaceAllows(
|
||||
assertTrue(DepositPlacer.placementSurfaceAllows(
|
||||
IrisDepositPlacementScope.ABOVE_TERRAIN, 81, 80, 0));
|
||||
assertTrue(IrisDepositModifier.placementSurfaceAllows(
|
||||
assertTrue(DepositPlacer.placementSurfaceAllows(
|
||||
IrisDepositPlacementScope.FULL_HEIGHT, 1, 80, 64));
|
||||
assertTrue(IrisDepositModifier.placementSurfaceAllows(
|
||||
assertTrue(DepositPlacer.placementSurfaceAllows(
|
||||
IrisDepositPlacementScope.FULL_HEIGHT, 700, 80, 64));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void variantHeightUsesAbsoluteWorldY() {
|
||||
assertEquals(-32, IrisDepositModifier.absoluteWorldY(-64, 32));
|
||||
assertEquals(96, IrisDepositModifier.absoluteWorldY(0, 96));
|
||||
assertEquals(-32, DepositPlacer.absoluteWorldY(-64, 32));
|
||||
assertEquals(96, DepositPlacer.absoluteWorldY(0, 96));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,27 +69,27 @@ public class IrisDepositModifierContainmentTest {
|
||||
when(air.isAir()).thenReturn(true);
|
||||
when(fluid.isFluid()).thenReturn(true);
|
||||
|
||||
assertTrue(IrisDepositModifier.canReplaceDepositTarget(solid));
|
||||
assertFalse(IrisDepositModifier.canReplaceDepositTarget(air));
|
||||
assertFalse(IrisDepositModifier.canReplaceDepositTarget(fluid));
|
||||
assertFalse(IrisDepositModifier.canReplaceDepositTarget(null));
|
||||
assertTrue(DepositPlacer.canReplaceDepositTarget(solid));
|
||||
assertFalse(DepositPlacer.canReplaceDepositTarget(air));
|
||||
assertFalse(DepositPlacer.canReplaceDepositTarget(fluid));
|
||||
assertFalse(DepositPlacer.canReplaceDepositTarget(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oreFrequencyMultiplierKeepsConfiguredShareOfVeins() {
|
||||
assertTrue(IrisDepositModifier.passesOreFrequency(0.4D, 0.399D));
|
||||
assertFalse(IrisDepositModifier.passesOreFrequency(0.4D, 0.4D));
|
||||
assertTrue(IrisDepositModifier.passesOreFrequency(1D, 0.999D));
|
||||
assertFalse(IrisDepositModifier.passesOreFrequency(0D, 0D));
|
||||
assertTrue(DepositPlacer.passesOreFrequency(0.4D, 0.399D));
|
||||
assertFalse(DepositPlacer.passesOreFrequency(0.4D, 0.4D));
|
||||
assertTrue(DepositPlacer.passesOreFrequency(1D, 0.999D));
|
||||
assertFalse(DepositPlacer.passesOreFrequency(0D, 0D));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void largerVeinsRemainCenteredAndInsideTheChunk() {
|
||||
assertEquals(6, IrisDepositModifier.clampDepositCenter(6, 5, 16));
|
||||
assertEquals(2, IrisDepositModifier.clampDepositCenter(1, 5, 16));
|
||||
assertEquals(13, IrisDepositModifier.clampDepositCenter(14, 5, 16));
|
||||
assertEquals(2, IrisDepositModifier.clampDepositCenter(1, 4, 16));
|
||||
assertEquals(14, IrisDepositModifier.clampDepositCenter(15, 4, 16));
|
||||
assertEquals(6, DepositPlacer.clampDepositCenter(6, 5, 16));
|
||||
assertEquals(2, DepositPlacer.clampDepositCenter(1, 5, 16));
|
||||
assertEquals(13, DepositPlacer.clampDepositCenter(14, 5, 16));
|
||||
assertEquals(2, DepositPlacer.clampDepositCenter(1, 4, 16));
|
||||
assertEquals(14, DepositPlacer.clampDepositCenter(15, 4, 16));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,7 +98,7 @@ public class IrisDepositModifierContainmentTest {
|
||||
boolean sampledBelowBottom = false;
|
||||
boolean sampledAboveBottom = false;
|
||||
for (int i = 0; i < 2_000; i++) {
|
||||
int y = IrisDepositModifier.sampleHeight(
|
||||
int y = DepositPlacer.sampleHeight(
|
||||
IrisDepositHeightDistribution.UNIFORM, uniform, -80, 80, 20);
|
||||
sampledBelowBottom |= y < 0;
|
||||
sampledAboveBottom |= y > 20;
|
||||
@@ -106,7 +106,7 @@ public class IrisDepositModifierContainmentTest {
|
||||
|
||||
assertTrue(sampledBelowBottom);
|
||||
assertTrue(sampledAboveBottom);
|
||||
assertEquals(14, IrisDepositModifier.sampleHeight(
|
||||
assertEquals(14, DepositPlacer.sampleHeight(
|
||||
IrisDepositHeightDistribution.UNIFORM, uniform, 14, 14, 10));
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class IrisDepositModifierContainmentTest {
|
||||
public void clippedHeightProviderPreservesLegacyTerrainClipping() {
|
||||
RNG rng = new RNG(44L);
|
||||
for (int i = 0; i < 2_000; i++) {
|
||||
int y = IrisDepositModifier.sampleHeight(
|
||||
int y = DepositPlacer.sampleHeight(
|
||||
IrisDepositHeightDistribution.CLIPPED_UNIFORM, rng, -80, 80, 20);
|
||||
assertTrue(y >= 0);
|
||||
assertTrue(y <= 20);
|
||||
@@ -129,7 +129,7 @@ public class IrisDepositModifierContainmentTest {
|
||||
long total = 0L;
|
||||
int samples = 100_000;
|
||||
for (int i = 0; i < samples; i++) {
|
||||
int y = IrisDepositModifier.sampleHeight(
|
||||
int y = DepositPlacer.sampleHeight(
|
||||
IrisDepositHeightDistribution.TRIANGLE, rng, -32, 32, 32);
|
||||
total += y;
|
||||
if (Math.abs(y) <= 4) {
|
||||
@@ -146,11 +146,11 @@ public class IrisDepositModifierContainmentTest {
|
||||
|
||||
@Test
|
||||
public void exposureDiscardRequiresAdjacentAirAndPassingChanceRoll() {
|
||||
assertFalse(IrisDepositModifier.shouldDiscardExposed(1D, 0D, false));
|
||||
assertTrue(IrisDepositModifier.shouldDiscardExposed(1D, 0.999D, true));
|
||||
assertTrue(IrisDepositModifier.shouldDiscardExposed(0.5D, 0.499D, true));
|
||||
assertFalse(IrisDepositModifier.shouldDiscardExposed(0.5D, 0.5D, true));
|
||||
assertFalse(IrisDepositModifier.shouldDiscardExposed(0D, 0D, true));
|
||||
assertFalse(DepositPlacer.shouldDiscardExposed(1D, 0D, false));
|
||||
assertTrue(DepositPlacer.shouldDiscardExposed(1D, 0.999D, true));
|
||||
assertTrue(DepositPlacer.shouldDiscardExposed(0.5D, 0.499D, true));
|
||||
assertFalse(DepositPlacer.shouldDiscardExposed(0.5D, 0.5D, true));
|
||||
assertFalse(DepositPlacer.shouldDiscardExposed(0D, 0D, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -167,9 +167,9 @@ public class IrisDepositModifierContainmentTest {
|
||||
}
|
||||
}
|
||||
|
||||
assertFalse(IrisDepositModifier.isAdjacentToAir(data, 1, 1, 1));
|
||||
assertFalse(DepositPlacer.isAdjacentToAir(data, 1, 1, 1));
|
||||
data.setRaw(2, 1, 1, air);
|
||||
assertTrue(IrisDepositModifier.isAdjacentToAir(data, 1, 1, 1));
|
||||
assertFalse(IrisDepositModifier.isAdjacentToAir(data, 0, 0, 0));
|
||||
assertTrue(DepositPlacer.isAdjacentToAir(data, 1, 1, 1));
|
||||
assertFalse(DepositPlacer.isAdjacentToAir(data, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,7 +16,7 @@ import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
|
||||
import art.arcane.iris.builtin.blocks.BlocksStages;
|
||||
import art.arcane.iris.builtin.bore.BoreStages;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.BuiltInPlacementPack;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
||||
import art.arcane.iris.core.modules.ObjectPlacementResult;
|
||||
import art.arcane.iris.core.modules.PlatformBlockStates;
|
||||
@@ -88,7 +88,7 @@ public class IrisObjectPlacementRegressionTest {
|
||||
|
||||
engine = mock(Engine.class);
|
||||
when(engine.getHeight()).thenReturn(256);
|
||||
BuiltInPlacementPack.seedWorld(engine, 7L);
|
||||
BuiltInPack.seedWorld(engine, 7L);
|
||||
data = mock(IrisData.class);
|
||||
when(data.getEngine()).thenReturn(engine);
|
||||
usePack(List.of());
|
||||
@@ -107,7 +107,7 @@ public class IrisObjectPlacementRegressionTest {
|
||||
if (pack != null) {
|
||||
pack.close();
|
||||
}
|
||||
pack = BuiltInPlacementPack.serve(data, folder, packModules);
|
||||
pack = BuiltInPack.serve(data, folder, packModules);
|
||||
}
|
||||
|
||||
/** Platform states by key, the way a registry answers them; keys without a namespace are Minecraft's. */
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.BuiltInPlacementPack;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
@@ -82,10 +82,10 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
||||
engine = mock(Engine.class);
|
||||
when(engine.getHeight()).thenReturn(256);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
BuiltInPlacementPack.seedWorld(engine, 7L);
|
||||
BuiltInPack.seedWorld(engine, 7L);
|
||||
data = mock(IrisData.class);
|
||||
when(data.getEngine()).thenReturn(engine);
|
||||
pack = BuiltInPlacementPack.serve(data, folder, List.of());
|
||||
pack = BuiltInPack.serve(data, folder, List.of());
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.BuiltInPlacementPack;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
@@ -81,10 +81,10 @@ public class NativeStructureObjectVetoTest {
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
when(engine.getDimension()).thenReturn(mock(IrisDimension.class));
|
||||
volumes();
|
||||
BuiltInPlacementPack.seedWorld(engine, 7L);
|
||||
BuiltInPack.seedWorld(engine, 7L);
|
||||
data = mock(IrisData.class);
|
||||
when(data.getEngine()).thenReturn(engine);
|
||||
pack = BuiltInPlacementPack.serve(data, folder, List.of());
|
||||
pack = BuiltInPack.serve(data, folder, List.of());
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
Reference in new issue
Block a user