mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 10:14:36 +00:00
Run every mantle stage as a mantle pass of its own, ordered by the stage graph
ModuleMantleComponent now runs one mantle stage. IrisEngineMantle builds one component per stage of the pack's mantle graph, in resolved order, each its own pass, when first needed after a load or hotload, so a pack mantle stage can order itself after Iris's objects and structures. A stage's radius is its reach, worked out from the pack (IrisPackSettings: the dimension, its regions and biomes). Iris's own stages keep the flags of the components they replace (CARVED, OBJECT, FLOATING_OBJECT, JIGSAW), so disabledComponents keeps working; pack stages get custom flags in order (MantleStageFlags). There is one mantle path now: the separately registered object, floating object and structure components, IrisMantleComponent, the ComponentFlag annotation, registerComponent and getObjectComponent are gone. Engine.getObjectsAt asks the runtime's ObjectPlacing.
This commit is contained in:
1 parent
0f63a3c59a
commit
0a06d5ff29
25 files changed
+463
-365
No files matched your search
@@ -21,6 +21,8 @@ package art.arcane.iris.core.modules;
|
|||||||
import art.arcane.iris.engine.actuator.BiomeModule;
|
import art.arcane.iris.engine.actuator.BiomeModule;
|
||||||
import art.arcane.iris.engine.actuator.DecorantModule;
|
import art.arcane.iris.engine.actuator.DecorantModule;
|
||||||
import art.arcane.iris.engine.actuator.TerrainModule;
|
import art.arcane.iris.engine.actuator.TerrainModule;
|
||||||
|
import art.arcane.iris.engine.mantle.components.ObjectModule;
|
||||||
|
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||||
import art.arcane.iris.engine.modifier.CarveModule;
|
import art.arcane.iris.engine.modifier.CarveModule;
|
||||||
import art.arcane.iris.engine.modifier.CustomModule;
|
import art.arcane.iris.engine.modifier.CustomModule;
|
||||||
import art.arcane.iris.engine.modifier.DepositModule;
|
import art.arcane.iris.engine.modifier.DepositModule;
|
||||||
@@ -65,8 +67,9 @@ public final class IrisModuleHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static List<IrisModule> generationModules() {
|
private static List<IrisModule> generationModules() {
|
||||||
return List.of(new BiomeModule(), new TerrainModule(), new CarveModule(), new PostModule(), new FloatingModule(),
|
return List.of(new BiomeModule(), new TerrainModule(), new CarveModule(), new ObjectModule(), new StructureModule(),
|
||||||
new DepositModule(), new MatterModule(), new DecorantModule(), new PerfectionModule(), new CustomModule());
|
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. */
|
/** Whether {@code type} is one of Iris's own classes that built-in settings may hold. */
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* 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.IrisRegistrant;
|
||||||
|
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;
|
||||||
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
|
import com.volmit.FeatureAttachment.Target;
|
||||||
|
import com.volmit.IrisFeature;
|
||||||
|
import com.volmit.config.FeatureSettings.Entry;
|
||||||
|
import com.volmit.config.PackSettings;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The settings an engine's pack declares, for working out mantle stage reaches when the pack loads: the
|
||||||
|
* engine's dimension, then every region it can reach, then every biome. Iris's built-in mantle stages size
|
||||||
|
* their reach from Iris's own pack data instead of module settings; they reach the engine through
|
||||||
|
* {@link #of(PackSettings)}.
|
||||||
|
*/
|
||||||
|
public final class IrisPackSettings implements PackSettings {
|
||||||
|
private static final String DIMENSION = "dimension";
|
||||||
|
private static final String REGION = "region";
|
||||||
|
private static final String BIOME = "biome";
|
||||||
|
|
||||||
|
private final Engine engine;
|
||||||
|
private final PackResourceIds ids;
|
||||||
|
|
||||||
|
IrisPackSettings(Engine engine) {
|
||||||
|
this.engine = engine;
|
||||||
|
this.ids = new PackResourceIds(engine.getData().getDataFolder());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Iris's own view of {@code settings}, which Iris hands to every reach it works out. */
|
||||||
|
public static IrisPackSettings of(PackSettings settings) {
|
||||||
|
if (!(settings instanceof IrisPackSettings irisSettings)) {
|
||||||
|
throw new IllegalArgumentException("Built-in reaches are worked out from an Iris engine's pack, not " + settings);
|
||||||
|
}
|
||||||
|
return irisSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The engine whose pack is loading. */
|
||||||
|
public Engine engine() {
|
||||||
|
return engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||||
|
IrisDimension dimension = engine.getDimension();
|
||||||
|
List<Entry<F>> entries = new ArrayList<>();
|
||||||
|
addEntry(entries, featureType, Target.DIMENSION, DIMENSION, dimension);
|
||||||
|
for (IrisRegion region : dimension.getAllRegions(engine)) {
|
||||||
|
addEntry(entries, featureType, Target.REGION, REGION, region);
|
||||||
|
}
|
||||||
|
for (IrisBiome biome : dimension.getReachableBiomes(engine)) {
|
||||||
|
addEntry(entries, featureType, Target.BIOME, BIOME, biome);
|
||||||
|
}
|
||||||
|
return List.copyOf(entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <F extends IrisFeature> void addEntry(List<Entry<F>> entries, Class<F> featureType, Target level, String kind,
|
||||||
|
IrisRegistrant owner) {
|
||||||
|
owner.getModuleSettings().find(featureType)
|
||||||
|
.ifPresent(value -> entries.add(new Entry<>(level, ids.of(kind, owner.getLoadKey()), value)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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.carve.CarveStages;
|
||||||
|
import art.arcane.iris.builtin.floating.FloatingStages;
|
||||||
|
import art.arcane.iris.builtin.objects.ObjectStages;
|
||||||
|
import art.arcane.iris.builtin.structure.StructureStages;
|
||||||
|
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||||
|
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
||||||
|
import com.volmit.host.ResolvedStage;
|
||||||
|
import com.volmit.resource.ResourceId;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mantle flag of each mantle stage: it marks a mantle chunk whose stage has run, and names the stage in a
|
||||||
|
* dimension's {@code disabledComponents}. Iris's own mantle stages keep the flags their mantle components had,
|
||||||
|
* so packs that disable {@code CARVED} keep doing so and existing worlds stay marked. Every other stage gets a
|
||||||
|
* custom flag in resolved order, so adding or removing a pack mantle stage can renumber the stages after it.
|
||||||
|
*/
|
||||||
|
public final class MantleStageFlags {
|
||||||
|
private static final List<BuiltIn> BUILT_IN = List.of(
|
||||||
|
new BuiltIn(CarveStages.CAVES.id(), ReservedFlag.CARVED),
|
||||||
|
new BuiltIn(ObjectStages.PLACE.id(), ReservedFlag.OBJECT),
|
||||||
|
new BuiltIn(FloatingStages.OBJECTS.id(), ReservedFlag.FLOATING_OBJECT),
|
||||||
|
new BuiltIn(StructureStages.PLACE.id(), ReservedFlag.JIGSAW));
|
||||||
|
|
||||||
|
private MantleStageFlags() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The flags of Iris's own mantle stages, in their order, which a dimension can list in {@code disabledComponents}. */
|
||||||
|
public static List<MantleFlag> builtIn() {
|
||||||
|
return BUILT_IN.stream().map(BuiltIn::flag).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One flag per stage, in the order of {@code stages}. */
|
||||||
|
static List<MantleFlag> assign(List<ResolvedStage> stages) {
|
||||||
|
List<MantleFlag> flags = new ArrayList<>(stages.size());
|
||||||
|
int nextCustom = MantleFlag.MIN_ORDINAL;
|
||||||
|
for (ResolvedStage stage : stages) {
|
||||||
|
Optional<MantleFlag> builtIn = builtInFlag(stage.stage().id());
|
||||||
|
if (builtIn.isPresent()) {
|
||||||
|
flags.add(builtIn.get());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (nextCustom > MantleFlag.MAX_ORDINAL) {
|
||||||
|
throw new IllegalStateException("The pack has more mantle stages than Iris has mantle flags for; stage "
|
||||||
|
+ stage.stage().id() + " of module " + stage.module() + " is one too many");
|
||||||
|
}
|
||||||
|
flags.add(MantleFlag.of(nextCustom++));
|
||||||
|
}
|
||||||
|
return List.copyOf(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Optional<MantleFlag> builtInFlag(ResourceId stage) {
|
||||||
|
return BUILT_IN.stream().filter(builtIn -> builtIn.stage().equals(stage)).map(BuiltIn::flag).findFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
private record BuiltIn(ResourceId stage, MantleFlag flag) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,74 +19,103 @@
|
|||||||
package art.arcane.iris.core.modules;
|
package art.arcane.iris.core.modules;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
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.IrisMantleComponent;
|
|
||||||
import art.arcane.iris.engine.mantle.MantleWriter;
|
import art.arcane.iris.engine.mantle.MantleWriter;
|
||||||
import art.arcane.iris.util.project.context.ChunkContext;
|
import art.arcane.iris.util.project.context.ChunkContext;
|
||||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||||
import com.volmit.host.LoadedPack;
|
import com.volmit.host.LoadedPack;
|
||||||
import com.volmit.host.MantleRunner;
|
import com.volmit.host.MantleRunner;
|
||||||
import com.volmit.host.ResolvedGraph;
|
import com.volmit.host.ResolvedGraph;
|
||||||
|
import com.volmit.host.ResolvedStage;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the pack's mantle pipeline, Iris's built-in mantle stages included, as one of Iris's mantle components:
|
* Runs one mantle stage of the pack, Iris's built-in ones included, as a mantle component of its own: a pass of
|
||||||
* once for every chunk the mantle prepares around a generating chunk, as far as the pipeline's declared reach.
|
* Iris's mantle at the stage's place in the resolved order, so the stage sees everything earlier stages wrote
|
||||||
* It is the first pass, where carving has always run, so Iris's object, floating object and structure passes
|
* into the chunks around it. Its radius is the stage's reach, worked out from the pack when the components are
|
||||||
* see the caves and whatever else mantle stages wrote. It is disabled while the pack has no mantle stages.
|
* built; its flag comes from {@link MantleStageFlags}, so a dimension's {@code disabledComponents} turns it off.
|
||||||
*/
|
*/
|
||||||
public final class ModuleMantleComponent extends IrisMantleComponent {
|
public final class ModuleMantleComponent implements MantleComponent {
|
||||||
/** Marks a mantle chunk whose module stages have run. */
|
private final Engine engine;
|
||||||
public static final MantleFlag FLAG = MantleFlag.of(MantleFlag.MIN_ORDINAL);
|
private final LoadedPack pack;
|
||||||
/** The first pass: the carving stage it runs had priority 0 as a component of its own. */
|
private final MantleRunner runner;
|
||||||
private static final int PRIORITY = 0;
|
private final ResolvedStage stage;
|
||||||
|
private final MantleFlag flag;
|
||||||
|
private final int priority;
|
||||||
|
private final int reachBlocks;
|
||||||
|
private final boolean enabled;
|
||||||
|
|
||||||
/** Whether the pack has mantle stages; asked on every chunk, so kept until the next hotload. */
|
private ModuleMantleComponent(Engine engine, LoadedPack pack, MantleRunner runner, ResolvedStage stage,
|
||||||
private volatile Boolean hasStages;
|
MantleFlag flag, int priority, int reachBlocks, boolean enabled) {
|
||||||
|
this.engine = engine;
|
||||||
|
this.pack = pack;
|
||||||
|
this.runner = runner;
|
||||||
|
this.stage = stage;
|
||||||
|
this.flag = flag;
|
||||||
|
this.priority = priority;
|
||||||
|
this.reachBlocks = reachBlocks;
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public ModuleMantleComponent(EngineMantle engineMantle) {
|
/**
|
||||||
super(engineMantle, FLAG, PRIORITY);
|
* One component per mantle stage of the engine's pack, in resolved order, each its own pass. A stage whose
|
||||||
|
* flag is in {@code disabled} is turned off.
|
||||||
|
*/
|
||||||
|
public static List<ModuleMantleComponent> forPack(Engine engine, Set<MantleFlag> disabled) {
|
||||||
|
return forPack(engine, engine.getData().getModules().pack(), disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<ModuleMantleComponent> forPack(Engine engine, LoadedPack pack, Set<MantleFlag> disabled) {
|
||||||
|
ResolvedGraph graph = pack.mantle();
|
||||||
|
MantleRunner runner = new MantleRunner(graph);
|
||||||
|
IrisPackSettings settings = new IrisPackSettings(engine);
|
||||||
|
List<MantleFlag> flags = MantleStageFlags.assign(graph.stages());
|
||||||
|
List<ModuleMantleComponent> components = new ArrayList<>(flags.size());
|
||||||
|
for (int position = 0; position < flags.size(); position++) {
|
||||||
|
ResolvedStage stage = graph.stages().get(position);
|
||||||
|
MantleFlag flag = flags.get(position);
|
||||||
|
components.add(new ModuleMantleComponent(engine, pack, runner, stage, flag, position,
|
||||||
|
stage.reachBlocks(settings), !disabled.contains(flag)));
|
||||||
|
}
|
||||||
|
return List.copyOf(components);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The stage this component runs. */
|
||||||
|
public ResolvedStage stage() {
|
||||||
|
return stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRadius() {
|
||||||
|
return reachBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MantleFlag getFlag() {
|
||||||
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return super.isEnabled() && hasStages();
|
return enabled;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hotload() {
|
|
||||||
super.hotload();
|
|
||||||
hasStages = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int computeRadius() {
|
|
||||||
return pipeline().reach().blocks();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||||
Engine engine = getEngineMantle().getEngine();
|
new IrisMantleChunk(engine, writer, x, z, context).runBound(() -> generate(x, z, 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. */
|
/** Runs the stage for chunk {@code x}, {@code z}, with the mantle chunks within the stage's reach of it. */
|
||||||
static void generate(LoadedPack pack, Engine engine, int x, int z, int reachBlocks, IrisModuleMantle.Chunks chunks) {
|
void generate(int x, int z, IrisModuleMantle.Chunks chunks) {
|
||||||
IrisMantleGenerationContext inputs = new IrisMantleGenerationContext(engine, x, z, reachBlocks, chunks, pack.catalog().mantle());
|
IrisMantleGenerationContext inputs = new IrisMantleGenerationContext(engine, x, z, reachBlocks, chunks, pack.catalog().mantle());
|
||||||
long seed = ModuleSeeds.chunk(engine.getSeedManager().getSeed(), x, z);
|
runner.generate(stage.stage(), inputs, ModuleSeeds.chunk(engine.getSeedManager().getSeed(), x, z));
|
||||||
new MantleRunner(pack.mantle()).generate(inputs, seed);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasStages() {
|
|
||||||
Boolean known = hasStages;
|
|
||||||
if (known == null) {
|
|
||||||
known = !pipeline().stages().isEmpty();
|
|
||||||
hasStages = known;
|
|
||||||
}
|
|
||||||
return known;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResolvedGraph pipeline() {
|
|
||||||
return getEngineMantle().getEngine().getData().getModules().pack().mantle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,6 +47,7 @@ import art.arcane.iris.core.nms.container.BlockPos;
|
|||||||
import art.arcane.iris.core.nms.container.Pair;
|
import art.arcane.iris.core.nms.container.Pair;
|
||||||
import art.arcane.iris.core.structure.StructureIndexService;
|
import art.arcane.iris.core.structure.StructureIndexService;
|
||||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||||
|
import art.arcane.iris.engine.mantle.components.ObjectModule;
|
||||||
import art.arcane.iris.util.common.data.B;
|
import art.arcane.iris.util.common.data.B;
|
||||||
import art.arcane.iris.util.common.plugin.VolmitSender;
|
import art.arcane.iris.util.common.plugin.VolmitSender;
|
||||||
import art.arcane.iris.spi.PlatformBiome;
|
import art.arcane.iris.spi.PlatformBiome;
|
||||||
@@ -386,7 +387,7 @@ public class IrisEngine implements Engine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getObjectsAt(int x, int z) {
|
public Set<String> getObjectsAt(int x, int z) {
|
||||||
return getMantle().getObjectComponent().guess(x, z);
|
return ObjectModule.placing(this).guess(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,16 +27,11 @@ import art.arcane.iris.engine.framework.Engine;
|
|||||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||||
import art.arcane.iris.engine.mantle.MantleComponent;
|
import art.arcane.iris.engine.mantle.MantleComponent;
|
||||||
import art.arcane.iris.engine.mantle.MantlePass;
|
import art.arcane.iris.engine.mantle.MantlePass;
|
||||||
import art.arcane.iris.engine.mantle.components.MantleFloatingObjectComponent;
|
|
||||||
import art.arcane.iris.engine.mantle.components.MantleObjectComponent;
|
|
||||||
import art.arcane.iris.engine.mantle.components.IrisStructureComponent;
|
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.iris.spi.IrisPlatforms;
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
import art.arcane.iris.spi.PlatformBlockState;
|
import art.arcane.iris.spi.PlatformBlockState;
|
||||||
import art.arcane.iris.util.project.matter.IrisMatterContext;
|
import art.arcane.iris.util.project.matter.IrisMatterContext;
|
||||||
import art.arcane.iris.util.project.matter.IrisMatterSupport;
|
import art.arcane.iris.util.project.matter.IrisMatterSupport;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
import art.arcane.volmlib.util.collection.KMap;
|
|
||||||
import art.arcane.volmlib.util.format.Form;
|
import art.arcane.volmlib.util.format.Form;
|
||||||
import art.arcane.volmlib.util.mantle.io.Lz4IOWorkerCodecSupport;
|
import art.arcane.volmlib.util.mantle.io.Lz4IOWorkerCodecSupport;
|
||||||
import art.arcane.volmlib.util.mantle.runtime.IOWorker;
|
import art.arcane.volmlib.util.mantle.runtime.IOWorker;
|
||||||
@@ -44,7 +39,6 @@ import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
|||||||
import art.arcane.volmlib.util.mantle.runtime.MantleDataAdapter;
|
import art.arcane.volmlib.util.mantle.runtime.MantleDataAdapter;
|
||||||
import art.arcane.volmlib.util.mantle.runtime.MantleHooks;
|
import art.arcane.volmlib.util.mantle.runtime.MantleHooks;
|
||||||
import art.arcane.volmlib.util.mantle.runtime.TectonicPlate;
|
import art.arcane.volmlib.util.mantle.runtime.TectonicPlate;
|
||||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
|
||||||
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
||||||
import art.arcane.iris.util.common.format.C;
|
import art.arcane.iris.util.common.format.C;
|
||||||
import art.arcane.volmlib.util.matter.IrisMatter;
|
import art.arcane.volmlib.util.matter.IrisMatter;
|
||||||
@@ -60,9 +54,7 @@ import lombok.ToString;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@@ -73,110 +65,61 @@ import java.util.function.Supplier;
|
|||||||
public class IrisEngineMantle implements EngineMantle {
|
public class IrisEngineMantle implements EngineMantle {
|
||||||
private final Engine engine;
|
private final Engine engine;
|
||||||
private final Mantle<Matter> mantle;
|
private final Mantle<Matter> mantle;
|
||||||
|
/** The pack's mantle stages, one component each, built when first needed after the pack loads. */
|
||||||
@Getter(AccessLevel.NONE)
|
@Getter(AccessLevel.NONE)
|
||||||
private final KMap<Integer, KList<MantleComponent>> components;
|
private final AtomicCache<List<ModuleMantleComponent>> stageComponents = new AtomicCache<>();
|
||||||
private final KMap<MantleFlag, MantleComponent> registeredComponents = new KMap<>();
|
@Getter(AccessLevel.NONE)
|
||||||
private final AtomicCache<List<MantlePass>> componentsCache = new AtomicCache<>();
|
private final AtomicCache<List<MantlePass>> passes = new AtomicCache<>();
|
||||||
private final AtomicCache<Set<MantleFlag>> disabledFlags = new AtomicCache<>();
|
|
||||||
private final MantleObjectComponent object;
|
|
||||||
|
|
||||||
public IrisEngineMantle(Engine engine) {
|
public IrisEngineMantle(Engine engine) {
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
this.mantle = createMantle(engine);
|
this.mantle = createMantle(engine);
|
||||||
components = new KMap<>();
|
|
||||||
object = new MantleObjectComponent(this);
|
|
||||||
registerComponent(object);
|
|
||||||
registerComponent(new MantleFloatingObjectComponent(this));
|
|
||||||
registerComponent(new IrisStructureComponent(this));
|
|
||||||
registerComponent(new ModuleMantleComponent(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRadius() {
|
public int getRadius() {
|
||||||
if (components.isEmpty()) return 0;
|
List<MantlePass> passes = getComponents();
|
||||||
return getComponents().getFirst().passChunkRadius();
|
return passes.isEmpty() ? 0 : passes.getFirst().passChunkRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRealRadius() {
|
public int getRealRadius() {
|
||||||
if (components.isEmpty()) return 0;
|
List<MantlePass> passes = getComponents();
|
||||||
return getComponents().getLast().passChunkRadius();
|
return passes.isEmpty() ? 0 : passes.getLast().passChunkRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** One pass per mantle stage, in the stage graph's order. */
|
||||||
@Override
|
@Override
|
||||||
public List<MantlePass> getComponents() {
|
public List<MantlePass> getComponents() {
|
||||||
return componentsCache.aquire(() -> {
|
return passes.aquire(() -> passesOf(stageComponents()));
|
||||||
List<List<MantleComponent>> passes = components.keySet()
|
|
||||||
.stream()
|
|
||||||
.sorted()
|
|
||||||
.map(components::get)
|
|
||||||
.map(List::<MantleComponent>copyOf)
|
|
||||||
.filter(pass -> !pass.isEmpty())
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
MantlePass[] built = new MantlePass[passes.size()];
|
|
||||||
int downstreamBlockRadius = 0;
|
|
||||||
for (int i = passes.size() - 1; i >= 0; i--) {
|
|
||||||
List<MantleComponent> pass = passes.get(i);
|
|
||||||
int passBlockRadius = pass.stream()
|
|
||||||
.filter(MantleComponent::isEnabled)
|
|
||||||
.mapToInt(MantleComponent::getRadius)
|
|
||||||
.max()
|
|
||||||
.orElse(0);
|
|
||||||
int passInputRadius = pass.stream()
|
|
||||||
.filter(MantleComponent::isEnabled)
|
|
||||||
.mapToInt(MantleComponent::getInputRadius)
|
|
||||||
.max()
|
|
||||||
.orElse(0);
|
|
||||||
int invocationRadius = downstreamBlockRadius + passBlockRadius;
|
|
||||||
built[i] = new MantlePass(pass, Math.ceilDiv(invocationRadius, 16), downstreamBlockRadius);
|
|
||||||
downstreamBlockRadius = invocationRadius + passInputRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
return List.of(built);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<MantleFlag, MantleComponent> getRegisteredComponents() {
|
|
||||||
return Collections.unmodifiableMap(registeredComponents);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean registerComponent(MantleComponent c) {
|
|
||||||
if (registeredComponents.putIfAbsent(c.getFlag(), c) != null) return false;
|
|
||||||
c.setEnabled(!getDisabledFlags().contains(c.getFlag()));
|
|
||||||
components.computeIfAbsent(c.getPriority(), k -> new KList<>()).add(c);
|
|
||||||
componentsCache.reset();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KList<MantleFlag> getComponentFlags() {
|
|
||||||
return new KList<>(registeredComponents.keySet());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hotload() {
|
public void hotload() {
|
||||||
disabledFlags.reset();
|
stageComponents.reset();
|
||||||
for (MantleComponent component : registeredComponents.values()) {
|
passes.reset();
|
||||||
component.hotload();
|
}
|
||||||
component.setEnabled(!getDisabledFlags().contains(component.getFlag()));
|
|
||||||
|
private List<ModuleMantleComponent> stageComponents() {
|
||||||
|
return stageComponents.aquire(() -> ModuleMantleComponent.forPack(engine, Set.copyOf(getDimension().getDisabledComponents())));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each pass must complete its own reach plus the reach of every later pass, or a later pass reads chunks this
|
||||||
|
* one never wrote. Disabled components reach nothing.
|
||||||
|
*/
|
||||||
|
private static List<MantlePass> passesOf(List<? extends MantleComponent> components) {
|
||||||
|
MantlePass[] built = new MantlePass[components.size()];
|
||||||
|
int downstreamBlockRadius = 0;
|
||||||
|
for (int i = components.size() - 1; i >= 0; i--) {
|
||||||
|
MantleComponent component = components.get(i);
|
||||||
|
int passBlockRadius = component.isEnabled() ? component.getRadius() : 0;
|
||||||
|
int passInputRadius = component.isEnabled() ? component.getInputRadius() : 0;
|
||||||
|
int invocationRadius = downstreamBlockRadius + passBlockRadius;
|
||||||
|
built[i] = new MantlePass(List.of(component), Math.ceilDiv(invocationRadius, 16), downstreamBlockRadius);
|
||||||
|
downstreamBlockRadius = invocationRadius + passInputRadius;
|
||||||
}
|
}
|
||||||
componentsCache.reset();
|
return List.of(built);
|
||||||
}
|
|
||||||
|
|
||||||
private Set<MantleFlag> getDisabledFlags() {
|
|
||||||
return disabledFlags.aquire(() -> {
|
|
||||||
KList<MantleFlag> disabled = new KList<>();
|
|
||||||
disabled.addAll(getDimension().getDisabledComponents());
|
|
||||||
return Set.copyOf(disabled);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MantleObjectComponent getObjectComponent() {
|
|
||||||
return object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Mantle<Matter> createMantle(Engine engine) {
|
private static Mantle<Matter> createMantle(Engine engine) {
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package art.arcane.iris.engine.mantle;
|
|
||||||
|
|
||||||
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface ComponentFlag {
|
|
||||||
ReservedFlag value();
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,6 @@ import art.arcane.iris.engine.UpperDimensionContext;
|
|||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.framework.EngineTarget;
|
import art.arcane.iris.engine.framework.EngineTarget;
|
||||||
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
||||||
import art.arcane.iris.engine.mantle.components.MantleObjectComponent;
|
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
@@ -46,7 +45,6 @@ import art.arcane.iris.spi.PlatformBlockState;
|
|||||||
import org.jetbrains.annotations.UnmodifiableView;
|
import org.jetbrains.annotations.UnmodifiableView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public interface EngineMantle extends MatterGenerator {
|
public interface EngineMantle extends MatterGenerator {
|
||||||
@@ -63,14 +61,6 @@ public interface EngineMantle extends MatterGenerator {
|
|||||||
@UnmodifiableView
|
@UnmodifiableView
|
||||||
List<MantlePass> getComponents();
|
List<MantlePass> getComponents();
|
||||||
|
|
||||||
@UnmodifiableView
|
|
||||||
Map<MantleFlag, MantleComponent> getRegisteredComponents();
|
|
||||||
|
|
||||||
boolean registerComponent(MantleComponent c);
|
|
||||||
|
|
||||||
@UnmodifiableView
|
|
||||||
KList<MantleFlag> getComponentFlags();
|
|
||||||
|
|
||||||
void hotload();
|
void hotload();
|
||||||
|
|
||||||
default int getHighest(int x, int z) {
|
default int getHighest(int x, int z) {
|
||||||
@@ -231,8 +221,6 @@ public interface EngineMantle extends MatterGenerator {
|
|||||||
return getMantle().getLoadedRegionCount();
|
return getMantle().getLoadedRegionCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
MantleObjectComponent getObjectComponent();
|
|
||||||
|
|
||||||
default boolean isCovered(int x, int z) {
|
default boolean isCovered(int x, int z) {
|
||||||
int s = getRealRadius();
|
int s = getRealRadius();
|
||||||
|
|
||||||
|
|||||||
@@ -1,61 +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.mantle;
|
|
||||||
|
|
||||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(exclude = "engineMantle")
|
|
||||||
@ToString(exclude = "engineMantle")
|
|
||||||
public abstract class IrisMantleComponent implements MantleComponent {
|
|
||||||
private final EngineMantle engineMantle;
|
|
||||||
private final MantleFlag flag;
|
|
||||||
private final int priority;
|
|
||||||
|
|
||||||
private volatile int radius = -1;
|
|
||||||
private final Object lock = new Object();
|
|
||||||
private boolean enabled = true;
|
|
||||||
|
|
||||||
protected abstract int computeRadius();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hotload() {
|
|
||||||
synchronized (lock) {
|
|
||||||
radius = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final int getRadius() {
|
|
||||||
int r = radius;
|
|
||||||
if(r != -1) return r;
|
|
||||||
|
|
||||||
synchronized (lock) {
|
|
||||||
if((r = radius) != -1) {
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
r = computeRadius();
|
|
||||||
if(r < 0) r = 0;
|
|
||||||
return radius = r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,17 +18,16 @@
|
|||||||
|
|
||||||
package art.arcane.iris.engine.mantle;
|
package art.arcane.iris.engine.mantle;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.engine.IrisComplex;
|
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
|
||||||
import art.arcane.iris.util.project.context.ChunkContext;
|
import art.arcane.iris.util.project.context.ChunkContext;
|
||||||
import art.arcane.volmlib.util.documentation.ChunkCoordinates;
|
import art.arcane.volmlib.util.documentation.ChunkCoordinates;
|
||||||
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
|
||||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||||
import art.arcane.volmlib.util.matter.Matter;
|
|
||||||
import art.arcane.iris.util.common.parallel.BurstExecutor;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One pass of the mantle: {@link MatterGenerator} runs every component of a priority for each chunk within its
|
||||||
|
* radius plus every later pass's radius around a generating chunk, before the next priority starts. Iris's
|
||||||
|
* components are the pack's mantle stages, one each ({@code ModuleMantleComponent}).
|
||||||
|
*/
|
||||||
public interface MantleComponent extends Comparable<MantleComponent> {
|
public interface MantleComponent extends Comparable<MantleComponent> {
|
||||||
int getPriority();
|
int getPriority();
|
||||||
|
|
||||||
@@ -51,32 +50,6 @@ public interface MantleComponent extends Comparable<MantleComponent> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default IrisData getData() {
|
|
||||||
return getEngineMantle().getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
default IrisDimension getDimension() {
|
|
||||||
return getEngineMantle().getEngine().getDimension();
|
|
||||||
}
|
|
||||||
|
|
||||||
default IrisComplex getComplex() {
|
|
||||||
return getEngineMantle().getComplex();
|
|
||||||
}
|
|
||||||
|
|
||||||
default long seed() {
|
|
||||||
return getEngineMantle().getEngine().getSeedManager().getMantle();
|
|
||||||
}
|
|
||||||
|
|
||||||
default BurstExecutor burst() {
|
|
||||||
return getEngineMantle().getEngine().burst().burst();
|
|
||||||
}
|
|
||||||
|
|
||||||
EngineMantle getEngineMantle();
|
|
||||||
|
|
||||||
default Mantle<Matter> getMantle() {
|
|
||||||
return getEngineMantle().getMantle();
|
|
||||||
}
|
|
||||||
|
|
||||||
MantleFlag getFlag();
|
MantleFlag getFlag();
|
||||||
|
|
||||||
default MantleFlag[] getPrerequisiteFlags() {
|
default MantleFlag[] getPrerequisiteFlags() {
|
||||||
@@ -87,10 +60,6 @@ public interface MantleComponent extends Comparable<MantleComponent> {
|
|||||||
|
|
||||||
boolean isEnabled();
|
boolean isEnabled();
|
||||||
|
|
||||||
void setEnabled(boolean b);
|
|
||||||
|
|
||||||
void hotload();
|
|
||||||
|
|
||||||
@ChunkCoordinates
|
@ChunkCoordinates
|
||||||
void generateLayer(MantleWriter writer, int x, int z, ChunkContext context);
|
void generateLayer(MantleWriter writer, int x, int z, ChunkContext context);
|
||||||
|
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ public class DiagnosticSeverityPolicyTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void generationTracingStaysAtDebugLevel() {
|
public void generationTracingStaysAtDebugLevel() {
|
||||||
assertLoggedWith("engine/mantle/components/MantleObjectComponent.java", "Regen object layer start:", "debug");
|
assertLoggedWith("engine/mantle/components/ObjectPlacing.java", "Regen object layer start:", "debug");
|
||||||
assertLoggedWith("engine/mantle/components/MantleObjectComponent.java", "Goldendebug object attempt:", "debug");
|
assertLoggedWith("engine/mantle/components/ObjectPlacing.java", "Goldendebug object attempt:", "debug");
|
||||||
assertLoggedWith("engine/mantle/components/GoldenDebugObjectPlacer.java", "Goldendebug query:", "debug");
|
assertLoggedWith("engine/mantle/components/GoldenDebugObjectPlacer.java", "Goldendebug query:", "debug");
|
||||||
assertLoggedWith("engine/mantle/components/IrisStructureComponent.java", "[StructTrace] ORIGIN", "debug");
|
assertLoggedWith("engine/mantle/components/StructurePlacing.java", "[StructTrace] ORIGIN", "debug");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -20,11 +20,18 @@ package art.arcane.iris.core.modules;
|
|||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.builtin.deposit.DepositSettings;
|
import art.arcane.iris.builtin.deposit.DepositSettings;
|
||||||
|
import art.arcane.iris.builtin.structure.StructureStages;
|
||||||
import com.volmit.FeatureAttachment.Target;
|
import com.volmit.FeatureAttachment.Target;
|
||||||
|
import com.volmit.IrisModule;
|
||||||
|
import com.volmit.ModuleInfo;
|
||||||
|
import com.volmit.config.PackSettings;
|
||||||
import com.volmit.host.LoadedPack;
|
import com.volmit.host.LoadedPack;
|
||||||
import com.volmit.host.ResolvedGraph;
|
import com.volmit.host.ResolvedGraph;
|
||||||
import com.volmit.host.schema.FeatureSchema;
|
import com.volmit.host.schema.FeatureSchema;
|
||||||
import com.volmit.host.schema.ValueKind;
|
import com.volmit.host.schema.ValueKind;
|
||||||
|
import com.volmit.stage.MantleStage;
|
||||||
|
import com.volmit.stage.Stage;
|
||||||
|
import com.volmit.stage.StageGraph;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
@@ -42,6 +49,8 @@ public class BuiltInGenerationGraphTest {
|
|||||||
"iris:biome/write", "iris:terrain/shape", "iris:carve/apply", "iris:post/smooth", "iris:floating/solids",
|
"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:deposit/ores", "iris:matter/insert", "iris:decorant/decorate", "iris:floating/decorate",
|
||||||
"iris:perfection/surface", "iris:custom/blocks");
|
"iris:perfection/surface", "iris:custom/blocks");
|
||||||
|
private static final List<String> EXPECTED_MANTLE_ORDER = List.of(
|
||||||
|
"iris:carve/caves", "iris:objects/place", "iris:floating/objects", "iris:structure/place");
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder folder = new TemporaryFolder();
|
public TemporaryFolder folder = new TemporaryFolder();
|
||||||
@@ -56,12 +65,27 @@ public class BuiltInGenerationGraphTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cavesArePlannedInTheMantleOneBlockIntoEachNeighbor() throws IOException {
|
public void mantleStagesRunCavesObjectsFloatingObjectsThenStructures() throws IOException {
|
||||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||||
ResolvedGraph mantle = pack.mantle();
|
ResolvedGraph mantle = pack.mantle();
|
||||||
|
|
||||||
assertEquals(List.of("iris:carve/caves"), ids(mantle));
|
assertEquals(mantle.describe(), EXPECTED_MANTLE_ORDER, ids(mantle));
|
||||||
assertEquals(1, mantle.reach().blocks());
|
assertEquals("blended cave walls reach one block into each neighbor", 1,
|
||||||
|
mantle.stages().getFirst().reachBlocks(mock(PackSettings.class)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aPackMantleStageCanOrderItselfAfterIrisStructures() throws IOException {
|
||||||
|
MantleStage<Void> mark = Stage.mantle("test:marks/mark");
|
||||||
|
IrisModule marks = new IrisModule() {
|
||||||
|
public ModuleInfo info() { return ModuleInfo.of("test:marks", "Marks", "1"); }
|
||||||
|
public void install(StageGraph graph) { graph.define(mark).requires(StructureStages.PLACE).run(context -> { }); }
|
||||||
|
};
|
||||||
|
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of(marks))) {
|
||||||
|
List<String> order = ids(pack.mantle());
|
||||||
|
|
||||||
|
assertEquals(order.toString(), order.size() - 1, order.indexOf("test:marks/mark"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@@ -193,7 +194,7 @@ public class IrisModuleMantleTest {
|
|||||||
|
|
||||||
try (LoadedPack pack = LoadedPack.load(folder.newFolder("pack").toPath(),
|
try (LoadedPack pack = LoadedPack.load(folder.newFolder("pack").toPath(),
|
||||||
ModuleHost.of(List.of(veins)).copyingJarsTo(folder.newFolder("copies").toPath()))) {
|
ModuleHost.of(List.of(veins)).copyingJarsTo(folder.newFolder("copies").toPath()))) {
|
||||||
ModuleMantleComponent.generate(pack, engine, 0, 0, pack.mantle().reach().blocks(), this::chunk);
|
ModuleMantleComponent.forPack(engine, pack, Set.of()).getFirst().generate(0, 0, this::chunk);
|
||||||
|
|
||||||
IrisModuleMantle neighbor = new IrisModuleMantle(new BlockBox(16, MIN_Y, 0, 32, 0, 16), MIN_Y, this::chunk, pack.catalog().mantle());
|
IrisModuleMantle neighbor = new IrisModuleMantle(new BlockBox(16, MIN_Y, 0, 32, 0, 16), MIN_Y, this::chunk, pack.catalog().mantle());
|
||||||
assertEquals("vein", neighbor.layer(planned).get(20, -30, 3));
|
assertEquals("vein", neighbor.layer(planned).get(20, -30, 3));
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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.StructureStages;
|
||||||
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||||
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
|
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||||
|
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
||||||
|
import com.volmit.IrisModule;
|
||||||
|
import com.volmit.ModuleInfo;
|
||||||
|
import com.volmit.host.LoadedPack;
|
||||||
|
import com.volmit.stage.Stage;
|
||||||
|
import com.volmit.stage.StageGraph;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/** Every mantle stage is a mantle pass of its own, in the stage graph's order. */
|
||||||
|
public class ModuleMantleComponentTest {
|
||||||
|
private static final int MARK_REACH = 5;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public TemporaryFolder folder = new TemporaryFolder();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void everyMantleStageIsAPassOfItsOwnWithItsFlagAndThePacksReach() throws IOException {
|
||||||
|
IrisModule marks = new IrisModule() {
|
||||||
|
public ModuleInfo info() { return ModuleInfo.of("test:marks", "Marks", "1"); }
|
||||||
|
public void install(StageGraph graph) {
|
||||||
|
graph.define(Stage.mantle("test:marks/mark")).requires(StructureStages.PLACE).reach(settings -> MARK_REACH).run(context -> { });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
IrisData data = mock(IrisData.class);
|
||||||
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getData()).thenReturn(data);
|
||||||
|
when(engine.getDimension()).thenReturn(new IrisDimension());
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
|
|
||||||
|
try (LoadedPack ignored = BuiltInPack.serve(data, folder, List.of(marks))) {
|
||||||
|
List<ModuleMantleComponent> components = ModuleMantleComponent.forPack(engine, Set.of(ReservedFlag.CARVED));
|
||||||
|
|
||||||
|
assertEquals(List.of("iris:carve/caves", "iris:objects/place", "iris:floating/objects", "iris:structure/place", "test:marks/mark"),
|
||||||
|
components.stream().map(component -> component.stage().stage().id().toString()).toList());
|
||||||
|
assertEquals(List.of(ReservedFlag.CARVED, ReservedFlag.OBJECT, ReservedFlag.FLOATING_OBJECT, ReservedFlag.JIGSAW, MantleFlag.of(MantleFlag.MIN_ORDINAL)),
|
||||||
|
components.stream().map(ModuleMantleComponent::getFlag).toList());
|
||||||
|
assertEquals(List.of(0, 1, 2, 3, 4), components.stream().map(ModuleMantleComponent::getPriority).toList());
|
||||||
|
assertEquals("a pack without objects or structures: caves 1, floating objects at least 16", List.of(1, 0, 16, 0, MARK_REACH),
|
||||||
|
components.stream().map(ModuleMantleComponent::getRadius).toList());
|
||||||
|
assertEquals("disabledComponents: [CARVED] turns the cave pass off", List.of(false, true, true, true, true),
|
||||||
|
components.stream().map(ModuleMantleComponent::isEnabled).toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
-13
@@ -204,11 +204,6 @@ public class MatterGeneratorCarvePassRadiusTest {
|
|||||||
return lazyInputGeneration;
|
return lazyInputGeneration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public EngineMantle getEngineMantle() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MantleFlag getFlag() {
|
public MantleFlag getFlag() {
|
||||||
return flag;
|
return flag;
|
||||||
@@ -219,14 +214,6 @@ public class MatterGeneratorCarvePassRadiusTest {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEnabled(boolean enabled) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hotload() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||||
visited.add(x + "," + z);
|
visited.add(x + "," + z);
|
||||||
|
|||||||
@@ -177,11 +177,6 @@ public class MatterGeneratorConcurrencyTest {
|
|||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public EngineMantle getEngineMantle() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MantleFlag getFlag() {
|
public MantleFlag getFlag() {
|
||||||
return flag;
|
return flag;
|
||||||
@@ -192,14 +187,6 @@ public class MatterGeneratorConcurrencyTest {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEnabled(boolean enabled) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hotload() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -105,8 +105,8 @@ public class CaveObjectPlacementTransactionTest {
|
|||||||
transaction.set(4, 70, 7, mock(PlatformBlockState.class));
|
transaction.set(4, 70, 7, mock(PlatformBlockState.class));
|
||||||
|
|
||||||
assertEquals(CaveObjectPlacementTransaction.CommitResult.COMMITTED, transaction.commit());
|
assertEquals(CaveObjectPlacementTransaction.CommitResult.COMMITTED, transaction.commit());
|
||||||
assertEquals(71, MantleObjectComponent.caveAnchorScanUpperBound(128, 80, 10));
|
assertEquals(71, ObjectPlacing.caveAnchorScanUpperBound(128, 80, 10));
|
||||||
assertEquals(61, MantleObjectComponent.caveAnchorScanUpperBound(128, 80, 20));
|
assertEquals(61, ObjectPlacing.caveAnchorScanUpperBound(128, 80, 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IObjectPlacer createPlacer(int worldHeight, int surfaceHeight, int caveFloor, int caveCeiling) {
|
private IObjectPlacer createPlacer(int worldHeight, int surfaceHeight, int caveFloor, int caveCeiling) {
|
||||||
|
|||||||
+3
-6
@@ -22,7 +22,6 @@ import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
|||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.core.loader.ResourceLoader;
|
import art.arcane.iris.core.loader.ResourceLoader;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
|
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
|
||||||
@@ -50,7 +49,7 @@ import static org.mockito.ArgumentMatchers.anyString;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class MantleFloatingObjectComponentBoundaryRadiusTest {
|
public class FloatingObjectPlacingBoundaryRadiusTest {
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||||
|
|
||||||
@@ -107,10 +106,8 @@ public class MantleFloatingObjectComponentBoundaryRadiusTest {
|
|||||||
|
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
EngineMantle engineMantle = mock(EngineMantle.class);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engineMantle.getEngine()).thenReturn(engine);
|
|
||||||
when(engineMantle.getData()).thenReturn(data);
|
|
||||||
|
|
||||||
assertEquals(33, new MantleFloatingObjectComponent(engineMantle).getRadius());
|
assertEquals(33, new FloatingObjectPlacing(engine).reach());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-9
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class MantleFloatingObjectComponentInvertedPlacementTest {
|
public class FloatingObjectPlacingInvertedPlacementTest {
|
||||||
|
|
||||||
private FloatingObjectFootprint footprint(int lowestSolidKeyY, int highestSolidKeyY, int tallestKx, int tallestKz) throws Exception {
|
private FloatingObjectFootprint footprint(int lowestSolidKeyY, int highestSolidKeyY, int tallestKx, int tallestKz) throws Exception {
|
||||||
return footprint(lowestSolidKeyY, highestSolidKeyY, tallestKx, tallestKz, new long[0]);
|
return footprint(lowestSolidKeyY, highestSolidKeyY, tallestKx, tallestKz, new long[0]);
|
||||||
@@ -67,21 +67,21 @@ public class MantleFloatingObjectComponentInvertedPlacementTest {
|
|||||||
public void invertedBaseY_anchorsOriginalLowestSolidBelowBottomFace() throws Exception {
|
public void invertedBaseY_anchorsOriginalLowestSolidBelowBottomFace() throws Exception {
|
||||||
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
||||||
|
|
||||||
assertEquals(104, MantleFloatingObjectComponent.invertedBaseY(100, footprint));
|
assertEquals(104, FloatingObjectPlacing.invertedBaseY(100, footprint));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invertedBaseX_usesTopFootprintAnchor() throws Exception {
|
public void invertedBaseX_usesTopFootprintAnchor() throws Exception {
|
||||||
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
||||||
|
|
||||||
assertEquals(106, MantleFloatingObjectComponent.invertedBaseX(100, 8, footprint));
|
assertEquals(106, FloatingObjectPlacing.invertedBaseX(100, 8, footprint));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invertedBaseZ_mirrorsTopFootprintAnchor() throws Exception {
|
public void invertedBaseZ_mirrorsTopFootprintAnchor() throws Exception {
|
||||||
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
||||||
|
|
||||||
assertEquals(111, MantleFloatingObjectComponent.invertedBaseZ(100, 8, footprint));
|
assertEquals(111, FloatingObjectPlacing.invertedBaseZ(100, 8, footprint));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -89,7 +89,7 @@ public class MantleFloatingObjectComponentInvertedPlacementTest {
|
|||||||
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
||||||
IrisObjectRotation rotation = IrisObjectRotation.xFlip180WithY(90);
|
IrisObjectRotation rotation = IrisObjectRotation.xFlip180WithY(90);
|
||||||
|
|
||||||
assertEquals(111, MantleFloatingObjectComponent.invertedBaseX(100, 8, footprint, rotation));
|
assertEquals(111, FloatingObjectPlacing.invertedBaseX(100, 8, footprint, rotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -97,7 +97,7 @@ public class MantleFloatingObjectComponentInvertedPlacementTest {
|
|||||||
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
||||||
IrisObjectRotation rotation = IrisObjectRotation.xFlip180WithY(90);
|
IrisObjectRotation rotation = IrisObjectRotation.xFlip180WithY(90);
|
||||||
|
|
||||||
assertEquals(110, MantleFloatingObjectComponent.invertedBaseZ(100, 8, footprint, rotation));
|
assertEquals(110, FloatingObjectPlacing.invertedBaseZ(100, 8, footprint, rotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -105,7 +105,7 @@ public class MantleFloatingObjectComponentInvertedPlacementTest {
|
|||||||
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
|
||||||
IrisObjectRotation rotation = IrisObjectRotation.xFlip180WithY(270);
|
IrisObjectRotation rotation = IrisObjectRotation.xFlip180WithY(270);
|
||||||
|
|
||||||
assertEquals(104, MantleFloatingObjectComponent.invertedBaseY(100, footprint, rotation));
|
assertEquals(104, FloatingObjectPlacing.invertedBaseY(100, footprint, rotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -115,11 +115,11 @@ public class MantleFloatingObjectComponentInvertedPlacementTest {
|
|||||||
long[] cells = {0L, 1L << 32};
|
long[] cells = {0L, 1L << 32};
|
||||||
FloatingObjectFootprint footprint = footprint(0, 0, 0, 0, cells);
|
FloatingObjectFootprint footprint = footprint(0, 0, 0, 0, cells);
|
||||||
|
|
||||||
assertTrue(MantleFloatingObjectComponent.isFootprintFlat(
|
assertTrue(FloatingObjectPlacing.isFootprintFlat(
|
||||||
footprint, 15, 0, 109,
|
footprint, 15, 0, 109,
|
||||||
(x, z) -> z == 0 && (x == 15 || x == 16) ? sample : null,
|
(x, z) -> z == 0 && (x == 15 || x == 16) ? sample : null,
|
||||||
entry, 2));
|
entry, 2));
|
||||||
assertFalse(MantleFloatingObjectComponent.isFootprintFlat(
|
assertFalse(FloatingObjectPlacing.isFootprintFlat(
|
||||||
footprint, 15, 0, 109,
|
footprint, 15, 0, 109,
|
||||||
(x, z) -> x == 15 && z == 0 ? sample : null,
|
(x, z) -> x == 15 && z == 0 ? sample : null,
|
||||||
entry, 2));
|
entry, 2));
|
||||||
+2
-2
@@ -25,7 +25,7 @@ public class IrisStructureFoundationWriteTest {
|
|||||||
PlatformBlockState deepslateBricks = mock(PlatformBlockState.class);
|
PlatformBlockState deepslateBricks = mock(PlatformBlockState.class);
|
||||||
when(palette.get(rng, 12, -247, -18, data)).thenReturn(deepslateBricks);
|
when(palette.get(rng, 12, -247, -18, data)).thenReturn(deepslateBricks);
|
||||||
|
|
||||||
IrisStructureComponent.writeFoundationSupport(
|
StructurePlacing.writeFoundationSupport(
|
||||||
writer, palette, rng, data, 12, 9, -18, -256);
|
writer, palette, rng, data, 12, 9, -18, -256);
|
||||||
|
|
||||||
InOrder order = inOrder(palette, writer);
|
InOrder order = inOrder(palette, writer);
|
||||||
@@ -42,7 +42,7 @@ public class IrisStructureFoundationWriteTest {
|
|||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IrisStructureComponent.writeFoundationSupport(
|
StructurePlacing.writeFoundationSupport(
|
||||||
writer, palette, rng, data, 12, 9, -18, -256);
|
writer, palette, rng, data, 12, 9, -18, -256);
|
||||||
} catch (IllegalStateException error) {
|
} catch (IllegalStateException error) {
|
||||||
assertTrue(error.getMessage().contains("12,-247,-18"));
|
assertTrue(error.getMessage().contains("12,-247,-18"));
|
||||||
|
|||||||
+15
-16
@@ -5,7 +5,6 @@ import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
|||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.core.loader.ResourceLoader;
|
import art.arcane.iris.core.loader.ResourceLoader;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
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.MantleComponent;
|
||||||
import art.arcane.iris.engine.mantle.MantlePass;
|
import art.arcane.iris.engine.mantle.MantlePass;
|
||||||
import art.arcane.iris.engine.mantle.MatterGenerator;
|
import art.arcane.iris.engine.mantle.MatterGenerator;
|
||||||
@@ -28,6 +27,7 @@ import art.arcane.iris.spi.PlatformRegistries;
|
|||||||
import art.arcane.iris.util.common.math.IrisBlockVector;
|
import art.arcane.iris.util.common.math.IrisBlockVector;
|
||||||
import art.arcane.iris.util.project.context.ChunkContext;
|
import art.arcane.iris.util.project.context.ChunkContext;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
|
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
||||||
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
||||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||||
import art.arcane.volmlib.util.matter.Matter;
|
import art.arcane.volmlib.util.matter.Matter;
|
||||||
@@ -52,10 +52,9 @@ import static org.mockito.ArgumentMatchers.anyInt;
|
|||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class MantleObjectComponentBoundaryRadiusTest {
|
public class ObjectPlacingBoundaryRadiusTest {
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||||
|
|
||||||
@@ -92,7 +91,7 @@ public class MantleObjectComponentBoundaryRadiusTest {
|
|||||||
.setRotation(IrisObjectRotation.of(90, 0, 0))
|
.setRotation(IrisObjectRotation.of(90, 0, 0))
|
||||||
.setTranslate(new IrisObjectTranslate().setX(3).setY(4));
|
.setTranslate(new IrisObjectTranslate().setX(3).setY(4));
|
||||||
|
|
||||||
assertEquals(53, MantleObjectComponent.calculatePlacementReach(new IrisBlockVector(5, 48, 7), placement));
|
assertEquals(53, ObjectPlacing.calculatePlacementReach(new IrisBlockVector(5, 48, 7), placement));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -103,7 +102,7 @@ public class MantleObjectComponentBoundaryRadiusTest {
|
|||||||
.setMode(ObjectPlaceMode.VACUUM)
|
.setMode(ObjectPlaceMode.VACUUM)
|
||||||
.setVacuumSettings(new IrisVacuumSettings().setRadius(12));
|
.setVacuumSettings(new IrisVacuumSettings().setRadius(12));
|
||||||
|
|
||||||
assertEquals(43, MantleObjectComponent.calculatePlacementReach(new IrisBlockVector(5, 4, 3), placement));
|
assertEquals(43, ObjectPlacing.calculatePlacementReach(new IrisBlockVector(5, 4, 3), placement));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -126,11 +125,9 @@ public class MantleObjectComponentBoundaryRadiusTest {
|
|||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
EngineMantle engineMantle = mock(EngineMantle.class);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engineMantle.getEngine()).thenReturn(engine);
|
|
||||||
when(engineMantle.getData()).thenReturn(data);
|
|
||||||
|
|
||||||
assertEquals(53, new MantleObjectComponent(engineMantle).getRadius());
|
assertEquals(53, new ObjectPlacing(engine).reach());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -157,17 +154,19 @@ public class MantleObjectComponentBoundaryRadiusTest {
|
|||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
when(data.getObjectLoader()).thenReturn(objectLoader);
|
when(data.getObjectLoader()).thenReturn(objectLoader);
|
||||||
|
|
||||||
EngineMantle engineMantle = mock(EngineMantle.class);
|
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(engine.getMantle()).thenReturn(engineMantle);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engineMantle.getEngine()).thenReturn(engine);
|
|
||||||
when(engineMantle.getData()).thenReturn(data);
|
|
||||||
|
|
||||||
MantleObjectComponent component = spy(new MantleObjectComponent(engineMantle));
|
int reach = new ObjectPlacing(engine).reach();
|
||||||
assertEquals(33, component.getRadius());
|
assertEquals(33, reach);
|
||||||
int chunkRadius = Math.ceilDiv(component.getRadius(), 16);
|
int chunkRadius = Math.ceilDiv(reach, 16);
|
||||||
assertEquals(3, chunkRadius);
|
assertEquals(3, chunkRadius);
|
||||||
|
MantleComponent component = mock(MantleComponent.class);
|
||||||
|
when(component.getRadius()).thenReturn(reach);
|
||||||
|
when(component.getFlag()).thenReturn(ReservedFlag.OBJECT);
|
||||||
|
when(component.isEnabled()).thenReturn(true);
|
||||||
|
when(component.getPrerequisiteFlags()).thenReturn(MantleComponent.EMPTY_PREREQUISITES);
|
||||||
|
|
||||||
Mantle<Matter> mantle = mock(Mantle.class);
|
Mantle<Matter> mantle = mock(Mantle.class);
|
||||||
MantleChunk<Matter> chunk = mock(MantleChunk.class);
|
MantleChunk<Matter> chunk = mock(MantleChunk.class);
|
||||||
+11
-11
@@ -7,16 +7,16 @@ import org.junit.Test;
|
|||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class MantleObjectComponentCaveAnchorTest {
|
public class ObjectPlacingCaveAnchorTest {
|
||||||
@Test
|
@Test
|
||||||
public void biomeOwnedPlacementsRejectForeignCaveBands() {
|
public void biomeOwnedPlacementsRejectForeignCaveBands() {
|
||||||
IrisBiome frozen = biome("carving/ice");
|
IrisBiome frozen = biome("carving/ice");
|
||||||
IrisBiome deepDark = biome("carving/standard-deepdark");
|
IrisBiome deepDark = biome("carving/standard-deepdark");
|
||||||
IrisBiome surface = biome("frozen/ice-spikes");
|
IrisBiome surface = biome("frozen/ice-spikes");
|
||||||
|
|
||||||
assertFalse(MantleObjectComponent.caveAnchorBiomeConflicts(frozen, surface, "carving/ice"));
|
assertFalse(ObjectPlacing.caveAnchorBiomeConflicts(frozen, surface, "carving/ice"));
|
||||||
assertTrue(MantleObjectComponent.caveAnchorBiomeConflicts(deepDark, surface, "carving/ice"));
|
assertTrue(ObjectPlacing.caveAnchorBiomeConflicts(deepDark, surface, "carving/ice"));
|
||||||
assertFalse(MantleObjectComponent.caveAnchorBiomeConflicts(deepDark, surface, null));
|
assertFalse(ObjectPlacing.caveAnchorBiomeConflicts(deepDark, surface, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -25,10 +25,10 @@ public class MantleObjectComponentCaveAnchorTest {
|
|||||||
MatterCavern water = new MatterCavern(true, "", (byte) 1);
|
MatterCavern water = new MatterCavern(true, "", (byte) 1);
|
||||||
MatterCavern lava = new MatterCavern(true, "", (byte) 2);
|
MatterCavern lava = new MatterCavern(true, "", (byte) 2);
|
||||||
|
|
||||||
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(false, water, 20, 8));
|
assertFalse(ObjectPlacing.acceptsCaveAnchorFluid(false, water, 20, 8));
|
||||||
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(false, lava, 20, 8));
|
assertFalse(ObjectPlacing.acceptsCaveAnchorFluid(false, lava, 20, 8));
|
||||||
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(false, air, 8, 8));
|
assertFalse(ObjectPlacing.acceptsCaveAnchorFluid(false, air, 8, 8));
|
||||||
assertTrue(MantleObjectComponent.acceptsCaveAnchorFluid(false, air, 9, 8));
|
assertTrue(ObjectPlacing.acceptsCaveAnchorFluid(false, air, 9, 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -36,9 +36,9 @@ public class MantleObjectComponentCaveAnchorTest {
|
|||||||
MatterCavern water = new MatterCavern(true, "", (byte) 1);
|
MatterCavern water = new MatterCavern(true, "", (byte) 1);
|
||||||
MatterCavern forcedAir = new MatterCavern(true, "", (byte) 3);
|
MatterCavern forcedAir = new MatterCavern(true, "", (byte) 3);
|
||||||
|
|
||||||
assertTrue(MantleObjectComponent.acceptsCaveAnchorFluid(true, water, 20, 8));
|
assertTrue(ObjectPlacing.acceptsCaveAnchorFluid(true, water, 20, 8));
|
||||||
assertTrue(MantleObjectComponent.acceptsCaveAnchorFluid(false, forcedAir, 0, 8));
|
assertTrue(ObjectPlacing.acceptsCaveAnchorFluid(false, forcedAir, 0, 8));
|
||||||
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(
|
assertFalse(ObjectPlacing.acceptsCaveAnchorFluid(
|
||||||
true,
|
true,
|
||||||
new MatterCavern(false, "", (byte) 0),
|
new MatterCavern(false, "", (byte) 0),
|
||||||
20,
|
20,
|
||||||
+3
-3
@@ -6,13 +6,13 @@ import org.junit.Test;
|
|||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class MantleObjectComponentProceduralChanceTest {
|
public class ObjectPlacingProceduralChanceTest {
|
||||||
@Test
|
@Test
|
||||||
public void exactChanceBoundariesRemainExact() {
|
public void exactChanceBoundariesRemainExact() {
|
||||||
for (int seed = 0; seed < 1000; seed++) {
|
for (int seed = 0; seed < 1000; seed++) {
|
||||||
RNG rng = new RNG(seed);
|
RNG rng = new RNG(seed);
|
||||||
assertFalse(MantleObjectComponent.passesProceduralChance(rng, 0.0));
|
assertFalse(ObjectPlacing.passesProceduralChance(rng, 0.0));
|
||||||
assertTrue(MantleObjectComponent.passesProceduralChance(rng, 1.0));
|
assertTrue(ObjectPlacing.passesProceduralChance(rng, 1.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+14
-14
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class IrisStructureComponentMarkerTest {
|
public class StructurePlacingMarkerTest {
|
||||||
@Test
|
@Test
|
||||||
public void markerFilterAcceptsOnlyStorageContainers() {
|
public void markerFilterAcceptsOnlyStorageContainers() {
|
||||||
PlatformBlockState storage = mock(PlatformBlockState.class);
|
PlatformBlockState storage = mock(PlatformBlockState.class);
|
||||||
@@ -26,16 +26,16 @@ public class IrisStructureComponentMarkerTest {
|
|||||||
when(storage.isStorageChest()).thenReturn(true);
|
when(storage.isStorageChest()).thenReturn(true);
|
||||||
when(solid.isStorageChest()).thenReturn(false);
|
when(solid.isStorageChest()).thenReturn(false);
|
||||||
|
|
||||||
assertTrue(IrisStructureComponent.shouldWriteStructureMarker(storage));
|
assertTrue(StructurePlacing.shouldWriteStructureMarker(storage));
|
||||||
assertFalse(IrisStructureComponent.shouldWriteStructureMarker(solid));
|
assertFalse(StructurePlacing.shouldWriteStructureMarker(solid));
|
||||||
assertFalse(IrisStructureComponent.shouldWriteStructureMarker(null));
|
assertFalse(StructurePlacing.shouldWriteStructureMarker(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void placementIdIsStableAndCoordinateSensitive() {
|
public void placementIdIsStableAndCoordinateSensitive() {
|
||||||
int first = IrisStructureComponent.structurePlacementId("structures/village", "pieces/house", 20, -14, 35);
|
int first = StructurePlacing.structurePlacementId("structures/village", "pieces/house", 20, -14, 35);
|
||||||
int repeated = IrisStructureComponent.structurePlacementId("structures/village", "pieces/house", 20, -14, 35);
|
int repeated = StructurePlacing.structurePlacementId("structures/village", "pieces/house", 20, -14, 35);
|
||||||
int moved = IrisStructureComponent.structurePlacementId("structures/village", "pieces/house", 21, -14, 35);
|
int moved = StructurePlacing.structurePlacementId("structures/village", "pieces/house", 21, -14, 35);
|
||||||
|
|
||||||
assertEquals(first, repeated);
|
assertEquals(first, repeated);
|
||||||
assertNotEquals(first, moved);
|
assertNotEquals(first, moved);
|
||||||
@@ -48,9 +48,9 @@ public class IrisStructureComponentMarkerTest {
|
|||||||
when(solid.isAir()).thenReturn(false);
|
when(solid.isAir()).thenReturn(false);
|
||||||
when(air.isAir()).thenReturn(true);
|
when(air.isAir()).thenReturn(true);
|
||||||
|
|
||||||
assertTrue(IrisStructureComponent.isOccupiedStructureState(solid));
|
assertTrue(StructurePlacing.isOccupiedStructureState(solid));
|
||||||
assertFalse(IrisStructureComponent.isOccupiedStructureState(air));
|
assertFalse(StructurePlacing.isOccupiedStructureState(air));
|
||||||
assertFalse(IrisStructureComponent.isOccupiedStructureState(null));
|
assertFalse(StructurePlacing.isOccupiedStructureState(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -58,8 +58,8 @@ public class IrisStructureComponentMarkerTest {
|
|||||||
IrisStructureLocator.ResolvedPlacement resolved = resolvedPlacement(
|
IrisStructureLocator.ResolvedPlacement resolved = resolvedPlacement(
|
||||||
NativeStructureSuppression.NONE, new KList<>());
|
NativeStructureSuppression.NONE, new KList<>());
|
||||||
|
|
||||||
assertNull(IrisStructureComponent.resolvedPiecesOrNull(resolved, 4, -3));
|
assertNull(StructurePlacing.resolvedPiecesOrNull(resolved, 4, -3));
|
||||||
IrisStructureComponent.requireAppliedPieces(resolvedWithOnePiece(NativeStructureSuppression.NONE),
|
StructurePlacing.requireAppliedPieces(resolvedWithOnePiece(NativeStructureSuppression.NONE),
|
||||||
4, -3, 1);
|
4, -3, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class IrisStructureComponentMarkerTest {
|
|||||||
NativeStructureSuppression.REPLACE_SOURCE, new KList<>());
|
NativeStructureSuppression.REPLACE_SOURCE, new KList<>());
|
||||||
|
|
||||||
assertReplacementFailure(
|
assertReplacementFailure(
|
||||||
() -> IrisStructureComponent.resolvedPiecesOrNull(resolved, 4, -3),
|
() -> StructurePlacing.resolvedPiecesOrNull(resolved, 4, -3),
|
||||||
"placement application received no assembled pieces");
|
"placement application received no assembled pieces");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public class IrisStructureComponentMarkerTest {
|
|||||||
NativeStructureSuppression.REPLACE_SOURCE);
|
NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
|
|
||||||
assertReplacementFailure(
|
assertReplacementFailure(
|
||||||
() -> IrisStructureComponent.requireAppliedPieces(resolved, 4, -3, 1),
|
() -> StructurePlacing.requireAppliedPieces(resolved, 4, -3, 1),
|
||||||
"object placement rejected 1 of 1 assembled piece(s)");
|
"object placement rejected 1 of 1 assembled piece(s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
+6
-6
@@ -6,18 +6,18 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class IrisStructureComponentOverboreTest {
|
public class StructurePlacingOverboreTest {
|
||||||
@Test
|
@Test
|
||||||
public void ordinaryMarkersAreSeparatedFromStructureMarkers() {
|
public void ordinaryMarkersAreSeparatedFromStructureMarkers() {
|
||||||
assertTrue(IrisStructureComponent.isOrdinaryObjectMarker("trees/oak@42"));
|
assertTrue(StructurePlacing.isOrdinaryObjectMarker("trees/oak@42"));
|
||||||
assertFalse(IrisStructureComponent.isOrdinaryObjectMarker(
|
assertFalse(StructurePlacing.isOrdinaryObjectMarker(
|
||||||
"@iris-structure:v1:dHJlZXMvb2Fr:42:bWluZWNyYWZ0Om1hbnNpb24"));
|
"@iris-structure:v1:dHJlZXMvb2Fr:42:bWluZWNyYWZ0Om1hbnNpb24"));
|
||||||
assertFalse(IrisStructureComponent.isOrdinaryObjectMarker("not-a-marker"));
|
assertFalse(StructurePlacing.isOrdinaryObjectMarker("not-a-marker"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void collidingObjectSearchCoversTheWholeMarkerOwnedObject() {
|
public void collidingObjectSearchCoversTheWholeMarkerOwnedObject() {
|
||||||
IrisStructureComponent.ObjectMarkerBounds bounds = IrisStructureComponent.markerSearchBounds(
|
StructurePlacing.ObjectMarkerBounds bounds = StructurePlacing.markerSearchBounds(
|
||||||
20, 64, -8, 21, 66, -7, 7, 12, 384);
|
20, 64, -8, 21, 66, -7, 7, 12, 384);
|
||||||
|
|
||||||
assertEquals(14, bounds.minX());
|
assertEquals(14, bounds.minX());
|
||||||
@@ -30,7 +30,7 @@ public class IrisStructureComponentOverboreTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void collidingObjectSearchClampsToTheWorldHeight() {
|
public void collidingObjectSearchClampsToTheWorldHeight() {
|
||||||
IrisStructureComponent.ObjectMarkerBounds bounds = IrisStructureComponent.markerSearchBounds(
|
StructurePlacing.ObjectMarkerBounds bounds = StructurePlacing.markerSearchBounds(
|
||||||
0, 2, 0, 0, 379, 0, 1, 12, 384);
|
0, 2, 0, 0, 379, 0, 1, 12, 384);
|
||||||
|
|
||||||
assertEquals(0, bounds.minY());
|
assertEquals(0, bounds.minY());
|
||||||
Reference in new issue
Block a user