Narrow force place scope

- Stop treating underground ORGANIC_STILT and CEILING_HANG pieces as forced, so they keep the veto and submerged check
- Return null for broken references on a submerged start, as before force place
- State force placement in the placeMode, underwater and allowWater descriptions and recapture the schema digest
- Pin static objects writing every block over planned river and pond water
- Add tests for forced pieces on open sea, unforced multi-piece starts on sea columns and underground pieces in water
This commit is contained in:
Brian Fopiano committed 2026-11-02 19:51:52 -05:00
1 parent b2255d6bf9
commit bad795f9a7
8 files changed
+239 -39

No files matched your search

@@ -219,6 +219,25 @@ public class IrisStructureComponentWaterTest {
assertTrue("allowWater fills the water", writes.stream().anyMatch(write -> write.y() == head));
}
@Test
public void undergroundPiecesKeepTheVeto() {
world.water(WaterRole.CHANNEL, 9, 13);
IrisObject object = HydrologyWaterFixture.raft();
int head = world.headAt(X, Z);
PlacedStructurePiece explicit = new PlacedStructurePiece(null, object, X, head + 1, Z, IrisObjectRotation.of(0, 0, 0),
X - 1, head, Z - 1, X + 1, head + 2, Z + 1);
for (ObjectPlaceMode mode : List.of(ObjectPlaceMode.ORGANIC_STILT, ObjectPlaceMode.CEILING_HANG)) {
writes.clear();
IrisStructure structure = new IrisStructure().setPlaceMode(mode);
IrisStructurePlacement placement = new IrisStructurePlacement().setUnderground(true);
assertEquals(mode.name(), 0, component.placePieces(writer, placement, structure, new KList<>(explicit), new RNG(7L)));
assertFalse(mode.name(), writes.isEmpty());
assertNoWaterOverwritten();
}
}
@Test
public void unforcedObjectsStayOffRiverWater() {
world.water(WaterRole.CHANNEL, 9, 13);
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
@ClassRule
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
private static final String EXPECTED_SCHEMA_DIGEST = "7eaf3ddcf305811c453a61368a9ae886cedb1ce47d4ca6dc53953ab8f26f5a77";
private static final String EXPECTED_SCHEMA_DIGEST = "4a9903e9c810bf297530a347175cd4a7ce24f181f4f623db9704727204c9573a";
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
IrisDimension.class,
@@ -1,6 +1,9 @@
package art.arcane.iris.structure.object;
import art.arcane.iris.generation.block.TileData;
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
import art.arcane.iris.generation.hydrology.raster.WaterRole;
import art.arcane.iris.generation.mantle.ObjectContinuationBundle;
import art.arcane.iris.integration.Identifier;
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
@@ -32,6 +35,7 @@ import art.arcane.volmlib.util.matter.Matter;
import art.arcane.volmlib.util.matter.IrisMatter;
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
import art.arcane.volmlib.util.matter.MatterSlice;
import art.arcane.volmlib.util.stream.ProceduralStream;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
@@ -50,6 +54,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
@@ -206,6 +211,56 @@ public class IrisStaticObjectLayerTest {
verify(tiles).set(15, 0, 15, null);
}
@Test
@SuppressWarnings("unchecked")
public void staticObjectOverPlannedRiverOrPondWaterWritesEveryBlock() {
for (WaterRole role : List.of(WaterRole.CHANNEL, WaterRole.POND)) {
IrisObject object = object("through-water", 3, 3, 1);
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
object.getBlocks().put(new IrisBlockVector(x, y, 0), state("minecraft:stone"));
}
}
IrisStaticObjectLayer layer = compile(entry("through-water", 8, 0, 8));
Engine engine = mock(Engine.class);
IrisComplex complex = mock(IrisComplex.class);
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
ChunkWaterRaster raster = mock(ChunkWaterRaster.class);
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
ProceduralStream<Double> heads = mock(ProceduralStream.class);
ProceduralStream<Integer> floors = mock(ProceduralStream.class);
when(engine.getComplex()).thenReturn(complex);
when(complex.getHydrologyRuntime()).thenReturn(runtime);
when(complex.getWaterRoleStream()).thenReturn(roles);
when(complex.getWaterHeadStream()).thenReturn(heads);
when(complex.getRoundedHeighteightStream()).thenReturn(floors);
when(runtime.enabled()).thenReturn(true);
when(runtime.raster(anyInt(), anyInt())).thenReturn(raster);
when(raster.role(anyInt(), anyInt())).thenReturn(role);
when(raster.waterHead(anyInt(), anyInt())).thenReturn(70);
when(raster.terrainHeight(anyInt(), anyInt())).thenReturn(60);
when(roles.get(anyDouble(), anyDouble())).thenReturn(role);
when(heads.getDouble(anyDouble(), anyDouble())).thenReturn(70D);
when(floors.get(anyDouble(), anyDouble())).thenReturn(60);
EngineMantle engineMantle = mock(EngineMantle.class);
Mantle<Matter> mantle = mock(Mantle.class);
MantleChunk<Matter> chunk = mock(MantleChunk.class);
when(engine.getMantle()).thenReturn(engineMantle);
when(engineMantle.getMantle()).thenReturn(mantle);
when(mantle.useChunk(anyInt(), anyInt())).thenReturn(chunk);
when(chunk.getOrCreate(anyInt())).thenReturn(mock(Matter.class));
Hunk<NativeBlockState> output = Hunk.newArrayHunk(16, 384, 16);
layer.apply(engine, 0, 0, output);
for (int x = 7; x <= 9; x++) {
for (int y = 63; y <= 65; y++) {
assertSame(role + " " + x + "," + y, state("minecraft:stone"), output.get(x, y, 8));
}
}
}
}
@Test
public void transitionRejectsWholeRotatedPlacementBeforeChunkWrites() {
IrisObject object = object("rotated", 1, 1, 5);
@@ -47,6 +47,7 @@ import art.arcane.volmlib.util.stream.ProceduralStream;
import org.junit.Test;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.junit.Assert.assertEquals;
@@ -54,6 +55,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -502,28 +504,7 @@ public class IrisStructureLocatorContractTest {
@Test
public void forcedSinglePiecesPlaceInTheMiddleOfARiver() {
Engine engine = densityEngine(1.0, false, -64, 384, -2032, 2032);
IrisObject object = engine.getData().load(IrisObject.class, "test:density/object", false);
when(object.getW()).thenReturn(10);
when(object.getD()).thenReturn(10);
IrisComplex complex = mock(IrisComplex.class);
when(engine.getComplex()).thenReturn(complex);
when(complex.allowsNewGenerationFootprint(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(true);
@SuppressWarnings("unchecked")
ProceduralStream<Double> waterHead = mock(ProceduralStream.class);
when(complex.getWaterHeadStream()).thenReturn(waterHead);
when(waterHead.get(anyDouble(), anyDouble())).thenReturn(124D);
when(waterHead.getDouble(anyDouble(), anyDouble())).thenReturn(124D);
@SuppressWarnings("unchecked")
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
when(complex.getWaterRoleStream()).thenReturn(roles);
when(roles.get(anyDouble(), anyDouble())).thenReturn(WaterRole.CHANNEL);
@SuppressWarnings("unchecked")
ProceduralStream<Integer> beds = mock(ProceduralStream.class);
when(beds.get(anyDouble(), anyDouble())).thenReturn(120);
when(complex.getRoundedHeighteightStream()).thenReturn(beds);
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(120);
when(engine.getDimension().getFluidHeight()).thenReturn(63);
Engine engine = submergedEngine(WaterRole.CHANNEL, false, -2032, 2032);
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
@@ -540,6 +521,135 @@ public class IrisStructureLocatorContractTest {
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
}
@Test
public void forcedSurfacePiecesPlaceOnOpenSea() {
Engine engine = submergedEngine(WaterRole.NONE, false, -2032, 2032);
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
assertFalse(placement.isUnderwater());
assertNull("an unforced structure stays off the sea",
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
assertNotNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
}
@Test
public void unforcedMultiPieceStartsStayOffSeaColumns() {
Engine engine = submergedEngine(WaterRole.NONE, false, -2032, 2032);
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
registerTwoPieceGraph(engine.getData(), structure, "test:density");
placement.setUnderwater(true);
IrisStructureLocator.ResolvedPlacement allowed = IrisStructureLocator.resolvePlacement(engine, placement, 3, 4);
assertNotNull(allowed);
assertEquals(2, allowed.pieces().size());
placement.setUnderwater(false);
assertNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
}
@Test
public void undergroundPiecesKeepTheSubmergedCheck() {
for (ObjectPlaceMode mode : List.of(ObjectPlaceMode.ORGANIC_STILT, ObjectPlaceMode.CEILING_HANG)) {
Engine engine = submergedEngine(WaterRole.CHANNEL, true, -40, -20);
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
structure.setPlaceMode(mode);
assertFalse(placement.forcesPieces(structure, 1));
assertNull(mode.name(), IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
}
}
@Test
public void brokenReferencesOnASubmergedStartReturnNull() {
Engine engine = submergedEngine(WaterRole.NONE, false, -2032, 2032);
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
structure.setStartPool("test:missing-pool");
assertNull("a graph that cannot assemble", IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
placement.getStructures().clear();
placement.getStructures().add("test:missing-structure");
assertNull("a missing structure", IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
}
@Test
public void brokenReferencesOnADryStartStillThrow() {
Engine engine = submergedEngine(WaterRole.NONE, false, -2032, 2032);
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(180);
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
structure.setStartPool("test:missing-pool");
assertThrows(IllegalStateException.class, () -> IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
placement.getStructures().clear();
placement.getStructures().add("test:missing-structure");
assertThrows(IllegalStateException.class, () -> IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
}
private Engine submergedEngine(WaterRole role, boolean underground, int placementMin, int placementMax) {
Engine engine = densityEngine(1.0, underground, -64, 384, placementMin, placementMax);
IrisObject object = engine.getData().load(IrisObject.class, "test:density/object", false);
when(object.getW()).thenReturn(10);
when(object.getD()).thenReturn(10);
IrisComplex complex = mock(IrisComplex.class);
when(engine.getComplex()).thenReturn(complex);
when(complex.allowsNewGenerationFootprint(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(true);
@SuppressWarnings("unchecked")
ProceduralStream<Double> waterHead = mock(ProceduralStream.class);
when(complex.getWaterHeadStream()).thenReturn(waterHead);
when(waterHead.get(anyDouble(), anyDouble())).thenReturn(124D);
when(waterHead.getDouble(anyDouble(), anyDouble())).thenReturn(124D);
@SuppressWarnings("unchecked")
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
when(complex.getWaterRoleStream()).thenReturn(roles);
when(roles.get(anyDouble(), anyDouble())).thenReturn(role);
@SuppressWarnings("unchecked")
ProceduralStream<Integer> beds = mock(ProceduralStream.class);
when(beds.get(anyDouble(), anyDouble())).thenReturn(120);
when(complex.getRoundedHeighteightStream()).thenReturn(beds);
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(120);
when(engine.getDimension().getFluidHeight()).thenReturn(63);
return engine;
}
private void registerTwoPieceGraph(IrisData data, IrisStructure structure, String prefix) {
registerSinglePieceGraph(data, structure, prefix);
String targetPool = prefix + "/target";
String targetPiece = prefix + "/target-piece";
IrisJigsawPiece start = data.load(IrisJigsawPiece.class, prefix + "/piece", false);
start.setRotatable(false);
start.getConnectors().add(new IrisJigsawConnector()
.setPosition(new IrisPosition(0, 0, 0))
.setDirection(IrisDirection.EAST_POSITIVE_X)
.setPool(targetPool)
.setName("source")
.setTargetName("door"));
IrisJigsawPiece target = new IrisJigsawPiece().setObject(prefix + "/object").setRotatable(false);
target.getConnectors().add(new IrisJigsawConnector()
.setPosition(new IrisPosition(0, 0, 0))
.setDirection(IrisDirection.WEST_NEGATIVE_X)
.setPool(targetPool)
.setName("door")
.setTargetName("unused"));
IrisJigsawPool pool = new IrisJigsawPool();
pool.getPieces().add(new IrisJigsawPieceEntry(targetPiece, 1));
when(data.load(IrisJigsawPool.class, targetPool, false)).thenReturn(pool);
when(data.load(IrisJigsawPiece.class, targetPiece, false)).thenReturn(target);
structure.setMaxDepth(1);
}
@Test
public void undergroundIrisStructuresIgnoreRiversAbove() {
Engine engine = densityEngine(1.0, true, -64, 384, -40, -20);