mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 08:14:45 +00:00
Veto springs near structures
- Drop a spring when an imported structure piece lies within 32 blocks, from world minimum to one block above the seep - Pass the seep position to the carved terrain structure check - Clear the block update when a pool wall replaces a spring - Pin the spring guards with behaviour tests across several seeds - Pin startsNear reach and the springs-only component and runtime gates
This commit is contained in:
11 files changed
+335
-26
No files matched your search
+1
-1
@@ -7,5 +7,5 @@ public interface CarvedTerrain {
|
||||
|
||||
String caveFluid(int x, int y, int z);
|
||||
|
||||
boolean structureNear();
|
||||
boolean structureNear(int x, int y, int z);
|
||||
}
|
||||
+6
-1
@@ -5,6 +5,7 @@ import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||
import art.arcane.iris.generation.hydrology.grid.CellHash;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.mantle.MantleWriter;
|
||||
import art.arcane.volmlib.util.matter.slices.UpdateMatter;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
|
||||
@@ -174,9 +175,13 @@ public final class CavePoolFiller {
|
||||
}
|
||||
int y = unpackY(cell);
|
||||
HydrologyCaveCell existing = writer.getDataIfPresent(x, y, z, HydrologyCaveCell.class);
|
||||
if (existing == null || existing.action() == HydrologyCaveAction.SPRING_SOURCE || replacesSharedWall(existing, value)) {
|
||||
boolean spring = existing != null && existing.action() == HydrologyCaveAction.SPRING_SOURCE;
|
||||
if (existing == null || spring || replacesSharedWall(existing, value)) {
|
||||
writer.setData(x, y, z, value);
|
||||
}
|
||||
if (spring) {
|
||||
writer.setData(x, y, z, UpdateMatter.OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public final class CaveSpringPlacer {
|
||||
int x = (chunkX << 4) + (int) (column & 15);
|
||||
int z = (chunkZ << 4) + (int) ((column >>> 4) & 15);
|
||||
int y = seep(carved, x, z, seed);
|
||||
if (y >= 0 && contained(carved, x, y, z) && !carved.structureNear()) {
|
||||
if (y >= 0 && contained(carved, x, y, z) && !carved.structureNear(x, y, z)) {
|
||||
write(chunkX, chunkZ, x, y, z, new HydrologyCaveCell(HydrologyCaveAction.SPRING_SOURCE, fluid(carved, x, y, z)), writer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.generation.terrain.Terrain3DColumn;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementScope;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.NativeStructureVolume;
|
||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
@@ -31,6 +32,7 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
||||
private static final int SPAN = 48;
|
||||
private static final int UNKNOWN = Integer.MIN_VALUE;
|
||||
private static final int STRUCTURE_REACH_CHUNKS = 8;
|
||||
private static final int IMPORTED_STRUCTURE_REACH = 32;
|
||||
|
||||
private final MantleWriter writer;
|
||||
private final IrisComplex complex;
|
||||
@@ -123,13 +125,27 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean structureNear() {
|
||||
public boolean structureNear(int x, int y, int z) {
|
||||
long revision = ProvisionalSampling.revision();
|
||||
boolean near = StructurePlacementScope.startsNear(engine, chunkX, chunkZ, STRUCTURE_REACH_CHUNKS);
|
||||
boolean near = importedStructureNear(x, y, z) || StructurePlacementScope.startsNear(engine, chunkX, chunkZ, STRUCTURE_REACH_CHUNKS);
|
||||
requireFinal(revision, chunkX << 4, chunkZ << 4);
|
||||
return near;
|
||||
}
|
||||
|
||||
private boolean importedStructureNear(int x, int y, int z) {
|
||||
int minX = x - IMPORTED_STRUCTURE_REACH;
|
||||
int minZ = z - IMPORTED_STRUCTURE_REACH;
|
||||
int maxX = x + IMPORTED_STRUCTURE_REACH;
|
||||
int maxZ = z + IMPORTED_STRUCTURE_REACH;
|
||||
int maxY = y + minimumY + 1;
|
||||
for (NativeStructureVolume volume : engine.getNativeStructureVolumes(minX, minZ, maxX, maxZ)) {
|
||||
if (volume.intersects(minX, minimumY, minZ, maxX, maxY, maxZ)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Collection<SeaInlet> inlets(HydrologyRuntime runtime, int chunkX, int chunkZ) {
|
||||
Map<Long, SeaInlet> inlets = new LinkedHashMap<>();
|
||||
for (int offsetZ = -1; offsetZ <= 1; offsetZ++) {
|
||||
|
||||
+25
@@ -950,6 +950,31 @@ public class HydrologyRuntimeTest {
|
||||
assertDisabled(HydrologyRuntime.create(engine, complex));
|
||||
}
|
||||
|
||||
@Test(timeout = 180_000L)
|
||||
public void policyFluidsReachSpringsWithCavePoolsOff() throws Exception {
|
||||
try (EngineFixture.Environment ignored = EngineFixture.environment();
|
||||
EngineFixture fixture = new EngineFixture(EngineFixture.pack(temporaryFolder.newFolder().toPath(), false))) {
|
||||
IrisHydrology config = new IrisHydrology().setEnabled(true).setPrefetchRings(0);
|
||||
config.getUnderground().getCavePools().setEnabled(false);
|
||||
config.getUnderground().getCaveSprings().setFluid("water");
|
||||
fixture.dimension.setHydrology(config);
|
||||
fixture.dimension.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("water"));
|
||||
|
||||
assertFalse(caveFluidPolicies(fixture));
|
||||
config.getUnderground().getCaveSprings().setEnabled(true);
|
||||
assertTrue(caveFluidPolicies(fixture));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean caveFluidPolicies(EngineFixture fixture) {
|
||||
HydrologyRuntime runtime = HydrologyRuntime.create(fixture.engine, fixture.complex);
|
||||
try {
|
||||
return runtime.caveFluidPolicies();
|
||||
} finally {
|
||||
runtime.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zeroDensitySkipsRuntimePlanningAfterValidatingSettings() throws Exception {
|
||||
Engine engine = mock(Engine.class);
|
||||
|
||||
+1
-1
@@ -516,7 +516,7 @@ public class CavePoolFillerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean structureNear() {
|
||||
public boolean structureNear(int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+165
-18
@@ -39,6 +39,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
public class CaveSpringPlacerTest {
|
||||
private static final long SEED = 1337L;
|
||||
private static final long[] SEEDS = {1337L, 42L, 7L, 99L, 2048L, -5L, 31337L, 88L};
|
||||
private static final int FLOOR = 50;
|
||||
private static final int CEILING = 70;
|
||||
private static final int[][] SIDES = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
@@ -47,8 +48,10 @@ public class CaveSpringPlacerTest {
|
||||
public void placesOneSourceInARockWallAboveAnOpeningAndAsksForAnUpdate() {
|
||||
World world = pillars();
|
||||
Recorder recorder = new Recorder();
|
||||
placer(springs -> {
|
||||
}).place(0, 0, () -> world, recorder.writer, SEED);
|
||||
for (long seed : SEEDS) {
|
||||
placer(springs -> {
|
||||
}).place(0, 0, () -> world, recorder.writer, seed);
|
||||
}
|
||||
|
||||
assertFalse(recorder.cells.isEmpty());
|
||||
for (Map.Entry<Long, HydrologyCaveCell> entry : recorder.cells.entrySet()) {
|
||||
@@ -122,24 +125,26 @@ public class CaveSpringPlacerTest {
|
||||
World world = pillars();
|
||||
CaveSpringPlacer placer = placer(springs -> {
|
||||
});
|
||||
Recorder forward = new Recorder();
|
||||
List<int[]> chunks = new ArrayList<>();
|
||||
for (int chunkX = -2; chunkX <= 2; chunkX++) {
|
||||
for (int chunkZ = -2; chunkZ <= 2; chunkZ++) {
|
||||
chunks.add(new int[]{chunkX, chunkZ});
|
||||
}
|
||||
}
|
||||
for (int[] chunk : chunks) {
|
||||
placer.place(chunk[0], chunk[1], () -> world, forward.writer, SEED);
|
||||
for (long seed : SEEDS) {
|
||||
Recorder forward = new Recorder();
|
||||
for (int[] chunk : chunks) {
|
||||
placer.place(chunk[0], chunk[1], () -> world, forward.writer, seed);
|
||||
}
|
||||
Collections.shuffle(chunks, new Random(seed));
|
||||
Recorder shuffled = new Recorder();
|
||||
for (int[] chunk : chunks) {
|
||||
placer.place(chunk[0], chunk[1], () -> world, shuffled.writer, seed);
|
||||
}
|
||||
assertFalse(forward.cells.isEmpty());
|
||||
assertEquals(forward.cells, shuffled.cells);
|
||||
assertEquals(forward.updates.keySet(), shuffled.updates.keySet());
|
||||
}
|
||||
Collections.shuffle(chunks, new Random(SEED));
|
||||
Recorder shuffled = new Recorder();
|
||||
for (int[] chunk : chunks) {
|
||||
placer.place(chunk[0], chunk[1], () -> world, shuffled.writer, SEED);
|
||||
}
|
||||
assertFalse(forward.cells.isEmpty());
|
||||
assertEquals(forward.cells, shuffled.cells);
|
||||
assertEquals(forward.updates.keySet(), shuffled.updates.keySet());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,6 +166,110 @@ public class CaveSpringPlacerTest {
|
||||
place(sloped, springs -> springs.setMinDepthBelowSurface(16)).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theFlowKeepsMinDepthOnGroundThatStaysAboveIt() {
|
||||
World lowGround = pillars();
|
||||
lowGround.surfaceAt = (x, z) -> x >= 8 ? 60 : 200;
|
||||
assertFalse("the floor at 51 lies 9 under the low ground",
|
||||
place(lowGround, springs -> springs.setMinDepthBelowSurface(9)).isEmpty());
|
||||
assertTrue("the same floor is too shallow for 10",
|
||||
place(lowGround, springs -> springs.setMinDepthBelowSurface(10)).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aForeignCellBesideTheSeepDropsItEvenWithAnotherSideOpen() {
|
||||
World walled = pillars();
|
||||
for (int x = -16; x < 32; x++) {
|
||||
for (int z = -16; z < 32; z++) {
|
||||
if (Math.floorMod(x + z, 2) == 1 && Math.floorMod(z, 2) == 1) {
|
||||
for (int y = FLOOR + 2; y <= CEILING; y++) {
|
||||
walled.foreign(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue(place(walled, springs -> {
|
||||
}).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anOpeningWithNoDropHoldsNoSeep() {
|
||||
World slit = new World();
|
||||
World drop = new World();
|
||||
for (int x = -16; x < 32; x++) {
|
||||
for (int z = -16; z < 32; z++) {
|
||||
if (Math.floorMod(x + z, 2) == 1) {
|
||||
slit.carve(x, x, z, z, 60, 60);
|
||||
drop.carve(x, x, z, z, 59, 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue(place(slit, springs -> {
|
||||
}).isEmpty());
|
||||
assertFalse(place(drop, springs -> {
|
||||
}).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aSeepNeedsRockDirectlyAboveAndBelow() {
|
||||
World layered = pillars();
|
||||
for (int x = -16; x < 32; x++) {
|
||||
for (int z = -16; z < 32; z++) {
|
||||
if (Math.floorMod(x + z, 2) == 0) {
|
||||
for (int y = FLOOR + 4; y <= CEILING; y += 3) {
|
||||
layered.carve(x, x, z, z, y, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue("every wall block has air directly above or below it", place(layered, springs -> {
|
||||
}).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void seepsCoverEveryColumnOfTheirChunk() {
|
||||
World world = pillars();
|
||||
CaveSpringPlacer placer = placer(springs -> {
|
||||
});
|
||||
Recorder recorder = new Recorder();
|
||||
for (long seed = 0L; seed < 128L; seed++) {
|
||||
placer.place(0, 0, () -> world, recorder.writer, seed);
|
||||
}
|
||||
Set<Integer> xs = new HashSet<>();
|
||||
Set<Integer> zs = new HashSet<>();
|
||||
for (long cell : recorder.cells.keySet()) {
|
||||
xs.add(x(cell));
|
||||
zs.add(z(cell));
|
||||
}
|
||||
Set<Integer> chunk = new HashSet<>();
|
||||
for (int column = 0; column < 16; column++) {
|
||||
chunk.add(column);
|
||||
}
|
||||
assertEquals(chunk, xs);
|
||||
assertEquals(chunk, zs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theFlowIsFollowedFifteenBlocksAndNoFurther() {
|
||||
Consumer<IrisCaveSprings> one = springs -> springs.setDensity(1D);
|
||||
int checked = 0;
|
||||
for (long seed : SEEDS) {
|
||||
Map<Long, HydrologyCaveCell> clean = placeAt(pillars(), seed, one);
|
||||
for (long cell : clean.keySet()) {
|
||||
for (int[] side : SIDES) {
|
||||
World inside = pillars();
|
||||
inside.foreign(x(cell) + side[0] * 15, FLOOR, z(cell) + side[1] * 15);
|
||||
assertTrue(placeAt(inside, seed, one).isEmpty());
|
||||
World outside = pillars();
|
||||
outside.foreign(x(cell) + side[0] * 16, FLOOR, z(cell) + side[1] * 16);
|
||||
assertEquals(clean, placeAt(outside, seed, one));
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue(checked > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aSeepThatWouldOpenOntoTheSurfaceIsDropped() {
|
||||
World open = pillars();
|
||||
@@ -194,11 +303,26 @@ public class CaveSpringPlacerTest {
|
||||
@Test
|
||||
public void structuresNearbyDropTheSpring() {
|
||||
World world = pillars();
|
||||
world.structures = true;
|
||||
world.structures = (x, y, z) -> true;
|
||||
assertTrue(place(world, springs -> {
|
||||
}).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theStructureCheckIsAskedAboutTheSeepItself() {
|
||||
Consumer<IrisCaveSprings> one = springs -> springs.setDensity(1D);
|
||||
int checked = 0;
|
||||
for (long seed : SEEDS) {
|
||||
for (long cell : placeAt(pillars(), seed, one).keySet()) {
|
||||
World world = pillars();
|
||||
world.structures = (x, y, z) -> key(x, y, z) == cell;
|
||||
assertTrue(placeAt(world, seed, one).isEmpty());
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
assertTrue(checked > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void poolWallsWinOverSpringsWhicheverChunkWritesFirst() {
|
||||
World world = new World();
|
||||
@@ -218,6 +342,7 @@ public class CaveSpringPlacerTest {
|
||||
placer.place(0, 0, () -> world, poolsFirst.writer, SEED);
|
||||
|
||||
assertEquals(springsFirst.cells, poolsFirst.cells);
|
||||
assertEquals("a replaced spring asks for no block update", liveUpdates(poolsFirst), liveUpdates(springsFirst));
|
||||
Set<Long> replaced = new HashSet<>();
|
||||
for (long cell : placed.keySet()) {
|
||||
if (springsFirst.cells.get(cell).action() == HydrologyCaveAction.SEAL_GUARD) {
|
||||
@@ -232,11 +357,29 @@ public class CaveSpringPlacerTest {
|
||||
}
|
||||
|
||||
private static Map<Long, HydrologyCaveCell> place(World world, Consumer<IrisCaveSprings> springs) {
|
||||
Map<Long, HydrologyCaveCell> written = new HashMap<>();
|
||||
for (long seed : SEEDS) {
|
||||
written.putAll(placeAt(world, seed, springs));
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
private static Map<Long, HydrologyCaveCell> placeAt(World world, long seed, Consumer<IrisCaveSprings> springs) {
|
||||
Recorder recorder = new Recorder();
|
||||
placer(springs).place(0, 0, () -> world, recorder.writer, SEED);
|
||||
placer(springs).place(0, 0, () -> world, recorder.writer, seed);
|
||||
return recorder.cells;
|
||||
}
|
||||
|
||||
private static Set<Long> liveUpdates(Recorder recorder) {
|
||||
Set<Long> live = new HashSet<>();
|
||||
for (Map.Entry<Long, MatterUpdate> update : recorder.updates.entrySet()) {
|
||||
if (update.getValue().isUpdate()) {
|
||||
live.add(update.getKey());
|
||||
}
|
||||
}
|
||||
return live;
|
||||
}
|
||||
|
||||
private static IrisHydrology config(Consumer<IrisCaveSprings> springs) {
|
||||
IrisHydrology config = new IrisHydrology().setEnabled(true);
|
||||
config.getFluids().add(new IrisFluidProfile().setName("lava").setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:lava")));
|
||||
@@ -286,6 +429,10 @@ public class CaveSpringPlacerTest {
|
||||
int at(int x, int z);
|
||||
}
|
||||
|
||||
private interface StructureAt {
|
||||
boolean at(int x, int y, int z);
|
||||
}
|
||||
|
||||
private static final class Recorder {
|
||||
private final Map<Long, HydrologyCaveCell> cells = new HashMap<>();
|
||||
private final Map<Long, MatterUpdate> updates = new HashMap<>();
|
||||
@@ -318,7 +465,7 @@ public class CaveSpringPlacerTest {
|
||||
private SurfaceAt surfaceAt;
|
||||
private IntFunction<String> policyFluid = x -> null;
|
||||
private int historicMinX = Integer.MAX_VALUE;
|
||||
private boolean structures;
|
||||
private StructureAt structures = (x, y, z) -> false;
|
||||
|
||||
void carve(int minX, int maxX, int minZ, int maxZ, int minY, int maxY) {
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
@@ -364,8 +511,8 @@ public class CaveSpringPlacerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean structureNear() {
|
||||
return structures;
|
||||
public boolean structureNear(int x, int y, int z) {
|
||||
return structures.at(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import art.arcane.iris.generation.hydrology.underground.SeaInletRasterizer;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.EnginePlatformHooks;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.runtime.SeedManager;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainCell;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainPlan;
|
||||
@@ -23,10 +24,13 @@ import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.generation.terrain.Terrain3DColumn;
|
||||
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
||||
import art.arcane.iris.structure.placement.StructureDistribution;
|
||||
import art.arcane.iris.world.IrisWorld;
|
||||
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
||||
import art.arcane.iris.world.storage.matter.PreObjectMatterCell;
|
||||
import art.arcane.iris.world.storage.matter.PreObjectMatterTest;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.NativeStructureVolume;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
||||
@@ -268,6 +272,60 @@ public class MantleCarvedTerrainTest {
|
||||
poolFluids(poolRoom(new Underground(volcanic, magma, region("temperate", null), new IrisDimension())).generate(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importedStructuresWithinTheFlowsReachAndBelowTheSeepTopAreNear() {
|
||||
assertFalse(nearSeep());
|
||||
assertTrue("on the seep", nearSeep(volume(8, -34, 8, 8, -34, 8)));
|
||||
assertTrue("at the bottom of the world", nearSeep(volume(8, -64, 8, 8, -64, 8)));
|
||||
assertTrue("one block above the seep", nearSeep(volume(8, -33, 8, 8, -20, 8)));
|
||||
assertFalse("above that", nearSeep(volume(8, -32, 8, 8, -20, 8)));
|
||||
assertTrue(nearSeep(volume(40, -60, 8, 50, -50, 8)));
|
||||
assertFalse(nearSeep(volume(41, -60, 8, 50, -50, 8)));
|
||||
assertTrue(nearSeep(volume(-30, -60, 8, -24, -50, 8)));
|
||||
assertFalse(nearSeep(volume(-30, -60, 8, -25, -50, 8)));
|
||||
assertTrue(nearSeep(volume(8, -60, 40, 8, -50, 50)));
|
||||
assertFalse(nearSeep(volume(8, -60, 41, 8, -50, 50)));
|
||||
assertTrue(nearSeep(volume(8, -60, -30, 8, -50, -24)));
|
||||
assertFalse(nearSeep(volume(8, -60, -30, 8, -50, -25)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void placementsThatCanStartNearbyAreNear() {
|
||||
Scene scene = structureScene();
|
||||
assertFalse(scene.carved().structureNear(8, 30, 8));
|
||||
|
||||
Scene dense = structureScene();
|
||||
dense.engine.getDimension().setStructures(new KList<>(new IrisStructurePlacement().setDistribution(StructureDistribution.DENSITY).setDensity(1D)));
|
||||
assertTrue(dense.carved().structureNear(8, 30, 8));
|
||||
}
|
||||
|
||||
private static boolean nearSeep(NativeStructureVolume... volumes) {
|
||||
return structureScene(volumes).carved().structureNear(8, 30, 8);
|
||||
}
|
||||
|
||||
private static NativeStructureVolume volume(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||
return new NativeStructureVolume("minecraft:mineshaft", minX, minY, minZ, maxX, maxY, maxZ, null);
|
||||
}
|
||||
|
||||
private static Scene structureScene(NativeStructureVolume... volumes) {
|
||||
Scene scene = new Scene();
|
||||
IrisWorld world = mock(IrisWorld.class);
|
||||
when(world.minHeight()).thenReturn(-64);
|
||||
when(scene.engine.getWorld()).thenReturn(world);
|
||||
when(scene.engine.getSeedManager()).thenReturn(new SeedManager(SEED));
|
||||
when(scene.engine.getAllBiomes()).thenReturn(new KList<>());
|
||||
when(scene.engine.getNativeStructureVolumes(anyInt(), anyInt(), anyInt(), anyInt())).thenAnswer(invocation -> {
|
||||
KList<NativeStructureVolume> matches = new KList<>();
|
||||
for (NativeStructureVolume volume : volumes) {
|
||||
if (volume.intersectsInfluenceRect(invocation.getArgument(0), invocation.getArgument(1), invocation.getArgument(2), invocation.getArgument(3))) {
|
||||
matches.add(volume);
|
||||
}
|
||||
}
|
||||
return matches;
|
||||
});
|
||||
return scene;
|
||||
}
|
||||
|
||||
private static Scene poolRoom(Underground underground) {
|
||||
Scene scene = new Scene(underground);
|
||||
Matter[] room = scene.chunk(0, 0);
|
||||
|
||||
+19
@@ -8,6 +8,7 @@ import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
import art.arcane.iris.generation.hydrology.underground.CavePoolFiller;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
@@ -84,6 +85,24 @@ public class MantleHydrologyComponentTest {
|
||||
assertFalse(MantleHydrologyComponent.isEnabledFor(dimension));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springsAloneKeepTheCaveWaterReach() {
|
||||
IrisDimension dimension = new IrisDimension();
|
||||
IrisHydrology hydrology = new IrisHydrology().setEnabled(true);
|
||||
hydrology.getUnderground().getCavePools().setEnabled(false);
|
||||
dimension.setHydrology(hydrology);
|
||||
Engine engine = mock(Engine.class);
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
EngineMantle mantle = mock(EngineMantle.class);
|
||||
when(mantle.getEngine()).thenReturn(engine);
|
||||
MantleHydrologyComponent component = new MantleHydrologyComponent(mantle);
|
||||
|
||||
assertEquals(0, component.getInputRadius());
|
||||
hydrology.getUnderground().getCaveSprings().setEnabled(true);
|
||||
assertEquals(CavePoolFiller.REACH, component.getInputRadius());
|
||||
assertEquals(CavePoolFiller.REACH, component.computeRadius());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void everyDropBetweenWetColumnsFallsFromTheHigherHead() {
|
||||
MantleHydrologyComponent.Falls falls = MantleHydrologyComponent.plan(0, 0, WORLD_HEIGHT,
|
||||
|
||||
+1
-1
@@ -446,7 +446,7 @@ public class IrisCarveModifierHydrologyTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean structureNear() {
|
||||
public boolean structureNear(int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+40
-1
@@ -12,6 +12,8 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class StructurePlacementScopeStartsNearTest {
|
||||
private static final long MANTLE_SEED = 1337L;
|
||||
|
||||
@Test
|
||||
public void reportsAStartWithinTheReachAndNothingOutsideIt() {
|
||||
IrisStructurePlacement dense = new IrisStructurePlacement().setDistribution(StructureDistribution.DENSITY).setDensity(1D);
|
||||
@@ -22,10 +24,47 @@ public class StructurePlacementScopeStartsNearTest {
|
||||
assertFalse(StructurePlacementScope.startsNear(engine(new KList<>()), 3, -2, 8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aStartCountsExactlyUpToTheReachOnEverySide() {
|
||||
IrisStructurePlacement sparse = new IrisStructurePlacement().setDistribution(StructureDistribution.DENSITY).setDensity(0.0005D);
|
||||
Engine engine = engine(new KList<>(sparse));
|
||||
int[] start = loneStart(sparse);
|
||||
for (int reach : new int[]{1, 3, 8}) {
|
||||
for (int[] side : new int[][]{{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {-1, -1}}) {
|
||||
int chunkX = start[0] + side[0] * reach;
|
||||
int chunkZ = start[1] + side[1] * reach;
|
||||
assertTrue(StructurePlacementScope.startsNear(engine, chunkX, chunkZ, reach));
|
||||
assertFalse(StructurePlacementScope.startsNear(engine, chunkX, chunkZ, reach - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int[] loneStart(IrisStructurePlacement placement) {
|
||||
for (int x = 0; x < 4096; x++) {
|
||||
for (int z = 0; z < 4096; z++) {
|
||||
if (StructurePlacementGrid.startsInChunk(placement, x, z, MANTLE_SEED) && alone(placement, x, z)) {
|
||||
return new int[]{x, z};
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new AssertionError("No lone start in the searched chunks");
|
||||
}
|
||||
|
||||
private static boolean alone(IrisStructurePlacement placement, int startX, int startZ) {
|
||||
for (int x = startX - 16; x <= startX + 16; x++) {
|
||||
for (int z = startZ - 16; z <= startZ + 16; z++) {
|
||||
if ((x != startX || z != startZ) && StructurePlacementGrid.startsInChunk(placement, x, z, MANTLE_SEED)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Engine engine(KList<IrisStructurePlacement> placements) {
|
||||
Engine engine = mock(Engine.class);
|
||||
SeedManager seeds = mock(SeedManager.class);
|
||||
when(seeds.getMantle()).thenReturn(1337L);
|
||||
when(seeds.getMantle()).thenReturn(MANTLE_SEED);
|
||||
when(engine.getSeedManager()).thenReturn(seeds);
|
||||
IrisDimension dimension = new IrisDimension();
|
||||
dimension.setStructures(placements);
|
||||
|
||||
Reference in new issue
Block a user