Supply structure sea surface

- GenerationWritePolicy.seaSurface returns minHeight + fluidHeight and the first fluid of the dimension fluidPalette
- Dimensions with no sea fluid or a sea at the world floor return StructureSeaSurface.NONE
- Bukkit and modded structure stage policies supply the sea surface to native structure fitting
- Native fitter tests pass SeaSurface.NONE to keep their expectations
- FLATTEN descriptions state the sea-surface clamp and sea-fluid fill
- Schema digest recaptured for the description change
This commit is contained in:
Brian Neumann-Fopiano committed 2026-11-01 16:50:57 -05:00
1 parent 8bc1ed760e
commit 701b3191eb
11 files changed
+243 -121

No files matched your search

@@ -21,6 +21,7 @@ import art.arcane.volmlib.nativelib.terrain.structure.StructureLocateSearchAcces
import art.arcane.volmlib.nativelib.terrain.structure.StructurePalette;
import art.arcane.volmlib.nativelib.terrain.structure.StructurePlacementDecision;
import art.arcane.volmlib.nativelib.terrain.structure.StructureReferencePolicy;
import art.arcane.volmlib.nativelib.terrain.structure.StructureSeaSurface;
import art.arcane.volmlib.nativelib.terrain.structure.StructureVolumePolicy;
import art.arcane.volmlib.util.math.RNG;
@@ -120,6 +121,11 @@ public final class BukkitStructureStagePolicy implements StructureStagePolicy<
return (x, z) -> Engine.hostHeight(context, x, z, true) + context.getMinHeight();
}
@Override
public StructureSeaSurface seaSurface(Engine context) {
return GenerationWritePolicy.seaSurface(context);
}
@Override
public IntBinaryOperator worldgenHeight(Engine context, int runtimeMinY, boolean floor) {
return (x, z) -> Engine.hostHeight(context, x, z, floor) + runtimeMinY + 1;
@@ -4,9 +4,12 @@ import art.arcane.iris.generation.runtime.DimensionStackContext;
import art.arcane.iris.generation.runtime.DimensionStackLayout;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.IrisEngine;
import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
import art.arcane.iris.structure.object.IrisStaticObjectLayer;
import art.arcane.volmlib.nativelib.terrain.NativeBlockPositionPredicate;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.volmlib.nativelib.terrain.structure.StructureSeaSurface;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -23,6 +26,20 @@ public final class GenerationWritePolicy {
return router != null && activation < router.history().activeActivation().activationId();
}
public static StructureSeaSurface seaSurface(Engine engine) {
IrisDimension dimension = engine.getDimension();
int fluidHeight = dimension.getFluidHeight();
if (fluidHeight <= 0) {
return StructureSeaSurface.NONE;
}
for (NativeBlockState fluid : dimension.getFluidPalette().getBlockData(engine.getData())) {
if (fluid.isFluid()) {
return new StructureSeaSurface(engine.getMinHeight() + fluidHeight, fluid);
}
}
return StructureSeaSurface.NONE;
}
public static NativeBlockPositionPredicate protectedPositions(
IrisStaticObjectLayer staticObjects,
DimensionStackContext stackContext,
@@ -58,7 +58,7 @@ public class IrisVanillaStructureAdjustment {
@Description("Optional foundation columns placed beneath the native structure piece bases after placement.")
private IrisStructureStiltSettings stilt = null;
@Description("Optional terrain integration override. FLATTEN cuts and fills exposed surface foundations within flattenRange, blending across horizontalPadding blocks while preserving buried and submerged structures. VACUUM raises processed rigid-template foundations with a fixed 12-block falloff without lowering ground. BORE and FORCE_CARVE clear every intersecting chunk before native placement, while ENCASE fills it. Left unset, SOURCE replays the registered structure's authored terrain adaptation.")
@Description("Optional terrain integration override. FLATTEN cuts and fills exposed surface foundations within flattenRange, blending across horizontalPadding blocks while preserving buried and submerged structures. It never lowers dry ground outside a structure footprint below the dimension fluidHeight, and cuts at or below fluidHeight fill with the dimension sea fluid instead of air. VACUUM raises processed rigid-template foundations with a fixed 12-block falloff without lowering ground. BORE and FORCE_CARVE clear every intersecting chunk before native placement, while ENCASE fills it. Left unset, SOURCE replays the registered structure's authored terrain adaptation.")
private IrisStructureTerrain terrain = null;
public boolean matches(String key) {
@@ -30,7 +30,7 @@ public class IrisStructureTerrain implements StructureTerrainSettings {
private static final double MAX_EROSION_FREQUENCY = 1D;
private static final double MAX_LOBE_FREQUENCY = 1D;
@Description("Terrain operation. SOURCE applies the registered native structure's authored terrain adaptation and is a no-op for editable Iris structures. PRESERVE disables terrain integration. FLATTEN cuts and fills exposed native structure terrain within flattenRange, blending across horizontalPadding blocks. VACUUM raises terrain from processed rigid-template foundations with a fixed 12-block falloff without lowering ground. BORE and FORCE_CARVE clear the requested envelope, while ENCASE fills it before placement.")
@Description("Terrain operation. SOURCE applies the registered native structure's authored terrain adaptation and is a no-op for editable Iris structures. PRESERVE disables terrain integration. FLATTEN cuts and fills exposed native structure terrain within flattenRange, blending across horizontalPadding blocks, and never lowers dry ground outside a structure footprint below the dimension fluidHeight. SOURCE and FLATTEN surface cuts at or below fluidHeight fill with the dimension sea fluid instead of air. VACUUM raises terrain from processed rigid-template foundations with a fixed 12-block falloff without lowering ground. BORE and FORCE_CARVE clear the requested envelope, while ENCASE fills it before placement.")
private StructureTerrainMode mode = StructureTerrainMode.SOURCE;
@MinNumber(0)
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
@ClassRule
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
private static final String EXPECTED_SCHEMA_DIGEST = "0b7bc58cb81a7e630d13662b2157868bd306f3afef571942dc5b8e667323a250";
private static final String EXPECTED_SCHEMA_DIGEST = "d6a5c5f92c4487eb61ba8b540681e2e014f07943c527b39ae4f36fed33f53ca6";
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
IrisDimension.class,
@@ -0,0 +1,89 @@
package art.arcane.iris.platform.bukkit.nms;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.pack.value.IrisRange;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.volmlib.nativelib.terrain.structure.StructureSeaSurface;
import art.arcane.volmlib.util.collection.KList;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class BukkitStructureStagePolicySeaSurfaceTest {
private static final int MIN_HEIGHT = -256;
private static final int SEA_LEVEL = 50;
private static final IrisData DATA = mock(IrisData.class);
@Test
public void topYIsMinHeightPlusFluidHeight() {
NativeBlockState water = fluid();
Engine engine = engine(dimension(SEA_LEVEL, water));
StructureSeaSurface sea = new BukkitStructureStagePolicy(engine).seaSurface(engine);
assertEquals(engine.getMinHeight() + engine.getDimension().getFluidHeight(), sea.topY());
assertEquals(SEA_LEVEL, sea.topY());
assertSame(water, sea.fluid());
}
@Test
public void lavaSeaDimensionSuppliesLava() {
NativeBlockState lava = fluid();
Engine engine = engine(dimension(SEA_LEVEL, lava));
StructureSeaSurface sea = new BukkitStructureStagePolicy(engine).seaSurface(engine);
assertEquals(SEA_LEVEL, sea.topY());
assertSame(lava, sea.fluid());
}
@Test
public void seaFluidIsTheFirstFluidOfThePalette() {
NativeBlockState lava = fluid();
Engine engine = engine(dimension(SEA_LEVEL, nonFluid(), lava, fluid()));
assertSame(lava, new BukkitStructureStagePolicy(engine).seaSurface(engine).fluid());
}
@Test
public void dimensionWithoutASeaSuppliesNone() {
Engine dryPalette = engine(dimension(SEA_LEVEL, nonFluid()));
Engine seaAtTheFloor = engine(dimension(MIN_HEIGHT, fluid()));
assertSame(StructureSeaSurface.NONE, new BukkitStructureStagePolicy(dryPalette).seaSurface(dryPalette));
assertSame(StructureSeaSurface.NONE, new BukkitStructureStagePolicy(seaAtTheFloor).seaSurface(seaAtTheFloor));
}
private static IrisDimension dimension(int fluidHeight, NativeBlockState... fluidPalette) {
IrisMaterialPalette palette = mock(IrisMaterialPalette.class);
when(palette.getBlockData(DATA)).thenReturn(new KList<>(fluidPalette));
return new IrisDimension()
.setDimensionHeight(new IrisRange(MIN_HEIGHT, 512))
.setFluidHeight(fluidHeight)
.setFluidPalette(palette);
}
private static Engine engine(IrisDimension dimension) {
Engine engine = mock(Engine.class);
when(engine.getMinHeight()).thenReturn(MIN_HEIGHT);
when(engine.getDimension()).thenReturn(dimension);
when(engine.getData()).thenReturn(DATA);
return engine;
}
private static NativeBlockState fluid() {
NativeBlockState state = nonFluid();
when(state.isFluid()).thenReturn(true);
return state;
}
private static NativeBlockState nonFluid() {
return mock(NativeBlockState.class);
}
}