mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Merge tiling
This commit is contained in:
commit
04649aedbc
17 files changed
+633
-290
No files matched your search
@@ -1405,11 +1405,6 @@ public class IrisComplex implements DataProvider {
|
||||
return tier == null ? pondMaterials : tier.materials();
|
||||
}
|
||||
|
||||
public boolean isTidalBank(int x, int z) {
|
||||
WaterRole role = resolveWaterRole(x, z);
|
||||
return (role == WaterRole.BANK || role == WaterRole.SHORE) && chunkRasterAt(x, z).tier(x & 15, z & 15) == hydrologyRuntime.settings().tidalTier();
|
||||
}
|
||||
|
||||
public HydrologyVegetation.Decorators resolveWaterDecorators(int x, int z) {
|
||||
if (!waterVegetation.planted()) {
|
||||
return HydrologyVegetation.Decorators.EMPTY;
|
||||
|
||||
@@ -51,7 +51,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
private static final BoundBlockState DIRT = BoundBlockState.of("minecraft:dirt");
|
||||
private static final BoundBlockState NETHERRACK = BoundBlockState.of("minecraft:netherrack");
|
||||
private static final int INLET_SEA_LAYERS = 1;
|
||||
private static final int TIDAL_BANK_SHALLOW_CUT = 16;
|
||||
@Getter
|
||||
private final RNG rng;
|
||||
|
||||
@@ -87,16 +86,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The palette index for a column that erosion cut {@code cut} blocks down into. The offset is
|
||||
* clamped to the deepest authored layer so an exposed bank shows soil rather than raw rock,
|
||||
* while a depth past the authored soil still runs off the end and falls through to rock. A
|
||||
* cut of zero collapses to {@code depth}, leaving every uncut column untouched.
|
||||
*/
|
||||
static int strataIndex(int depth, int cut, int paletteSize) {
|
||||
return depth + Math.min(cut, Math.max(0, paletteSize - 1 - depth));
|
||||
}
|
||||
|
||||
private static IrisMaterialPalette rolePalette(WaterRole role, IrisHydrologyMaterials materials) {
|
||||
if (materials == null) {
|
||||
return null;
|
||||
@@ -135,7 +124,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
return painted == null ? layerBlock : painted;
|
||||
}
|
||||
|
||||
private static NativeBlockState submergedSoil(NativeBlockState block) {
|
||||
public static NativeBlockState submergedSoil(NativeBlockState block) {
|
||||
if (block == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -235,9 +224,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
int terrainSpan = terrainColumn == null ? -1 : terrainColumn.spanCount() - 1;
|
||||
int layerSurfaceY = he;
|
||||
int layerCeilingY = 0;
|
||||
boolean exposeStrata = role != WaterRole.NONE && seaFloor;
|
||||
Terrain3DColumn naturalColumn = exposeStrata ? complex.naturalTerrainColumn(realX, realZ) : null;
|
||||
int cut = 0;
|
||||
boolean keepGravityAway = materials != null && !materials.isAllowGravityBlocks();
|
||||
IrisMaterialPalette rolePalette = rolePalette(role, materials);
|
||||
int paintDepth = rolePalette == null ? 0 : roleDepth(role, materials);
|
||||
@@ -310,16 +296,8 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
continue;
|
||||
}
|
||||
if (blocks == null) {
|
||||
if (exposeStrata) {
|
||||
int naturalSurfaceY = naturalColumn == null
|
||||
? complex.naturalTrueHeight(realX, realZ) : naturalColumn.surfaceY(layerSurfaceY);
|
||||
cut = Math.max(0, naturalSurfaceY - layerSurfaceY);
|
||||
}
|
||||
blocks = biome.generateLayers(dimension, realX, realZ, rng,
|
||||
layerSurfaceY + cut + 1 - bedrockFloor, layerSurfaceY + cut, data, complex);
|
||||
if (exposeStrata && cut <= TIDAL_BANK_SHALLOW_CUT && complex.isTidalBank(realX, realZ)) {
|
||||
cut = 0;
|
||||
}
|
||||
layerSurfaceY + 1 - bedrockFloor, layerSurfaceY, data, complex);
|
||||
}
|
||||
|
||||
int deepFloor = Math.max(bedrockFloor, layerCeilingY > 0 ? layerCeilingY + 2 : 0);
|
||||
@@ -340,9 +318,8 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
continue;
|
||||
}
|
||||
|
||||
int strataIndex = strataIndex(depth, cut, blocks.size());
|
||||
NativeBlockState layerBlock = paintWaterMaterial(
|
||||
blocks.hasIndex(strataIndex) ? blocks.get(strataIndex) : null,
|
||||
blocks.hasIndex(depth) ? blocks.get(depth) : null,
|
||||
rolePalette, paintDepth, depth, rng, realX, i, realZ, data);
|
||||
if (submerged && layerSurfaceY == he) {
|
||||
layerBlock = submergedSoil(layerBlock);
|
||||
|
||||
@@ -14,6 +14,7 @@ import art.arcane.iris.structure.nativegen.NativeStructureStartPlan;
|
||||
import art.arcane.iris.structure.nativegen.NativeStructureVolumeIndex;
|
||||
import art.arcane.iris.structure.nativegen.StructureLocateSearch;
|
||||
import art.arcane.iris.structure.placement.IrisStructureLocator;
|
||||
import art.arcane.iris.structure.placement.IrisStructureStrata;
|
||||
import art.arcane.iris.structure.placement.IrisStructureWater;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockChangeSet;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockPositionPredicate;
|
||||
@@ -24,6 +25,7 @@ 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.nativelib.terrain.structure.StructureStrata;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
@@ -133,6 +135,11 @@ public final class BukkitStructureStagePolicy implements StructureStagePolicy<
|
||||
return IrisStructureWater.world(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureStrata strata(Engine context) {
|
||||
return IrisStructureStrata.world(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntBinaryOperator worldgenHeight(Engine context, int runtimeMinY, boolean floor) {
|
||||
return (x, z) -> Engine.hostHeight(context, x, z, floor) + runtimeMinY + 1;
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package art.arcane.iris.structure.placement;
|
||||
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.decoration.IrisOreBands;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.stage.IrisTerrainNormalActuator;
|
||||
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureStrata;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.stream.interpolation.Interpolated;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class IrisStructureStrata implements StructureStrata {
|
||||
private static final ProceduralStream<Double> FLAT_GROUND = ProceduralStream.of((x, z) -> 0D, Interpolated.DOUBLE);
|
||||
|
||||
private final IrisComplex complex;
|
||||
private final IrisDimension dimension;
|
||||
private final IrisData data;
|
||||
private final RNG rng;
|
||||
private final int offsetY;
|
||||
private final int bedrockFloor;
|
||||
private final boolean hideOres;
|
||||
|
||||
private IrisStructureStrata(Engine engine) {
|
||||
complex = Objects.requireNonNull(engine.getComplex(), "Structure strata require a terrain complex");
|
||||
dimension = engine.getDimension();
|
||||
data = engine.getData();
|
||||
rng = new RNG(engine.getSeedManager().getTerrain());
|
||||
offsetY = engine.getMinHeight();
|
||||
bedrockFloor = dimension.isBedrock() ? 1 : 0;
|
||||
hideOres = dimension.isHideOresForHiddenOre();
|
||||
}
|
||||
|
||||
public static StructureStrata world(Engine engine) {
|
||||
return new IrisStructureStrata(engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Column column(int x, int z, int surfaceY, boolean submerged) {
|
||||
long revision = ProvisionalSampling.revision();
|
||||
IrisBiome biome = complex.getTrueBiomeStream().get(x, z);
|
||||
IrisRegion region = complex.getRegionStream().get(x, z);
|
||||
NativeBlockState rock = complex.getRockStream().get(x, z);
|
||||
NativeBlockState mapped = complex.getImageMapRuntime().sampleSurfaceBlock(x, z);
|
||||
if (ProvisionalSampling.revision() != revision && !complex.isPlatformMainThread()) {
|
||||
throw new ProvisionalAnswerException("Structure strata at " + x + "," + z
|
||||
+ " read a provisional answer; structures are only fitted over final terrain.");
|
||||
}
|
||||
int surface = surfaceY - offsetY;
|
||||
KList<NativeBlockState> layers = biome.generateLayersWithSlope(dimension, x, z, rng,
|
||||
surface + 1 - bedrockFloor, surface, data, FLAT_GROUND);
|
||||
return new StrataColumn(x, z, surface, submerged, layers, mapped, rock, biome, region);
|
||||
}
|
||||
|
||||
private final class StrataColumn implements Column {
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final int surface;
|
||||
private final boolean submerged;
|
||||
private final KList<NativeBlockState> layers;
|
||||
private final NativeBlockState mapped;
|
||||
private final NativeBlockState rock;
|
||||
private final IrisOreBands biomeSurface;
|
||||
private final IrisOreBands regionSurface;
|
||||
private final IrisOreBands dimensionSurface;
|
||||
private final IrisOreBands biomeUnderground;
|
||||
private final IrisOreBands regionUnderground;
|
||||
private final IrisOreBands dimensionUnderground;
|
||||
|
||||
private StrataColumn(int x, int z, int surface, boolean submerged, KList<NativeBlockState> layers,
|
||||
NativeBlockState mapped, NativeBlockState rock, IrisBiome biome, IrisRegion region) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.surface = surface;
|
||||
this.submerged = submerged;
|
||||
this.layers = layers;
|
||||
this.mapped = mapped;
|
||||
this.rock = rock;
|
||||
biomeSurface = hideOres ? IrisOreBands.EMPTY : biome.getSurfaceOreBands();
|
||||
regionSurface = hideOres ? IrisOreBands.EMPTY : region.getSurfaceOreBands();
|
||||
dimensionSurface = hideOres ? IrisOreBands.EMPTY : dimension.getSurfaceOreBands();
|
||||
biomeUnderground = hideOres ? IrisOreBands.EMPTY : biome.getUndergroundOreBands();
|
||||
regionUnderground = hideOres ? IrisOreBands.EMPTY : region.getUndergroundOreBands();
|
||||
dimensionUnderground = hideOres ? IrisOreBands.EMPTY : dimension.getUndergroundOreBands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NativeBlockState block(int y) {
|
||||
int internalY = y - offsetY;
|
||||
NativeBlockState ore = ore(biomeSurface, regionSurface, dimensionSurface, internalY);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
int depth = surface - internalY;
|
||||
if (depth == 0 && mapped != null) {
|
||||
return submerged ? IrisTerrainNormalActuator.submergedSoil(mapped) : mapped;
|
||||
}
|
||||
if (layers.hasIndex(depth)) {
|
||||
NativeBlockState layer = layers.get(depth);
|
||||
return submerged ? IrisTerrainNormalActuator.submergedSoil(layer) : layer;
|
||||
}
|
||||
ore = ore(biomeUnderground, regionUnderground, dimensionUnderground, internalY);
|
||||
return ore != null ? ore : rock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int soilDepth() {
|
||||
return layers.size();
|
||||
}
|
||||
|
||||
private NativeBlockState ore(IrisOreBands first, IrisOreBands second, IrisOreBands third, int internalY) {
|
||||
NativeBlockState ore = null;
|
||||
if (first.contains(internalY)) {
|
||||
ore = first.generate(x, internalY, z, rng, data, data == null ? null : data.getEngine());
|
||||
}
|
||||
if (ore == null && second.contains(internalY)) {
|
||||
ore = second.generate(x, internalY, z, rng, data, data == null ? null : data.getEngine());
|
||||
}
|
||||
if (ore == null && third.contains(internalY)) {
|
||||
ore = third.generate(x, internalY, z, rng, data, data == null ? null : data.getEngine());
|
||||
}
|
||||
return ore;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-67
@@ -34,26 +34,18 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisTerrainNormalActuatorStrataCutTest {
|
||||
public class IrisTerrainNormalActuatorBankCutTest {
|
||||
@Rule
|
||||
public final PlatformBinding platform = PlatformBinding.mockPlatform();
|
||||
|
||||
@Test
|
||||
public void exposedBankCutDeeperThanThePaletteShowsTheDeepestAuthoredLayer() {
|
||||
public void aBankCutPaintsTheBiomeLayersFromItsNewSurface() {
|
||||
Fixture fixture = new Fixture(WaterRole.BANK);
|
||||
|
||||
Hunk<NativeBlockState> output = fixture.actuate();
|
||||
|
||||
assertBlock(fixture.dirt, output.get(0, 40, 0));
|
||||
assertBlock(fixture.grass, output.get(0, 40, 0));
|
||||
assertBlock(fixture.dirt, output.get(0, 39, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exposedBankBelowTheAuthoredSoilStillFallsThroughToRock() {
|
||||
Fixture fixture = new Fixture(WaterRole.BANK);
|
||||
|
||||
Hunk<NativeBlockState> output = fixture.actuate();
|
||||
|
||||
assertBlock(fixture.rock, output.get(0, 38, 0));
|
||||
}
|
||||
|
||||
@@ -69,21 +61,9 @@ public class IrisTerrainNormalActuatorStrataCutTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void everyDryWaterRoleExposesItsCutStrata() {
|
||||
for (WaterRole role : List.of(WaterRole.BANK, WaterRole.SHORE, WaterRole.POND_SHORE, WaterRole.DAM)) {
|
||||
Fixture fixture = new Fixture(role);
|
||||
|
||||
Hunk<NativeBlockState> output = fixture.actuate();
|
||||
|
||||
assertBlock(fixture.dirt, output.get(0, 40, 0));
|
||||
assertBlock(fixture.dirt, output.get(0, 39, 0));
|
||||
assertBlock(fixture.rock, output.get(0, 38, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wetAndNaturalColumnsKeepTheirPaletteAtTheCut() {
|
||||
for (WaterRole role : List.of(WaterRole.NONE, WaterRole.CHANNEL, WaterRole.POND)) {
|
||||
public void everyRoleKeepsItsPaletteAtTheCut() {
|
||||
for (WaterRole role : List.of(WaterRole.NONE, WaterRole.CHANNEL, WaterRole.POND,
|
||||
WaterRole.BANK, WaterRole.SHORE, WaterRole.POND_SHORE, WaterRole.DAM)) {
|
||||
Fixture fixture = new Fixture(role);
|
||||
|
||||
Hunk<NativeBlockState> output = fixture.actuate();
|
||||
@@ -94,47 +74,6 @@ public class IrisTerrainNormalActuatorStrataCutTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aSolidCutBankMeasuresItsCutFromTheNaturalHeight() {
|
||||
Fixture fixture = new Fixture(WaterRole.BANK);
|
||||
when(fixture.complex.terrainColumn(11, -4)).thenReturn(null);
|
||||
when(fixture.complex.naturalTerrainColumn(11, -4)).thenReturn(null);
|
||||
when(fixture.complex.naturalTrueHeight(11, -4)).thenReturn(62);
|
||||
|
||||
Hunk<NativeBlockState> output = fixture.actuate();
|
||||
|
||||
assertBlock(fixture.dirt, output.get(0, 60, 0));
|
||||
assertBlock(fixture.dirt, output.get(0, 59, 0));
|
||||
assertBlock(fixture.rock, output.get(0, 58, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aCutClampsToTheDeepestAuthoredLayerAndNoFurther() {
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(0, 6, 4));
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(1, 6, 4));
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(2, 6, 4));
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(3, 6, 4));
|
||||
assertEquals(4, IrisTerrainNormalActuator.strataIndex(4, 6, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aModestCutStillShiftsTheStrataInsteadOfClamping() {
|
||||
assertEquals(1, IrisTerrainNormalActuator.strataIndex(0, 1, 4));
|
||||
assertEquals(2, IrisTerrainNormalActuator.strataIndex(1, 1, 4));
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(2, 1, 4));
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(3, 1, 4));
|
||||
assertEquals(4, IrisTerrainNormalActuator.strataIndex(4, 1, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aZeroCutIndexesTheBiomePaletteByDepthAlone() {
|
||||
for (int paletteSize = 0; paletteSize <= 16; paletteSize++) {
|
||||
for (int depth = 0; depth <= 32; depth++) {
|
||||
assertEquals(depth, IrisTerrainNormalActuator.strataIndex(depth, 0, paletteSize));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertBlock(NativeBlockState expected, NativeBlockState actual) {
|
||||
assertEquals(expected.key(), actual == null ? null : actual.key());
|
||||
assertSame(expected, actual);
|
||||
+2
-10
@@ -252,9 +252,6 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
int terrainSpan = terrainColumn == null ? -1 : terrainColumn.spanCount() - 1;
|
||||
int layerSurfaceY = he;
|
||||
int layerCeilingY = 0;
|
||||
boolean exposeStrata = role != WaterRole.NONE && seaFloor;
|
||||
Terrain3DColumn naturalColumn = exposeStrata ? terrainColumn : null;
|
||||
int cut = 0;
|
||||
boolean keepGravityAway = materials != null && !materials.isAllowGravityBlocks();
|
||||
String paletteName = materials == null ? null : rolePalette(role);
|
||||
NativeBlockState paletteBlock = paletteName == null ? null : palettes.get(paletteName);
|
||||
@@ -321,12 +318,8 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
continue;
|
||||
}
|
||||
if (blocks == null) {
|
||||
if (exposeStrata) {
|
||||
int naturalSurfaceY = naturalColumn == null ? he + 5 : naturalColumn.surfaceY(layerSurfaceY);
|
||||
cut = Math.max(0, naturalSurfaceY - layerSurfaceY);
|
||||
}
|
||||
blocks = biome.generateLayers(dimension, realX, realZ, rng,
|
||||
layerSurfaceY + cut, layerSurfaceY + cut, data, complex);
|
||||
layerSurfaceY, layerSurfaceY, data, complex);
|
||||
}
|
||||
if (layerCeilingY > 0 && depth >= 2 && i - layerCeilingY < 2) {
|
||||
if (ceilingBlocks == null) {
|
||||
@@ -336,9 +329,8 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
h.setRaw(xf, i, zf, ceilingBlocks.hasIndex(ceilingDepth) ? ceilingBlocks.get(ceilingDepth) : rock);
|
||||
continue;
|
||||
}
|
||||
int strataIndex = IrisTerrainNormalActuator.strataIndex(depth, cut, blocks.size());
|
||||
NativeBlockState layerBlock = paletteBlock != null && depth < paintDepth ? paletteBlock
|
||||
: blocks.hasIndex(strataIndex) ? blocks.get(strataIndex) : null;
|
||||
: blocks.hasIndex(depth) ? blocks.get(depth) : null;
|
||||
if (layerBlock != null) {
|
||||
if (keepGravityAway && IrisProceduralBlocks.isGravityAffected(layerBlock)) {
|
||||
layerBlock = rock;
|
||||
|
||||
+8
-15
@@ -137,23 +137,16 @@ public class IrisTerrainNormalActuatorHydrologyTest {
|
||||
|
||||
Painter cliff = new Painter(WaterRole.INLET, HEAD);
|
||||
when(cliff.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND + 20);
|
||||
assertSame("a slot cut through the cliff shows the strata below the old surface", cliff.dirt, cliff.paint().get(0, GROUND, 0));
|
||||
assertSame("a slot cut through the cliff keeps the submerged soil top", submergedDirt, cliff.paint().get(0, GROUND, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shallowTidalBankCutsKeepTheBiomeSurfaceLayer() {
|
||||
Painter cut = new Painter(WaterRole.BANK, 0);
|
||||
when(cut.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND + 3);
|
||||
NativeBlockState stripped = cut.paint().get(0, GROUND, 0);
|
||||
Painter tidal = new Painter(WaterRole.BANK, 0);
|
||||
when(tidal.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND + 3);
|
||||
when(tidal.complex.isTidalBank(11, -4)).thenReturn(true);
|
||||
assertSame("the shallow tidal cut is resurfaced", tidal.grass, tidal.paint().get(0, GROUND, 0));
|
||||
assertSame("a river bank keeps its strata", cut.dirt, stripped);
|
||||
Painter deep = new Painter(WaterRole.BANK, 0);
|
||||
when(deep.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND + 20);
|
||||
when(deep.complex.isTidalBank(11, -4)).thenReturn(true);
|
||||
assertSame("a deep tidal cut shows the strata", deep.dirt, deep.paint().get(0, GROUND, 0));
|
||||
public void bankCutsOfAnyDepthKeepTheBiomeSurfaceLayer() {
|
||||
for (int cut : new int[]{1, 3, 16, 20, 60}) {
|
||||
Painter bank = new Painter(WaterRole.BANK, 0);
|
||||
when(bank.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND + cut);
|
||||
assertSame("a cut of " + cut, bank.grass, bank.paint().get(0, GROUND, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -395,7 +388,7 @@ public class IrisTerrainNormalActuatorHydrologyTest {
|
||||
materials.setShore(null).setBank(null);
|
||||
output = painter.paint();
|
||||
assertSame(role.name(), painter.grass, output.get(0, 60, 0));
|
||||
assertSame(role.name(), painter.dirt, output.get(0, 40, 0));
|
||||
assertSame(role.name(), painter.grass, output.get(0, 40, 0));
|
||||
assertSame(role.name(), painter.rock, output.get(0, 38, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package art.arcane.iris.structure.placement;
|
||||
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.decoration.IrisOreBands;
|
||||
import art.arcane.iris.generation.image.IrisImageMapRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.runtime.SeedManager;
|
||||
import art.arcane.iris.generation.stage.IrisTerrainNormalActuator;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.testsupport.PlatformBinding;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureStrata;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import art.arcane.volmlib.util.stream.interpolation.Interpolated;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisStructureStrataTest {
|
||||
private static final int MIN_HEIGHT = -64;
|
||||
|
||||
@Rule
|
||||
public final PlatformBinding platform = PlatformBinding.mockPlatform();
|
||||
|
||||
private final NativeBlockState rock = state("minecraft:stone");
|
||||
private final NativeBlockState grass = state("minecraft:grass_block");
|
||||
private final NativeBlockState dirt = state("minecraft:dirt");
|
||||
private final Engine engine = mock(Engine.class);
|
||||
private final IrisComplex complex = mock(IrisComplex.class);
|
||||
private final IrisBiome biome = mock(IrisBiome.class);
|
||||
private final IrisImageMapRuntime imageMap = mock(IrisImageMapRuntime.class);
|
||||
private final IrisData data = mock(IrisData.class);
|
||||
private final IrisDimension dimension = new IrisDimension().setBedrock(true).setHideOresForHiddenOre(true);
|
||||
|
||||
@Before
|
||||
public void wireEngine() {
|
||||
IrisRegion region = new IrisRegion();
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getSeedManager()).thenReturn(mock(SeedManager.class));
|
||||
when(engine.getMinHeight()).thenReturn(MIN_HEIGHT);
|
||||
when(complex.getTrueBiomeStream()).thenReturn(ProceduralStream.of((x, z) -> biome, Interpolated.of(value -> 0D, value -> biome)));
|
||||
when(complex.getRegionStream()).thenReturn(ProceduralStream.of((x, z) -> region, Interpolated.of(value -> 0D, value -> region)));
|
||||
when(complex.getRockStream()).thenReturn(ProceduralStream.of((x, z) -> rock, Interpolated.of(value -> 0D, value -> rock)));
|
||||
when(complex.getImageMapRuntime()).thenReturn(imageMap);
|
||||
when(biome.generateLayersWithSlope(eq(dimension), anyDouble(), anyDouble(), any(RNG.class),
|
||||
anyInt(), anyInt(), eq(data), any())).thenReturn(new KList<>(List.of(grass, dirt, dirt)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aColumnPaintsTheBiomeSurfaceThenSoilThenRockDownFromItsSurface() {
|
||||
StructureStrata.Column column = IrisStructureStrata.world(engine).column(3, 5, 90, false);
|
||||
|
||||
assertSame(grass, column.block(90));
|
||||
assertSame(dirt, column.block(89));
|
||||
assertSame(dirt, column.block(88));
|
||||
assertSame(rock, column.block(87));
|
||||
assertSame(rock, column.block(40));
|
||||
assertEquals(3, column.soilDepth());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void layersComeFromTheInternalSurfaceHeight() {
|
||||
IrisStructureStrata.world(engine).column(3, 5, 90, false);
|
||||
|
||||
verify(biome).generateLayersWithSlope(eq(dimension), eq(3D), eq(5D), any(RNG.class),
|
||||
eq(90 - MIN_HEIGHT), eq(90 - MIN_HEIGHT), eq(data), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aMappedSurfaceReplacesOnlyTheTopBlock() {
|
||||
NativeBlockState mapped = state("minecraft:podzol");
|
||||
when(imageMap.sampleSurfaceBlock(3, 5)).thenReturn(mapped);
|
||||
|
||||
StructureStrata.Column column = IrisStructureStrata.world(engine).column(3, 5, 90, false);
|
||||
|
||||
assertSame(mapped, column.block(90));
|
||||
assertSame(dirt, column.block(89));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aSubmergedSurfaceTakesSoilInsteadOfLivingGrass() {
|
||||
StructureStrata.Column column = IrisStructureStrata.world(engine).column(3, 5, 50, true);
|
||||
|
||||
assertSame(IrisTerrainNormalActuator.submergedSoil(grass), column.block(50));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oreBandsAreSampledAtEachHeightSoAFillNeverStretchesOneOreBlock() {
|
||||
dimension.setHideOresForHiddenOre(false);
|
||||
NativeBlockState coal = state("minecraft:coal_ore");
|
||||
IrisOreBands bands = mock(IrisOreBands.class);
|
||||
when(biome.getSurfaceOreBands()).thenReturn(IrisOreBands.EMPTY);
|
||||
when(biome.getUndergroundOreBands()).thenReturn(bands);
|
||||
when(bands.contains(anyInt())).thenReturn(true);
|
||||
when(bands.generate(eq(3), eq(40 - MIN_HEIGHT), eq(5), any(RNG.class), eq(data), any())).thenReturn(coal);
|
||||
|
||||
StructureStrata.Column column = IrisStructureStrata.world(engine).column(3, 5, 90, false);
|
||||
|
||||
assertSame(coal, column.block(40));
|
||||
assertSame(rock, column.block(41));
|
||||
}
|
||||
|
||||
private static NativeBlockState state(String key) {
|
||||
NativeBlockState state = mock(NativeBlockState.class);
|
||||
when(state.key()).thenReturn(key);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user