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:
piexel committed 2026-10-08 12:44:43 +02:00
1 parent 0f63a3c59a
commit 0a06d5ff29
25 files changed
+463 -365

No files matched your search

@@ -51,10 +51,10 @@ public class DiagnosticSeverityPolicyTest {
@Test
public void generationTracingStaysAtDebugLevel() {
assertLoggedWith("engine/mantle/components/MantleObjectComponent.java", "Regen object layer start:", "debug");
assertLoggedWith("engine/mantle/components/MantleObjectComponent.java", "Goldendebug object attempt:", "debug");
assertLoggedWith("engine/mantle/components/ObjectPlacing.java", "Regen object layer start:", "debug");
assertLoggedWith("engine/mantle/components/ObjectPlacing.java", "Goldendebug object attempt:", "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
@@ -20,11 +20,18 @@ package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.builtin.deposit.DepositSettings;
import art.arcane.iris.builtin.structure.StructureStages;
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.ResolvedGraph;
import com.volmit.host.schema.FeatureSchema;
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.Test;
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:deposit/ores", "iris:matter/insert", "iris:decorant/decorate", "iris:floating/decorate",
"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
public TemporaryFolder folder = new TemporaryFolder();
@@ -56,12 +65,27 @@ public class BuiltInGenerationGraphTest {
}
@Test
public void cavesArePlannedInTheMantleOneBlockIntoEachNeighbor() throws IOException {
public void mantleStagesRunCavesObjectsFloatingObjectsThenStructures() 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());
assertEquals(mantle.describe(), EXPECTED_MANTLE_ORDER, ids(mantle));
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.List;
import java.util.Map;
import java.util.Set;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -193,7 +194,7 @@ public class IrisModuleMantleTest {
try (LoadedPack pack = LoadedPack.load(folder.newFolder("pack").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());
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());
}
}
}
@@ -204,11 +204,6 @@ public class MatterGeneratorCarvePassRadiusTest {
return lazyInputGeneration;
}
@Override
public EngineMantle getEngineMantle() {
return null;
}
@Override
public MantleFlag getFlag() {
return flag;
@@ -219,14 +214,6 @@ public class MatterGeneratorCarvePassRadiusTest {
return true;
}
@Override
public void setEnabled(boolean enabled) {
}
@Override
public void hotload() {
}
@Override
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
visited.add(x + "," + z);
@@ -177,11 +177,6 @@ public class MatterGeneratorConcurrencyTest {
return radius;
}
@Override
public EngineMantle getEngineMantle() {
return null;
}
@Override
public MantleFlag getFlag() {
return flag;
@@ -192,14 +187,6 @@ public class MatterGeneratorConcurrencyTest {
return true;
}
@Override
public void setEnabled(boolean enabled) {
}
@Override
public void hotload() {
}
@Override
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
}
@@ -105,8 +105,8 @@ public class CaveObjectPlacementTransactionTest {
transaction.set(4, 70, 7, mock(PlatformBlockState.class));
assertEquals(CaveObjectPlacementTransaction.CommitResult.COMMITTED, transaction.commit());
assertEquals(71, MantleObjectComponent.caveAnchorScanUpperBound(128, 80, 10));
assertEquals(61, MantleObjectComponent.caveAnchorScanUpperBound(128, 80, 20));
assertEquals(71, ObjectPlacing.caveAnchorScanUpperBound(128, 80, 10));
assertEquals(61, ObjectPlacing.caveAnchorScanUpperBound(128, 80, 20));
}
private IObjectPlacer createPlacer(int worldHeight, int surfaceHeight, int caveFloor, int caveCeiling) {
@@ -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.ResourceLoader;
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.dimension.IrisDimension;
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.when;
public class MantleFloatingObjectComponentBoundaryRadiusTest {
public class FloatingObjectPlacingBoundaryRadiusTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -107,10 +106,8 @@ public class MantleFloatingObjectComponentBoundaryRadiusTest {
Engine engine = mock(Engine.class);
when(engine.getDimension()).thenReturn(dimension);
EngineMantle engineMantle = mock(EngineMantle.class);
when(engineMantle.getEngine()).thenReturn(engine);
when(engineMantle.getData()).thenReturn(data);
when(engine.getData()).thenReturn(data);
assertEquals(33, new MantleFloatingObjectComponent(engineMantle).getRadius());
assertEquals(33, new FloatingObjectPlacing(engine).reach());
}
}
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
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 {
return footprint(lowestSolidKeyY, highestSolidKeyY, tallestKx, tallestKz, new long[0]);
@@ -67,21 +67,21 @@ public class MantleFloatingObjectComponentInvertedPlacementTest {
public void invertedBaseY_anchorsOriginalLowestSolidBelowBottomFace() throws Exception {
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
assertEquals(104, MantleFloatingObjectComponent.invertedBaseY(100, footprint));
assertEquals(104, FloatingObjectPlacing.invertedBaseY(100, footprint));
}
@Test
public void invertedBaseX_usesTopFootprintAnchor() throws Exception {
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
assertEquals(106, MantleFloatingObjectComponent.invertedBaseX(100, 8, footprint));
assertEquals(106, FloatingObjectPlacing.invertedBaseX(100, 8, footprint));
}
@Test
public void invertedBaseZ_mirrorsTopFootprintAnchor() throws Exception {
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
assertEquals(111, MantleFloatingObjectComponent.invertedBaseZ(100, 8, footprint));
assertEquals(111, FloatingObjectPlacing.invertedBaseZ(100, 8, footprint));
}
@Test
@@ -89,7 +89,7 @@ public class MantleFloatingObjectComponentInvertedPlacementTest {
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
IrisObjectRotation rotation = IrisObjectRotation.xFlip180WithY(90);
assertEquals(111, MantleFloatingObjectComponent.invertedBaseX(100, 8, footprint, rotation));
assertEquals(111, FloatingObjectPlacing.invertedBaseX(100, 8, footprint, rotation));
}
@Test
@@ -97,7 +97,7 @@ public class MantleFloatingObjectComponentInvertedPlacementTest {
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
IrisObjectRotation rotation = IrisObjectRotation.xFlip180WithY(90);
assertEquals(110, MantleFloatingObjectComponent.invertedBaseZ(100, 8, footprint, rotation));
assertEquals(110, FloatingObjectPlacing.invertedBaseZ(100, 8, footprint, rotation));
}
@Test
@@ -105,7 +105,7 @@ public class MantleFloatingObjectComponentInvertedPlacementTest {
FloatingObjectFootprint footprint = footprint(5, 30, 2, 3);
IrisObjectRotation rotation = IrisObjectRotation.xFlip180WithY(270);
assertEquals(104, MantleFloatingObjectComponent.invertedBaseY(100, footprint, rotation));
assertEquals(104, FloatingObjectPlacing.invertedBaseY(100, footprint, rotation));
}
@Test
@@ -115,11 +115,11 @@ public class MantleFloatingObjectComponentInvertedPlacementTest {
long[] cells = {0L, 1L << 32};
FloatingObjectFootprint footprint = footprint(0, 0, 0, 0, cells);
assertTrue(MantleFloatingObjectComponent.isFootprintFlat(
assertTrue(FloatingObjectPlacing.isFootprintFlat(
footprint, 15, 0, 109,
(x, z) -> z == 0 && (x == 15 || x == 16) ? sample : null,
entry, 2));
assertFalse(MantleFloatingObjectComponent.isFootprintFlat(
assertFalse(FloatingObjectPlacing.isFootprintFlat(
footprint, 15, 0, 109,
(x, z) -> x == 15 && z == 0 ? sample : null,
entry, 2));
@@ -25,7 +25,7 @@ public class IrisStructureFoundationWriteTest {
PlatformBlockState deepslateBricks = mock(PlatformBlockState.class);
when(palette.get(rng, 12, -247, -18, data)).thenReturn(deepslateBricks);
IrisStructureComponent.writeFoundationSupport(
StructurePlacing.writeFoundationSupport(
writer, palette, rng, data, 12, 9, -18, -256);
InOrder order = inOrder(palette, writer);
@@ -42,7 +42,7 @@ public class IrisStructureFoundationWriteTest {
IrisData data = mock(IrisData.class);
try {
IrisStructureComponent.writeFoundationSupport(
StructurePlacing.writeFoundationSupport(
writer, palette, rng, data, 12, 9, -18, -256);
} catch (IllegalStateException error) {
assertTrue(error.getMessage().contains("12,-247,-18"));
@@ -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.ResourceLoader;
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.MatterGenerator;
@@ -28,6 +27,7 @@ import art.arcane.iris.spi.PlatformRegistries;
import art.arcane.iris.util.common.math.IrisBlockVector;
import art.arcane.iris.util.project.context.ChunkContext;
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.MantleChunk;
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.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
public class MantleObjectComponentBoundaryRadiusTest {
public class ObjectPlacingBoundaryRadiusTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -92,7 +91,7 @@ public class MantleObjectComponentBoundaryRadiusTest {
.setRotation(IrisObjectRotation.of(90, 0, 0))
.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
@@ -103,7 +102,7 @@ public class MantleObjectComponentBoundaryRadiusTest {
.setMode(ObjectPlaceMode.VACUUM)
.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
@@ -126,11 +125,9 @@ public class MantleObjectComponentBoundaryRadiusTest {
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
Engine engine = mock(Engine.class);
when(engine.getDimension()).thenReturn(dimension);
EngineMantle engineMantle = mock(EngineMantle.class);
when(engineMantle.getEngine()).thenReturn(engine);
when(engineMantle.getData()).thenReturn(data);
when(engine.getData()).thenReturn(data);
assertEquals(53, new MantleObjectComponent(engineMantle).getRadius());
assertEquals(53, new ObjectPlacing(engine).reach());
}
@Test
@@ -157,17 +154,19 @@ public class MantleObjectComponentBoundaryRadiusTest {
IrisData data = mock(IrisData.class);
when(data.getObjectLoader()).thenReturn(objectLoader);
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);
when(engineMantle.getData()).thenReturn(data);
when(engine.getData()).thenReturn(data);
MantleObjectComponent component = spy(new MantleObjectComponent(engineMantle));
assertEquals(33, component.getRadius());
int chunkRadius = Math.ceilDiv(component.getRadius(), 16);
int reach = new ObjectPlacing(engine).reach();
assertEquals(33, reach);
int chunkRadius = Math.ceilDiv(reach, 16);
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);
MantleChunk<Matter> chunk = mock(MantleChunk.class);
@@ -7,16 +7,16 @@ import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class MantleObjectComponentCaveAnchorTest {
public class ObjectPlacingCaveAnchorTest {
@Test
public void biomeOwnedPlacementsRejectForeignCaveBands() {
IrisBiome frozen = biome("carving/ice");
IrisBiome deepDark = biome("carving/standard-deepdark");
IrisBiome surface = biome("frozen/ice-spikes");
assertFalse(MantleObjectComponent.caveAnchorBiomeConflicts(frozen, surface, "carving/ice"));
assertTrue(MantleObjectComponent.caveAnchorBiomeConflicts(deepDark, surface, "carving/ice"));
assertFalse(MantleObjectComponent.caveAnchorBiomeConflicts(deepDark, surface, null));
assertFalse(ObjectPlacing.caveAnchorBiomeConflicts(frozen, surface, "carving/ice"));
assertTrue(ObjectPlacing.caveAnchorBiomeConflicts(deepDark, surface, "carving/ice"));
assertFalse(ObjectPlacing.caveAnchorBiomeConflicts(deepDark, surface, null));
}
@Test
@@ -25,10 +25,10 @@ public class MantleObjectComponentCaveAnchorTest {
MatterCavern water = new MatterCavern(true, "", (byte) 1);
MatterCavern lava = new MatterCavern(true, "", (byte) 2);
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(false, water, 20, 8));
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(false, lava, 20, 8));
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(false, air, 8, 8));
assertTrue(MantleObjectComponent.acceptsCaveAnchorFluid(false, air, 9, 8));
assertFalse(ObjectPlacing.acceptsCaveAnchorFluid(false, water, 20, 8));
assertFalse(ObjectPlacing.acceptsCaveAnchorFluid(false, lava, 20, 8));
assertFalse(ObjectPlacing.acceptsCaveAnchorFluid(false, air, 8, 8));
assertTrue(ObjectPlacing.acceptsCaveAnchorFluid(false, air, 9, 8));
}
@Test
@@ -36,9 +36,9 @@ public class MantleObjectComponentCaveAnchorTest {
MatterCavern water = new MatterCavern(true, "", (byte) 1);
MatterCavern forcedAir = new MatterCavern(true, "", (byte) 3);
assertTrue(MantleObjectComponent.acceptsCaveAnchorFluid(true, water, 20, 8));
assertTrue(MantleObjectComponent.acceptsCaveAnchorFluid(false, forcedAir, 0, 8));
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(
assertTrue(ObjectPlacing.acceptsCaveAnchorFluid(true, water, 20, 8));
assertTrue(ObjectPlacing.acceptsCaveAnchorFluid(false, forcedAir, 0, 8));
assertFalse(ObjectPlacing.acceptsCaveAnchorFluid(
true,
new MatterCavern(false, "", (byte) 0),
20,
@@ -6,13 +6,13 @@ import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class MantleObjectComponentProceduralChanceTest {
public class ObjectPlacingProceduralChanceTest {
@Test
public void exactChanceBoundariesRemainExact() {
for (int seed = 0; seed < 1000; seed++) {
RNG rng = new RNG(seed);
assertFalse(MantleObjectComponent.passesProceduralChance(rng, 0.0));
assertTrue(MantleObjectComponent.passesProceduralChance(rng, 1.0));
assertFalse(ObjectPlacing.passesProceduralChance(rng, 0.0));
assertTrue(ObjectPlacing.passesProceduralChance(rng, 1.0));
}
}
}
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class IrisStructureComponentMarkerTest {
public class StructurePlacingMarkerTest {
@Test
public void markerFilterAcceptsOnlyStorageContainers() {
PlatformBlockState storage = mock(PlatformBlockState.class);
@@ -26,16 +26,16 @@ public class IrisStructureComponentMarkerTest {
when(storage.isStorageChest()).thenReturn(true);
when(solid.isStorageChest()).thenReturn(false);
assertTrue(IrisStructureComponent.shouldWriteStructureMarker(storage));
assertFalse(IrisStructureComponent.shouldWriteStructureMarker(solid));
assertFalse(IrisStructureComponent.shouldWriteStructureMarker(null));
assertTrue(StructurePlacing.shouldWriteStructureMarker(storage));
assertFalse(StructurePlacing.shouldWriteStructureMarker(solid));
assertFalse(StructurePlacing.shouldWriteStructureMarker(null));
}
@Test
public void placementIdIsStableAndCoordinateSensitive() {
int first = IrisStructureComponent.structurePlacementId("structures/village", "pieces/house", 20, -14, 35);
int repeated = IrisStructureComponent.structurePlacementId("structures/village", "pieces/house", 20, -14, 35);
int moved = IrisStructureComponent.structurePlacementId("structures/village", "pieces/house", 21, -14, 35);
int first = StructurePlacing.structurePlacementId("structures/village", "pieces/house", 20, -14, 35);
int repeated = StructurePlacing.structurePlacementId("structures/village", "pieces/house", 20, -14, 35);
int moved = StructurePlacing.structurePlacementId("structures/village", "pieces/house", 21, -14, 35);
assertEquals(first, repeated);
assertNotEquals(first, moved);
@@ -48,9 +48,9 @@ public class IrisStructureComponentMarkerTest {
when(solid.isAir()).thenReturn(false);
when(air.isAir()).thenReturn(true);
assertTrue(IrisStructureComponent.isOccupiedStructureState(solid));
assertFalse(IrisStructureComponent.isOccupiedStructureState(air));
assertFalse(IrisStructureComponent.isOccupiedStructureState(null));
assertTrue(StructurePlacing.isOccupiedStructureState(solid));
assertFalse(StructurePlacing.isOccupiedStructureState(air));
assertFalse(StructurePlacing.isOccupiedStructureState(null));
}
@Test
@@ -58,8 +58,8 @@ public class IrisStructureComponentMarkerTest {
IrisStructureLocator.ResolvedPlacement resolved = resolvedPlacement(
NativeStructureSuppression.NONE, new KList<>());
assertNull(IrisStructureComponent.resolvedPiecesOrNull(resolved, 4, -3));
IrisStructureComponent.requireAppliedPieces(resolvedWithOnePiece(NativeStructureSuppression.NONE),
assertNull(StructurePlacing.resolvedPiecesOrNull(resolved, 4, -3));
StructurePlacing.requireAppliedPieces(resolvedWithOnePiece(NativeStructureSuppression.NONE),
4, -3, 1);
}
@@ -69,7 +69,7 @@ public class IrisStructureComponentMarkerTest {
NativeStructureSuppression.REPLACE_SOURCE, new KList<>());
assertReplacementFailure(
() -> IrisStructureComponent.resolvedPiecesOrNull(resolved, 4, -3),
() -> StructurePlacing.resolvedPiecesOrNull(resolved, 4, -3),
"placement application received no assembled pieces");
}
@@ -79,7 +79,7 @@ public class IrisStructureComponentMarkerTest {
NativeStructureSuppression.REPLACE_SOURCE);
assertReplacementFailure(
() -> IrisStructureComponent.requireAppliedPieces(resolved, 4, -3, 1),
() -> StructurePlacing.requireAppliedPieces(resolved, 4, -3, 1),
"object placement rejected 1 of 1 assembled piece(s)");
}
@@ -6,18 +6,18 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class IrisStructureComponentOverboreTest {
public class StructurePlacingOverboreTest {
@Test
public void ordinaryMarkersAreSeparatedFromStructureMarkers() {
assertTrue(IrisStructureComponent.isOrdinaryObjectMarker("trees/oak@42"));
assertFalse(IrisStructureComponent.isOrdinaryObjectMarker(
assertTrue(StructurePlacing.isOrdinaryObjectMarker("trees/oak@42"));
assertFalse(StructurePlacing.isOrdinaryObjectMarker(
"@iris-structure:v1:dHJlZXMvb2Fr:42:bWluZWNyYWZ0Om1hbnNpb24"));
assertFalse(IrisStructureComponent.isOrdinaryObjectMarker("not-a-marker"));
assertFalse(StructurePlacing.isOrdinaryObjectMarker("not-a-marker"));
}
@Test
public void collidingObjectSearchCoversTheWholeMarkerOwnedObject() {
IrisStructureComponent.ObjectMarkerBounds bounds = IrisStructureComponent.markerSearchBounds(
StructurePlacing.ObjectMarkerBounds bounds = StructurePlacing.markerSearchBounds(
20, 64, -8, 21, 66, -7, 7, 12, 384);
assertEquals(14, bounds.minX());
@@ -30,7 +30,7 @@ public class IrisStructureComponentOverboreTest {
@Test
public void collidingObjectSearchClampsToTheWorldHeight() {
IrisStructureComponent.ObjectMarkerBounds bounds = IrisStructureComponent.markerSearchBounds(
StructurePlacing.ObjectMarkerBounds bounds = StructurePlacing.markerSearchBounds(
0, 2, 0, 0, 379, 0, 1, 12, 384);
assertEquals(0, bounds.minY());