mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Merge stream lowering
- Streams go down with structure cuts - Recaptures the schema digest for F1 and F3 together
This commit is contained in:
commit
1ddda75efb
10 files changed
+853
-90
No files matched your search
+93
-44
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWaterColumn;
|
||||
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.terrain.NativeStructureVerticalPlacer;
|
||||
|
||||
@@ -241,7 +242,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)),
|
||||
(x, z) -> x < 2 ? groundY - 32 : groundY + 32, SeaSurface.NONE);
|
||||
(x, z) -> x < 2 ? groundY - 32 : groundY + 32, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int x = 0; x <= 3; x++) {
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, x, groundY, 0));
|
||||
@@ -269,7 +270,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
put(blocks, 0, groundY - 19, 0, Blocks.DIRT.defaultBlockState());
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY, SeaSurface.NONE);
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = groundY - 19; y <= groundY; y++) {
|
||||
assertEquals(Blocks.DIRT.defaultBlockState(), state(blocks, 0, y, 0));
|
||||
@@ -295,7 +296,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureTerrainIntegrator.TerrainTarget target = surfaceTarget(start, StructureTerrainMode.FLATTEN);
|
||||
((IrisStructureTerrain) target.terrain()).setHorizontalPadding(24).setFlattenRange(64);
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area, List.of(target), (px, pz) -> groundY, SeaSurface.NONE);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area, List.of(target), (px, pz) -> groundY, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = groundY - 34; y <= groundY - 13; y++) {
|
||||
assertEquals("Cave at " + y, Blocks.CAVE_AIR.defaultBlockState(), state(blocks, x, y, z));
|
||||
@@ -318,7 +319,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
}
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY, SeaSurface.NONE);
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = groundY - 8; y < groundY; y++) {
|
||||
assertEquals("Foundation at " + y, Blocks.STONE.defaultBlockState(), state(blocks, 0, y, 0));
|
||||
@@ -340,9 +341,9 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
Map<BlockPos, BlockState> originalSubmerged = new HashMap<>(submerged);
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(buried), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> 100, SeaSurface.NONE);
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> 100, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(submerged), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY - 8, SeaSurface.NONE);
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY - 8, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBuried, buried);
|
||||
assertEquals(originalSubmerged, submerged);
|
||||
@@ -389,7 +390,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
return method.invoke(delegate, arguments);
|
||||
});
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(bounded, area, List.of(target), (x, z) -> 127, SeaSurface.NONE);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(bounded, area, List.of(target), (x, z) -> 127, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GOLD_BLOCK.defaultBlockState(), state(blocks, 0, 94, 0));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(), state(blocks, 0, 95, 0));
|
||||
@@ -397,6 +398,54 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
assertTrue(state(blocks, 0, 128, 0).isAir());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flattenKeepsDryBanksAtTheWaterSurface() {
|
||||
StructureStart start = desertStart();
|
||||
int groundY = start.getBoundingBox().minY() - 1;
|
||||
int streamX = start.getBoundingBox().maxX() + 6;
|
||||
NativeStructureTerrainIntegrator.TerrainTarget target = new NativeStructureTerrainIntegrator.TerrainTarget(
|
||||
"minecraft:village_plains", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.FLATTEN).setHorizontalPadding(24).setFlattenRange(64));
|
||||
assertStreamStaysBetweenItsBanks(target, streamX, start.getBoundingBox().minZ(), groundY + 8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceFittingKeepsDryBanksAtTheWaterSurface() {
|
||||
StructureStart start = desertStart(TerrainAdjustment.BEARD_THIN);
|
||||
BoundingBox piece = start.getPieces().getFirst().getBoundingBox();
|
||||
assertStreamStaysBetweenItsBanks(surfaceTarget(start, StructureTerrainMode.SOURCE), piece.maxX() + 3,
|
||||
piece.minZ(), piece.minY() + 7);
|
||||
}
|
||||
|
||||
private static void assertStreamStaysBetweenItsBanks(
|
||||
NativeStructureTerrainIntegrator.TerrainTarget target, int streamX, int z, int bedY) {
|
||||
int waterY = bedY + 1;
|
||||
BoundingBox area = new BoundingBox(streamX - 1, 0, z, streamX + 1, 127, z);
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
for (int x = streamX - 1; x <= streamX + 1; x++) {
|
||||
for (int y = 0; y <= (x == streamX ? bedY : waterY); y++) {
|
||||
put(blocks, x, y, z, Blocks.STONE.defaultBlockState());
|
||||
}
|
||||
}
|
||||
put(blocks, streamX, bedY, z, Blocks.SAND.defaultBlockState());
|
||||
put(blocks, streamX, waterY, z, Blocks.WATER.defaultBlockState());
|
||||
StructureWater water = (x, columnZ) -> x == streamX && columnZ == z
|
||||
? new StructureWaterColumn(true, true, bedY, waterY) : StructureWaterColumn.DRY;
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area, List.of(target),
|
||||
(x, columnZ) -> x == streamX && columnZ == z ? bedY : waterY, SeaSurface.NONE, water);
|
||||
|
||||
int top = waterY;
|
||||
while (top >= 0 && state(blocks, streamX, top, z).getFluidState().isEmpty()) {
|
||||
top--;
|
||||
}
|
||||
assertTrue("the stream goes down with its banks", top >= 0 && top < waterY);
|
||||
assertEquals(Blocks.SAND.defaultBlockState(), state(blocks, streamX, top - 1, z));
|
||||
assertTrue("nothing stands above the lowered water", state(blocks, streamX, waterY, z).isAir());
|
||||
assertFalse("west bank holds the water", state(blocks, streamX - 1, top, z).isAir());
|
||||
assertFalse("east bank holds the water", state(blocks, streamX + 1, top, z).isAir());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flattenReferencesIncludeTheMaximumConfiguredFeather() throws Exception {
|
||||
PoolElementStructurePiece piece = rigidTemplatePiece(new InlineSinglePoolElement(template(List.of(
|
||||
@@ -409,9 +458,9 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
BoundingBox references = NativeStructureReferenceEnvelope.referenceBounds(start, start.getStructure(), terrain);
|
||||
|
||||
assertEquals(-128, references.minX());
|
||||
assertEquals(128, references.maxX());
|
||||
assertEquals(143, references.maxX());
|
||||
assertEquals(-128, references.minZ());
|
||||
assertEquals(128, references.maxZ());
|
||||
assertEquals(143, references.maxZ());
|
||||
NativeStructureSurfaceFitter.FlattenAnchor anchor = new NativeStructureSurfaceFitter.FlattenAnchor(
|
||||
new NativeStructureSurfaceFitter.SurfaceAnchor(0, 0, 0, 0, 64, 2), 128, 128);
|
||||
assertTrue(NativeStructureSurfaceFitter.resolveFlattenSurface(List.of(anchor), 127, 0, 100).range() > 0);
|
||||
@@ -480,7 +529,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)),
|
||||
(x, z) -> x == footprint.minX() ? 80 : 112, SeaSurface.NONE);
|
||||
(x, z) -> x == footprint.minX() ? 80 : 112, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(81, piece.getBoundingBox().minY());
|
||||
assertTrue(piece.attemptVanillaAlignment());
|
||||
@@ -514,7 +563,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
WorldGenLevel world = world(blocks);
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world, area, List.of(target),
|
||||
(x, z) -> x == 0 || x == 8 ? 64 : 96, SeaSurface.NONE);
|
||||
(x, z) -> x == 0 || x == 8 ? 64 : 96, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureTemplateOccupancy.OccupancyResult occupancy = NativeStructureTemplateOccupancy.resolve(
|
||||
world, path, BlockPos.ZERO, area,
|
||||
NativeStructurePostProcessorSurfaceTerrainTest::forbiddenTemplateManager,
|
||||
@@ -558,7 +607,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
WorldGenLevel world = world(chunk);
|
||||
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan plan = NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world, area, List.of(target), (x, z) -> x < 4 ? 96 : 32, SeaSurface.NONE);
|
||||
world, area, List.of(target), (x, z) -> x < 4 ? 96 : 32, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(96, chunk.getHeight(Heightmap.Types.WORLD_SURFACE_WG, 0, 0));
|
||||
assertEquals(32, chunk.getHeight(Heightmap.Types.WORLD_SURFACE_WG, 8, 0));
|
||||
@@ -618,7 +667,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
WorldGenLevel world = world(chunk);
|
||||
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan plan = NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world, area, List.of(target), (x, z) -> x == 0 || x == 8 ? 64 : 96, SeaSurface.NONE);
|
||||
world, area, List.of(target), (x, z) -> x == 0 || x == 8 ? 64 : 96, SeaSurface.NONE, StructureWater.DRY);
|
||||
plan.primeHeightmaps(chunk);
|
||||
NativeStructureTemplateOccupancy.OccupancyResult occupancy = NativeStructureTemplateOccupancy.resolve(
|
||||
world, path, BlockPos.ZERO, area,
|
||||
@@ -673,7 +722,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
}
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan plan = NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, List.of(target),
|
||||
(x, z) -> (x == 0 || x == 8) && (z == 0 || z == 8) ? 64 : 96, SeaSurface.NONE);
|
||||
(x, z) -> (x == 0 || x == 8) && (z == 0 || z == 8) ? 64 : 96, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int x = 0; x <= 8; x++) {
|
||||
for (int z = 0; z <= 8; z++) {
|
||||
@@ -743,7 +792,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, List.of(surfaceTarget(start)),
|
||||
(x, z) -> 64, SeaSurface.NONE);
|
||||
(x, z) -> 64, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(before, blocks);
|
||||
}
|
||||
@@ -869,7 +918,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.SOURCE)));
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, targets,
|
||||
(x, z) -> 65, SeaSurface.NONE);
|
||||
(x, z) -> 65, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 1, 71, 1));
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 11, 71, 1));
|
||||
@@ -894,7 +943,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, List.of(surfaceTarget(start)),
|
||||
(x, z) -> 64, SeaSurface.NONE);
|
||||
(x, z) -> 64, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 68, 0));
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 15, 64, 0));
|
||||
@@ -915,7 +964,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, List.of(surfaceTarget(start)),
|
||||
(x, z) -> 40, SeaSurface.NONE);
|
||||
(x, z) -> 40, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 46, 0));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, 47, 0));
|
||||
@@ -947,7 +996,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, List.of(surfaceTarget(start)),
|
||||
(x, z) -> x == 0 ? 60 : x == 30 ? 72 : 64, SeaSurface.NONE);
|
||||
(x, z) -> x == 0 ? 60 : x == 30 ? 72 : 64, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 61, 0));
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 30, 71, 0));
|
||||
@@ -975,7 +1024,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, 64, 0));
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 63, 0));
|
||||
@@ -1000,7 +1049,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 65, 0));
|
||||
assertEquals(Blocks.DIRT.defaultBlockState(), state(blocks, 0, 64, 0));
|
||||
@@ -1021,7 +1070,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 80, SeaSurface.NONE);
|
||||
(x, z) -> 80, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = 61; y <= 74; y++) {
|
||||
assertFalse(state(blocks, 0, y, 0).isAir());
|
||||
@@ -1046,7 +1095,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 79, SeaSurface.NONE);
|
||||
(x, z) -> 79, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = 61; y <= 74; y++) {
|
||||
assertFalse(state(blocks, 0, y, 0).isAir());
|
||||
@@ -1078,7 +1127,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
for (int y = 61; y <= 64; y++) {
|
||||
put(blocks, 0, y, 0, Blocks.CAVE_AIR.defaultBlockState());
|
||||
}
|
||||
@@ -1118,7 +1167,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
put(blocks, 0, 65, 0, Blocks.COBBLESTONE.defaultBlockState());
|
||||
|
||||
NativeStructureSurfaceFitter.repairVacuumFoundations(
|
||||
@@ -1148,13 +1197,13 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan widePlan =
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(wideBlocks), wideArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(wideBlocks), wideArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan westPlan =
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(splitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(splitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan eastPlan =
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(splitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(splitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
for (int x = 15; x <= 16; x++) {
|
||||
for (int y = 61; y <= 64; y++) {
|
||||
put(wideBlocks, x, y, 0, Blocks.CAVE_AIR.defaultBlockState());
|
||||
@@ -1189,7 +1238,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1210,7 +1259,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1234,7 +1283,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 1, 66, 0));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 1, 67, 0));
|
||||
@@ -1259,7 +1308,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1279,7 +1328,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 65, 0));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, 66, 0));
|
||||
@@ -1304,7 +1353,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1325,7 +1374,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 4, 61, 4));
|
||||
}
|
||||
@@ -1343,7 +1392,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 50, SeaSurface.NONE);
|
||||
(x, z) -> 50, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1362,7 +1411,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE, 1);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY, 1);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1386,7 +1435,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = 61; y <= 65; y++) {
|
||||
assertFalse(state(blocks, 10, y, 0).isAir());
|
||||
@@ -1414,15 +1463,15 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
Map<BlockPos, BlockState> reverseSplitBlocks = flatTerrain(wideArea, 60);
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(wideBlocks), wideArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(wideBlocks), wideArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(splitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(splitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(splitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(splitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(reverseSplitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(reverseSplitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(reverseSplitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(reverseSplitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(wideBlocks, splitBlocks);
|
||||
assertEquals(wideBlocks, reverseSplitBlocks);
|
||||
@@ -1886,7 +1935,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
List<NativeStructureTerrainIntegrator.TerrainTarget> targets =
|
||||
List.of(surfaceTarget(start));
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world, area, targets, (x, z) -> 60, SeaSurface.NONE);
|
||||
world, area, targets, (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 2, 62, 2));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 2, 65, 2));
|
||||
|
||||
+93
-44
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.nativegen.v26_3_R1;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWaterColumn;
|
||||
|
||||
import art.arcane.volmlib.nativelib.v26_3_R1.terrain.NativeStructureVerticalPlacer;
|
||||
|
||||
@@ -241,7 +242,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)),
|
||||
(x, z) -> x < 2 ? groundY - 32 : groundY + 32, SeaSurface.NONE);
|
||||
(x, z) -> x < 2 ? groundY - 32 : groundY + 32, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int x = 0; x <= 3; x++) {
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, x, groundY, 0));
|
||||
@@ -269,7 +270,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
put(blocks, 0, groundY - 19, 0, Blocks.DIRT.defaultBlockState());
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY, SeaSurface.NONE);
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = groundY - 19; y <= groundY; y++) {
|
||||
assertEquals(Blocks.DIRT.defaultBlockState(), state(blocks, 0, y, 0));
|
||||
@@ -295,7 +296,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureTerrainIntegrator.TerrainTarget target = surfaceTarget(start, StructureTerrainMode.FLATTEN);
|
||||
((IrisStructureTerrain) target.terrain()).setHorizontalPadding(24).setFlattenRange(64);
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area, List.of(target), (px, pz) -> groundY, SeaSurface.NONE);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area, List.of(target), (px, pz) -> groundY, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = groundY - 34; y <= groundY - 13; y++) {
|
||||
assertEquals("Cave at " + y, Blocks.CAVE_AIR.defaultBlockState(), state(blocks, x, y, z));
|
||||
@@ -318,7 +319,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
}
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY, SeaSurface.NONE);
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = groundY - 8; y < groundY; y++) {
|
||||
assertEquals("Foundation at " + y, Blocks.STONE.defaultBlockState(), state(blocks, 0, y, 0));
|
||||
@@ -340,9 +341,9 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
Map<BlockPos, BlockState> originalSubmerged = new HashMap<>(submerged);
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(buried), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> 100, SeaSurface.NONE);
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> 100, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(submerged), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY - 8, SeaSurface.NONE);
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)), (x, z) -> groundY - 8, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBuried, buried);
|
||||
assertEquals(originalSubmerged, submerged);
|
||||
@@ -389,7 +390,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
return method.invoke(delegate, arguments);
|
||||
});
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(bounded, area, List.of(target), (x, z) -> 127, SeaSurface.NONE);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(bounded, area, List.of(target), (x, z) -> 127, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GOLD_BLOCK.defaultBlockState(), state(blocks, 0, 94, 0));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(), state(blocks, 0, 95, 0));
|
||||
@@ -397,6 +398,54 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
assertTrue(state(blocks, 0, 128, 0).isAir());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flattenKeepsDryBanksAtTheWaterSurface() {
|
||||
StructureStart start = desertStart();
|
||||
int groundY = start.getBoundingBox().minY() - 1;
|
||||
int streamX = start.getBoundingBox().maxX() + 6;
|
||||
NativeStructureTerrainIntegrator.TerrainTarget target = new NativeStructureTerrainIntegrator.TerrainTarget(
|
||||
"minecraft:village_plains", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.FLATTEN).setHorizontalPadding(24).setFlattenRange(64));
|
||||
assertStreamStaysBetweenItsBanks(target, streamX, start.getBoundingBox().minZ(), groundY + 8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceFittingKeepsDryBanksAtTheWaterSurface() {
|
||||
StructureStart start = desertStart(TerrainAdjustment.BEARD_THIN);
|
||||
BoundingBox piece = start.getPieces().getFirst().getBoundingBox();
|
||||
assertStreamStaysBetweenItsBanks(surfaceTarget(start, StructureTerrainMode.SOURCE), piece.maxX() + 3,
|
||||
piece.minZ(), piece.minY() + 7);
|
||||
}
|
||||
|
||||
private static void assertStreamStaysBetweenItsBanks(
|
||||
NativeStructureTerrainIntegrator.TerrainTarget target, int streamX, int z, int bedY) {
|
||||
int waterY = bedY + 1;
|
||||
BoundingBox area = new BoundingBox(streamX - 1, 0, z, streamX + 1, 127, z);
|
||||
Map<BlockPos, BlockState> blocks = new HashMap<>();
|
||||
for (int x = streamX - 1; x <= streamX + 1; x++) {
|
||||
for (int y = 0; y <= (x == streamX ? bedY : waterY); y++) {
|
||||
put(blocks, x, y, z, Blocks.STONE.defaultBlockState());
|
||||
}
|
||||
}
|
||||
put(blocks, streamX, bedY, z, Blocks.SAND.defaultBlockState());
|
||||
put(blocks, streamX, waterY, z, Blocks.WATER.defaultBlockState());
|
||||
StructureWater water = (x, columnZ) -> x == streamX && columnZ == z
|
||||
? new StructureWaterColumn(true, true, bedY, waterY) : StructureWaterColumn.DRY;
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area, List.of(target),
|
||||
(x, columnZ) -> x == streamX && columnZ == z ? bedY : waterY, SeaSurface.NONE, water);
|
||||
|
||||
int top = waterY;
|
||||
while (top >= 0 && state(blocks, streamX, top, z).getFluidState().isEmpty()) {
|
||||
top--;
|
||||
}
|
||||
assertTrue("the stream goes down with its banks", top >= 0 && top < waterY);
|
||||
assertEquals(Blocks.SAND.defaultBlockState(), state(blocks, streamX, top - 1, z));
|
||||
assertTrue("nothing stands above the lowered water", state(blocks, streamX, waterY, z).isAir());
|
||||
assertFalse("west bank holds the water", state(blocks, streamX - 1, top, z).isAir());
|
||||
assertFalse("east bank holds the water", state(blocks, streamX + 1, top, z).isAir());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flattenReferencesIncludeTheMaximumConfiguredFeather() throws Exception {
|
||||
PoolElementStructurePiece piece = rigidTemplatePiece(new InlineSinglePoolElement(template(List.of(
|
||||
@@ -409,9 +458,9 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
BoundingBox references = NativeStructureReferenceEnvelope.referenceBounds(start, start.getStructure(), terrain);
|
||||
|
||||
assertEquals(-128, references.minX());
|
||||
assertEquals(128, references.maxX());
|
||||
assertEquals(143, references.maxX());
|
||||
assertEquals(-128, references.minZ());
|
||||
assertEquals(128, references.maxZ());
|
||||
assertEquals(143, references.maxZ());
|
||||
NativeStructureSurfaceFitter.FlattenAnchor anchor = new NativeStructureSurfaceFitter.FlattenAnchor(
|
||||
new NativeStructureSurfaceFitter.SurfaceAnchor(0, 0, 0, 0, 64, 2), 128, 128);
|
||||
assertTrue(NativeStructureSurfaceFitter.resolveFlattenSurface(List.of(anchor), 127, 0, 100).range() > 0);
|
||||
@@ -480,7 +529,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.FLATTEN)),
|
||||
(x, z) -> x == footprint.minX() ? 80 : 112, SeaSurface.NONE);
|
||||
(x, z) -> x == footprint.minX() ? 80 : 112, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(81, piece.getBoundingBox().minY());
|
||||
assertTrue(piece.attemptVanillaAlignment());
|
||||
@@ -514,7 +563,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
WorldGenLevel world = world(blocks);
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(world, area, List.of(target),
|
||||
(x, z) -> x == 0 || x == 8 ? 64 : 96, SeaSurface.NONE);
|
||||
(x, z) -> x == 0 || x == 8 ? 64 : 96, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureTemplateOccupancy.OccupancyResult occupancy = NativeStructureTemplateOccupancy.resolve(
|
||||
world, path, BlockPos.ZERO, area,
|
||||
NativeStructurePostProcessorSurfaceTerrainTest::forbiddenTemplateManager,
|
||||
@@ -558,7 +607,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
WorldGenLevel world = world(chunk);
|
||||
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan plan = NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world, area, List.of(target), (x, z) -> x < 4 ? 96 : 32, SeaSurface.NONE);
|
||||
world, area, List.of(target), (x, z) -> x < 4 ? 96 : 32, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(96, chunk.getHeight(Heightmap.Types.WORLD_SURFACE_WG, 0, 0));
|
||||
assertEquals(32, chunk.getHeight(Heightmap.Types.WORLD_SURFACE_WG, 8, 0));
|
||||
@@ -618,7 +667,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
WorldGenLevel world = world(chunk);
|
||||
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan plan = NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world, area, List.of(target), (x, z) -> x == 0 || x == 8 ? 64 : 96, SeaSurface.NONE);
|
||||
world, area, List.of(target), (x, z) -> x == 0 || x == 8 ? 64 : 96, SeaSurface.NONE, StructureWater.DRY);
|
||||
plan.primeHeightmaps(chunk);
|
||||
NativeStructureTemplateOccupancy.OccupancyResult occupancy = NativeStructureTemplateOccupancy.resolve(
|
||||
world, path, BlockPos.ZERO, area,
|
||||
@@ -673,7 +722,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
}
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan plan = NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, List.of(target),
|
||||
(x, z) -> (x == 0 || x == 8) && (z == 0 || z == 8) ? 64 : 96, SeaSurface.NONE);
|
||||
(x, z) -> (x == 0 || x == 8) && (z == 0 || z == 8) ? 64 : 96, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int x = 0; x <= 8; x++) {
|
||||
for (int z = 0; z <= 8; z++) {
|
||||
@@ -743,7 +792,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, List.of(surfaceTarget(start)),
|
||||
(x, z) -> 64, SeaSurface.NONE);
|
||||
(x, z) -> 64, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(before, blocks);
|
||||
}
|
||||
@@ -869,7 +918,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.SOURCE)));
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, targets,
|
||||
(x, z) -> 65, SeaSurface.NONE);
|
||||
(x, z) -> 65, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 1, 71, 1));
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 11, 71, 1));
|
||||
@@ -894,7 +943,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, List.of(surfaceTarget(start)),
|
||||
(x, z) -> 64, SeaSurface.NONE);
|
||||
(x, z) -> 64, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 68, 0));
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 15, 64, 0));
|
||||
@@ -915,7 +964,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, List.of(surfaceTarget(start)),
|
||||
(x, z) -> 40, SeaSurface.NONE);
|
||||
(x, z) -> 40, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 46, 0));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, 47, 0));
|
||||
@@ -947,7 +996,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area, List.of(surfaceTarget(start)),
|
||||
(x, z) -> x == 0 ? 60 : x == 30 ? 72 : 64, SeaSurface.NONE);
|
||||
(x, z) -> x == 0 ? 60 : x == 30 ? 72 : 64, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 61, 0));
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 30, 71, 0));
|
||||
@@ -975,7 +1024,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, 64, 0));
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 63, 0));
|
||||
@@ -1000,7 +1049,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 65, 0));
|
||||
assertEquals(Blocks.DIRT.defaultBlockState(), state(blocks, 0, 64, 0));
|
||||
@@ -1021,7 +1070,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 80, SeaSurface.NONE);
|
||||
(x, z) -> 80, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = 61; y <= 74; y++) {
|
||||
assertFalse(state(blocks, 0, y, 0).isAir());
|
||||
@@ -1046,7 +1095,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 79, SeaSurface.NONE);
|
||||
(x, z) -> 79, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = 61; y <= 74; y++) {
|
||||
assertFalse(state(blocks, 0, y, 0).isAir());
|
||||
@@ -1078,7 +1127,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
for (int y = 61; y <= 64; y++) {
|
||||
put(blocks, 0, y, 0, Blocks.CAVE_AIR.defaultBlockState());
|
||||
}
|
||||
@@ -1118,7 +1167,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
put(blocks, 0, 65, 0, Blocks.COBBLESTONE.defaultBlockState());
|
||||
|
||||
NativeStructureSurfaceFitter.repairVacuumFoundations(
|
||||
@@ -1148,13 +1197,13 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan widePlan =
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(wideBlocks), wideArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(wideBlocks), wideArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan westPlan =
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(splitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(splitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.SurfaceTerrainPlan eastPlan =
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(splitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(splitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
for (int x = 15; x <= 16; x++) {
|
||||
for (int y = 61; y <= 64; y++) {
|
||||
put(wideBlocks, x, y, 0, Blocks.CAVE_AIR.defaultBlockState());
|
||||
@@ -1189,7 +1238,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1210,7 +1259,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1234,7 +1283,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 1, 66, 0));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 1, 67, 0));
|
||||
@@ -1259,7 +1308,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1279,7 +1328,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 65, 0));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, 66, 0));
|
||||
@@ -1304,7 +1353,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1325,7 +1374,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 4, 61, 4));
|
||||
}
|
||||
@@ -1343,7 +1392,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 50, SeaSurface.NONE);
|
||||
(x, z) -> 50, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1362,7 +1411,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE, 1);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY, 1);
|
||||
|
||||
assertEquals(originalBlocks, blocks);
|
||||
}
|
||||
@@ -1386,7 +1435,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(blocks), area,
|
||||
List.of(surfaceTarget(start, StructureTerrainMode.VACUUM)),
|
||||
(x, z) -> 60, SeaSurface.NONE);
|
||||
(x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
for (int y = 61; y <= 65; y++) {
|
||||
assertFalse(state(blocks, 10, y, 0).isAir());
|
||||
@@ -1414,15 +1463,15 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
Map<BlockPos, BlockState> reverseSplitBlocks = flatTerrain(wideArea, 60);
|
||||
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(wideBlocks), wideArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(wideBlocks), wideArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(splitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(splitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(splitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(splitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(reverseSplitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(reverseSplitBlocks), eastArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world(reverseSplitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE);
|
||||
world(reverseSplitBlocks), westArea, List.of(target), (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(wideBlocks, splitBlocks);
|
||||
assertEquals(wideBlocks, reverseSplitBlocks);
|
||||
@@ -1886,7 +1935,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
List<NativeStructureTerrainIntegrator.TerrainTarget> targets =
|
||||
List.of(surfaceTarget(start));
|
||||
NativeStructureSurfaceFitter.prepareSurfaceStructures(
|
||||
world, area, targets, (x, z) -> 60, SeaSurface.NONE);
|
||||
world, area, targets, (x, z) -> 60, SeaSurface.NONE, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 2, 62, 2));
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 2, 65, 2));
|
||||
|
||||
@@ -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, and never lowers dry ground outside a structure footprint below the dimension fluidHeight. SOURCE and FLATTEN surface cuts beneath water or lava, such as a riverbed, fill with that fluid, and other 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.")
|
||||
@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 beneath water or lava, such as a riverbed, fill with that fluid, and other cuts at or below fluidHeight fill with the dimension sea fluid instead of air. A hydrology stream beside a SOURCE or FLATTEN cut goes down with the cut and holds the lowered level until its own head falls below it. Water joined to the sea and wide rivers stay at their level, a stream feeding them stops at that level, and a drop stops at 16 blocks; two blocks of bank keep whatever level the water ends at. 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 = "3ed821f505deefbe3bdd3a105ece18893e4778e4cfc902591c43a18e1fceb2c1";
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "050cf892aa20a9b8796dd8bb0299cb39a92cdabc46569fdf165db6dc960ecf4b";
|
||||
|
||||
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
|
||||
IrisDimension.class,
|
||||
|
||||
@@ -16,6 +16,7 @@ configurations {
|
||||
dependencies {
|
||||
implementation(project(':core'))
|
||||
compileOnly(libs.spigot)
|
||||
compileOnly(libs.lz4)
|
||||
testImplementation('junit:junit:4.13.2')
|
||||
testImplementation(libs.mockito.core)
|
||||
testImplementation(libs.gson)
|
||||
@@ -109,6 +110,22 @@ tasks.register('hydrologyProbe', JavaExec) {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('waterPerchCensus', JavaExec) {
|
||||
group = 'verification'
|
||||
description = 'Reads copied region files and counts source water on a solid bed beside lower ground, inside and outside structure flatten blends.'
|
||||
mainClass = 'art.arcane.iris.probe.WaterPerchCensus'
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
maxHeapSize = '6g'
|
||||
dependsOn(':core:compileJava')
|
||||
doFirst {
|
||||
Provider<String> regions = providers.gradleProperty('censusRegions')
|
||||
if (!regions.isPresent() || regions.get().isBlank()) {
|
||||
throw new GradleException('waterPerchCensus requires -PcensusRegions=<copied region folder>')
|
||||
}
|
||||
args(regions.get(), providers.gradleProperty('censusPadding').getOrElse('24'))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('riverTransectProbe', JavaExec) {
|
||||
group = 'verification'
|
||||
description = 'Plans hydrology over a window range of a real pack and renders each window as a plan, river cross-sections and pond outlines.'
|
||||
|
||||
@@ -167,6 +167,7 @@ public final class HydrologyProbe {
|
||||
HydrologyBlockMetrics.Counts blocks = blockMetrics.count(key);
|
||||
generationErrors += blocks.errors();
|
||||
HydrologyUnderground.Counts underground = underground(key, plan);
|
||||
System.out.println("IRIS_HYDROLOGY_LINK wx=" + key.wx() + " wz=" + key.wz() + " unlinkedWater=" + rasterMetrics.unlinkedWater(plan));
|
||||
HydrologyColdRuns.ColdRun cold = colds.get(key);
|
||||
measured.add(new HydrologyReport.WindowMetrics(key, cold.millis(), cold.naturalSamples(), cold.baseSamples(),
|
||||
plans.windowCpu(key), plans.regionCpu(key.region()), cold.depth(), plans.landTiles(key), planMetrics.rivers(key),
|
||||
|
||||
@@ -11,7 +11,11 @@ import art.arcane.iris.generation.hydrology.water.PondKind;
|
||||
import art.arcane.iris.generation.hydrology.water.Reach;
|
||||
import art.arcane.iris.generation.hydrology.water.ReachStyle;
|
||||
import art.arcane.iris.generation.hydrology.raster.NaturalHeights;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureStreamLowering;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
final class HydrologyRasterMetrics {
|
||||
@@ -22,6 +26,7 @@ final class HydrologyRasterMetrics {
|
||||
private final Rasters rasters;
|
||||
private final NaturalHeights naturalHeight;
|
||||
private final HydrologyWindows.WindowRange range;
|
||||
private static final int LINK_SEARCH = 32;
|
||||
private final Consumer<String> examples;
|
||||
|
||||
@FunctionalInterface
|
||||
@@ -89,6 +94,66 @@ final class HydrologyRasterMetrics {
|
||||
return rising;
|
||||
}
|
||||
|
||||
long unlinkedWater(WindowPlan plan) {
|
||||
long unlinked = 0L;
|
||||
for (Reach reach : plan.reaches()) {
|
||||
int lastX = 0;
|
||||
int lastZ = 0;
|
||||
boolean wet = false;
|
||||
for (int point = 0; point + 1 < reach.xs().length; point++) {
|
||||
float fromX = reach.xs()[point];
|
||||
float fromZ = reach.zs()[point];
|
||||
float toX = reach.xs()[point + 1];
|
||||
float toZ = reach.zs()[point + 1];
|
||||
int steps = Math.max(1, (int) Math.ceil(Math.max(Math.abs(toX - fromX), Math.abs(toZ - fromZ))));
|
||||
for (int step = 0; step <= steps; step++) {
|
||||
int x = (int) Math.floor(fromX + (toX - fromX) * step / steps);
|
||||
int z = (int) Math.floor(fromZ + (toZ - fromZ) * step / steps);
|
||||
if (!wetInRange(x, z)) {
|
||||
continue;
|
||||
}
|
||||
if (wet && !linkedByWater(lastX, lastZ, x, z)) {
|
||||
unlinked++;
|
||||
examples.accept("water gap along reach " + reach.id() + " from " + lastX + "," + lastZ + " to " + x + "," + z);
|
||||
}
|
||||
lastX = x;
|
||||
lastZ = z;
|
||||
wet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return unlinked;
|
||||
}
|
||||
|
||||
private boolean wetInRange(int x, int z) {
|
||||
return range.containsBlock(x, z) && rasters.get(x >> 4, z >> 4).role(x & 15, z & 15).wet();
|
||||
}
|
||||
|
||||
private boolean linkedByWater(int fromX, int fromZ, int toX, int toZ) {
|
||||
Set<Long> seen = new HashSet<>();
|
||||
ArrayDeque<int[]> open = new ArrayDeque<>();
|
||||
open.add(new int[]{fromX, fromZ});
|
||||
seen.add(HydrologyVoxels.columnKey(fromX, fromZ));
|
||||
int limit = StructureStreamLowering.LINK + LINK_SEARCH + Math.max(Math.abs(toX - fromX), Math.abs(toZ - fromZ));
|
||||
while (!open.isEmpty()) {
|
||||
int[] cell = open.poll();
|
||||
if (Math.max(Math.abs(cell[0] - toX), Math.abs(cell[1] - toZ)) <= StructureStreamLowering.LINK) {
|
||||
return true;
|
||||
}
|
||||
for (int dz = -StructureStreamLowering.LINK; dz <= StructureStreamLowering.LINK; dz++) {
|
||||
for (int dx = -StructureStreamLowering.LINK; dx <= StructureStreamLowering.LINK; dx++) {
|
||||
int x = cell[0] + dx;
|
||||
int z = cell[1] + dz;
|
||||
if (Math.max(Math.abs(x - fromX), Math.abs(z - fromZ)) <= limit && wetInRange(x, z)
|
||||
&& seen.add(HydrologyVoxels.columnKey(x, z))) {
|
||||
open.add(new int[]{x, z});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
long chunkSeams(WindowKey key) {
|
||||
long mismatches = 0L;
|
||||
int minX = key.wx() * WindowKey.SIZE;
|
||||
|
||||
@@ -0,0 +1,393 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.volmlib.util.nbt.io.NBTUtil;
|
||||
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.IntArrayTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.ListTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.LongArrayTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.NumberTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.StringTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.Tag;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
public final class WaterPerchCensus {
|
||||
private static final Pattern REGION_FILE = Pattern.compile("r\\.(-?\\d+)\\.(-?\\d+)\\.mca");
|
||||
private static final int SECTOR_BYTES = 4096;
|
||||
private static final int[][] CARDINALS = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
private static final int LISTED_CELLS = 40;
|
||||
private static final int NOT_WATER = Integer.MIN_VALUE;
|
||||
private static final int MISSING = Integer.MIN_VALUE;
|
||||
private static final int FLOWING_BIT = 1;
|
||||
private static final int SOLID_BED_BIT = 2;
|
||||
private static final Set<String> NON_SOLID_BED = Set.of("minecraft:air", "minecraft:cave_air", "minecraft:void_air");
|
||||
private static final List<String> FLATTEN_STRUCTURES = List.of("minecraft:village", "minecraft:pillager_outpost",
|
||||
"minecraft:mansion", "minecraft:desert_pyramid", "minecraft:jungle_pyramid", "minecraft:igloo",
|
||||
"minecraft:swamp_hut", "minecraft:shipwreck_beached", "minecraft:ruined_portal");
|
||||
|
||||
private WaterPerchCensus() {
|
||||
}
|
||||
|
||||
public static void main(String[] arguments) throws IOException {
|
||||
if (arguments.length < 1 || arguments.length > 2) {
|
||||
throw new IllegalArgumentException("Usage: <copied region folder> [blend padding]");
|
||||
}
|
||||
int padding = arguments.length == 2 ? Integer.parseInt(arguments[1]) : 24;
|
||||
Result result = scan(Path.of(arguments[0]), padding);
|
||||
for (String line : result.lines()) {
|
||||
System.out.println(line);
|
||||
}
|
||||
System.exit(result.insideSources() == 0 ? 0 : 1);
|
||||
}
|
||||
|
||||
static Result scan(Path regionFolder, int padding) throws IOException {
|
||||
Map<Long, int[]> tops = new HashMap<>();
|
||||
Map<Long, int[]> waters = new HashMap<>();
|
||||
List<Start> starts = new ArrayList<>();
|
||||
try (Stream<Path> files = Files.list(regionFolder)) {
|
||||
for (Path file : files.sorted().toList()) {
|
||||
Matcher matcher = REGION_FILE.matcher(file.getFileName().toString());
|
||||
if (matcher.matches()) {
|
||||
readRegion(file, Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), tops, waters, starts);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<Long, List<Start>> startsByChunk = new HashMap<>();
|
||||
for (Start start : starts) {
|
||||
for (Bounds piece : start.pieces()) {
|
||||
for (int chunkX = (piece.minX() - padding) >> 4; chunkX <= (piece.maxX() + padding) >> 4; chunkX++) {
|
||||
for (int chunkZ = (piece.minZ() - padding) >> 4; chunkZ <= (piece.maxZ() + padding) >> 4; chunkZ++) {
|
||||
List<Start> near = startsByChunk.computeIfAbsent(chunkKey(chunkX, chunkZ), key -> new ArrayList<>());
|
||||
if (!near.contains(start)) {
|
||||
near.add(start);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long waterColumns = 0L;
|
||||
long insideSources = 0L;
|
||||
long outsideSources = 0L;
|
||||
long insideFlowing = 0L;
|
||||
long outsideFlowing = 0L;
|
||||
long skippedEdges = 0L;
|
||||
Map<String, Long> byStructure = new TreeMap<>();
|
||||
Map<Long, Boolean> insideChunks = new HashMap<>();
|
||||
List<String> cells = new ArrayList<>();
|
||||
for (Map.Entry<Long, int[]> chunk : waters.entrySet()) {
|
||||
int chunkX = (int) (chunk.getKey() >> 32);
|
||||
int chunkZ = (int) (long) chunk.getKey();
|
||||
for (int index = 0; index < 256; index++) {
|
||||
int water = chunk.getValue()[index];
|
||||
if (water == NOT_WATER) {
|
||||
continue;
|
||||
}
|
||||
waterColumns++;
|
||||
int x = (chunkX << 4) + (index & 15);
|
||||
int z = (chunkZ << 4) + (index >> 4);
|
||||
int surface = waterY(water);
|
||||
boolean lower = false;
|
||||
boolean known = true;
|
||||
for (int[] direction : CARDINALS) {
|
||||
int neighbourTop = top(tops, x + direction[0], z + direction[1]);
|
||||
if (neighbourTop == MISSING) {
|
||||
known = false;
|
||||
continue;
|
||||
}
|
||||
lower |= neighbourTop < surface;
|
||||
}
|
||||
if (!known) {
|
||||
skippedEdges++;
|
||||
}
|
||||
if (!lower || !solidBed(water)) {
|
||||
continue;
|
||||
}
|
||||
Start blend = blendAt(startsByChunk.get(chunkKey(chunkX, chunkZ)), x, z, padding);
|
||||
boolean source = isSource(water);
|
||||
if (blend != null) {
|
||||
if (source) {
|
||||
insideSources++;
|
||||
insideChunks.put(chunk.getKey(), true);
|
||||
byStructure.merge(blend.id(), 1L, Long::sum);
|
||||
if (cells.size() < LISTED_CELLS) {
|
||||
cells.add(x + "," + surface + "," + z + " " + blend.id());
|
||||
}
|
||||
} else {
|
||||
insideFlowing++;
|
||||
}
|
||||
} else if (source) {
|
||||
outsideSources++;
|
||||
if (cells.size() < LISTED_CELLS) {
|
||||
cells.add(x + "," + surface + "," + z + " outside");
|
||||
}
|
||||
} else {
|
||||
outsideFlowing++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Result(tops.size(), waterColumns, skippedEdges, insideSources, outsideSources, insideFlowing, outsideFlowing,
|
||||
insideChunks.size(), starts.size(), byStructure, cells);
|
||||
}
|
||||
|
||||
private static int encodeWater(int y, boolean source, boolean solidBed) {
|
||||
return (y << 2) | (source ? 0 : FLOWING_BIT) | (solidBed ? SOLID_BED_BIT : 0);
|
||||
}
|
||||
|
||||
private static int waterY(int water) {
|
||||
return water >> 2;
|
||||
}
|
||||
|
||||
private static boolean isSource(int water) {
|
||||
return (water & FLOWING_BIT) == 0;
|
||||
}
|
||||
|
||||
private static boolean solidBed(int water) {
|
||||
return (water & SOLID_BED_BIT) != 0;
|
||||
}
|
||||
|
||||
private static int top(Map<Long, int[]> tops, int x, int z) {
|
||||
int[] chunk = tops.get(chunkKey(x >> 4, z >> 4));
|
||||
return chunk == null ? MISSING : chunk[((z & 15) << 4) | (x & 15)];
|
||||
}
|
||||
|
||||
private static Start blendAt(List<Start> near, int x, int z, int padding) {
|
||||
if (near == null) {
|
||||
return null;
|
||||
}
|
||||
for (Start start : near) {
|
||||
for (Bounds piece : start.pieces()) {
|
||||
if (x >= piece.minX() - padding && x <= piece.maxX() + padding
|
||||
&& z >= piece.minZ() - padding && z <= piece.maxZ() + padding) {
|
||||
return start;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static long chunkKey(int chunkX, int chunkZ) {
|
||||
return ((long) chunkX << 32) | (chunkZ & 0xFFFFFFFFL);
|
||||
}
|
||||
|
||||
private static void readRegion(Path file, int regionX, int regionZ, Map<Long, int[]> tops, Map<Long, int[]> waters,
|
||||
List<Start> starts) throws IOException {
|
||||
byte[] region = Files.readAllBytes(file);
|
||||
if (region.length < SECTOR_BYTES * 2) {
|
||||
return;
|
||||
}
|
||||
ByteBuffer buffer = ByteBuffer.wrap(region);
|
||||
for (int index = 0; index < 1024; index++) {
|
||||
int location = buffer.getInt(index * 4);
|
||||
int sector = location >>> 8;
|
||||
if (sector == 0 || (long) sector * SECTOR_BYTES + 5 > region.length) {
|
||||
continue;
|
||||
}
|
||||
int chunkX = (regionX << 5) + (index & 31);
|
||||
int chunkZ = (regionZ << 5) + (index >> 5);
|
||||
int length = buffer.getInt(sector * SECTOR_BYTES);
|
||||
int compression = region[sector * SECTOR_BYTES + 4];
|
||||
if (length <= 1 || (compression & 0x80) != 0 || (long) sector * SECTOR_BYTES + 4 + length > region.length) {
|
||||
continue;
|
||||
}
|
||||
ByteArrayInputStream raw = new ByteArrayInputStream(region, sector * SECTOR_BYTES + 5, length - 1);
|
||||
try (InputStream input = switch (compression) {
|
||||
case 1 -> new GZIPInputStream(raw);
|
||||
case 2 -> new InflaterInputStream(raw);
|
||||
case 3 -> raw;
|
||||
case 4 -> new LZ4BlockInputStream(raw);
|
||||
default -> throw new IOException("Chunk " + chunkX + "," + chunkZ + " uses unknown compression " + compression);
|
||||
}) {
|
||||
Tag<?> parsed = NBTUtil.read(input, false).getTag();
|
||||
if (!(parsed instanceof CompoundTag root)) {
|
||||
throw new IOException("Chunk " + chunkX + "," + chunkZ + " is not a compound");
|
||||
}
|
||||
readChunk(root, chunkX, chunkZ, tops, waters, starts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void readChunk(CompoundTag root, int chunkX, int chunkZ, Map<Long, int[]> tops, Map<Long, int[]> waters,
|
||||
List<Start> starts) throws IOException {
|
||||
if (root.get("Status") instanceof StringTag status
|
||||
&& !status.getValue().equals("minecraft:full") && !status.getValue().equals("full")) {
|
||||
return;
|
||||
}
|
||||
if (!(root.get("sections") instanceof ListTag<?> sections)) {
|
||||
return;
|
||||
}
|
||||
Map<Integer, Palette> blocks = new TreeMap<>();
|
||||
for (Tag<?> entry : sections) {
|
||||
if (entry instanceof CompoundTag section && section.get("block_states") instanceof CompoundTag states
|
||||
&& section.get("Y") instanceof NumberTag<?> sectionY) {
|
||||
blocks.put(sectionY.asInt(), Palette.read(states));
|
||||
}
|
||||
}
|
||||
int[] top = new int[256];
|
||||
int[] water = new int[256];
|
||||
List<Integer> descending = new ArrayList<>(blocks.keySet());
|
||||
descending.sort((left, right) -> right - left);
|
||||
for (int index = 0; index < 256; index++) {
|
||||
top[index] = Integer.MIN_VALUE + 1;
|
||||
water[index] = NOT_WATER;
|
||||
int x = index & 15;
|
||||
int z = index >> 4;
|
||||
boolean found = false;
|
||||
for (int sectionIndex = 0; sectionIndex < descending.size() && !found; sectionIndex++) {
|
||||
int sectionY = descending.get(sectionIndex);
|
||||
Palette palette = blocks.get(sectionY);
|
||||
for (int localY = 15; localY >= 0 && !found; localY--) {
|
||||
Block block = palette.get(x, localY, z);
|
||||
if (block.air()) {
|
||||
continue;
|
||||
}
|
||||
found = true;
|
||||
int y = sectionY * 16 + localY;
|
||||
top[index] = y;
|
||||
if (block.water()) {
|
||||
Block below = blockAt(blocks, x, y - 1, z);
|
||||
water[index] = encodeWater(y, block.source(), below != null && !below.air() && !below.water());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tops.put(chunkKey(chunkX, chunkZ), top);
|
||||
waters.put(chunkKey(chunkX, chunkZ), water);
|
||||
if (root.get("structures") instanceof CompoundTag structures && structures.get("starts") instanceof CompoundTag startTags) {
|
||||
for (Map.Entry<String, Tag<?>> entry : startTags) {
|
||||
if (entry.getValue() instanceof CompoundTag start) {
|
||||
readStart(entry.getKey(), start, starts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Block blockAt(Map<Integer, Palette> blocks, int x, int y, int z) throws IOException {
|
||||
Palette palette = blocks.get(Math.floorDiv(y, 16));
|
||||
return palette == null ? null : palette.get(x, Math.floorMod(y, 16), z);
|
||||
}
|
||||
|
||||
private static void readStart(String id, CompoundTag start, List<Start> starts) {
|
||||
boolean flatten = false;
|
||||
for (String prefix : FLATTEN_STRUCTURES) {
|
||||
flatten |= id.startsWith(prefix);
|
||||
}
|
||||
if (!flatten || !(start.get("Children") instanceof ListTag<?> children)) {
|
||||
return;
|
||||
}
|
||||
List<Bounds> pieces = new ArrayList<>();
|
||||
for (Tag<?> child : children) {
|
||||
if (child instanceof CompoundTag piece && piece.get("BB") instanceof IntArrayTag box && box.getValue().length == 6) {
|
||||
int[] value = box.getValue();
|
||||
pieces.add(new Bounds(value[0], value[2], value[3], value[5]));
|
||||
}
|
||||
}
|
||||
if (!pieces.isEmpty()) {
|
||||
starts.add(new Start(id, List.copyOf(pieces)));
|
||||
}
|
||||
}
|
||||
|
||||
record Bounds(int minX, int minZ, int maxX, int maxZ) {
|
||||
}
|
||||
|
||||
record Start(String id, List<Bounds> pieces) {
|
||||
}
|
||||
|
||||
private record Block(boolean air, boolean water, boolean source) {
|
||||
}
|
||||
|
||||
private static final class Palette {
|
||||
private final Block[] values;
|
||||
private final long[] data;
|
||||
private final int bits;
|
||||
private final int perLong;
|
||||
|
||||
private Palette(Block[] values, long[] data) {
|
||||
this.values = values;
|
||||
this.data = data;
|
||||
bits = Math.max(4, 32 - Integer.numberOfLeadingZeros(values.length - 1));
|
||||
perLong = 64 / bits;
|
||||
}
|
||||
|
||||
private static Palette read(CompoundTag states) throws IOException {
|
||||
if (!(states.get("palette") instanceof ListTag<?> palette) || palette.size() == 0) {
|
||||
throw new IOException("Section has no block palette");
|
||||
}
|
||||
Block[] values = new Block[palette.size()];
|
||||
int index = 0;
|
||||
for (Tag<?> entry : palette) {
|
||||
values[index++] = block(entry);
|
||||
}
|
||||
long[] data = states.get("data") instanceof LongArrayTag longs ? longs.getValue() : new long[0];
|
||||
return new Palette(values, data);
|
||||
}
|
||||
|
||||
private static Block block(Tag<?> entry) throws IOException {
|
||||
Tag<?> state = entry;
|
||||
if (state instanceof CompoundTag wrapped && wrapped.size() == 1 && wrapped.containsKey("")) {
|
||||
state = wrapped.get("");
|
||||
}
|
||||
if (state instanceof StringTag name) {
|
||||
return describe(name.getValue(), "0");
|
||||
}
|
||||
if (state instanceof CompoundTag compound) {
|
||||
String name = compound.get("Name") instanceof StringTag upper ? upper.getValue()
|
||||
: compound.get("id") instanceof StringTag lower ? lower.getValue() : null;
|
||||
if (name == null) {
|
||||
throw new IOException("Block palette entry has no name");
|
||||
}
|
||||
Tag<?> properties = compound.containsKey("Properties") ? compound.get("Properties") : compound.get("properties");
|
||||
String level = properties instanceof CompoundTag values && values.get("level") instanceof StringTag text
|
||||
? text.getValue() : "0";
|
||||
return describe(name, level);
|
||||
}
|
||||
throw new IOException("Block palette entry is not a block state");
|
||||
}
|
||||
|
||||
private static Block describe(String name, String level) {
|
||||
String key = name.toLowerCase(Locale.ROOT);
|
||||
return new Block(NON_SOLID_BED.contains(key), key.equals("minecraft:water"), level.equals("0"));
|
||||
}
|
||||
|
||||
private Block get(int x, int y, int z) {
|
||||
if (values.length == 1) {
|
||||
return values[0];
|
||||
}
|
||||
int index = (y << 8) | (z << 4) | x;
|
||||
int packed = (int) ((data[index / perLong] >>> ((index % perLong) * bits)) & ((1L << bits) - 1L));
|
||||
return values[packed];
|
||||
}
|
||||
}
|
||||
|
||||
record Result(int chunks, long waterColumns, long skippedEdges, long insideSources, long outsideSources,
|
||||
long insideFlowing, long outsideFlowing, int insideChunks, int flattenStarts,
|
||||
Map<String, Long> byStructure, List<String> cells) {
|
||||
List<String> lines() {
|
||||
List<String> lines = new ArrayList<>();
|
||||
lines.add("[census] chunks=" + chunks + " waterTopped=" + waterColumns + " edgeColumnsWithAMissingNeighbour=" + skippedEdges
|
||||
+ " flattenStarts=" + flattenStarts);
|
||||
lines.add("[census] perched sources inside blends=" + insideSources + " (" + insideChunks + " chunks), outside=" + outsideSources);
|
||||
lines.add("[census] perched flowing inside blends=" + insideFlowing + ", outside=" + outsideFlowing);
|
||||
byStructure.forEach((String id, Long count) -> lines.add("[census] " + id + " " + count));
|
||||
cells.forEach((String cell) -> lines.add("[census] cell " + cell));
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,6 +156,29 @@ public class HydrologyMetricsTest {
|
||||
assertRises(0L, null, List.of(mouth), List.of(), level);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void waterAlongAReachMustStayWithinTheStreamLinkRadius() {
|
||||
Reach reach = reach(1L, STREAM, 0L, 1000f, new int[]{60, 60}, 10f, 10f, 30f, 10f);
|
||||
Map<Long, Column> linked = new HashMap<>();
|
||||
for (int x = 10; x <= 30; x += 2) {
|
||||
linked.put(HydrologyVoxels.columnKey(x, 10), new Column(WaterRole.CHANNEL, 60, 58, 1L));
|
||||
}
|
||||
assertEquals(0L, unlinked(reach, linked));
|
||||
|
||||
Map<Long, Column> gapped = new HashMap<>(linked);
|
||||
gapped.remove(HydrologyVoxels.columnKey(20, 10));
|
||||
assertEquals(1L, unlinked(reach, gapped));
|
||||
}
|
||||
|
||||
private static long unlinked(Reach reach, Map<Long, Column> columns) {
|
||||
WindowPlan plan = plan(WEST, List.of(reach), List.of());
|
||||
HydrologyPlanMetrics plans = new HydrologyPlanMetrics(SETTINGS, windows(plan, plan(EAST, List.of(), List.of())), List.of(), BOTH, ignored -> {
|
||||
});
|
||||
HydrologyRasterMetrics metrics = new HydrologyRasterMetrics(SETTINGS, plans, rasters(columns), (x, z) -> NATURAL, BOTH, ignored -> {
|
||||
});
|
||||
return metrics.unlinkedWater(plan);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aReachEndingInItsPondAtThePondsSnappedHeadDoesNotRise() {
|
||||
Pond odd = pond(10L, 51, square(96, 96, 3), 0L, 100, 100);
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.volmlib.util.nbt.io.NBTUtil;
|
||||
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.ListTag;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class WaterPerchCensusTest {
|
||||
private static final int GROUND = 3;
|
||||
private static final int STONE = 1;
|
||||
private static final int WATER = 2;
|
||||
private static final int FLOWING = 3;
|
||||
private static final int LAKE_FLOOR = 0;
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void countsPerchedSourcesInsideAndOutsideBlends() throws IOException {
|
||||
int[][][] blocks = column(heights(GROUND));
|
||||
blocks[GROUND + 1][4][4] = WATER;
|
||||
blocks[GROUND + 1][4][12] = WATER;
|
||||
blocks[GROUND + 1][12][12] = FLOWING;
|
||||
Path regions = folder.newFolder("region").toPath();
|
||||
writeRegion(regions, 0, 0, section(blocks), startAt(0, 0, 0, 8));
|
||||
|
||||
WaterPerchCensus.Result result = WaterPerchCensus.scan(regions, 0);
|
||||
|
||||
assertEquals(3L, result.waterColumns());
|
||||
assertEquals("the source within the piece", 1L, result.insideSources());
|
||||
assertEquals("the source away from the piece", 1L, result.outsideSources());
|
||||
assertEquals(1L, result.outsideFlowing());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void waterHeldByEqualOrTallerBanksIsNotPerched() throws IOException {
|
||||
int[][][] blocks = column(heights(GROUND));
|
||||
for (int z = 3; z <= 5; z++) {
|
||||
for (int x = 3; x <= 5; x++) {
|
||||
blocks[GROUND + 1][z][x] = STONE;
|
||||
}
|
||||
}
|
||||
blocks[GROUND + 1][4][4] = WATER;
|
||||
Path regions = folder.newFolder("region").toPath();
|
||||
writeRegion(regions, 0, 0, section(blocks), null);
|
||||
|
||||
WaterPerchCensus.Result result = WaterPerchCensus.scan(regions, 24);
|
||||
|
||||
assertEquals(1L, result.waterColumns());
|
||||
assertEquals(0L, result.insideSources());
|
||||
assertEquals(0L, result.outsideSources());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void waterWithoutASolidBedIsNotCounted() throws IOException {
|
||||
int[][][] blocks = column(heights(LAKE_FLOOR));
|
||||
blocks[GROUND][4][4] = WATER;
|
||||
Path regions = folder.newFolder("region").toPath();
|
||||
writeRegion(regions, 0, 0, section(blocks), null);
|
||||
|
||||
assertEquals(0L, WaterPerchCensus.scan(regions, 24).outsideSources());
|
||||
}
|
||||
|
||||
private static int[][] heights(int height) {
|
||||
int[][] heights = new int[16][16];
|
||||
for (int[] row : heights) {
|
||||
Arrays.fill(row, height);
|
||||
}
|
||||
return heights;
|
||||
}
|
||||
|
||||
private static int[][][] column(int[][] heights) {
|
||||
int[][][] blocks = new int[16][16][16];
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y <= heights[z][x] && y < 16; y++) {
|
||||
blocks[y][z][x] = STONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private static CompoundTag section(int[][][] blocks) {
|
||||
ListTag<CompoundTag> palette = new ListTag<>(CompoundTag.class);
|
||||
palette.add(state("minecraft:air", null));
|
||||
palette.add(state("minecraft:stone", null));
|
||||
palette.add(state("minecraft:water", "0"));
|
||||
palette.add(state("minecraft:water", "1"));
|
||||
long[] data = new long[256];
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
int index = (y << 8) | (z << 4) | x;
|
||||
data[index / 16] |= (long) blocks[y][z][x] << ((index % 16) * 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
CompoundTag states = new CompoundTag();
|
||||
states.put("palette", palette);
|
||||
states.putLongArray("data", data);
|
||||
CompoundTag section = new CompoundTag();
|
||||
section.putByte("Y", (byte) 0);
|
||||
section.put("block_states", states);
|
||||
return section;
|
||||
}
|
||||
|
||||
private static CompoundTag state(String name, String level) {
|
||||
CompoundTag state = new CompoundTag();
|
||||
state.putString("Name", name);
|
||||
if (level != null) {
|
||||
CompoundTag properties = new CompoundTag();
|
||||
properties.putString("level", level);
|
||||
state.put("Properties", properties);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
private static CompoundTag startAt(int minX, int minZ, int maxX, int maxZ) {
|
||||
CompoundTag piece = new CompoundTag();
|
||||
piece.putIntArray("BB", new int[]{minX, 0, minZ, 8, 15, maxZ});
|
||||
ListTag<CompoundTag> children = new ListTag<>(CompoundTag.class);
|
||||
children.add(piece);
|
||||
CompoundTag start = new CompoundTag();
|
||||
start.put("Children", children);
|
||||
return start;
|
||||
}
|
||||
|
||||
private static void writeRegion(Path folder, int chunkX, int chunkZ, CompoundTag section, CompoundTag start) throws IOException {
|
||||
CompoundTag root = new CompoundTag();
|
||||
root.putString("Status", "minecraft:full");
|
||||
ListTag<CompoundTag> sections = new ListTag<>(CompoundTag.class);
|
||||
sections.add(section);
|
||||
root.put("sections", sections);
|
||||
if (start != null) {
|
||||
CompoundTag starts = new CompoundTag();
|
||||
starts.put("minecraft:village_plains", start);
|
||||
CompoundTag structures = new CompoundTag();
|
||||
structures.put("starts", starts);
|
||||
root.put("structures", structures);
|
||||
}
|
||||
ByteArrayOutputStream compressed = new ByteArrayOutputStream();
|
||||
try (DeflaterOutputStream deflater = new DeflaterOutputStream(compressed)) {
|
||||
NBTUtil.write(root, deflater, false);
|
||||
}
|
||||
byte[] payload = compressed.toByteArray();
|
||||
ByteBuffer region = ByteBuffer.allocate(4096 * (3 + payload.length / 4096));
|
||||
region.putInt((chunkZ << 5 | chunkX) * 4, 2 << 8 | (1 + payload.length / 4096));
|
||||
region.putInt(4096 * 2, payload.length + 1);
|
||||
region.put(4096 * 2 + 4, (byte) 2);
|
||||
region.put(4096 * 2 + 5, payload);
|
||||
Files.write(folder.resolve("r.0.0.mca"), region.array());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user