mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Native structures respect rivers
- Supply hydrology water to the native structure stages through IrisStructureWater on the Bukkit and modded policies - Carry each native placement's allowWater on its start plan - Judge native placements by the columns their assembled pieces cover in the stage instead of by the start chunk at plan time - Apply the same start rule in the headless probe planner - Move Iris structure footprints and carves onto the shared StructureWaterRules and remove StructureWaterFootprint and StructureCarveWater - Add allowWater to the content-derived placement identity when set, so deduplicated native starts do not depend on list order - Pass dry water to native terrain integrator calls in the adapter tests
This commit is contained in:
1 parent
ba0bb1a2c0
commit
e4efd7800d
22 files changed
+264
-264
No files matched your search
+7
-5
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructurePalette;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureTerrainSettings;
|
||||
@@ -90,7 +92,7 @@ public class NativeStructurePostProcessorEncaseTest {
|
||||
.setHorizontalPadding(1)
|
||||
.setCeilingPadding(1)
|
||||
.setFloorPadding(1),
|
||||
null);
|
||||
null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.DIRT.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.minY(), bounds.minZ()));
|
||||
@@ -111,7 +113,7 @@ public class NativeStructurePostProcessorEncaseTest {
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), bounds, "minecraft:stronghold", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.ENCASE),
|
||||
null);
|
||||
null, StructureWater.DRY);
|
||||
|
||||
assertEquals(-1, bounds.minY());
|
||||
assertEquals(Blocks.DEEPSLATE.defaultBlockState(),
|
||||
@@ -222,7 +224,7 @@ public class NativeStructurePostProcessorEncaseTest {
|
||||
new IrisStructureTerrain()
|
||||
.setMode(StructureTerrainMode.ENCASE)
|
||||
.setEncasePalette(palette),
|
||||
NativeStructurePostProcessorEncaseTest::tuffBlock);
|
||||
NativeStructurePostProcessorEncaseTest::tuffBlock, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.TUFF.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.minY(), bounds.minZ()));
|
||||
@@ -250,7 +252,7 @@ public class NativeStructurePostProcessorEncaseTest {
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), area, "test:bury", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.SOURCE), null);
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.SOURCE), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 5, groundY, bounds.minZ()));
|
||||
@@ -277,7 +279,7 @@ public class NativeStructurePostProcessorEncaseTest {
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), area, "test:encapsulate", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.SOURCE), null);
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.SOURCE), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 11, bounds.minY(), bounds.minZ()));
|
||||
|
||||
+12
-10
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.nativegen;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.terrain.NativeStructureVerticalPlacer;
|
||||
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.terrain.NativeStructureReferenceEnvelope;
|
||||
@@ -2185,7 +2187,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), bounds, "minecraft:desert_pyramid", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.VACUUM), null);
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.VACUUM), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.minY(), bounds.minZ()));
|
||||
@@ -2209,7 +2211,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
new IrisStructureTerrain()
|
||||
.setMode(StructureTerrainMode.FORCE_CARVE)
|
||||
.setHorizontalPadding(1)
|
||||
.setCeilingPadding(1), null);
|
||||
.setCeilingPadding(1), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, bounds.maxX() + 1, bounds.minY(), bounds.maxZ()));
|
||||
@@ -2241,7 +2243,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), area, "minecraft:ancient_city", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.FORCE_CARVE), null);
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.FORCE_CARVE), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, firstBounds.minX(), y, z));
|
||||
@@ -2382,7 +2384,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
bounds.maxX() + 6, bounds.maxY() + 12, bounds.maxZ() + 6);
|
||||
Map<BlockPos, BlockState> blocks = fill(area);
|
||||
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(world(blocks), area, carve);
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(world(blocks), area, StructureWater.DRY, carve);
|
||||
|
||||
int centerX = bounds.minX() + bounds.getXSpan() / 2;
|
||||
int centerZ = bounds.minZ() + bounds.getZSpan() / 2;
|
||||
@@ -2407,9 +2409,9 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
Map<BlockPos, BlockState> lobedBlocks = fill(area);
|
||||
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(
|
||||
world(uniformBlocks), area, organicCarve(start, 10, 0D));
|
||||
world(uniformBlocks), area, StructureWater.DRY, organicCarve(start, 10, 0D));
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(
|
||||
world(lobedBlocks), area, organicCarve(start, 10, 0.85D));
|
||||
world(lobedBlocks), area, StructureWater.DRY, organicCarve(start, 10, 0.85D));
|
||||
|
||||
int uniform = 0;
|
||||
int lobed = 0;
|
||||
@@ -2457,9 +2459,9 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
// Each chunk context rebuilds its own noise channels from the shared start identity.
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(
|
||||
world(wideBlocks), wide, organicCarve(start, 6));
|
||||
world(wideBlocks), wide, StructureWater.DRY, organicCarve(start, 6));
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(
|
||||
world(narrowBlocks), narrow, organicCarve(start, 6));
|
||||
world(narrowBlocks), narrow, StructureWater.DRY, organicCarve(start, 6));
|
||||
|
||||
int carved = 0;
|
||||
for (int x = narrow.minX(); x <= narrow.maxX(); x++) {
|
||||
@@ -2496,7 +2498,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
.setCeilingPadding(8)
|
||||
.setFloorPadding(0)
|
||||
.setErosionStrength(1D)
|
||||
.setErosionFrequency(0.05D), null);
|
||||
.setErosionFrequency(0.05D), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, centerX, bounds.minY(), centerZ));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
@@ -2814,7 +2816,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
SLAB_WIDTH - 1 + SLAB_PADDING, transectY, SLAB_DEPTH - 1);
|
||||
Map<BlockPos, BlockState> blocks = fill(area);
|
||||
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(world(blocks), area,
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(world(blocks), area, StructureWater.DRY,
|
||||
NativeStructureTerrainIntegrator.organicCarve(
|
||||
footprint, terrain, StructureCarveShape.ERODED, TEST_SEED));
|
||||
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.platform.bukkit.nms.v26_2_R1;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
|
||||
import art.arcane.volmlib.nativelib.v26_2_R1.terrain.NativeStructureWorldgenAccess;
|
||||
|
||||
import art.arcane.iris.structure.placement.IrisStructureTerrain;
|
||||
@@ -94,13 +96,13 @@ public class NativeStructureWorldgenAccessTest {
|
||||
unbounded.rejectDistantTerrainReads = true;
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> NativeStructurePostProcessor.prepareTerrain(
|
||||
unbounded.world(), area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState()));
|
||||
unbounded.world(), area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState(), StructureWater.DRY));
|
||||
|
||||
RecordingDelegate recording = new RecordingDelegate();
|
||||
recording.rejectDistantTerrainReads = true;
|
||||
NativeStructureWorldgenAccess access = access(recording);
|
||||
NativeStructurePostProcessor.prepareTerrain(
|
||||
access, area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState());
|
||||
access, area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState(), StructureWater.DRY);
|
||||
|
||||
assertEquals(0, recording.heightReads);
|
||||
assertEquals(0, recording.chunkReads);
|
||||
|
||||
+9
-1
@@ -1,6 +1,8 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeGenerationScope;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWaterRules;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureInjectionPolicy;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureOwnershipRecordView;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructurePlacementDecision;
|
||||
@@ -159,6 +161,11 @@ final class HeadlessStructurePlanner {
|
||||
policies.injection().discard(plan.structureKey(), chunk.getPos().x(), chunk.getPos().z());
|
||||
continue;
|
||||
}
|
||||
if (!StructureWaterRules.admitsStart(plan, policies.water(), NativeStructureTerrainIntegrator.pieceFootprints(generated))) {
|
||||
chunk.setStartForStructure(structure, StructureStart.INVALID_START);
|
||||
policies.injection().discard(plan.structureKey(), chunk.getPos().x(), chunk.getPos().z());
|
||||
continue;
|
||||
}
|
||||
BoundingBox envelope = NativeStructureReferenceEnvelope.referenceBounds(generated, structure,
|
||||
plan.terrain(), plan.structureKey());
|
||||
policies.injection().record(plan, NativeStructureOwnershipFingerprint.capture(plan.structureKey(), generated, envelope));
|
||||
@@ -319,11 +326,12 @@ final class HeadlessStructurePlanner {
|
||||
|
||||
record Policies<P extends StructureStartPlan, O extends StructureOwnershipRecordView<O>>(
|
||||
StructureInjectionPolicy<P> injection, StructureReferencePolicy<P, O> references,
|
||||
Predicate<BoundingBox> allowsFootprint) {
|
||||
Predicate<BoundingBox> allowsFootprint, StructureWater water) {
|
||||
Policies {
|
||||
Objects.requireNonNull(injection, "injection");
|
||||
Objects.requireNonNull(references, "references");
|
||||
Objects.requireNonNull(allowsFootprint, "allowsFootprint");
|
||||
Objects.requireNonNull(water, "water");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.iris.structure.placement.IrisStructureWater;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.platform.bukkit.nms.BukkitBiomePolicy;
|
||||
import art.arcane.iris.structure.nativegen.IrisStructurePolicy;
|
||||
@@ -63,7 +64,8 @@ final class HeadlessTerrainContext implements AutoCloseable {
|
||||
IrisStructurePolicy policy = new IrisStructurePolicy(engine);
|
||||
policies = new HeadlessStructurePlanner.Policies<>(policy, policy,
|
||||
bounds -> engine.getComplex().allowsNewGenerationFootprint(
|
||||
bounds.minX(), bounds.minZ(), bounds.maxX(), bounds.maxZ()));
|
||||
bounds.minX(), bounds.minZ(), bounds.maxX(), bounds.maxZ()),
|
||||
IrisStructureWater.world(engine));
|
||||
NativeBiomeRegistryImpl registry = new NativeBiomeRegistryImpl(runtime.registries().lookupOrThrow(Registries.BIOME));
|
||||
biomes = new BukkitBiomePolicy<>(new BukkitBiomePolicy.RuntimeOptions<>(seed, engine, null, () -> registry), registry);
|
||||
serialization = new HeadlessChunkSerialization.Context(new StructurePieceSerializationContext(
|
||||
|
||||
+7
-5
@@ -1,5 +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.StructurePalette;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureTerrainSettings;
|
||||
@@ -90,7 +92,7 @@ public class NativeStructurePostProcessorEncaseTest {
|
||||
.setHorizontalPadding(1)
|
||||
.setCeilingPadding(1)
|
||||
.setFloorPadding(1),
|
||||
null);
|
||||
null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.DIRT.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.minY(), bounds.minZ()));
|
||||
@@ -111,7 +113,7 @@ public class NativeStructurePostProcessorEncaseTest {
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), bounds, "minecraft:stronghold", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.ENCASE),
|
||||
null);
|
||||
null, StructureWater.DRY);
|
||||
|
||||
assertEquals(-1, bounds.minY());
|
||||
assertEquals(Blocks.DEEPSLATE.defaultBlockState(),
|
||||
@@ -222,7 +224,7 @@ public class NativeStructurePostProcessorEncaseTest {
|
||||
new IrisStructureTerrain()
|
||||
.setMode(StructureTerrainMode.ENCASE)
|
||||
.setEncasePalette(palette),
|
||||
NativeStructurePostProcessorEncaseTest::tuffBlock);
|
||||
NativeStructurePostProcessorEncaseTest::tuffBlock, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.TUFF.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.minY(), bounds.minZ()));
|
||||
@@ -250,7 +252,7 @@ public class NativeStructurePostProcessorEncaseTest {
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), area, "test:bury", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.SOURCE), null);
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.SOURCE), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 5, groundY, bounds.minZ()));
|
||||
@@ -277,7 +279,7 @@ public class NativeStructurePostProcessorEncaseTest {
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), area, "test:encapsulate", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.SOURCE), null);
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.SOURCE), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX() - 11, bounds.minY(), bounds.minZ()));
|
||||
|
||||
+12
-10
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.nativegen.v26_3_R1;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
|
||||
import art.arcane.volmlib.nativelib.v26_3_R1.terrain.NativeStructureVerticalPlacer;
|
||||
|
||||
import art.arcane.volmlib.nativelib.v26_3_R1.terrain.NativeStructureReferenceEnvelope;
|
||||
@@ -2185,7 +2187,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), bounds, "minecraft:desert_pyramid", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.VACUUM), null);
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.VACUUM), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
state(blocks, bounds.minX(), bounds.minY(), bounds.minZ()));
|
||||
@@ -2209,7 +2211,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
new IrisStructureTerrain()
|
||||
.setMode(StructureTerrainMode.FORCE_CARVE)
|
||||
.setHorizontalPadding(1)
|
||||
.setCeilingPadding(1), null);
|
||||
.setCeilingPadding(1), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, bounds.maxX() + 1, bounds.minY(), bounds.maxZ()));
|
||||
@@ -2241,7 +2243,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
NativeStructureTerrainIntegrator.integrateTerrain(
|
||||
world(blocks), area, "minecraft:ancient_city", start,
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.FORCE_CARVE), null);
|
||||
new IrisStructureTerrain().setMode(StructureTerrainMode.FORCE_CARVE), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.AIR.defaultBlockState(),
|
||||
state(blocks, firstBounds.minX(), y, z));
|
||||
@@ -2382,7 +2384,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
bounds.maxX() + 6, bounds.maxY() + 12, bounds.maxZ() + 6);
|
||||
Map<BlockPos, BlockState> blocks = fill(area);
|
||||
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(world(blocks), area, carve);
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(world(blocks), area, StructureWater.DRY, carve);
|
||||
|
||||
int centerX = bounds.minX() + bounds.getXSpan() / 2;
|
||||
int centerZ = bounds.minZ() + bounds.getZSpan() / 2;
|
||||
@@ -2407,9 +2409,9 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
Map<BlockPos, BlockState> lobedBlocks = fill(area);
|
||||
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(
|
||||
world(uniformBlocks), area, organicCarve(start, 10, 0D));
|
||||
world(uniformBlocks), area, StructureWater.DRY, organicCarve(start, 10, 0D));
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(
|
||||
world(lobedBlocks), area, organicCarve(start, 10, 0.85D));
|
||||
world(lobedBlocks), area, StructureWater.DRY, organicCarve(start, 10, 0.85D));
|
||||
|
||||
int uniform = 0;
|
||||
int lobed = 0;
|
||||
@@ -2457,9 +2459,9 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
|
||||
// Each chunk context rebuilds its own noise channels from the shared start identity.
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(
|
||||
world(wideBlocks), wide, organicCarve(start, 6));
|
||||
world(wideBlocks), wide, StructureWater.DRY, organicCarve(start, 6));
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(
|
||||
world(narrowBlocks), narrow, organicCarve(start, 6));
|
||||
world(narrowBlocks), narrow, StructureWater.DRY, organicCarve(start, 6));
|
||||
|
||||
int carved = 0;
|
||||
for (int x = narrow.minX(); x <= narrow.maxX(); x++) {
|
||||
@@ -2496,7 +2498,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
.setCeilingPadding(8)
|
||||
.setFloorPadding(0)
|
||||
.setErosionStrength(1D)
|
||||
.setErosionFrequency(0.05D), null);
|
||||
.setErosionFrequency(0.05D), null, StructureWater.DRY);
|
||||
|
||||
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, centerX, bounds.minY(), centerZ));
|
||||
assertEquals(Blocks.STONE.defaultBlockState(),
|
||||
@@ -2814,7 +2816,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
SLAB_WIDTH - 1 + SLAB_PADDING, transectY, SLAB_DEPTH - 1);
|
||||
Map<BlockPos, BlockState> blocks = fill(area);
|
||||
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(world(blocks), area,
|
||||
NativeStructureTerrainIntegrator.carveOrganicColumns(world(blocks), area, StructureWater.DRY,
|
||||
NativeStructureTerrainIntegrator.organicCarve(
|
||||
footprint, terrain, StructureCarveShape.ERODED, TEST_SEED));
|
||||
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.platform.bukkit.nms.v26_3_R1;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
|
||||
import art.arcane.volmlib.nativelib.v26_3_R1.terrain.NativeStructureWorldgenAccess;
|
||||
|
||||
import art.arcane.iris.structure.placement.IrisStructureTerrain;
|
||||
@@ -94,13 +96,13 @@ public class NativeStructureWorldgenAccessTest {
|
||||
unbounded.rejectDistantTerrainReads = true;
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> NativeStructurePostProcessor.prepareTerrain(
|
||||
unbounded.world(), area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState()));
|
||||
unbounded.world(), area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState(), StructureWater.DRY));
|
||||
|
||||
RecordingDelegate recording = new RecordingDelegate();
|
||||
recording.rejectDistantTerrainReads = true;
|
||||
NativeStructureWorldgenAccess access = access(recording);
|
||||
NativeStructurePostProcessor.prepareTerrain(
|
||||
access, area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState());
|
||||
access, area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState(), StructureWater.DRY);
|
||||
|
||||
assertEquals(0, recording.heightReads);
|
||||
assertEquals(0, recording.chunkReads);
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
|
||||
import art.arcane.iris.structure.nativegen.IrisNativeStructure;
|
||||
import art.arcane.iris.structure.nativegen.IrisNativeStructureDecision;
|
||||
import art.arcane.iris.structure.nativegen.NativeStructureGenerationStatus;
|
||||
@@ -215,7 +217,7 @@ public class HeadlessStructurePlannerTest {
|
||||
new IrisNativeStructure().setStructure("probe:hut"), -1, 0, 30);
|
||||
TestPolicy policy = new TestPolicy(plan);
|
||||
HeadlessStructurePlanner.Policies<NativeStructureStartPlan, NativeStructureOwnershipRecord> policies =
|
||||
new HeadlessStructurePlanner.Policies<>(policy, policy, footprint -> true);
|
||||
new HeadlessStructurePlanner.Policies<>(policy, policy, footprint -> true, StructureWater.DRY);
|
||||
try (MultiPackResourceManager resources = resources();
|
||||
LevelStorageSource.LevelStorageAccess storage = LevelStorageSource.createDefault(temporary.newFolder().toPath()).createAccess("world")) {
|
||||
StructureTemplateManager templates = new StructureTemplateManager(resources, storage,
|
||||
@@ -249,7 +251,7 @@ public class HeadlessStructurePlannerTest {
|
||||
assertTrue(target.chunk().getAllReferences().get(hut.value()).contains(new ChunkPos(-1, 0).pack()));
|
||||
assertEquals(ChunkStatus.STRUCTURE_REFERENCES, target.chunk().getPersistedStatus());
|
||||
HeadlessStructurePlanner.Policies<NativeStructureStartPlan, NativeStructureOwnershipRecord> excluded =
|
||||
new HeadlessStructurePlanner.Policies<>(policy, policy, footprint -> false);
|
||||
new HeadlessStructurePlanner.Policies<>(policy, policy, footprint -> false, StructureWater.DRY);
|
||||
HeadlessStructurePlanner.PlannedChunk<NativeStructureOwnershipRecord> rejected = HeadlessStructurePlanner.plan(
|
||||
context, excluded, new ChunkPos(-1, 0));
|
||||
assertFalse(rejected.chunk().getStartForStructure(hut.value()).isValid());
|
||||
|
||||
+7
@@ -12,6 +12,7 @@ import art.arcane.iris.structure.nativegen.NativeStructureStartPlan;
|
||||
import art.arcane.iris.structure.nativegen.NativeStructureVolumeIndex;
|
||||
import art.arcane.iris.structure.nativegen.StructureLocateSearch;
|
||||
import art.arcane.iris.structure.placement.IrisStructureLocator;
|
||||
import art.arcane.iris.structure.placement.IrisStructureWater;
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeModdedStructureStage;
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.terrain.NativeStructureVolumeSource;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockChangeSet;
|
||||
@@ -23,6 +24,7 @@ import art.arcane.volmlib.nativelib.terrain.structure.StructurePlacementDecision
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureReferencePolicy;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureSeaSurface;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureVolumePolicy;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -130,6 +132,11 @@ final class ModdedNativeStructurePolicy implements NativeModdedStructureStage.Po
|
||||
return GenerationWritePolicy.seaSurface(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureWater water(Engine context) {
|
||||
return IrisStructureWater.world(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntBinaryOperator worldgenHeight(Engine context, int runtimeMinY, boolean floor) {
|
||||
return (x, z) -> Engine.hostHeight(context, x, z, floor) + runtimeMinY + 1;
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.modded.ModdedNativeStructureWorldgenAccess;
|
||||
|
||||
import art.arcane.iris.structure.placement.IrisStructureTerrain;
|
||||
@@ -94,13 +96,13 @@ public class ModdedNativeStructureWorldgenAccessTest {
|
||||
unbounded.rejectDistantTerrainReads = true;
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> NativeStructurePostProcessor.prepareTerrain(
|
||||
unbounded.world(), area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState()));
|
||||
unbounded.world(), area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState(), StructureWater.DRY));
|
||||
|
||||
RecordingDelegate recording = new RecordingDelegate();
|
||||
recording.rejectDistantTerrainReads = true;
|
||||
ModdedNativeStructureWorldgenAccess access = access(recording);
|
||||
NativeStructurePostProcessor.prepareTerrain(
|
||||
access, area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState());
|
||||
access, area, targets, (palette, rng, x, y, z) -> Blocks.STONE.defaultBlockState(), StructureWater.DRY);
|
||||
|
||||
assertEquals(0, recording.heightReads);
|
||||
assertEquals(0, recording.chunkReads);
|
||||
|
||||
@@ -22,11 +22,14 @@ import art.arcane.volmlib.util.structure.StructureCarvingFootprint;
|
||||
|
||||
import art.arcane.volmlib.util.structure.StructureCarveEnvelope;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWaterRules;
|
||||
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.cache.Cache;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.structure.placement.IrisStructureLocator;
|
||||
import art.arcane.iris.structure.placement.IrisStructureWater;
|
||||
import art.arcane.iris.structure.placement.PlacedStructurePiece;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementScope;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementMarker;
|
||||
@@ -338,7 +341,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
+ " margin=" + margin + " head=" + head + " floorCut=" + floorCut + " work=" + work);
|
||||
}
|
||||
|
||||
StructureCarveWater water = StructureCarveWater.of(getEngineMantle().getComplex(),
|
||||
StructureWaterRules.Carve water = StructureWaterRules.carve(IrisStructureWater.mantle(getEngineMantle().getComplex()),
|
||||
footprint.minX(), footprint.minZ(), footprint.maxX(), footprint.maxZ());
|
||||
double sideReachSquared = (double) margin * margin;
|
||||
double downReach = Math.max(1D, floorCut);
|
||||
@@ -397,7 +400,8 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
}
|
||||
|
||||
private void carveBox(MantleWriter writer, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int mantleOffset) {
|
||||
StructureCarveWater water = StructureCarveWater.of(getEngineMantle().getComplex(), minX, minZ, maxX, maxZ);
|
||||
StructureWaterRules.Carve water = StructureWaterRules.carve(IrisStructureWater.mantle(getEngineMantle().getComplex()),
|
||||
minX, minZ, maxX, maxZ);
|
||||
for (int bx = minX; bx <= maxX; bx++) {
|
||||
for (int bz = minZ; bz <= maxZ; bz++) {
|
||||
for (int by = minY; by <= maxY; by++) {
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
|
||||
final class StructureCarveWater {
|
||||
static final int CONTAINMENT = 2;
|
||||
static final int FLOOR = 2;
|
||||
private static final StructureCarveWater NONE = new StructureCarveWater(0, 0, 0, 0, null, null);
|
||||
|
||||
private final int minX;
|
||||
private final int minZ;
|
||||
private final int width;
|
||||
private final int depth;
|
||||
private final int[] floors;
|
||||
private final int[] tops;
|
||||
|
||||
private StructureCarveWater(int minX, int minZ, int width, int depth, int[] floors, int[] tops) {
|
||||
this.minX = minX;
|
||||
this.minZ = minZ;
|
||||
this.width = width;
|
||||
this.depth = depth;
|
||||
this.floors = floors;
|
||||
this.tops = tops;
|
||||
}
|
||||
|
||||
static StructureCarveWater of(IrisComplex complex, int minX, int minZ, int maxX, int maxZ) {
|
||||
if (complex == null || maxX < minX || maxZ < minZ) {
|
||||
return NONE;
|
||||
}
|
||||
int width = maxX - minX + 1;
|
||||
int depth = maxZ - minZ + 1;
|
||||
int sampleWidth = width + CONTAINMENT * 2;
|
||||
int sampleDepth = depth + CONTAINMENT * 2;
|
||||
boolean[] wet = new boolean[sampleWidth * sampleDepth];
|
||||
int[] beds = new int[wet.length];
|
||||
int[] heads = new int[wet.length];
|
||||
ProceduralStream<WaterRole> roles = complex.getWaterRoleStream();
|
||||
long revision = ProvisionalSampling.revision();
|
||||
boolean any = false;
|
||||
for (int sz = 0; sz < sampleDepth; sz++) {
|
||||
int z = minZ - CONTAINMENT + sz;
|
||||
for (int sx = 0; sx < sampleWidth; sx++) {
|
||||
int x = minX - CONTAINMENT + sx;
|
||||
if (!roles.get(x, z).wet()) {
|
||||
continue;
|
||||
}
|
||||
int index = sz * sampleWidth + sx;
|
||||
wet[index] = true;
|
||||
beds[index] = complex.getRoundedHeighteightStream().get(x, z);
|
||||
heads[index] = (int) Math.round(complex.getWaterHeadStream().getDouble(x, z));
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
if (ProvisionalSampling.revision() != revision) {
|
||||
throw new ProvisionalAnswerException("Structure carve over " + minX + "," + minZ + " to " + maxX + "," + maxZ
|
||||
+ " read a provisional water answer; structures only carve around final water.");
|
||||
}
|
||||
if (!any) {
|
||||
return NONE;
|
||||
}
|
||||
int[] floors = new int[width * depth];
|
||||
int[] tops = new int[width * depth];
|
||||
for (int z = 0; z < depth; z++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
int floor = Integer.MAX_VALUE;
|
||||
int top = Integer.MIN_VALUE;
|
||||
for (int dz = -CONTAINMENT; dz <= CONTAINMENT; dz++) {
|
||||
for (int dx = -CONTAINMENT; dx <= CONTAINMENT; dx++) {
|
||||
int sample = (z + CONTAINMENT + dz) * sampleWidth + x + CONTAINMENT + dx;
|
||||
if (!wet[sample]) {
|
||||
continue;
|
||||
}
|
||||
floor = Math.min(floor, beds[sample] - FLOOR);
|
||||
top = dx == 0 && dz == 0 ? Integer.MAX_VALUE : Math.max(top, heads[sample]);
|
||||
}
|
||||
}
|
||||
floors[z * width + x] = floor;
|
||||
tops[z * width + x] = top;
|
||||
}
|
||||
}
|
||||
return new StructureCarveWater(minX, minZ, width, depth, floors, tops);
|
||||
}
|
||||
|
||||
boolean keeps(int x, int y, int z) {
|
||||
if (floors == null) {
|
||||
return false;
|
||||
}
|
||||
int localX = x - minX;
|
||||
int localZ = z - minZ;
|
||||
if (localX < 0 || localZ < 0 || localX >= width || localZ >= depth) {
|
||||
return false;
|
||||
}
|
||||
int index = localZ * width + localX;
|
||||
return y >= floors[index] && y <= tops[index];
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import art.arcane.iris.structure.nativegen.NativeStructureStartPlan;
|
||||
import art.arcane.iris.structure.nativegen.NativeStructureVolumeIndex;
|
||||
import art.arcane.iris.structure.nativegen.StructureLocateSearch;
|
||||
import art.arcane.iris.structure.placement.IrisStructureLocator;
|
||||
import art.arcane.iris.structure.placement.IrisStructureWater;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockChangeSet;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockPositionPredicate;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
@@ -23,6 +24,7 @@ import art.arcane.volmlib.nativelib.terrain.structure.StructurePlacementDecision
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureReferencePolicy;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureSeaSurface;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureVolumePolicy;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -126,6 +128,11 @@ public final class BukkitStructureStagePolicy implements StructureStagePolicy<
|
||||
return GenerationWritePolicy.seaSurface(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureWater water(Engine context) {
|
||||
return IrisStructureWater.world(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntBinaryOperator worldgenHeight(Engine context, int runtimeMinY, boolean floor) {
|
||||
return (x, z) -> Engine.hostHeight(context, x, z, floor) + runtimeMinY + 1;
|
||||
|
||||
-5
@@ -3,7 +3,6 @@ package art.arcane.iris.structure.nativegen;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementGrid;
|
||||
import art.arcane.iris.structure.placement.StructurePlacementScope;
|
||||
import art.arcane.iris.structure.placement.StructureWaterFootprint;
|
||||
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.structure.placement.IrisStructureAnchorMode;
|
||||
@@ -65,10 +64,6 @@ public final class NativeStructurePlacementPlanner {
|
||||
if (baseY == null) {
|
||||
return null;
|
||||
}
|
||||
if (!placement.isUnderground()
|
||||
&& !StructureWaterFootprint.admitsChunk(activeEngine, placement, source.getStructure(), chunkX, chunkZ)) {
|
||||
return null;
|
||||
}
|
||||
return new NativeStructureStartPlan(placement, source, chunkX, chunkZ, baseY);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ public record NativeStructureStartPlan(
|
||||
return placement.isUnderground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowWater() {
|
||||
return placement.isAllowWater();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replacesSource() {
|
||||
return placement.getNativeSuppression() == NativeStructureSuppression.REPLACE_SOURCE;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package art.arcane.iris.structure.placement;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureLocateCandidate;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureStagePolicy;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWaterRules;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.StructureLocateLimitException;
|
||||
|
||||
@@ -590,8 +592,8 @@ public final class IrisStructureLocator {
|
||||
"assembled pieces exceed the configured structure or world bounds")) {
|
||||
return null;
|
||||
}
|
||||
if (!placement.isAnchoredUnderground()
|
||||
&& !StructureWaterFootprint.admitsPieces(engine, placement, selectedKey, pieces, cx, cz)) {
|
||||
if (!placement.isAnchoredUnderground() && !placement.isAllowWater()
|
||||
&& !StructureWaterRules.admitsFootprint(IrisStructureWater.mantle(engine.getComplex()), pieceFootprints(pieces))) {
|
||||
return null;
|
||||
}
|
||||
if (!allowsResolvedFootprint(engine, placement, structure, pieces)) {
|
||||
@@ -939,6 +941,14 @@ public final class IrisStructureLocator {
|
||||
);
|
||||
}
|
||||
|
||||
private static List<StructureStagePolicy.Footprint> pieceFootprints(KList<PlacedStructurePiece> pieces) {
|
||||
List<StructureStagePolicy.Footprint> footprints = new ArrayList<>(pieces.size());
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
footprints.add(new StructureStagePolicy.Footprint(piece.getMinX(), piece.getMinZ(), piece.getMaxX(), piece.getMaxZ()));
|
||||
}
|
||||
return footprints;
|
||||
}
|
||||
|
||||
private static int saturatedOffset(int coordinate, int offset) {
|
||||
long result = (long) coordinate + offset;
|
||||
return (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, result));
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package art.arcane.iris.structure.placement;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWaterColumn;
|
||||
|
||||
public final class IrisStructureWater implements StructureWater {
|
||||
private final IrisComplex complex;
|
||||
private final int offsetY;
|
||||
|
||||
private IrisStructureWater(IrisComplex complex, int offsetY) {
|
||||
this.complex = complex;
|
||||
this.offsetY = offsetY;
|
||||
}
|
||||
|
||||
public static StructureWater mantle(IrisComplex complex) {
|
||||
return complex == null ? StructureWater.DRY : new IrisStructureWater(complex, 0);
|
||||
}
|
||||
|
||||
public static StructureWater world(Engine engine) {
|
||||
IrisComplex complex = engine.getComplex();
|
||||
return complex == null ? StructureWater.DRY : new IrisStructureWater(complex, engine.getMinHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureWaterColumn column(int x, int z) {
|
||||
long revision = ProvisionalSampling.revision();
|
||||
WaterRole role = complex.getWaterRoleStream().get(x, z);
|
||||
StructureWaterColumn column = role.wet()
|
||||
? new StructureWaterColumn(true, river(role),
|
||||
complex.getRoundedHeighteightStream().get(x, z) + offsetY,
|
||||
(int) Math.round(complex.getWaterHeadStream().getDouble(x, z)) + offsetY)
|
||||
: StructureWaterColumn.DRY;
|
||||
if (ProvisionalSampling.revision() != revision && !complex.isPlatformMainThread()) {
|
||||
throw new ProvisionalAnswerException("Structure water at " + x + "," + z
|
||||
+ " read a provisional answer; structures are only placed and carved around final water.");
|
||||
}
|
||||
return column;
|
||||
}
|
||||
|
||||
static boolean river(WaterRole role) {
|
||||
return switch (role) {
|
||||
case CHANNEL, POND, CASCADE, WATERFALL -> true;
|
||||
case NONE, BANK, SHORE, POND_SHORE, DAM, MOUTH, INLET -> false;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -159,6 +159,9 @@ public final class StructurePlacementGrid {
|
||||
signature = appendLong(signature, placement.isUnderwater() ? 1L : 0L);
|
||||
signature = appendSources(signature, placement);
|
||||
signature = appendAnchor(signature, placement);
|
||||
if (placement.isAllowWater()) {
|
||||
signature = appendLong(signature, 1L);
|
||||
}
|
||||
}
|
||||
return signature;
|
||||
}
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
package art.arcane.iris.structure.placement;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
|
||||
public final class StructureWaterFootprint {
|
||||
private static final int MAX_WATER_PERCENT = 10;
|
||||
private static final int CHUNK = 16;
|
||||
|
||||
private StructureWaterFootprint() {
|
||||
}
|
||||
|
||||
public static boolean admitsChunk(Engine engine, IrisStructurePlacement placement, String structureKey,
|
||||
int chunkX, int chunkZ) {
|
||||
IrisComplex complex = engine.getComplex();
|
||||
if (placement.isAllowWater() || complex == null) {
|
||||
return true;
|
||||
}
|
||||
ProceduralStream<WaterRole> roles = complex.getWaterRoleStream();
|
||||
long revision = ProvisionalSampling.revision();
|
||||
int water = 0;
|
||||
int minX = chunkX << 4;
|
||||
int minZ = chunkZ << 4;
|
||||
for (int x = minX; x < minX + CHUNK; x++) {
|
||||
for (int z = minZ; z < minZ + CHUNK; z++) {
|
||||
if (coversWater(roles.get(x, z))) {
|
||||
water++;
|
||||
}
|
||||
}
|
||||
}
|
||||
requireFinal(complex, revision, structureKey, chunkX, chunkZ);
|
||||
return admits(water, CHUNK * CHUNK);
|
||||
}
|
||||
|
||||
public static boolean admitsPieces(Engine engine, IrisStructurePlacement placement, String structureKey,
|
||||
KList<PlacedStructurePiece> pieces, int chunkX, int chunkZ) {
|
||||
IrisComplex complex = engine.getComplex();
|
||||
if (placement.isAllowWater() || complex == null) {
|
||||
return true;
|
||||
}
|
||||
LongOpenHashSet columns = new LongOpenHashSet();
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
for (int x = piece.getMinX(); x <= piece.getMaxX(); x++) {
|
||||
for (int z = piece.getMinZ(); z <= piece.getMaxZ(); z++) {
|
||||
columns.add(columnKey(x, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
ProceduralStream<WaterRole> roles = complex.getWaterRoleStream();
|
||||
long revision = ProvisionalSampling.revision();
|
||||
int water = 0;
|
||||
LongIterator iterator = columns.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
long column = iterator.nextLong();
|
||||
if (coversWater(roles.get((int) (column >> 32), (int) column))) {
|
||||
water++;
|
||||
}
|
||||
}
|
||||
requireFinal(complex, revision, structureKey, chunkX, chunkZ);
|
||||
return admits(water, columns.size());
|
||||
}
|
||||
|
||||
static boolean coversWater(WaterRole role) {
|
||||
return switch (role) {
|
||||
case CHANNEL, POND, CASCADE, WATERFALL -> true;
|
||||
case NONE, BANK, SHORE, POND_SHORE, DAM, MOUTH, INLET -> false;
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean admits(int water, int columns) {
|
||||
return (long) water * 100L <= (long) columns * MAX_WATER_PERCENT;
|
||||
}
|
||||
|
||||
private static void requireFinal(IrisComplex complex, long revision, String structureKey, int chunkX, int chunkZ) {
|
||||
if (ProvisionalSampling.revision() == revision || complex.isPlatformMainThread()) {
|
||||
return;
|
||||
}
|
||||
throw new ProvisionalAnswerException("Structure '" + structureKey + "' starting in chunk " + chunkX + "," + chunkZ
|
||||
+ " read a provisional water answer; structures are only placed from final water.");
|
||||
}
|
||||
|
||||
private static long columnKey(int x, int z) {
|
||||
return ((long) x << 32) | (z & 0xffffffffL);
|
||||
}
|
||||
}
|
||||
+102
-23
@@ -9,20 +9,28 @@ import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.platform.bukkit.nms.BukkitStructureStagePolicy;
|
||||
import art.arcane.iris.structure.placement.IrisStructureAnchorMode;
|
||||
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
||||
import art.arcane.iris.structure.placement.IrisStructureTerrain;
|
||||
import art.arcane.volmlib.util.structure.StructureTerrainMode;
|
||||
import art.arcane.iris.structure.placement.StructureDistribution;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureStagePolicy;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWaterColumn;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWaterRules;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
@@ -36,6 +44,13 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class NativeStructurePlacementPlannerTest {
|
||||
private static final int BED = 140;
|
||||
private static final int HEAD = 143;
|
||||
private static final long LAND_IDENTITY = 7387932304999188754L;
|
||||
private static final List<StructureStagePolicy.Footprint> VILLAGE = List.of(
|
||||
new StructureStagePolicy.Footprint(0, 0, 15, 15),
|
||||
new StructureStagePolicy.Footprint(16, 0, 39, 15));
|
||||
|
||||
@Test
|
||||
public void undergroundPlanIsDeterministicAndUsesConfiguredBand() {
|
||||
Engine engine = engine(982374L, -64, 384, 90);
|
||||
@@ -144,26 +159,58 @@ public class NativeStructurePlacementPlannerTest {
|
||||
Engine engine = engine(77L, -64, 384, 150);
|
||||
Map<Long, WaterRole> roles = new HashMap<>();
|
||||
waterComplex(engine, roles, false);
|
||||
IrisStructurePlacement placement = nativePlacement();
|
||||
WaterRole[] water = {WaterRole.CHANNEL, WaterRole.POND, WaterRole.CASCADE, WaterRole.WATERFALL};
|
||||
for (int column = 0; column < 25; column++) {
|
||||
roles.put(columnKey(column & 15, column >> 4), water[column & 3]);
|
||||
for (int x = 36; x <= 39; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
roles.put(columnKey(x, z), water[(x + z) & 3]);
|
||||
}
|
||||
}
|
||||
IrisStructurePlacement placement = nativePlacement();
|
||||
NativeStructureStartPlan plan = NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0);
|
||||
StructureWater stageWater = new BukkitStructureStagePolicy(engine).water(engine);
|
||||
|
||||
assertNotNull("25 of 256 start-chunk columns of river, pond and fall water are within 10%",
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
assertNotNull(plan);
|
||||
assertTrue("64 of 640 piece columns, all beyond the start chunk, are 10% river",
|
||||
StructureWaterRules.admitsStart(plan, stageWater, VILLAGE));
|
||||
|
||||
roles.put(columnKey(9, 1), WaterRole.CHANNEL);
|
||||
assertNull("26 of 256 columns are more than 10% water",
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
roles.put(columnKey(35, 15), WaterRole.CHANNEL);
|
||||
assertFalse("65 of 640 piece columns are more than 10% river",
|
||||
StructureWaterRules.admitsStart(plan, stageWater, VILLAGE));
|
||||
|
||||
roles.clear();
|
||||
WaterRole[] dry = {WaterRole.MOUTH, WaterRole.INLET, WaterRole.SHORE, WaterRole.POND_SHORE, WaterRole.BANK, WaterRole.DAM};
|
||||
for (int column = 0; column < 256; column++) {
|
||||
roles.put(columnKey(column & 15, column >> 4), dry[column % dry.length]);
|
||||
int column = 0;
|
||||
for (int x = 0; x <= 39; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
roles.put(columnKey(x, z), dry[column++ % dry.length]);
|
||||
}
|
||||
}
|
||||
assertNotNull("mouths, inlets, shores, banks and dams do not count as river water",
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
assertTrue("mouths, inlets, shores, banks and dams do not count as river water",
|
||||
StructureWaterRules.admitsStart(plan, stageWater, VILLAGE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void riverInTheStartChunkLeavesTheDecisionToThePieces() {
|
||||
Engine engine = engine(77L, -64, 384, 150);
|
||||
Map<Long, WaterRole> roles = new HashMap<>();
|
||||
waterComplex(engine, roles, false);
|
||||
flood(roles);
|
||||
|
||||
assertNotNull(NativeStructurePlacementPlanner.planAt(engine, nativePlacement(), 0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stageWaterReportsWorldHeights() {
|
||||
Engine engine = engine(77L, -64, 384, 150);
|
||||
Map<Long, WaterRole> roles = new HashMap<>();
|
||||
waterComplex(engine, roles, false);
|
||||
roles.put(columnKey(3, 4), WaterRole.MOUTH);
|
||||
roles.put(columnKey(5, 4), WaterRole.POND);
|
||||
StructureWater stageWater = new BukkitStructureStagePolicy(engine).water(engine);
|
||||
|
||||
assertEquals(new StructureWaterColumn(true, false, BED - 64, HEAD - 64), stageWater.column(3, 4));
|
||||
assertEquals(new StructureWaterColumn(true, true, BED - 64, HEAD - 64), stageWater.column(5, 4));
|
||||
assertEquals(StructureWaterColumn.DRY, stageWater.column(6, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -176,8 +223,10 @@ public class NativeStructurePlacementPlannerTest {
|
||||
.setUnderground(true)
|
||||
.setMinHeight(-45)
|
||||
.setMaxHeight(-20);
|
||||
NativeStructureStartPlan plan = NativeStructurePlacementPlanner.planAt(engine, placement, 12, -7);
|
||||
|
||||
assertNotNull(NativeStructurePlacementPlanner.planAt(engine, placement, 12, -7));
|
||||
assertNotNull(plan);
|
||||
assertTrue(StructureWaterRules.admitsStart(plan, new BukkitStructureStagePolicy(engine).water(engine), VILLAGE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -186,28 +235,51 @@ public class NativeStructurePlacementPlannerTest {
|
||||
Map<Long, WaterRole> roles = new HashMap<>();
|
||||
waterComplex(engine, roles, false);
|
||||
flood(roles);
|
||||
StructureWater stageWater = new BukkitStructureStagePolicy(engine).water(engine);
|
||||
IrisStructurePlacement placement = nativePlacement();
|
||||
|
||||
assertNull(NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
assertFalse(StructureWaterRules.admitsStart(
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0), stageWater, VILLAGE));
|
||||
|
||||
placement.setAllowWater(true);
|
||||
assertNotNull(NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
NativeStructureStartPlan plan = NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0);
|
||||
assertTrue(plan.allowWater());
|
||||
assertTrue(StructureWaterRules.admitsStart(plan, stageWater, VILLAGE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void provisionalWaterAnswersNeverPlaceANativeStructure() {
|
||||
Engine engine = engine(77L, -64, 384, 150);
|
||||
IrisComplex complex = waterComplex(engine, new HashMap<>(), true);
|
||||
IrisStructurePlacement placement = nativePlacement();
|
||||
StructureWater stageWater = new BukkitStructureStagePolicy(engine).water(engine);
|
||||
|
||||
ProvisionalAnswerException failure = assertThrows(ProvisionalAnswerException.class,
|
||||
() -> NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
assertTrue(failure.getMessage().contains("minecraft:ancient_city"));
|
||||
assertTrue(failure.getMessage().contains("0,0"));
|
||||
() -> stageWater.column(20, 3));
|
||||
assertTrue(failure.getMessage().contains("20,3"));
|
||||
|
||||
when(complex.isPlatformMainThread()).thenReturn(true);
|
||||
assertNotNull("the server thread answers from what it has, as for heights",
|
||||
NativeStructurePlacementPlanner.planAt(engine, placement, 0, 0));
|
||||
assertEquals("the server thread answers from what it has, as for heights",
|
||||
StructureWaterColumn.DRY, stageWater.column(20, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowWaterSeparatesOtherwiseIdenticalPlacements() {
|
||||
IrisStructurePlacement land = nativePlacement();
|
||||
IrisStructurePlacement water = nativePlacement().setAllowWater(true);
|
||||
|
||||
assertEquals("placements that keep out of water keep their identity",
|
||||
LAND_IDENTITY, StructurePlacementGrid.placementIdentity(land));
|
||||
assertNotEquals(StructurePlacementGrid.placementIdentity(land), StructurePlacementGrid.placementIdentity(water));
|
||||
assertEquals("a placementId stays the whole identity",
|
||||
StructurePlacementGrid.placementIdentity(nativePlacement().setPlacementId("hut")),
|
||||
StructurePlacementGrid.placementIdentity(nativePlacement().setPlacementId("hut").setAllowWater(true)));
|
||||
|
||||
Engine engine = engine(77L, -64, 384, 150);
|
||||
bindPlacements(engine, land, water);
|
||||
IrisStructurePlacement first = NativeStructurePlacementPlanner.plansAt(engine, 0, 0).getFirst().placement();
|
||||
bindPlacements(engine, water, land);
|
||||
assertSame("the deduplicated start does not depend on list order",
|
||||
first, NativeStructurePlacementPlanner.plansAt(engine, 0, 0).getFirst().placement());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -305,6 +377,11 @@ public class NativeStructurePlacementPlannerTest {
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<WaterRole> roleStream = mock(ProceduralStream.class);
|
||||
when(heads.get(anyDouble(), anyDouble())).thenReturn(0D);
|
||||
when(heads.getDouble(anyDouble(), anyDouble())).thenReturn((double) HEAD);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<Integer> heights = mock(ProceduralStream.class);
|
||||
when(heights.get(anyDouble(), anyDouble())).thenReturn(BED);
|
||||
when(complex.getRoundedHeighteightStream()).thenReturn(heights);
|
||||
when(roleStream.get(anyDouble(), anyDouble())).thenAnswer(call -> {
|
||||
if (provisional) {
|
||||
ProvisionalSampling.mark();
|
||||
@@ -319,8 +396,10 @@ public class NativeStructurePlacementPlannerTest {
|
||||
}
|
||||
|
||||
private static void flood(Map<Long, WaterRole> roles) {
|
||||
for (int column = 0; column < 256; column++) {
|
||||
roles.put(columnKey(column & 15, column >> 4), WaterRole.CHANNEL);
|
||||
for (int x = 0; x <= 39; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
roles.put(columnKey(x, z), WaterRole.CHANNEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -469,6 +469,11 @@ public class IrisStructureLocatorContractTest {
|
||||
when(roles.get(anyDouble(), anyDouble())).thenAnswer(call -> river.contains(columnKey(
|
||||
(int) Math.floor(call.<Double>getArgument(0)), (int) Math.floor(call.<Double>getArgument(1))))
|
||||
? WaterRole.CHANNEL : WaterRole.NONE);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<Integer> beds = mock(ProceduralStream.class);
|
||||
when(beds.get(anyDouble(), anyDouble())).thenReturn(120);
|
||||
when(complex.getRoundedHeighteightStream()).thenReturn(beds);
|
||||
when(waterHead.getDouble(anyDouble(), anyDouble())).thenReturn(124D);
|
||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(128);
|
||||
when(engine.getDimension().getFluidHeight()).thenReturn(63);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
|
||||
Reference in new issue
Block a user