mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Merge lane B
- Land force place, unknown hydrology key warnings and the river fluid warning - Rename dryDrawdown, minHeadKeep and waterfallMinDrop across new code - Drop minCliffHeight with the old sea inlet passages - Keep per-placement failure containment on forced and replaced pieces - Repin the schema digest
This commit is contained in:
67 files changed
+2088
-340
No files matched your search
+5
-5
@@ -16,17 +16,17 @@ public class IrisHydrologyDefaultsTest {
|
||||
private static final String PLAN_JSON = """
|
||||
{
|
||||
"enabled": false,
|
||||
"drainage": { "fillEpsilon": 0.001, "breachDepth": 24, "wetnessThinning": true, "minimumHeadKeep": 0.25, "saturationCatchment": 4194304 },
|
||||
"drainage": { "fillEpsilon": 0.001, "breachDepth": 24, "wetnessThinning": true, "minHeadKeep": 0.25, "saturationCatchment": 4194304 },
|
||||
"tiers": [
|
||||
{ "name": "stream", "minCatchment": 1500, "halfWidth": [0.5, 2], "widthFactor": 1.0, "depthRatio": 0.4, "inset": 1, "cascades": true, "waterfallMinimumDrop": 6, "bankBand": 0, "bankStyle": "SMOOTH", "estuary": { "length": 48, "flare": 2.5 }, "delta": { "channels": 0, "spreadDegrees": 35, "length": 64 }, "materials": {}, "fluid": "water" },
|
||||
{ "name": "river", "minCatchment": 20000, "halfWidth": [2, 8], "widthFactor": 1.0, "depthRatio": 0.45, "inset": 2, "cascades": true, "waterfallMinimumDrop": 6, "bankBand": 32, "bankStyle": "SMOOTH", "estuary": { "length": 48, "flare": 2.5 }, "delta": { "channels": 0, "spreadDegrees": 35, "length": 64 }, "materials": {}, "fluid": "water" },
|
||||
{ "name": "major", "minCatchment": 320000, "halfWidth": [8, 16], "widthFactor": 1.0, "depthRatio": 0.5, "inset": 3, "cascades": true, "waterfallMinimumDrop": 6, "bankBand": 48, "bankStyle": "SMOOTH", "estuary": { "length": 48, "flare": 2.5 }, "delta": { "channels": 0, "spreadDegrees": 35, "length": 64 }, "materials": {}, "fluid": "water" }
|
||||
{ "name": "stream", "minCatchment": 1500, "halfWidth": [0.5, 2], "widthFactor": 1.0, "depthRatio": 0.4, "inset": 1, "cascades": true, "waterfallMinDrop": 6, "bankBand": 0, "bankStyle": "SMOOTH", "estuary": { "length": 48, "flare": 2.5 }, "delta": { "channels": 0, "spreadDegrees": 35, "length": 64 }, "materials": {}, "fluid": "water" },
|
||||
{ "name": "river", "minCatchment": 20000, "halfWidth": [2, 8], "widthFactor": 1.0, "depthRatio": 0.45, "inset": 2, "cascades": true, "waterfallMinDrop": 6, "bankBand": 32, "bankStyle": "SMOOTH", "estuary": { "length": 48, "flare": 2.5 }, "delta": { "channels": 0, "spreadDegrees": 35, "length": 64 }, "materials": {}, "fluid": "water" },
|
||||
{ "name": "major", "minCatchment": 320000, "halfWidth": [8, 16], "widthFactor": 1.0, "depthRatio": 0.5, "inset": 3, "cascades": true, "waterfallMinDrop": 6, "bankBand": 48, "bankStyle": "SMOOTH", "estuary": { "length": 48, "flare": 2.5 }, "delta": { "channels": 0, "spreadDegrees": 35, "length": 64 }, "materials": {}, "fluid": "water" }
|
||||
],
|
||||
"ponds": {
|
||||
"natural": { "enabled": true, "keep": 1.0, "minArea": 256, "maxArea": 65536, "minDepth": 2 },
|
||||
"seeded": { "enabled": true, "density": 4.0, "radius": [6, 24], "depth": [3, 8], "maxSlope": 0.6, "alongChannels": true, "channelSpacing": [96, 256] },
|
||||
"dams": { "enabled": false, "maxRaise": 4 },
|
||||
"freeboard": [1, 3], "climateDrawdown": 6,
|
||||
"freeboard": [1, 3], "dryDrawdown": 6,
|
||||
"shore": { "roundness": 0.5, "shelf": 6, "taper": 14, "maxDepth": 8 },
|
||||
"materials": {}, "fluid": "water"
|
||||
},
|
||||
|
||||
+1
-1
@@ -263,7 +263,7 @@ public class IrisHydrologyTerrainSourceTest {
|
||||
Pond swamp = floorPond(fixture, settings, column);
|
||||
spires.setHydrologyPolicy(new IrisHydrologyPolicy().setPondDensity(16D).setWetness(new IrisHydrologyWetness().setMin(1D)));
|
||||
Pond kept = floorPond(fixture, settings, column);
|
||||
int drawdown = settings.ponds().climateDrawdown();
|
||||
int drawdown = settings.ponds().dryDrawdown();
|
||||
assertEquals((int) Math.floor(kept.spillHeight()) - 1, kept.level());
|
||||
assertEquals(kept.level() - Math.round(drawdown * 0.3f), swamp.level());
|
||||
assertEquals(kept.level() - Math.round(drawdown * 0.85f), dry.level());
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ public class ConfluenceIncisionTest {
|
||||
}
|
||||
String label = "seed " + seed + " foot " + foot + " " + major;
|
||||
assertTrue(label + " is cut " + cut + " into the wall", cut <= MAX_WALL_CUT);
|
||||
double tallestFall = WALL_HEIGHT / 2D + major.tier().waterfallMinimumDrop() + (seed == SEED ? 0D : OTHER_SEED_FALL_MARGIN);
|
||||
double tallestFall = WALL_HEIGHT / 2D + major.tier().waterfallMinDrop() + (seed == SEED ? 0D : OTHER_SEED_FALL_MARGIN);
|
||||
assertTrue(label + " falls " + largest + " blocks at once down a " + WALL_HEIGHT + "-block wall", largest <= tallestFall);
|
||||
totalCut += cut;
|
||||
cases++;
|
||||
|
||||
@@ -98,9 +98,9 @@ final class PlannedScene {
|
||||
new IrisHydrologyTier().setName("river").setMinCatchment(5000D).setHalfWidth(new KList<>(2.5D, 9D)).setWidthFactor(1.2D)
|
||||
.setDepthRatio(0.45D).setInset(2).setBankBand(32),
|
||||
new IrisHydrologyTier().setName("major").setMinCatchment(200000D).setHalfWidth(new KList<>(9D, 18D)).setWidthFactor(1.2D)
|
||||
.setDepthRatio(0.5D).setInset(3).setBankBand(48).setWaterfallMinimumDrop(8)));
|
||||
.setDepthRatio(0.5D).setInset(3).setBankBand(48).setWaterfallMinDrop(8)));
|
||||
config.getPonds().setFreeboard(new KList<>(1, 2));
|
||||
config.getPonds().setClimateDrawdown(3);
|
||||
config.getPonds().setDryDrawdown(3);
|
||||
config.getPonds().getSeeded().setDensity(10D).setRadius(new KList<>(6, 22)).setMaxSlope(0.7D).setChannelSpacing(new KList<>(80, 192));
|
||||
config.getPonds().getShore().setRoundness(0.5D).setShelf(6).setTaper(14).setMaxDepth(8);
|
||||
return config;
|
||||
|
||||
@@ -339,7 +339,7 @@ public class PlannedSceneTest {
|
||||
}
|
||||
zone[point] = along <= OUTLET_LENGTH;
|
||||
}
|
||||
ReachStyle[] style = ReachShaper.styles(reach.grade(), new boolean[zone.length], zone, reach.tier().waterfallMinimumDrop(), seaLevel, reach.tier().stepHeight());
|
||||
ReachStyle[] style = ReachShaper.styles(reach.grade(), new boolean[zone.length], zone, reach.tier().waterfallMinDrop(), seaLevel, reach.tier().stepHeight());
|
||||
return new Reach(reach.id(), reach.tier(), reach.downstreamId(), reach.xs(), reach.zs(), reach.grade(), reach.halfWidth(), reach.depth(),
|
||||
style, reach.catchment());
|
||||
}
|
||||
@@ -365,7 +365,7 @@ public class PlannedSceneTest {
|
||||
halfWidths[point] = halfWidth;
|
||||
depths[point] = tier.depth(halfWidth);
|
||||
int drop = point == 0 ? 0 : grades[point - 1] - grades[point];
|
||||
styles[point] = drop >= tier.waterfallMinimumDrop() ? ReachStyle.WATERFALL
|
||||
styles[point] = drop >= tier.waterfallMinDrop() ? ReachStyle.WATERFALL
|
||||
: drop >= 2 ? ReachStyle.CASCADE : drop == 1 ? ReachStyle.RIFFLE : ReachStyle.RUN;
|
||||
}
|
||||
return new Reach(id, tier, downstreamId, xs, zs, grades, halfWidths, depths, styles, 1000f);
|
||||
|
||||
@@ -1204,7 +1204,7 @@ public class WindowPlannerTest {
|
||||
int last = feeder.xs().length - 1;
|
||||
int drop = feeder.grade()[last] - downstream.grade()[0];
|
||||
assertTrue(feeder + " meets " + downstream + " across the window line with a drop of " + drop,
|
||||
drop >= 0 && drop < downstream.tier().waterfallMinimumDrop());
|
||||
drop >= 0 && drop < downstream.tier().waterfallMinDrop());
|
||||
}
|
||||
assertTrue("reaches near the window line " + westOwned.size() + " + " + eastOwned.size(), westOwned.size() + eastOwned.size() >= 3);
|
||||
assertTrue("reach links between the two windows' plans " + links, links >= 1);
|
||||
|
||||
+3
-3
@@ -898,7 +898,7 @@ public class ChunkWaterRasterTest {
|
||||
public void clampedSeamDropsAreStyledAsFalls() {
|
||||
HydrologyTier narrow = tier("river", 2f, 0.5f, 4, IrisBankStyle.SMOOTH);
|
||||
HydrologyTier wide = tier("river", 3f, 0.5f, 4, IrisBankStyle.SMOOTH);
|
||||
assertEquals(6, narrow.waterfallMinimumDrop());
|
||||
assertEquals(6, narrow.waterfallMinDrop());
|
||||
Reach low = line(232L, wide, 0L, 504f, 200f, 600f, 200f, (x, z) -> 62);
|
||||
Reach hanging = line(231L, narrow, low.id(), 440f, 200f, 504f, 200f, (x, z) -> 70);
|
||||
Scene falls = new Scene(settings(new IrisHydrology()), (x, z) -> 90).reach(hanging).reach(low);
|
||||
@@ -1003,7 +1003,7 @@ public class ChunkWaterRasterTest {
|
||||
for (int point = 0; point < zone.length; point++) {
|
||||
zone[point] = drawn.xs()[point] - drawn.xs()[0] <= 8f;
|
||||
}
|
||||
ReachStyle[] style = ReachShaper.styles(drawn.grade(), new boolean[zone.length], zone, narrow.waterfallMinimumDrop(), SEA_LEVEL, narrow.stepHeight());
|
||||
ReachStyle[] style = ReachShaper.styles(drawn.grade(), new boolean[zone.length], zone, narrow.waterfallMinDrop(), SEA_LEVEL, narrow.stepHeight());
|
||||
assertEquals("the last outlet zone point steps down one block, shown as two", ReachStyle.CASCADE, style[4]);
|
||||
assertTrue("the step lies at the end of the outlet zone", zone[4] && !zone[5]);
|
||||
Reach outlet = new Reach(drawn.id(), narrow, drawn.downstreamId(), drawn.xs(), drawn.zs(), drawn.grade(), drawn.halfWidth(), drawn.depth(),
|
||||
@@ -2526,7 +2526,7 @@ public class ChunkWaterRasterTest {
|
||||
halfWidth[point] = tier.minHalfWidth();
|
||||
depth[point] = tier.depth(tier.minHalfWidth());
|
||||
int drop = point == 0 ? 0 : grades[point - 1] - grades[point];
|
||||
style[point] = drop >= tier.waterfallMinimumDrop() ? ReachStyle.WATERFALL
|
||||
style[point] = drop >= tier.waterfallMinDrop() ? ReachStyle.WATERFALL
|
||||
: drop >= 2 ? ReachStyle.CASCADE : drop == 1 ? ReachStyle.RIFFLE : ReachStyle.RUN;
|
||||
}
|
||||
return new Reach(id, tier, downstreamId, xs, zs, grades, halfWidth, depth, style, 1000f);
|
||||
|
||||
@@ -509,7 +509,7 @@ public class PondPlannerTest {
|
||||
Pond dry = single(plan(settings, new Terrain(terrain, 0f, ALLOW_ALL, null, MIN_Y, MAX_Y), 0, 0, 64, 64, null, List.of()));
|
||||
Pond damp = single(plan(settings, new Terrain(terrain, 0.5f, ALLOW_ALL, null, MIN_Y, MAX_Y), 0, 0, 64, 64, null, List.of()));
|
||||
assertEquals(wet.id(), dry.id());
|
||||
assertEquals(settings.ponds().climateDrawdown(), wet.level() - dry.level());
|
||||
assertEquals(settings.ponds().dryDrawdown(), wet.level() - dry.level());
|
||||
assertTrue(damp.level() < wet.level() && damp.level() > dry.level());
|
||||
assertContained(dry, terrain);
|
||||
}
|
||||
@@ -518,7 +518,7 @@ public class PondPlannerTest {
|
||||
public void drawdownFollowsClimateDryness() {
|
||||
HydrologySettings settings = settings(PondPlannerTest::naturalOnly, MIN_Y, MAX_Y);
|
||||
DoubleBinaryOperator terrain = bowl(256, 256, 60, 100, 12, 0.1);
|
||||
int drawdown = settings.ponds().climateDrawdown();
|
||||
int drawdown = settings.ponds().dryDrawdown();
|
||||
Pond full = single(plan(settings, new Terrain(terrain, 1f, ALLOW_ALL, null, MIN_Y, MAX_Y), 0, 0, 64, 64, null, List.of()));
|
||||
Pond wetZone = single(plan(settings, new Terrain(terrain, 0.5f, ALLOW_ALL, null, MIN_Y, MAX_Y).climateZoned((x, z) -> 1D),
|
||||
0, 0, 64, 64, null, List.of()));
|
||||
|
||||
+16
-16
@@ -75,7 +75,7 @@ public class ReachShaperTest {
|
||||
for (Reach reach : spread.reaches()) {
|
||||
Reach twin = steppedById.get(reach.id());
|
||||
assertNotNull(twin);
|
||||
int fall = reach.tier().waterfallMinimumDrop();
|
||||
int fall = reach.tier().waterfallMinDrop();
|
||||
int junction = twin.downstreamId() == 0L ? Integer.MIN_VALUE : twin.grade()[twin.grade().length - 1];
|
||||
assertTrue("trial " + trial + " " + reach + " gained a waterfall against " + Arrays.toString(twin.grade()),
|
||||
dropsAbove(reach, junction, fall, Integer.MAX_VALUE) <= dropsAbove(twin, Integer.MIN_VALUE, fall, Integer.MAX_VALUE));
|
||||
@@ -231,7 +231,7 @@ public class ReachShaperTest {
|
||||
public void dropAtWaterfallMinimumBecomesWaterfall() {
|
||||
HydrologySettings cascading = settings(config -> {
|
||||
});
|
||||
int minimum = cascading.tiers().get(1).waterfallMinimumDrop();
|
||||
int minimum = cascading.tiers().get(1).waterfallMinDrop();
|
||||
List<Drop> waterfall = drops(cascading, steppedValley(minimum));
|
||||
assertEquals("drops " + waterfall, 1, waterfall.size());
|
||||
assertEquals(minimum, waterfall.get(0).size());
|
||||
@@ -294,9 +294,9 @@ public class ReachShaperTest {
|
||||
int[] grade = steep.grade;
|
||||
for (int index = 1; index < grade.length; index++) {
|
||||
int drop = grade[index - 1] - grade[index];
|
||||
assertTrue(Arrays.toString(grade), drop >= 0 && drop < tier.waterfallMinimumDrop());
|
||||
assertTrue(Arrays.toString(grade), drop >= 0 && drop < tier.waterfallMinDrop());
|
||||
}
|
||||
assertTrue(Arrays.toString(grade), grade[0] > (int) ground[0] - tier.inset() - tier.waterfallMinimumDrop());
|
||||
assertTrue(Arrays.toString(grade), grade[0] > (int) ground[0] - tier.inset() - tier.waterfallMinDrop());
|
||||
assertEquals((int) ground[ground.length - 1] - tier.inset(), grade[grade.length - 1]);
|
||||
}
|
||||
|
||||
@@ -336,9 +336,9 @@ public class ReachShaperTest {
|
||||
assertTrue(label + " pools " + pools, pools >= 3);
|
||||
assertTrue(label + " drops " + drops, drops <= Math.ceil(STATION * last / StepPools.POOL_MIN));
|
||||
|
||||
int[] spread = graded(withSteps(tier, false, tier.waterfallMinimumDrop()), ground);
|
||||
int[] spread = graded(withSteps(tier, false, tier.waterfallMinDrop()), ground);
|
||||
for (int index = 1; index < spread.length; index++) {
|
||||
assertTrue("spread " + Arrays.toString(spread), spread[index - 1] - spread[index] < tier.waterfallMinimumDrop());
|
||||
assertTrue("spread " + Arrays.toString(spread), spread[index - 1] - spread[index] < tier.waterfallMinDrop());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ public class ReachShaperTest {
|
||||
for (int index = 1; index < grade.length; index++) {
|
||||
int drop = grade[index - 1] - grade[index];
|
||||
assertTrue(label, drop >= 0);
|
||||
if (drop >= tier.waterfallMinimumDrop()) {
|
||||
if (drop >= tier.waterfallMinDrop()) {
|
||||
falls++;
|
||||
foot = index;
|
||||
}
|
||||
@@ -574,7 +574,7 @@ public class ReachShaperTest {
|
||||
for (Reach reach : shaped.reaches()) {
|
||||
for (int index = 1; index < reach.xs().length; index++) {
|
||||
if (reach.xs()[index] >= WINDOW_MIN_X && reach.xs()[index] <= WINDOW_MAX_X
|
||||
&& reach.grade()[index - 1] - reach.grade()[index] >= reach.tier().waterfallMinimumDrop()) {
|
||||
&& reach.grade()[index - 1] - reach.grade()[index] >= reach.tier().waterfallMinDrop()) {
|
||||
return Math.toDegrees(Math.atan2(Math.abs(reach.zs()[index] - reach.zs()[index - 1]), Math.abs(reach.xs()[index] - reach.xs()[index - 1])));
|
||||
}
|
||||
}
|
||||
@@ -675,7 +675,7 @@ public class ReachShaperTest {
|
||||
draft.catchments = new float[points];
|
||||
Arrays.fill(draft.catchments, 40000f);
|
||||
draft.outletZone = new boolean[points];
|
||||
draft.style = ReachShaper.styles(draft.grade, draft.ocean, draft.outletZone, tier.waterfallMinimumDrop(), SEA_LEVEL, 2);
|
||||
draft.style = ReachShaper.styles(draft.grade, draft.ocean, draft.outletZone, tier.waterfallMinDrop(), SEA_LEVEL, 2);
|
||||
ReachShaper.widths(draft, 0f, 0f);
|
||||
float law = tier.halfWidth(40000f);
|
||||
assertEquals("the foot flares", 1.5f * law, draft.halfWidth[foot], 1e-3f);
|
||||
@@ -687,7 +687,7 @@ public class ReachShaperTest {
|
||||
for (int point = 0; point < mouth.length; point++) {
|
||||
mouth[point] = reach.style()[point] == ReachStyle.MOUTH;
|
||||
}
|
||||
return ReachShaper.plungeFlare(reach.grade(), reach.style(), mouth, ReachShaper.distances(reach.xs(), reach.zs()), 0f, reach.tier().waterfallMinimumDrop());
|
||||
return ReachShaper.plungeFlare(reach.grade(), reach.style(), mouth, ReachShaper.distances(reach.xs(), reach.zs()), 0f, reach.tier().waterfallMinDrop());
|
||||
}
|
||||
|
||||
private static float channelMaximum(Reach reach) {
|
||||
@@ -730,7 +730,7 @@ public class ReachShaperTest {
|
||||
|
||||
private static int footOf(Reach reach) {
|
||||
for (int point = 1; point < reach.xs().length; point++) {
|
||||
if (reach.grade()[point - 1] - reach.grade()[point] >= reach.tier().waterfallMinimumDrop()) {
|
||||
if (reach.grade()[point - 1] - reach.grade()[point] >= reach.tier().waterfallMinDrop()) {
|
||||
return point;
|
||||
}
|
||||
}
|
||||
@@ -745,7 +745,7 @@ public class ReachShaperTest {
|
||||
if (reach.xs()[index] < WINDOW_MIN_X || reach.xs()[index] > WINDOW_MAX_X) {
|
||||
continue;
|
||||
}
|
||||
if (reach.grade()[index - 1] - reach.grade()[index] >= reach.tier().waterfallMinimumDrop()) {
|
||||
if (reach.grade()[index - 1] - reach.grade()[index] >= reach.tier().waterfallMinDrop()) {
|
||||
falls++;
|
||||
midpoint = (reach.xs()[index - 1] + reach.xs()[index]) / 2f;
|
||||
}
|
||||
@@ -2279,7 +2279,7 @@ public class ReachShaperTest {
|
||||
for (int index = 1; index <= entry && fall < 0; index++) {
|
||||
fall = reach.grade()[index] == SEA_LEVEL ? index : -1;
|
||||
}
|
||||
if (reach.grade()[fall - 1] - SEA_LEVEL >= reach.tier().waterfallMinimumDrop()) {
|
||||
if (reach.grade()[fall - 1] - SEA_LEVEL >= reach.tier().waterfallMinDrop()) {
|
||||
falls++;
|
||||
int lip = fall == entry ? entry - 1 : fall;
|
||||
assertEquals(reach.toString(), ReachStyle.WATERFALL, reach.style()[lip]);
|
||||
@@ -3093,13 +3093,13 @@ public class ReachShaperTest {
|
||||
private static void ungrouped(IrisHydrology config) {
|
||||
for (IrisHydrologyTier tier : config.getTiers()) {
|
||||
tier.setCascades(false);
|
||||
tier.setWaterfallMinimumDrop(2);
|
||||
tier.setWaterfallMinDrop(2);
|
||||
}
|
||||
}
|
||||
|
||||
private static HydrologyTier withSteps(HydrologyTier tier, boolean cascades, int waterfallMinimumDrop) {
|
||||
private static HydrologyTier withSteps(HydrologyTier tier, boolean cascades, int waterfallMinDrop) {
|
||||
return new HydrologyTier(tier.name(), tier.minCatchment(), tier.minHalfWidth(), tier.maxHalfWidth(), tier.widthFactor(), tier.depthRatio(),
|
||||
tier.inset(), cascades, waterfallMinimumDrop, 2, tier.bankBand(), tier.bankStyle(), tier.estuary(), tier.delta(), tier.materials(),
|
||||
tier.inset(), cascades, waterfallMinDrop, 2, tier.bankBand(), tier.bankStyle(), tier.estuary(), tier.delta(), tier.materials(),
|
||||
tier.fluid(), tier.decorators());
|
||||
}
|
||||
|
||||
|
||||
+16
-7
@@ -24,6 +24,7 @@ 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.block.TileData;
|
||||
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.BlockPosition;
|
||||
@@ -54,7 +55,7 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
public void canopyCommitRechecksSolidsAndSkipsAssociatedMetadata() {
|
||||
IslandObjectPlacer delegate = createPlacer(true);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), ObjectWaterRule.KEEP_OUT);
|
||||
NativeBlockState canopy = mock(NativeBlockState.class);
|
||||
NativeBlockState trunk = mock(NativeBlockState.class);
|
||||
when(trunk.isSolid()).thenReturn(true);
|
||||
@@ -76,7 +77,7 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
public void unsupportedFinalTerrainRejectsBlocksTilesAndMarkersTogether() {
|
||||
IslandObjectPlacer delegate = createPlacer(false);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), ObjectWaterRule.KEEP_OUT);
|
||||
NativeBlockState first = mock(NativeBlockState.class);
|
||||
NativeBlockState second = mock(NativeBlockState.class);
|
||||
TileData tile = mock(TileData.class);
|
||||
@@ -103,7 +104,7 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
public void supportedNeighborChunkCommitsBlocksTilesAndMarkers() {
|
||||
IslandObjectPlacer delegate = createPlacer(true);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), ObjectWaterRule.KEEP_OUT);
|
||||
NativeBlockState first = mock(NativeBlockState.class);
|
||||
NativeBlockState second = mock(NativeBlockState.class);
|
||||
TileData tile = mock(TileData.class);
|
||||
@@ -149,7 +150,7 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
NativeBlockState state = mock(NativeBlockState.class);
|
||||
when(state.key()).thenReturn("minecraft:oak_log");
|
||||
ObjectContinuationBundle.PlacementKey key = new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 7);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate, key, false);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate, key, ObjectWaterRule.KEEP_OUT);
|
||||
transaction.set(15, 101, 8, state);
|
||||
transaction.set(16, 101, 8, state);
|
||||
transaction.setData(16, 101, 8, "floating-tree@7");
|
||||
@@ -166,7 +167,7 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void floatingObjectsKeepSolidBlocksOutOfRiverWaterUnlessTheyEnterWater() {
|
||||
public void floatingObjectsFollowTheirWaterRuleInRiverWater() {
|
||||
IObjectPlacer delegate = mock(IObjectPlacer.class);
|
||||
Engine engine = mock(Engine.class);
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
@@ -196,17 +197,25 @@ public class FloatingObjectPlacementTransactionTest {
|
||||
when(stone.isSolid()).thenReturn(true);
|
||||
ObjectContinuationBundle.PlacementKey key = new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0);
|
||||
|
||||
FloatingObjectPlacementTransaction land = new FloatingObjectPlacementTransaction(delegate, key, false);
|
||||
FloatingObjectPlacementTransaction land = new FloatingObjectPlacementTransaction(delegate, key, ObjectWaterRule.KEEP_OUT);
|
||||
land.set(3, 7, 3, stone);
|
||||
land.set(3, 10, 3, stone);
|
||||
assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, land.commit());
|
||||
verify(delegate, never()).set(3, 7, 3, stone);
|
||||
verify(delegate).set(3, 10, 3, stone);
|
||||
|
||||
FloatingObjectPlacementTransaction water = new FloatingObjectPlacementTransaction(delegate, key, true);
|
||||
FloatingObjectPlacementTransaction water = new FloatingObjectPlacementTransaction(delegate, key, ObjectWaterRule.ENTERS_WATER);
|
||||
water.set(3, 7, 3, stone);
|
||||
assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, water.commit());
|
||||
verify(delegate).set(3, 7, 3, stone);
|
||||
|
||||
NativeBlockState air = mock(NativeBlockState.class);
|
||||
FloatingObjectPlacementTransaction forced = new FloatingObjectPlacementTransaction(delegate, key, ObjectWaterRule.FORCED);
|
||||
forced.set(3, 8, 3, stone);
|
||||
forced.set(3, 6, 3, air);
|
||||
assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, forced.commit());
|
||||
verify(delegate).set(3, 8, 3, stone);
|
||||
verify(delegate).set(3, 6, 3, air);
|
||||
}
|
||||
|
||||
private static int local(Object coordinate) {
|
||||
|
||||
+39
-6
@@ -6,6 +6,7 @@ import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||
import art.arcane.iris.structure.placement.IrisStructure;
|
||||
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
@@ -26,11 +27,15 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InOrder;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.intThat;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.calls;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -116,12 +121,36 @@ public class IrisStructureComponentCarveWaterTest {
|
||||
component.placePieces(writer, placement, structure, slab(), new RNG(3L));
|
||||
|
||||
InOrder order = inOrder(writer);
|
||||
order.verify(writer).beginObjectPlacement(false);
|
||||
order.verify(writer).beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||
order.verify(writer, calls(1)).set(anyInt(), anyInt(), anyInt(), any(NativeBlockState.class));
|
||||
order.verify(writer).endObjectPlacement(anyInt());
|
||||
order.verify(writer).beginObjectPlacement(true);
|
||||
order.verify(writer).endObjectPlacement();
|
||||
order.verify(writer).beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||
order.verify(writer, calls(1)).set(anyInt(), anyInt(), anyInt(), any(NativeBlockState.class));
|
||||
order.verify(writer).endObjectPlacement(anyInt());
|
||||
order.verify(writer).endObjectPlacement();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aPieceAtWorldYMinusOneKeepsItsExplicitHeight() {
|
||||
KList<PlacedStructurePiece> pieces = slabAt(-1);
|
||||
IrisStructure structure = new IrisStructure().setPlaceMode(ObjectPlaceMode.STRUCTURE_PIECE);
|
||||
|
||||
component.placePieces(writer, new IrisStructurePlacement(), structure, pieces, new RNG(3L));
|
||||
|
||||
verify(writer, atLeastOnce()).set(anyInt(), eq(63), anyInt(), any(NativeBlockState.class));
|
||||
verify(writer, never()).set(anyInt(), intThat(y -> y != 63), anyInt(), any(NativeBlockState.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aFailureInsidePlacePiecesStillEndsTheObjectPlacement() {
|
||||
IllegalStateException failure = new IllegalStateException("piece failed");
|
||||
doThrow(failure).when(writer).set(anyInt(), anyInt(), anyInt(), any(NativeBlockState.class));
|
||||
IrisStructure structure = new IrisStructure().setPlaceMode(ObjectPlaceMode.STRUCTURE_PIECE);
|
||||
|
||||
assertEquals(1, component.placePieces(writer, new IrisStructurePlacement(), structure, slab(), new RNG(3L)));
|
||||
|
||||
InOrder order = inOrder(writer);
|
||||
order.verify(writer).beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||
order.verify(writer).endObjectPlacement();
|
||||
}
|
||||
|
||||
private void assertRiverKept() {
|
||||
@@ -154,6 +183,10 @@ public class IrisStructureComponentCarveWaterTest {
|
||||
}
|
||||
|
||||
private static KList<PlacedStructurePiece> slab() {
|
||||
return slabAt(-4);
|
||||
}
|
||||
|
||||
private static KList<PlacedStructurePiece> slabAt(int y) {
|
||||
NativeBlockState stone = mock(NativeBlockState.class);
|
||||
when(stone.isSolid()).thenReturn(true);
|
||||
when(stone.key()).thenReturn("minecraft:stone");
|
||||
@@ -164,7 +197,7 @@ public class IrisStructureComponentCarveWaterTest {
|
||||
object.setUnsigned(x, 0, z, stone);
|
||||
}
|
||||
}
|
||||
return new KList<>(new PlacedStructurePiece(null, object, 4, -4, 1, IrisObjectRotation.of(0, 0, 0),
|
||||
0, -4, 0, 8, -4, 2));
|
||||
return new KList<>(new PlacedStructurePiece(null, object, 4, y, 1, IrisObjectRotation.of(0, 0, 0),
|
||||
0, y, 0, 8, y, 2));
|
||||
}
|
||||
}
|
||||
+254
-29
@@ -1,84 +1,309 @@
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
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.integration.Identifier;
|
||||
import art.arcane.iris.structure.nativegen.NativeStructureSuppression;
|
||||
import art.arcane.iris.structure.object.HydrologyWaterFixture;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||
import art.arcane.iris.structure.placement.IrisStructure;
|
||||
import art.arcane.iris.structure.placement.IrisStructureLocator;
|
||||
import art.arcane.iris.structure.placement.IrisStructurePlacement;
|
||||
import art.arcane.iris.structure.placement.PlacedStructurePiece;
|
||||
import art.arcane.iris.testsupport.PlatformBinding;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import art.arcane.volmlib.util.matter.MatterSlice;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisStructureComponentWaterTest {
|
||||
private static final int X = 4;
|
||||
private static final int Z = 4;
|
||||
|
||||
@Rule
|
||||
public final PlatformBinding platform = PlatformBinding.mockPlatform();
|
||||
|
||||
private final HydrologyWaterFixture world = new HydrologyWaterFixture();
|
||||
private final List<Write> writes = new ArrayList<>();
|
||||
private final Map<Integer, Matter> sections = new HashMap<>();
|
||||
private IrisSettings previousSettings;
|
||||
private MantleWriter writer;
|
||||
private IrisStructureComponent component;
|
||||
|
||||
@Test
|
||||
public void forcedSinglePieceStructureStaysOutOfRiverWater() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
HydrologyWaterFixture.Placer placer = world.placer();
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT, false);
|
||||
@Before
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setUp() {
|
||||
previousSettings = IrisSettings.settings;
|
||||
IrisSettings.settings = new IrisSettings();
|
||||
Engine engine = world.data().getEngine();
|
||||
IrisComplex complex = world.complex();
|
||||
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
||||
ChunkWaterRaster raster = mock(ChunkWaterRaster.class);
|
||||
ProceduralStream<Integer> floors = mock(ProceduralStream.class);
|
||||
when(floors.get(anyDouble(), anyDouble())).thenAnswer(call -> world.floorAt(block(call.getArgument(0)), block(call.getArgument(1))));
|
||||
when(complex.getRoundedHeighteightStream()).thenReturn(floors);
|
||||
when(complex.getHydrologyRuntime()).thenReturn(runtime);
|
||||
when(runtime.enabled()).thenReturn(true);
|
||||
when(runtime.raster(anyInt(), anyInt())).thenReturn(raster);
|
||||
when(raster.role(anyInt(), anyInt())).thenAnswer(call -> complex.getWaterRoleStream().get((double) call.<Integer>getArgument(0), (double) call.<Integer>getArgument(1)));
|
||||
when(raster.waterHead(anyInt(), anyInt())).thenAnswer(call -> world.headAt(call.getArgument(0), call.getArgument(1)));
|
||||
when(raster.terrainHeight(anyInt(), anyInt())).thenAnswer(call -> world.floorAt(call.getArgument(0), call.getArgument(1)));
|
||||
EngineMantle engineMantle = mock(EngineMantle.class);
|
||||
when(engineMantle.getEngine()).thenReturn(engine);
|
||||
when(engineMantle.getComplex()).thenReturn(complex);
|
||||
when(engineMantle.getData()).thenReturn(world.data());
|
||||
HydrologyWaterFixture.Placer heights = world.placer();
|
||||
when(engineMantle.getHighest(anyInt(), anyInt(), any(), anyBoolean())).thenAnswer(call -> heights.getHighest(call.getArgument(0), call.getArgument(1), world.data(), call.<Boolean>getArgument(3)));
|
||||
Mantle<Matter> mantle = mock(Mantle.class);
|
||||
MantleChunk<Matter> chunk = mock(MantleChunk.class);
|
||||
when(mantle.getWorldHeight()).thenReturn(256);
|
||||
when(mantle.getChunk(0, 0)).thenReturn(chunk);
|
||||
when(mantle.useChunk(0, 0)).thenAnswer(call -> chunk.use());
|
||||
when(chunk.use()).thenReturn(chunk);
|
||||
when(chunk.getOrCreate(anyInt())).thenAnswer(call -> section(call.getArgument(0)));
|
||||
writer = new MantleWriter(engineMantle, mantle, 0, 0, 0, false);
|
||||
component = new IrisStructureComponent(engineMantle);
|
||||
}
|
||||
|
||||
assertTrue(config.isForcePlace());
|
||||
assertEquals(-1, object.place(0, 0, placer, config, new RNG(7L), world.data()));
|
||||
assertTrue(placer.writes().isEmpty());
|
||||
@After
|
||||
public void tearDown() {
|
||||
writer.close();
|
||||
IrisSettings.settings = previousSettings;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forcedSinglePieceStructureTurnedTowardsTheSlopeStaysOutOfRiverWater() {
|
||||
public void aForcedPieceFullyInsideARiverWritesEveryBlock() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
|
||||
int failed = placeSinglePiece(new IrisStructurePlacement());
|
||||
|
||||
assertEquals(0, failed);
|
||||
assertEquals("every block of the raft lands", 10, writes.size());
|
||||
assertEquals(world.headAt(X, Z), lowestWriteAt(X, Z));
|
||||
assertEquals(world.headAt(X - 1, Z - 1), lowestWriteAt(X - 1, Z - 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aForcedPieceTurnedTowardsTheSlopeWritesThroughTheRiver() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<Double> heights = mock(ProceduralStream.class);
|
||||
when(heights.get(anyDouble(), anyDouble())).thenAnswer(invocation -> (double) world.floorAt(
|
||||
(int) Math.floor((Double) invocation.getArgument(0)), (int) Math.floor((Double) invocation.getArgument(1))));
|
||||
block(invocation.getArgument(0)), block(invocation.getArgument(1))));
|
||||
when(world.complex().getHeightStream()).thenReturn(heights);
|
||||
HydrologyWaterFixture.Placer placer = world.placer();
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT, false);
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT);
|
||||
config.setRotateTowardsSlope(true);
|
||||
|
||||
assertEquals(-1, object.place(0, 0, placer, config, new RNG(7L), world.data()));
|
||||
assertTrue(placer.writes().isEmpty());
|
||||
writer.beginObjectPlacement(config.waterRule());
|
||||
int result = object.place(X, Z, writer, config, new RNG(7L), world.data());
|
||||
writer.endObjectPlacement();
|
||||
|
||||
assertTrue(result >= 0);
|
||||
assertEquals(10, writes.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forcedSinglePieceStructureThatAllowsWaterPlacesOnFlatRiverWater() {
|
||||
public void aForcedPieceWritesAcrossWetSupportColumns() {
|
||||
world.column(X + 1, Z, WaterRole.CHANNEL, 15, 19);
|
||||
world.column(X - 1, Z, WaterRole.SHORE, 15, 19);
|
||||
world.column(X, Z + 1, WaterRole.DAM, 15, 19);
|
||||
|
||||
int failed = placeSinglePiece(new IrisStructurePlacement());
|
||||
|
||||
assertEquals(0, failed);
|
||||
int anchorLayer = lowestWriteAt(X, Z);
|
||||
assertEquals(world.floorAt(X, Z), anchorLayer);
|
||||
assertEquals("the river column keeps the piece's block", anchorLayer, lowestWriteAt(X + 1, Z));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replaceSourceKeepsAForcedPieceOverWaterWithoutFailingTheChunk() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
HydrologyWaterFixture.Placer placer = world.placer();
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT, true);
|
||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
||||
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
||||
|
||||
assertTrue(config.entersWater());
|
||||
assertTrue(object.place(0, 0, placer, config, new RNG(7L), world.data()) >= 0);
|
||||
assertEquals(world.headAt(0, 0), placer.lowestWrite());
|
||||
int failed = placeSinglePiece(placement);
|
||||
|
||||
assertEquals(0, failed);
|
||||
assertEquals(10, writes.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forcedSinglePieceStructureStillPlacesOnDryLand() {
|
||||
HydrologyWaterFixture.Placer placer = world.placer();
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT, false);
|
||||
public void aForcedPieceWritesAcrossAFallWhetherOrNotItAllowsWater() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
world.column(X + 1, Z, WaterRole.CHANNEL, 9, 16);
|
||||
|
||||
assertTrue(object.place(0, 0, placer, config, new RNG(7L), world.data()) >= 0);
|
||||
assertFalse(placer.writes().isEmpty());
|
||||
assertEquals(0, placeSinglePiece(new IrisStructurePlacement()));
|
||||
assertEquals(10, writes.size());
|
||||
writes.clear();
|
||||
|
||||
assertEquals(0, placeSinglePiece(new IrisStructurePlacement().setAllowWater(true)));
|
||||
assertEquals(10, writes.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aForcedPiecePlacesOnDryLand() {
|
||||
int failed = placeSinglePiece(new IrisStructurePlacement());
|
||||
|
||||
assertEquals(0, failed);
|
||||
assertEquals(10, writes.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void objectsThatForcePlaceThemselvesWriteThroughUnevenWater() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
world.column(X + 1, Z, WaterRole.CHANNEL, 9, 16);
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisObjectPlacement config = new IrisObjectPlacement().setForcePlace(true);
|
||||
|
||||
writer.beginObjectPlacement(config.waterRule());
|
||||
int result = object.place(X, Z, writer, config, new RNG(7L), world.data());
|
||||
writer.endObjectPlacement();
|
||||
|
||||
assertTrue(result >= 0);
|
||||
assertEquals("every block lands over the channel", 10, writes.size());
|
||||
assertEquals(world.headAt(X, Z), lowestWriteAt(X, Z));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unforcedPiecesKeepTheVeto() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisStructure structure = new IrisStructure().setPlaceMode(ObjectPlaceMode.STRUCTURE_PIECE);
|
||||
int head = world.headAt(X, Z);
|
||||
PlacedStructurePiece explicit = new PlacedStructurePiece(null, object, X, head + 1, Z, IrisObjectRotation.of(0, 0, 0),
|
||||
X - 1, head, Z - 1, X + 1, head + 2, Z + 1);
|
||||
|
||||
assertEquals(0, component.placePieces(writer, new IrisStructurePlacement(), structure, new KList<>(explicit), new RNG(7L)));
|
||||
|
||||
assertFalse("the block above the water places", writes.isEmpty());
|
||||
assertNoWaterOverwritten();
|
||||
writes.clear();
|
||||
|
||||
assertEquals(0, component.placePieces(writer, new IrisStructurePlacement().setAllowWater(true), structure, new KList<>(explicit), new RNG(7L)));
|
||||
assertTrue("allowWater fills the water", writes.stream().anyMatch(write -> write.y() == head));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void undergroundPiecesKeepTheVeto() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
int head = world.headAt(X, Z);
|
||||
PlacedStructurePiece explicit = new PlacedStructurePiece(null, object, X, head + 1, Z, IrisObjectRotation.of(0, 0, 0),
|
||||
X - 1, head, Z - 1, X + 1, head + 2, Z + 1);
|
||||
for (ObjectPlaceMode mode : List.of(ObjectPlaceMode.ORGANIC_STILT, ObjectPlaceMode.CEILING_HANG)) {
|
||||
writes.clear();
|
||||
IrisStructure structure = new IrisStructure().setPlaceMode(mode);
|
||||
IrisStructurePlacement placement = new IrisStructurePlacement().setUnderground(true);
|
||||
|
||||
assertEquals(mode.name(), 0, component.placePieces(writer, placement, structure, new KList<>(explicit), new RNG(7L)));
|
||||
|
||||
assertFalse(mode.name(), writes.isEmpty());
|
||||
assertNoWaterOverwritten();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unforcedObjectsStayOffRiverWater() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
|
||||
int result = object.place(X, Z, writer, new IrisObjectPlacement(), new RNG(7L), world.data());
|
||||
|
||||
assertEquals(-1, result);
|
||||
assertTrue(writes.isEmpty());
|
||||
}
|
||||
|
||||
private int placeSinglePiece(IrisStructurePlacement placement) {
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
IrisStructure structure = new IrisStructure().setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||
return component.placePieces(writer, placement, structure, new KList<>(piece(object)), new RNG(7L));
|
||||
}
|
||||
|
||||
private IrisStructureLocator.ResolvedPlacement resolved(IrisStructurePlacement placement) {
|
||||
IrisObject object = HydrologyWaterFixture.raft();
|
||||
return new IrisStructureLocator.ResolvedPlacement(placement, "test/raft", new IrisStructure(),
|
||||
new KList<>(piece(object)), new RNG(7L), X, 0, Z, false);
|
||||
}
|
||||
|
||||
private void assertNoWaterOverwritten() {
|
||||
for (Write write : writes) {
|
||||
WaterRole role = world.complex().getWaterRoleStream().get((double) write.x(), (double) write.z());
|
||||
if (role.wet()) {
|
||||
assertFalse(write + " overwrites river water",
|
||||
write.y() > world.floorAt(write.x(), write.z()) && write.y() <= world.headAt(write.x(), write.z()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int lowestWriteAt(int x, int z) {
|
||||
int lowest = Integer.MAX_VALUE;
|
||||
for (Write write : writes) {
|
||||
if (write.x() == x && write.z() == z) {
|
||||
lowest = Math.min(lowest, write.y());
|
||||
}
|
||||
}
|
||||
return lowest;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Matter section(int index) {
|
||||
return sections.computeIfAbsent(index, ignored -> {
|
||||
Matter matter = mock(Matter.class);
|
||||
MatterSlice<NativeBlockState> blocks = mock(MatterSlice.class);
|
||||
doAnswer(call -> {
|
||||
writes.add(new Write(call.getArgument(0), (index << 4) | call.<Integer>getArgument(1), call.getArgument(2)));
|
||||
return null;
|
||||
}).when(blocks).set(anyInt(), anyInt(), anyInt(), any());
|
||||
when(matter.getClass(any())).thenAnswer(call -> call.getArgument(0).getClass());
|
||||
doReturn(blocks).when(matter).slice(NativeBlockState.class);
|
||||
doReturn(mock(MatterSlice.class)).when(matter).getSlice(Identifier.class);
|
||||
return matter;
|
||||
});
|
||||
}
|
||||
|
||||
private static PlacedStructurePiece piece(IrisObject object) {
|
||||
return new PlacedStructurePiece(null, object, 0, 0, 0, IrisObjectRotation.of(0, 0, 0), -1, 0, -1, 1, 2, 1);
|
||||
return new PlacedStructurePiece(null, object, X, 0, Z, IrisObjectRotation.of(0, 0, 0), X - 1, 0, Z - 1, X + 1, 2, Z + 1);
|
||||
}
|
||||
|
||||
private static int block(Object coordinate) {
|
||||
return (int) Math.floor(((Number) coordinate).doubleValue());
|
||||
}
|
||||
|
||||
private record Write(int x, int y, int z) {
|
||||
}
|
||||
}
|
||||
+299
@@ -0,0 +1,299 @@
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.cave.CarvingMode;
|
||||
import art.arcane.iris.generation.context.ChunkContext;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralObjects;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralPlacement;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.runtime.SeedManager;
|
||||
import art.arcane.iris.generation.runtime.UpperDimensionContext;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.object.IObjectPlacer;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InOrder;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class MantleObjectComponentWaterPlacementTest {
|
||||
private static final Answer<Integer> PLACES = call -> 64;
|
||||
private static final Answer<Integer> REJECTS = call -> -1;
|
||||
private static final Answer<Integer> THROWS = call -> {
|
||||
throw new IllegalArgumentException("malformed object");
|
||||
};
|
||||
|
||||
private IrisSettings previousSettings;
|
||||
|
||||
@Before
|
||||
public void bindSettings() {
|
||||
previousSettings = IrisSettings.settings;
|
||||
IrisSettings.settings = new IrisSettings();
|
||||
}
|
||||
|
||||
@After
|
||||
public void restoreSettings() {
|
||||
IrisSettings.settings = previousSettings;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptedSurfacePlacementIsRecordedThenEnded() {
|
||||
Fixture fixture = new Fixture(PLACES);
|
||||
fixture.biome.setObjects(new KList<>(fixture.surfacePlacement()));
|
||||
|
||||
fixture.generate();
|
||||
|
||||
fixture.assertRecordedThenEnded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectedSurfacePlacementEndsWithoutBeingRecorded() {
|
||||
Fixture fixture = new Fixture(REJECTS);
|
||||
fixture.biome.setObjects(new KList<>(fixture.surfacePlacement()));
|
||||
|
||||
fixture.generate();
|
||||
|
||||
fixture.assertEndedUnrecorded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void thrownSurfacePlacementEndsWithoutBeingRecorded() {
|
||||
Fixture fixture = new Fixture(THROWS);
|
||||
fixture.biome.setObjects(new KList<>(fixture.surfacePlacement()));
|
||||
|
||||
fixture.generate();
|
||||
|
||||
fixture.assertEndedUnrecorded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectedCavePlacementEndsWithoutBeingRecorded() {
|
||||
Fixture fixture = new Fixture(REJECTS);
|
||||
fixture.biome.setObjects(new KList<>(fixture.cavePlacement()));
|
||||
|
||||
fixture.generate();
|
||||
|
||||
fixture.assertEndedUnrecorded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void thrownCavePlacementEndsWithoutBeingRecorded() {
|
||||
Fixture fixture = new Fixture(THROWS);
|
||||
fixture.biome.setObjects(new KList<>(fixture.cavePlacement()));
|
||||
|
||||
fixture.generate();
|
||||
|
||||
fixture.assertEndedUnrecorded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void proceduralPlacementOutsideTheTransitionFootprintEndsWithoutBeingRecorded() {
|
||||
Fixture fixture = new Fixture(PLACES);
|
||||
fixture.biome.setProceduralObjects(fixture.proceduralObjects());
|
||||
when(fixture.complex.allowsNewGenerationFootprint(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(false);
|
||||
|
||||
fixture.generate();
|
||||
|
||||
fixture.assertEndedUnrecorded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectedProceduralPlacementEndsWithoutBeingRecorded() {
|
||||
Fixture fixture = new Fixture(REJECTS);
|
||||
fixture.biome.setProceduralObjects(fixture.proceduralObjects());
|
||||
|
||||
fixture.generate();
|
||||
|
||||
fixture.assertEndedUnrecorded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void thrownProceduralPlacementEndsWithoutBeingRecorded() {
|
||||
Fixture fixture = new Fixture(THROWS);
|
||||
fixture.biome.setProceduralObjects(fixture.proceduralObjects());
|
||||
|
||||
fixture.generate();
|
||||
|
||||
fixture.assertEndedUnrecorded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectedUpperPlacementEndsWithoutBeingRecorded() {
|
||||
Fixture fixture = new Fixture(REJECTS);
|
||||
fixture.upperObjects();
|
||||
|
||||
fixture.generate();
|
||||
|
||||
fixture.assertEndedUnrecorded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void thrownUpperPlacementEndsWithoutBeingRecorded() {
|
||||
Fixture fixture = new Fixture(THROWS);
|
||||
fixture.upperObjects();
|
||||
|
||||
fixture.generate();
|
||||
|
||||
fixture.assertEndedUnrecorded();
|
||||
}
|
||||
|
||||
private static final class Fixture {
|
||||
private final IrisBiome biome = new IrisBiome();
|
||||
private final IrisComplex complex = mock(IrisComplex.class);
|
||||
private final IrisObject object = mock(IrisObject.class);
|
||||
private final Engine engine = mock(Engine.class);
|
||||
private final IrisDimension dimension = mock(IrisDimension.class);
|
||||
private final ObjectPassPlacer placer = mock(ObjectPassPlacer.class);
|
||||
private final ChunkContext context = mock(ChunkContext.class);
|
||||
private final MantleObjectComponent component;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Fixture(Answer<Integer> placement) {
|
||||
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getSeedManager()).thenReturn(mock(SeedManager.class));
|
||||
when(engine.getHeight()).thenReturn(256);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
EngineMantle engineMantle = mock(EngineMantle.class);
|
||||
when(engineMantle.getEngine()).thenReturn(engine);
|
||||
when(engineMantle.getData()).thenReturn(mock(IrisData.class));
|
||||
when(engineMantle.getComplex()).thenReturn(complex);
|
||||
when(engineMantle.trueHeight(anyInt(), anyInt())).thenReturn(120);
|
||||
|
||||
when(object.getLoadKey()).thenReturn("trees/water");
|
||||
when(object.getW()).thenReturn(1);
|
||||
when(object.getH()).thenReturn(1);
|
||||
when(object.getD()).thenReturn(1);
|
||||
doAnswer(placement).when(object).place(anyInt(), anyInt(), any(IObjectPlacer.class), any(IrisObjectPlacement.class),
|
||||
any(RNG.class), any(), any(), any());
|
||||
doAnswer(placement).when(object).place(anyInt(), anyInt(), anyInt(), any(IObjectPlacer.class), any(IrisObjectPlacement.class),
|
||||
any(RNG.class), any(), any(), any());
|
||||
|
||||
biome.setLoadKey("water-biome");
|
||||
IrisRegion region = new IrisRegion();
|
||||
region.setLoadKey("water-region");
|
||||
ProceduralStream<IrisRegion> regions = mock(ProceduralStream.class);
|
||||
when(regions.get(anyDouble(), anyDouble())).thenReturn(region);
|
||||
ProceduralStream<IrisBiome> biomes = mock(ProceduralStream.class);
|
||||
when(biomes.get(anyDouble(), anyDouble())).thenReturn(biome);
|
||||
ProceduralStream<Integer> heights = mock(ProceduralStream.class);
|
||||
when(heights.get(anyDouble(), anyDouble())).thenReturn(64);
|
||||
when(complex.allowsNewGenerationChunk(anyInt(), anyInt())).thenReturn(true);
|
||||
when(complex.allowsNewGenerationFootprint(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(true);
|
||||
when(complex.getRegionStream()).thenReturn(regions);
|
||||
when(complex.getTrueBiomeStream()).thenReturn(biomes);
|
||||
when(complex.getRoundedHeighteightStream()).thenReturn(heights);
|
||||
when(context.getComplex()).thenReturn(complex);
|
||||
when(placer.getEngine()).thenReturn(engine);
|
||||
when(placer.getCarvedColumn(anyInt(), anyInt(), anyInt())).thenAnswer(call -> {
|
||||
byte[] column = new byte[call.<Integer>getArgument(2)];
|
||||
Arrays.fill(column, 20, 28, (byte) 1);
|
||||
return column;
|
||||
});
|
||||
when(placer.getDataIfPresent(anyInt(), anyInt(), anyInt(), eq(MatterCavern.class)))
|
||||
.thenReturn(new MatterCavern(true, "", (byte) 0));
|
||||
component = new MantleObjectComponent(engineMantle);
|
||||
}
|
||||
|
||||
private IrisObjectPlacement surfacePlacement() {
|
||||
IrisObjectPlacement placement = placement(CarvingMode.SURFACE_ONLY);
|
||||
when(placement.getDensity(any(RNG.class), anyDouble(), anyDouble(), any())).thenReturn(1);
|
||||
when(placement.getObject(any(), any(RNG.class))).thenReturn(object);
|
||||
return placement;
|
||||
}
|
||||
|
||||
private IrisObjectPlacement cavePlacement() {
|
||||
IrisObjectPlacement placement = placement(CarvingMode.CARVING_ONLY);
|
||||
when(placement.getDensity(any(RNG.class), anyDouble(), anyDouble(), any())).thenReturn(1);
|
||||
when(placement.getObject(any(), any(RNG.class))).thenReturn(object);
|
||||
return placement;
|
||||
}
|
||||
|
||||
private IrisProceduralObjects proceduralObjects() {
|
||||
IrisObjectPlacement placement = placement(CarvingMode.SURFACE_ONLY);
|
||||
IrisProceduralPlacement procedural = mock(IrisProceduralPlacement.class);
|
||||
when(procedural.getChance()).thenReturn(2D);
|
||||
when(procedural.getName()).thenReturn("water-procedural");
|
||||
when(procedural.getDensity()).thenReturn(1);
|
||||
when(procedural.asPlacement()).thenReturn(placement);
|
||||
when(procedural.getVariantObject(any(), any(), any())).thenReturn(object);
|
||||
IrisProceduralObjects objects = mock(IrisProceduralObjects.class);
|
||||
when(objects.isEmpty()).thenReturn(false);
|
||||
when(objects.getAllPlacements()).thenReturn(new KList<>(procedural));
|
||||
return objects;
|
||||
}
|
||||
|
||||
private void upperObjects() {
|
||||
IrisObjectPlacement forced = placement(CarvingMode.ANYWHERE);
|
||||
IrisObjectPlacement source = placement(CarvingMode.SURFACE_ONLY);
|
||||
when(source.getDensity(any(RNG.class), anyDouble(), anyDouble(), any())).thenReturn(1);
|
||||
when(source.getObject(any(UpperDimensionContext.class), any(RNG.class))).thenReturn(object);
|
||||
when(source.toPlacement(anyString())).thenReturn(forced);
|
||||
IrisBiome upperBiome = new IrisBiome();
|
||||
upperBiome.setLoadKey("upper-biome");
|
||||
upperBiome.setObjects(new KList<>(source));
|
||||
UpperDimensionContext upper = mock(UpperDimensionContext.class);
|
||||
when(upper.getUpperBiome(anyInt(), anyInt())).thenReturn(upperBiome);
|
||||
when(upper.getDimension()).thenReturn(dimension);
|
||||
when(upper.getEffectiveSurfaceY(anyInt(), anyInt())).thenReturn(64);
|
||||
when(engine.getUpperContext()).thenReturn(upper);
|
||||
when(dimension.isUpperDimensionObjects()).thenReturn(true);
|
||||
}
|
||||
|
||||
private IrisObjectPlacement placement(CarvingMode carving) {
|
||||
IrisObjectPlacement placement = mock(IrisObjectPlacement.class);
|
||||
when(placement.getChance()).thenReturn(2D);
|
||||
when(placement.getCarvingSupport()).thenReturn(carving);
|
||||
when(placement.getPlace()).thenReturn(new KList<>("trees/water"));
|
||||
when(placement.getAllowedCollisions()).thenReturn(new KList<>());
|
||||
when(placement.getForbiddenCollisions()).thenReturn(new KList<>());
|
||||
when(placement.scaleObject(any(RNG.class), any(), any())).thenReturn(object);
|
||||
when(placement.waterRule()).thenReturn(ObjectWaterRule.ENTERS_WATER);
|
||||
return placement;
|
||||
}
|
||||
|
||||
private void generate() {
|
||||
component.generateOrigin(placer, 0, 0, context);
|
||||
}
|
||||
|
||||
private void assertEndedUnrecorded() {
|
||||
InOrder order = inOrder(placer);
|
||||
order.verify(placer).beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||
order.verify(placer).endObjectPlacement();
|
||||
verify(placer, never()).recordObjectPlacement(anyInt());
|
||||
}
|
||||
|
||||
private void assertRecordedThenEnded() {
|
||||
InOrder order = inOrder(placer);
|
||||
order.verify(placer).beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||
order.verify(placer).recordObjectPlacement(anyInt());
|
||||
order.verify(placer).endObjectPlacement();
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
-6
@@ -8,6 +8,7 @@ import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.integration.Identifier;
|
||||
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||
import art.arcane.iris.testsupport.PlatformBinding;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.mantle.runtime.Mantle;
|
||||
@@ -93,14 +94,14 @@ public class MantleWriterObjectWaterTest {
|
||||
@Test
|
||||
public void structurePiecesKeepOutOfRiverWaterUnlessTheyAllowIt() {
|
||||
MatterCavern cavern = new MatterCavern(true, "", (byte) 3);
|
||||
int land = writer.beginObjectPlacement(false);
|
||||
int land = writer.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||
writer.set(3, 7, 3, stone);
|
||||
writer.set(3, 8, 3, air);
|
||||
writer.setData(3, 6, 3, cavern);
|
||||
writer.set(3, 5, 3, stone);
|
||||
writer.set(3, 10, 3, stone);
|
||||
writer.set(8, 7, 8, stone);
|
||||
writer.endObjectPlacement(land);
|
||||
writer.endObjectPlacement();
|
||||
|
||||
verify(blocks, never()).set(3, 7, 3, stone);
|
||||
verify(blocks, never()).set(3, 8, 3, air);
|
||||
@@ -109,19 +110,33 @@ public class MantleWriterObjectWaterTest {
|
||||
verify(blocks).set(3, 10, 3, stone);
|
||||
verify(blocks).set(8, 7, 8, stone);
|
||||
|
||||
int water = writer.beginObjectPlacement(true);
|
||||
int water = writer.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||
writer.set(3, 6, 3, stone);
|
||||
writer.set(3, 9, 3, air);
|
||||
writer.endObjectPlacement(water);
|
||||
writer.endObjectPlacement();
|
||||
|
||||
verify(blocks).set(3, 6, 3, stone);
|
||||
verify(blocks, never()).set(3, 9, 3, air);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forcedPlacementsWriteThroughRiverWater() {
|
||||
MatterCavern cavern = new MatterCavern(true, "", (byte) 3);
|
||||
writer.beginObjectPlacement(ObjectWaterRule.FORCED);
|
||||
writer.set(3, 7, 3, stone);
|
||||
writer.set(3, 8, 3, air);
|
||||
writer.setData(3, 6, 3, cavern);
|
||||
writer.endObjectPlacement();
|
||||
|
||||
verify(blocks).set(3, 7, 3, stone);
|
||||
verify(blocks).set(3, 8, 3, air);
|
||||
verify(caverns).set(3, 6, 3, cavern);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writesOutsideAnObjectPlacementAreNotVetoed() {
|
||||
int land = writer.beginObjectPlacement(false);
|
||||
writer.endObjectPlacement(land);
|
||||
int land = writer.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||
writer.endObjectPlacement();
|
||||
|
||||
writer.set(3, 7, 3, stone);
|
||||
writer.set(3, 8, 3, air);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||
import art.arcane.iris.testsupport.KeyedBlockState;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import org.junit.Test;
|
||||
@@ -21,7 +22,8 @@ public class MutationLogTest {
|
||||
new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(3, 70, -2, String.class), "marker", true),
|
||||
new ObjectDestinationTransaction.CustomBlockMutation(new ObjectDestinationTransaction.DataKey(-17, 4, 40, NativeBlockState.class), state, false)));
|
||||
for (int index = 0; index < 100; index++) {
|
||||
log.add(index, index + 1, -index, "grow" + index, (index & 1) == 0, (index & 2) == 0, (index & 4) == 0);
|
||||
log.add(index, index + 1, -index, "grow" + index, (index & 1) == 0, (index & 2) == 0,
|
||||
(index & 4) == 0 ? ObjectWaterRule.ENTERS_WATER : (index & 8) == 0 ? ObjectWaterRule.FORCED : ObjectWaterRule.KEEP_OUT);
|
||||
}
|
||||
|
||||
assertEquals(102, log.size());
|
||||
@@ -41,9 +43,10 @@ public class MutationLogTest {
|
||||
assertFalse(log.custom(101));
|
||||
assertTrue(log.canopy(98));
|
||||
assertFalse(log.canopy(100));
|
||||
assertFalse(log.entersWater(0));
|
||||
assertTrue(log.entersWater(98));
|
||||
assertFalse(log.entersWater(6));
|
||||
assertEquals(ObjectWaterRule.KEEP_OUT, log.waterRule(0));
|
||||
assertEquals(ObjectWaterRule.ENTERS_WATER, log.waterRule(98));
|
||||
assertEquals(ObjectWaterRule.FORCED, log.waterRule(6));
|
||||
assertEquals(ObjectWaterRule.KEEP_OUT, log.waterRule(14));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,7 +65,7 @@ public class MutationLogTest {
|
||||
int z = (index * 5) - 20;
|
||||
String value = "value" + (index % 9);
|
||||
boolean canopy = index % 4 == 0;
|
||||
log.add(x, y, z, value, false, canopy, false);
|
||||
log.add(x, y, z, value, false, canopy, ObjectWaterRule.KEEP_OUT);
|
||||
if (index >= 10) {
|
||||
tail.add(new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(x, y, z, String.class), value, canopy));
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformRegistries;
|
||||
import art.arcane.iris.structure.object.IObjectPlacer;
|
||||
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||
import art.arcane.iris.testsupport.PlatformLeakGuard;
|
||||
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
||||
import art.arcane.iris.world.storage.matter.TileWrapper;
|
||||
@@ -173,7 +174,7 @@ public class ObjectContinuationCanopyTest {
|
||||
when(firstChunk.getOrCreate(0)).thenReturn(first);
|
||||
when(secondChunk.getOrCreate(0)).thenReturn(second);
|
||||
FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate,
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), false);
|
||||
new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), ObjectWaterRule.KEEP_OUT);
|
||||
transaction.set(15, 5, 1, trunk);
|
||||
assertTrue(transaction.beginTreeCanopy(new BlockPosition(16, 5, 1)));
|
||||
transaction.set(16, 5, 1, custom);
|
||||
|
||||
@@ -8,6 +8,7 @@ import art.arcane.iris.integration.Identifier;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.pack.loading.IrisRegistrant;
|
||||
import art.arcane.iris.pack.loading.ResourceLoader;
|
||||
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||
import art.arcane.iris.world.entity.IrisSpawner;
|
||||
import art.arcane.iris.world.storage.matter.IrisMatterContext;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
@@ -58,17 +59,20 @@ public class ObjectContinuationTest {
|
||||
public void onlyAcceptedCrossingPlacementsLeaveFutureFragments() throws Exception {
|
||||
Fixture fixture = new Fixture();
|
||||
ObjectDestinationTransaction source = new ObjectDestinationTransaction(fixture.writer, 0, 0);
|
||||
int checkpoint = source.beginObjectPlacement(false);
|
||||
int checkpoint = source.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||
source.setData(1, 5, 1, "inside");
|
||||
source.endObjectPlacement(checkpoint);
|
||||
checkpoint = source.beginObjectPlacement(false);
|
||||
source.recordObjectPlacement(checkpoint);
|
||||
source.endObjectPlacement();
|
||||
checkpoint = source.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||
source.setData(15, 5, 1, "crossing");
|
||||
source.setData(16, 5, 1, "crossing");
|
||||
source.endObjectPlacement(checkpoint);
|
||||
checkpoint = source.beginObjectPlacement(false);
|
||||
source.recordObjectPlacement(checkpoint);
|
||||
source.endObjectPlacement();
|
||||
checkpoint = source.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||
source.setData(32, 5, 1, "unrelated");
|
||||
source.setData(48, 5, 1, "unrelated");
|
||||
source.endObjectPlacement(checkpoint);
|
||||
source.recordObjectPlacement(checkpoint);
|
||||
source.endObjectPlacement();
|
||||
source.setData(17, 5, 1, "rejected");
|
||||
ObjectSourcePlan plan = source.sourcePlanSince(0);
|
||||
|
||||
|
||||
+59
-16
@@ -16,6 +16,7 @@ import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.Terrain3DColumnFixtures;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.structure.object.ObjectWaterRule;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.BlockPosition;
|
||||
import art.arcane.iris.structure.object.DecayControlPlacer;
|
||||
@@ -193,14 +194,14 @@ public class ObjectDestinationTransactionTest {
|
||||
transaction.set(3, 9, 3, pier);
|
||||
transaction.set(6, 18, 6, pier);
|
||||
assertEquals("a pier keeps its blocks on the river bed and the shore", start + 2, transaction.mutationCheckpoint());
|
||||
transaction.beginObjectPlacement(true);
|
||||
transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||
transaction.set(3, 10, 3, pier);
|
||||
transaction.set(4, 15, 3, pier);
|
||||
assertEquals("an underwater pier keeps its blocks in the river", start + 4, transaction.mutationCheckpoint());
|
||||
transaction.set(3, 12, 3, pier);
|
||||
transaction.set(3, 10, 3, vine);
|
||||
assertEquals("an underwater object still keeps out of falls and open water", start + 4, transaction.mutationCheckpoint());
|
||||
transaction.beginObjectPlacement(false);
|
||||
transaction.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||
transaction.set(3, 16, 3, vine);
|
||||
transaction.set(3, 8, 3, vine);
|
||||
transaction.set(6, 19, 6, vine);
|
||||
@@ -239,12 +240,12 @@ public class ObjectDestinationTransactionTest {
|
||||
transaction.set(3, 10, 3, boulder);
|
||||
assertEquals("nothing an object places roofs or fills the slot between its water and the cliff top", start,
|
||||
transaction.mutationCheckpoint());
|
||||
transaction.beginObjectPlacement(true);
|
||||
transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||
transaction.set(3, 10, 3, boulder);
|
||||
transaction.set(3, 12, 3, boulder);
|
||||
assertEquals("an underwater object's solid block below the water may still sit on the slot bed", start + 1,
|
||||
transaction.mutationCheckpoint());
|
||||
transaction.beginObjectPlacement(false);
|
||||
transaction.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||
transaction.set(3, 31, 3, leaves);
|
||||
transaction.set(3, 36, 3, leaves);
|
||||
transaction.set(3, 33, 3, boulder);
|
||||
@@ -289,12 +290,13 @@ public class ObjectDestinationTransactionTest {
|
||||
setCanopy(transaction, 5, 14, 3, leaves);
|
||||
assertEquals("the bed, the air above the surface and dry land keep their leaves", start + 4,
|
||||
transaction.mutationCheckpoint());
|
||||
int underwater = transaction.beginObjectPlacement(true);
|
||||
int underwater = transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||
transaction.set(3, 12, 3, leaves);
|
||||
transaction.set(4, 9, 3, leaves);
|
||||
assertEquals("an underwater object keeps its solid blocks in the water", underwater + 2,
|
||||
transaction.mutationCheckpoint());
|
||||
transaction.endObjectPlacement(underwater);
|
||||
transaction.recordObjectPlacement(underwater);
|
||||
transaction.endObjectPlacement();
|
||||
ObjectDestinationTransaction destination = new ObjectDestinationTransaction(writer, 0, 0);
|
||||
destination.apply(transaction.sourcePlanSince(start));
|
||||
assertEquals("the destination replay keeps the underwater blocks", 6, destination.mutationCheckpoint());
|
||||
@@ -303,7 +305,7 @@ public class ObjectDestinationTransactionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onwaterRaftsAndOwnForcedObjectsKeepTheirLayerOnRiversButForcedStructurePiecesDoNot() {
|
||||
public void onwaterRaftsAndForcedPlacementsKeepTheirWritesThroughReplay() {
|
||||
MantleWriter writer = writer();
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
||||
@@ -325,25 +327,32 @@ public class ObjectDestinationTransactionTest {
|
||||
IrisObjectPlacement raft = new IrisObjectPlacement().setOnwater(true);
|
||||
IrisObjectPlacement forced = new IrisObjectPlacement().setForcePlace(true);
|
||||
IrisObjectPlacement piece = IrisStructureComponent.piecePlacement(new IrisStructure(), new PlacedStructurePiece(null,
|
||||
new IrisObject(1, 1, 1), 4, 14, 3, IrisObjectRotation.of(0, 0, 0), 4, 14, 3, 4, 14, 3), ObjectPlaceMode.CENTER_HEIGHT, false);
|
||||
new IrisObject(1, 1, 1), 4, 14, 3, IrisObjectRotation.of(0, 0, 0), 4, 14, 3, 4, 14, 3), ObjectPlaceMode.CENTER_HEIGHT);
|
||||
assertTrue(piece.isForcePlace());
|
||||
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
||||
|
||||
int raftStart = transaction.beginObjectPlacement(raft.entersWater());
|
||||
int raftStart = transaction.beginObjectPlacement(raft.waterRule());
|
||||
for (int x = 3; x <= 5; x++) {
|
||||
transaction.set(x, 14, 3, plank);
|
||||
}
|
||||
assertEquals("a one-block onwater raft keeps its layer on the river surface", raftStart + 3, transaction.mutationCheckpoint());
|
||||
int forcedStart = transaction.beginObjectPlacement(forced.entersWater());
|
||||
assertEquals(ObjectWaterRule.FORCED, forced.waterRule());
|
||||
assertEquals(ObjectWaterRule.FORCED, piece.waterRule());
|
||||
int forcedStart = transaction.beginObjectPlacement(forced.waterRule());
|
||||
transaction.set(3, 13, 3, plank);
|
||||
assertEquals("an object's own forcePlace keeps its solid blocks in the river", forcedStart + 1, transaction.mutationCheckpoint());
|
||||
int pieceStart = transaction.beginObjectPlacement(piece.entersWater());
|
||||
transaction.set(3, 12, 3, mock(NativeBlockState.class));
|
||||
transaction.setData(3, 11, 3, new MatterCavern(true, "", (byte) 3));
|
||||
assertEquals("a forced object writes solid blocks, open blocks and carves through the river", forcedStart + 3, transaction.mutationCheckpoint());
|
||||
int pieceStart = transaction.beginObjectPlacement(piece.waterRule());
|
||||
transaction.set(4, 13, 3, plank);
|
||||
transaction.set(5, 11, 3, plank);
|
||||
assertEquals("a forced structure piece still keeps its solid blocks out of the river", pieceStart, transaction.mutationCheckpoint());
|
||||
assertEquals("a forced structure piece writes through the river", pieceStart + 2, transaction.mutationCheckpoint());
|
||||
int landStart = transaction.beginObjectPlacement(ObjectWaterRule.KEEP_OUT);
|
||||
transaction.set(4, 12, 3, plank);
|
||||
assertEquals("an unforced object stays out of the river", landStart, transaction.mutationCheckpoint());
|
||||
ObjectDestinationTransaction destination = new ObjectDestinationTransaction(writer, 0, 0);
|
||||
destination.apply(transaction.sourcePlanSince(raftStart));
|
||||
assertEquals("the destination replay keeps the raft and the forced block", 4, destination.mutationCheckpoint());
|
||||
assertEquals("the destination replay keeps the forced writes beside the raft", 8, destination.mutationCheckpoint());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -366,15 +375,49 @@ public class ObjectDestinationTransactionTest {
|
||||
when(pier.isSolid()).thenReturn(true);
|
||||
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
||||
|
||||
int raft = transaction.beginObjectPlacement(true);
|
||||
int raft = transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||
transaction.set(3, 12, 3, pier);
|
||||
transaction.endObjectPlacement(raft);
|
||||
transaction.recordObjectPlacement(raft);
|
||||
transaction.endObjectPlacement();
|
||||
int afterRaft = transaction.mutationCheckpoint();
|
||||
transaction.set(3, 13, 3, pier);
|
||||
|
||||
assertEquals("a write after the water placement ends follows land rules", afterRaft, transaction.mutationCheckpoint());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aRejectedWaterPlacementReturnsToLandRules() {
|
||||
MantleWriter writer = writer();
|
||||
waterAtColumnThree(writer);
|
||||
NativeBlockState pier = mock(NativeBlockState.class);
|
||||
when(pier.isSolid()).thenReturn(true);
|
||||
ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0);
|
||||
|
||||
transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER);
|
||||
transaction.set(3, 12, 3, pier);
|
||||
transaction.endObjectPlacement();
|
||||
int afterRaft = transaction.mutationCheckpoint();
|
||||
transaction.set(3, 13, 3, pier);
|
||||
|
||||
assertEquals("a write after a rejected water placement follows land rules", afterRaft, transaction.mutationCheckpoint());
|
||||
}
|
||||
|
||||
private static void waterAtColumnThree(MantleWriter writer) {
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
||||
ChunkWaterRaster raster = mock(ChunkWaterRaster.class);
|
||||
when(writer.getEngine().getComplex()).thenReturn(complex);
|
||||
when(complex.getHydrologyRuntime()).thenReturn(runtime);
|
||||
when(runtime.enabled()).thenReturn(true);
|
||||
when(runtime.raster(anyInt(), anyInt())).thenReturn(raster);
|
||||
when(raster.role(anyInt(), anyInt())).thenReturn(WaterRole.NONE);
|
||||
when(raster.waterHead(anyInt(), anyInt())).thenReturn(Integer.MIN_VALUE);
|
||||
when(raster.role(3, 3)).thenReturn(WaterRole.CHANNEL);
|
||||
when(raster.waterHead(3, 3)).thenReturn(14);
|
||||
when(raster.terrainHeight(3, 3)).thenReturn(10);
|
||||
followRasterStreams(complex, raster);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceCaptureCannotReplaceAuthoredRoomSolids() {
|
||||
MantleWriter writer = writer();
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
package art.arcane.iris.pack;
|
||||
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorator;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPermission;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyTier;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyWetness;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.testsupport.CompatTestPlatform;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
@@ -13,7 +22,9 @@ import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -22,6 +33,10 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PackHydrologyValidatorTest {
|
||||
private static final String WATER = "{\"name\": \"water\", \"palette\": {\"palette\": [{\"block\": \"minecraft:water\"}]}}";
|
||||
private static final String LAVA = "{\"name\": \"lava\", \"palette\": {\"palette\": [{\"block\": \"minecraft:lava\"}]}}";
|
||||
private static final String CRUST = "{\"name\": \"crust\", \"palette\": {\"palette\": [{\"block\": \"minecraft:obsidian\"}]}}";
|
||||
private static final String SEA_IS_LAVA = "\"fluidPalette\": {\"palette\": [{\"block\": \"minecraft:lava\"}]},";
|
||||
private static final String WATER_ONLY = "{\"enabled\": true, \"fluids\": [{\"name\": \"water\"}]}";
|
||||
|
||||
@Rule
|
||||
@@ -45,7 +60,8 @@ public class PackHydrologyValidatorTest {
|
||||
},
|
||||
"fluids": [
|
||||
{"name": "water", "palette": {"palette": [{"block": "minecraft:water"}]}},
|
||||
{"name": "lava", "palette": {"palette": [{"block": "minecraft:lava"}]}}
|
||||
{"name": "lava", "palette": {"palette": [{"block": "minecraft:lava"}]}, "seam": "crust"},
|
||||
{"name": "crust", "palette": {"palette": [{"block": "minecraft:obsidian"}]}}
|
||||
]
|
||||
}
|
||||
""", "\"hydrologyPolicy\": {\"fluid\": \"lava\"},")));
|
||||
@@ -277,45 +293,214 @@ public class PackHydrologyValidatorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownHydrologyKeysAreIgnoredAndAMissingEnabledFlagLoadsAsOff() throws Exception {
|
||||
public void warnsAboutAnUnknownKeyAtTheTopOfHydrology() throws Exception {
|
||||
List<String> warnings = unknownKeyWarnings(validate(pack(dimension("{\"enabled\": true, \"unknownSection\": {\"enabled\": true, \"tiers\": 4}}", ""))));
|
||||
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.unknownSection is not a known key, so its value is ignored.");
|
||||
assertContains(warnings, "prefetchRings");
|
||||
assertEquals(warnings.toString(), 1, warnings.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warnsAboutAMisspeltEnabledFlagThoughTheBlockLoadsAsOff() throws Exception {
|
||||
File pack = pack(dimension("{\"enable\": true, \"ponds\": {\"dryDrawdon\": 3}}", ""));
|
||||
|
||||
List<String> warnings = unknownKeyWarnings(validate(pack));
|
||||
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.enable is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.ponds.dryDrawdon is not a known key");
|
||||
assertEquals(warnings.toString(), 2, warnings.size());
|
||||
assertFalse(loadHydrology(pack).isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warnsAboutUnknownKeysInNestedObjects() throws Exception {
|
||||
List<String> warnings = unknownKeyWarnings(validate(pack(dimension("""
|
||||
{
|
||||
"enabled": true,
|
||||
"ponds": {"seeded": {"radiusRange": [4, 12]}},
|
||||
"underground": {"cavePools": {"surface": 3}, "seaInlets": {"length": [24, 96], "chamber": {"radius": 4}}}
|
||||
}
|
||||
""", ""))));
|
||||
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.ponds.seeded.radiusRange is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.underground.cavePools.surface is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.underground.seaInlets.chamber is not a known key");
|
||||
assertEquals(warnings.toString(), 3, warnings.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warnsAboutUnknownKeysInsideTierArrayElements() throws Exception {
|
||||
File pack = pack(dimension("""
|
||||
{"unknownSection": {"enabled": true, "tiers": 4}, "unknownList": [{"enabled": true}]}
|
||||
{"enabled": true, "fluids": [{"name": "water", "palette": {"palette": [{"block": "minecraft:water", "bloc": 1}]}, "sealed": true}],
|
||||
"tiers": [
|
||||
{"name": "stream", "minCatchment": 900, "halfWidth": [0.5, 2.5], "bankBand": 8},
|
||||
{"name": "major", "minCatchment": 200000, "halfWidth": [9, 18], "bankBand": 48, "notATierField": {"depth": 3},
|
||||
"estuary": {"flair": 2},
|
||||
"decorators": [{"partOf": "SEA_FLOOR", "palette": [{"block": "minecraft:kelp"}], "stacks": 1}]}
|
||||
]}
|
||||
""", ""));
|
||||
|
||||
assertTrue(validate(pack).errors().isEmpty());
|
||||
IrisData data = IrisData.openDatapackCompiler(pack);
|
||||
try {
|
||||
IrisHydrology hydrology = data.getDimensionLoader().load("main").getHydrology();
|
||||
assertNotNull(hydrology);
|
||||
assertFalse(hydrology.isEnabled());
|
||||
} finally {
|
||||
data.close();
|
||||
List<String> warnings = unknownKeyWarnings(validate(pack));
|
||||
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.tiers[1].notATierField is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.tiers[1].estuary.flair is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.tiers[1].decorators[0].stacks is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.fluids[0].sealed is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.fluids[0].palette.palette[0].bloc is not a known key");
|
||||
assertEquals(warnings.toString(), 5, warnings.size());
|
||||
for (IrisHydrologyTier tier : loadHydrology(pack).getTiers()) {
|
||||
assertEquals(tier.getName(), 48, tier.getEstuary().getLength());
|
||||
assertEquals(tier.getName(), 2.5D, tier.getEstuary().getFlare(), 0D);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownTierKeysAreIgnoredAndTiersKeepTheDefaultEstuary() throws Exception {
|
||||
String written = """
|
||||
{"enabled": true, "tiers": [
|
||||
{"name": "stream", "minCatchment": 900, "halfWidth": [0.5, 2.5], "bankBand": 8%s},
|
||||
{"name": "major", "minCatchment": 200000, "halfWidth": [9, 18], "bankBand": 48%s}
|
||||
]}
|
||||
""";
|
||||
File extra = pack(dimension(written.formatted(", \"notATierField\": false", ", \"notATierField\": {\"depth\": 3}"), ""));
|
||||
File current = pack(dimension(written.formatted("", ""), ""));
|
||||
public void treatsMapKeysAsDataAndChecksTheObjectsInside() throws Exception {
|
||||
List<String> warnings = new ArrayList<>();
|
||||
JSONObject written = new JSONObject("""
|
||||
{"zones": {"swamp": {"min": 0.7, "max": 1}, "desert": {"minimum": 0.1}}}
|
||||
""");
|
||||
|
||||
PackHydrologyValidator.Validation validation = validate(extra);
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertTrue(validation.warnings().isEmpty());
|
||||
PackValidationResult packaging = PackValidator.validateForPackaging(extra);
|
||||
assertEquals(PackValidator.validateForPackaging(current).getBlockingErrors(), packaging.getBlockingErrors());
|
||||
IrisHydrology loaded = loadHydrology(extra);
|
||||
for (IrisHydrologyTier tier : loaded.getTiers()) {
|
||||
assertEquals(tier.getName(), 48, tier.getEstuary().getLength());
|
||||
assertEquals(tier.getName(), 2.5D, tier.getEstuary().getFlare(), 0D);
|
||||
PackHydrologyValidator.warnUnknownKeys("root", written, NamedZones.class, temporaryFolder.getRoot(), warnings);
|
||||
|
||||
assertContains(warnings, "root.zones.desert.minimum is not a known key");
|
||||
assertEquals(warnings.toString(), 1, warnings.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptsAnyKeyInsideABlockDataMap() throws Exception {
|
||||
PackHydrologyValidator.Validation validation = validate(pack(dimension("""
|
||||
{"enabled": true, "fluids": [{"name": "water", "palette": {"palette": [
|
||||
{"block": "minecraft:water", "data": {"level": 0, "anything": {"at": "all"}}, "tileData": {"SpawnData": {"entity": {}}}}
|
||||
]}}]}
|
||||
""", "")));
|
||||
|
||||
assertEquals(List.of(), unknownKeyWarnings(validation));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptsEveryKeyGsonWritesForTheConfigClasses() throws Exception {
|
||||
Gson gson = new Gson();
|
||||
PackHydrologyValidator.Validation defaults = validate(pack(dimension(gson.toJson(new IrisHydrology().setEnabled(true)), "")));
|
||||
assertEquals(List.of(), unknownKeyWarnings(defaults));
|
||||
|
||||
IrisHydrology hydrology = new IrisHydrology().setEnabled(true);
|
||||
hydrology.getTiers().get(0).getMaterials().setBed(new IrisMaterialPalette()).setShore(new IrisMaterialPalette()).setBank(new IrisMaterialPalette());
|
||||
IrisDecorator decorator = new IrisDecorator().setForceBlock(new IrisBlockData("minecraft:stone"));
|
||||
decorator.getStyle().setFracture(new IrisGeneratorStyle());
|
||||
hydrology.getTiers().get(0).getDecorators().add(decorator);
|
||||
IrisHydrologyPolicy policy = new IrisHydrologyPolicy().setRainfall(1D).setWetness(new IrisHydrologyWetness()).setStreams(IrisHydrologyPermission.ALLOW);
|
||||
|
||||
PackHydrologyValidator.Validation written = validate(pack(dimension(gson.toJson(hydrology), "\"hydrologyPolicy\": " + gson.toJson(policy) + ",")));
|
||||
|
||||
assertEquals(List.of(), keyWarnings(written));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warnsAboutEachRenamedKeyByItsOldName() throws Exception {
|
||||
List<String> warnings = unknownKeyWarnings(validate(pack(dimension("""
|
||||
{
|
||||
"enabled": true,
|
||||
"drainage": {"minimumHeadKeep": 0.6},
|
||||
"tiers": [
|
||||
{"name": "stream", "halfWidth": [0.5, 2], "bankBand": 0, "waterfallMinimumDrop": 6},
|
||||
{"name": "river", "minCatchment": 20000, "halfWidth": [2, 8], "bankBand": 32, "waterfallMinimumDrop": 8}
|
||||
],
|
||||
"ponds": {"climateDrawdown": 3},
|
||||
"underground": {"seaInlets": {"minimumCliffHeight": 8}}
|
||||
}
|
||||
""", ""))));
|
||||
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.drainage.minimumHeadKeep is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.tiers[0].waterfallMinimumDrop is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.tiers[1].waterfallMinimumDrop is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.ponds.climateDrawdown is not a known key");
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.underground.seaInlets.minimumCliffHeight is not a known key");
|
||||
assertEquals(warnings.toString(), 5, warnings.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warnsAboutUnknownKeysInHydrologyPoliciesAtEveryScope() throws Exception {
|
||||
File pack = pack(dimension(WATER_ONLY, "\"hydrologyPolicy\": {\"rainFall\": 1},"));
|
||||
write(pack, "regions/region.json", """
|
||||
{"landBiomes": ["biome"], "hydrologyPolicy": {"streamz": "BLOCK"}}
|
||||
""");
|
||||
write(pack, "biomes/biome.json", """
|
||||
{"name": "Biome", "hydrologyPolicy": {"wetness": {"middle": 0.5},
|
||||
"decorators": [{"partOf": "SHORE_LINE", "palette": [{"block": "minecraft:fern"}], "odds": 2}]}}
|
||||
""");
|
||||
|
||||
List<String> warnings = unknownKeyWarnings(validate(pack));
|
||||
|
||||
assertContains(warnings, "Dimension 'main'.hydrologyPolicy.rainFall is not a known key");
|
||||
assertContains(warnings, "Region 'region'.hydrologyPolicy.streamz is not a known key");
|
||||
assertContains(warnings, "Biome 'biome'.hydrologyPolicy.wetness.middle is not a known key");
|
||||
assertContains(warnings, "Biome 'biome'.hydrologyPolicy.decorators[0].odds is not a known key");
|
||||
assertEquals(warnings.toString(), 4, warnings.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void followsSnippetsAndNamesThemInThePath() throws Exception {
|
||||
File pack = pack(dimension("""
|
||||
{"enabled": true, "tiers": [{"name": "stream", "halfWidth": [0.5, 2], "bankBand": 0,
|
||||
"decorators": ["snippet/reeds", "snippet/decorator/fern", "snippet/decorator/missing"]}]}
|
||||
""", ""));
|
||||
write(pack, "snippet/decorator/reeds.json", """
|
||||
{"partOf": "SHORE_LINE", "palette": [{"block": "minecraft:sugar_cane"}], "odds": 2}
|
||||
""");
|
||||
write(pack, "snippet/decorator/fern.json", """
|
||||
{"partOf": "SHORE_LINE", "palette": [{"block": "minecraft:fern"}]}
|
||||
""");
|
||||
|
||||
List<String> warnings = keyWarnings(validate(pack));
|
||||
|
||||
assertContains(warnings, "Dimension 'main'.hydrology.tiers[0].decorators[0] (snippet/decorator/reeds).odds is not a known key");
|
||||
assertEquals(warnings.toString(), 1, warnings.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aSnippetThatRefersToItselfEnds() throws Exception {
|
||||
File pack = temporaryFolder.newFolder("cycle");
|
||||
write(pack, "snippet/style/loop.json", """
|
||||
{"fracture": "snippet/style/loop", "fractures": 1}
|
||||
""");
|
||||
List<String> warnings = new ArrayList<>();
|
||||
|
||||
PackHydrologyValidator.warnUnknownKeys("style", "snippet/style/loop", IrisGeneratorStyle.class, pack, warnings);
|
||||
|
||||
assertContains(warnings, "style (snippet/style/loop).fractures is not a known key");
|
||||
assertEquals(warnings.toString(), 1, warnings.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void leavesKeysOutsideTheHydrologyBlockAlone() throws Exception {
|
||||
File pack = pack("{\"regions\": [\"region\"], \"notADimensionKey\": 1, \"hydrology\": " + WATER_ONLY + "}");
|
||||
write(pack, "biomes/biome.json", "{\"name\": \"Biome\", \"notABiomeKey\": {\"a\": 1}}");
|
||||
|
||||
assertEquals(List.of(), unknownKeyWarnings(validate(pack)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownKeysNeverBlockAPackOnAnyValidationPath() throws Exception {
|
||||
File pack = pack(dimension("{\"enabled\": true, \"ponds\": {\"climateDrawdown\": 3}}", "\"hydrologyPolicy\": {\"rainFall\": 1},"));
|
||||
String key = "not a known key";
|
||||
|
||||
for (PackValidationResult result : List.of(PackValidator.validate(pack), PackValidator.validateForPackaging(pack), PackValidator.validateForDatapackBootstrap(pack))) {
|
||||
assertFalse(result.getBlockingErrors().toString(), result.getBlockingErrors().stream().anyMatch(message -> message.contains(key)));
|
||||
assertContains(result.getWarnings(), "Dimension 'main'.hydrology.ponds.climateDrawdown is " + key);
|
||||
assertContains(result.getWarnings(), "Dimension 'main'.hydrologyPolicy.rainFall is " + key);
|
||||
}
|
||||
assertEquals(HydrologySettings.compile(loadHydrology(current), 1337L, 62, -64, 320).fingerprint(),
|
||||
HydrologySettings.compile(loaded, 1337L, 62, -64, 320).fingerprint());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anObjectWhereAListIsDeclaredReportsNoListInternals() throws Exception {
|
||||
List<String> warnings = new ArrayList<>();
|
||||
JSONObject written = new JSONObject("{\"tiers\": {\"name\": \"stream\"}, \"fluids\": {\"elementData\": 1}}");
|
||||
|
||||
PackHydrologyValidator.warnUnknownKeys("root", written, IrisHydrology.class, temporaryFolder.getRoot(), warnings);
|
||||
|
||||
assertEquals(List.of(), warnings);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -525,16 +710,16 @@ public class PackHydrologyValidatorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsWaterfallMinimumDropBelowTwo() throws Exception {
|
||||
public void rejectsWaterfallMinDropBelowTwo() throws Exception {
|
||||
File pack = pack(dimension("""
|
||||
{"enabled": true, "tiers": [{"name": "stream", "halfWidth": [0.5, 2], "bankBand": 0},
|
||||
{"name": "river", "minCatchment": 20000, "halfWidth": [2, 8], "bankBand": 32, "waterfallMinimumDrop": 1}]}
|
||||
{"name": "river", "minCatchment": 20000, "halfWidth": [2, 8], "bankBand": 32, "waterfallMinDrop": 1}]}
|
||||
""", ""));
|
||||
write(pack, "dimensions/edge.json", dimension("""
|
||||
{"enabled": true, "tiers": [{"name": "stream", "halfWidth": [0.5, 2], "bankBand": 0, "waterfallMinimumDrop": 2}]}
|
||||
{"enabled": true, "tiers": [{"name": "stream", "halfWidth": [0.5, 2], "bankBand": 0, "waterfallMinDrop": 2}]}
|
||||
""", ""));
|
||||
|
||||
assertEquals(List.of("Dimension 'main'.hydrology does not compile: Hydrology tiers[1].waterfallMinimumDrop must be at least 2, got 1"),
|
||||
assertEquals(List.of("Dimension 'main'.hydrology does not compile: Hydrology tiers[1].waterfallMinDrop must be at least 2, got 1"),
|
||||
validate(pack).errors());
|
||||
}
|
||||
|
||||
@@ -677,6 +862,140 @@ public class PackHydrologyValidatorTest {
|
||||
assertTrue(widened.warnings().toString(), widened.warnings().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warnsWhenALavaRiverWithoutASeamCanMeetTheSea() throws Exception {
|
||||
File pack = pack(dimension(hydrology("lava", "lava", LAVA), ""));
|
||||
|
||||
PackHydrologyValidator.Validation validation = validate(pack);
|
||||
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertEquals(List.of("Dimension 'main'.hydrology.fluids profile 'lava' sets no seam, so where its rivers meet the sea"
|
||||
+ " the fluids lie side by side. Set seam on the profile to line that edge. Its rivers come from"
|
||||
+ " Dimension 'main'.hydrology.tiers[0].fluid, Dimension 'main'.hydrology.tiers[1].fluid."), validation.warnings());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warnsAgainstADifferentRiverFluidAndNamesTheBiomeItComesFrom() throws Exception {
|
||||
File pack = pack(dimension(hydrology("water", "water", WATER + ", " + LAVA), SEA_IS_LAVA));
|
||||
write(pack, "biomes/biome.json", """
|
||||
{"name": "Biome", "hydrologyPolicy": {"fluid": "lava"}}
|
||||
""");
|
||||
write(pack, "regions/region.json", """
|
||||
{"landBiomes": ["biome", "plain"]}
|
||||
""");
|
||||
write(pack, "biomes/plain.json", "{\"name\": \"Plain\"}");
|
||||
|
||||
PackHydrologyValidator.Validation validation = validate(pack);
|
||||
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertEquals(List.of("Dimension 'main'.hydrology.fluids profile 'lava' sets no seam, so where its rivers meet fluid 'water'"
|
||||
+ " the fluids lie side by side. Set seam on the profile to line that edge. Its rivers come from"
|
||||
+ " Biome 'biome'.hydrologyPolicy.fluid."), validation.warnings());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aSeamOnTheOtherRiverFluidLinesTheEdgeBetweenThem() throws Exception {
|
||||
String fluids = WATER + ", " + LAVA + ", " + """
|
||||
{"name": "tar", "palette": {"palette": [{"block": "mod:tar"}]}, "seam": "crust"}, %s
|
||||
""".formatted(CRUST);
|
||||
File pack = pack(dimension(hydrology("lava", "tar", fluids), SEA_IS_LAVA));
|
||||
|
||||
PackHydrologyValidator.Validation validation = validate(pack);
|
||||
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertTrue(validation.warnings().toString(), validation.warnings().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void silentWhenTheFluidHasASeam() throws Exception {
|
||||
String fluids = """
|
||||
{"name": "lava", "palette": {"palette": [{"block": "minecraft:lava"}]}, "seam": "crust"}, %s, %s
|
||||
""".formatted(CRUST, WATER);
|
||||
PackHydrologyValidator.Validation validation = validate(pack(dimension(hydrology("lava", "water", fluids), "")));
|
||||
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertTrue(validation.warnings().toString(), validation.warnings().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void silentForWaterRiversWhateverTheProfileIsCalled() throws Exception {
|
||||
String fluids = """
|
||||
{"name": "marsh", "palette": {"palette": [{"block": "water"}]}}, %s
|
||||
""".formatted(WATER);
|
||||
File pack = pack(dimension(hydrology("marsh", "water", fluids), SEA_IS_LAVA));
|
||||
|
||||
PackHydrologyValidator.Validation validation = validate(pack);
|
||||
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertTrue(validation.warnings().toString(), validation.warnings().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void silentWhenTheFluidsAreTheSame() throws Exception {
|
||||
String fluids = LAVA + ", " + """
|
||||
{"name": "magma", "palette": {"palette": [{"block": "lava"}]}}
|
||||
""";
|
||||
PackHydrologyValidator.Validation validation = validate(pack(dimension(hydrology("lava", "magma", fluids), SEA_IS_LAVA)));
|
||||
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertTrue(validation.warnings().toString(), validation.warnings().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void silentWhenAPolicyFluidReplacesEveryTierFluid() throws Exception {
|
||||
String config = hydrology("water", "water", WATER + ", " + LAVA);
|
||||
PackHydrologyValidator.Validation validation = validate(pack(dimension(config,
|
||||
SEA_IS_LAVA + " \"hydrologyPolicy\": {\"fluid\": \"lava\"},")));
|
||||
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertTrue(validation.warnings().toString(), validation.warnings().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aCaveBiomePolicyFluidIsNotARiverFluid() throws Exception {
|
||||
File pack = pack(dimension(hydrology("water", "water", WATER + ", " + LAVA), ""));
|
||||
write(pack, "regions/region.json", """
|
||||
{"landBiomes": ["biome"], "caveBiomes": ["hollow"]}
|
||||
""");
|
||||
write(pack, "biomes/hollow.json", """
|
||||
{"name": "Hollow", "hydrologyPolicy": {"fluid": "lava"}}
|
||||
""");
|
||||
|
||||
PackHydrologyValidator.Validation validation = validate(pack);
|
||||
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertTrue(validation.warnings().toString(), validation.warnings().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void silentAboutTheSeaWhenTheDimensionHasNoFluidHeight() throws Exception {
|
||||
PackHydrologyValidator.Validation validation = validate(pack(dimension(hydrology("lava", "lava", LAVA), "\"fluidHeight\": -64,")));
|
||||
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertTrue(validation.warnings().toString(), validation.warnings().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warnsAboutTheSeaOneBlockAboveTheDimensionFloor() throws Exception {
|
||||
String noInlets = hydrology("lava", "lava", LAVA).replace("\"underground\": {", "\"underground\": {\"seaInlets\": {\"enabled\": false}, ");
|
||||
PackHydrologyValidator.Validation validation = validate(pack(dimension(noInlets, "\"fluidHeight\": -63,")));
|
||||
|
||||
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
|
||||
assertContains(validation.warnings(), "where its rivers meet the sea");
|
||||
}
|
||||
|
||||
private static String hydrology(String streamFluid, String riverFluid, String fluids) {
|
||||
return """
|
||||
{"enabled": true,
|
||||
"tiers": [
|
||||
{"name": "stream", "minCatchment": 1500, "halfWidth": [0.5, 2], "bankBand": 0, "fluid": "%s"},
|
||||
{"name": "river", "minCatchment": 20000, "halfWidth": [2, 16], "bankBand": 8, "fluid": "%s"}],
|
||||
"ponds": {"fluid": "%s"},
|
||||
"underground": {"cavePools": {"fluid": "%s"}},
|
||||
"fluids": [%s]}
|
||||
""".formatted(streamFluid, riverFluid, streamFluid, streamFluid, fluids);
|
||||
}
|
||||
|
||||
private File shorePack(String dimensionWidth) throws Exception {
|
||||
File pack = pack(dimension(WATER_ONLY, "\"hydrologyPolicy\": {\"shoreBiomes\": [\"beach\"]" + dimensionWidth + "},"));
|
||||
write(pack, "regions/region.json", """
|
||||
@@ -692,6 +1011,10 @@ public class PackHydrologyValidatorTest {
|
||||
return pack;
|
||||
}
|
||||
|
||||
private static final class NamedZones {
|
||||
private Map<String, IrisHydrologyWetness> zones;
|
||||
}
|
||||
|
||||
private PackHydrologyValidator.Validation validate(File pack) {
|
||||
File[] dimensions = new File(pack, "dimensions").listFiles(
|
||||
file -> file.isFile() && file.getName().endsWith(".json"));
|
||||
@@ -718,6 +1041,15 @@ public class PackHydrologyValidatorTest {
|
||||
return pack;
|
||||
}
|
||||
|
||||
private List<String> unknownKeyWarnings(PackHydrologyValidator.Validation validation) {
|
||||
assertEquals(List.of(), validation.errors());
|
||||
return keyWarnings(validation);
|
||||
}
|
||||
|
||||
private List<String> keyWarnings(PackHydrologyValidator.Validation validation) {
|
||||
return validation.warnings().stream().filter(warning -> warning.contains("not a known key")).toList();
|
||||
}
|
||||
|
||||
private void assertContains(List<String> messages, String fragment) {
|
||||
for (String message : messages) {
|
||||
if (message.contains(fragment)) {
|
||||
|
||||
@@ -251,6 +251,38 @@ public class PackValidatorStructureGraphTest {
|
||||
assertTrue(errors.toString(), errors.stream().anyMatch(message -> message.contains("duplicates an anonymous placement grid")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowWaterMustBeABoolean() throws Exception {
|
||||
File pack = temporaryFolder.newFolder("invalid-allow-water");
|
||||
write(pack, "dimensions/main.json", "{\"structures\":[{"
|
||||
+ "\"nativeStructures\":[{\"structure\":\"minecraft:ancient_city\"}],"
|
||||
+ "\"allowWater\":\"yes\"}]}");
|
||||
|
||||
List<String> errors = PackObjectSurfaceValidator.validateStructureGraph(pack);
|
||||
|
||||
assertTrue(errors.toString(), errors.stream().anyMatch(message -> message.contains("allowWater must be a boolean")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowWaterSeparatesAnonymousGridsOnlyWhenTrue() throws Exception {
|
||||
File separate = temporaryFolder.newFolder("allow-water-grid");
|
||||
write(separate, "dimensions/main.json", "{\"structures\":[{"
|
||||
+ "\"nativeStructures\":[{\"structure\":\"minecraft:ancient_city\"}]}]}");
|
||||
write(separate, "regions/river.json", "{\"structures\":[{\"allowWater\":true,"
|
||||
+ "\"nativeStructures\":[{\"structure\":\"minecraft:ancient_city\"}]}]}");
|
||||
File duplicate = temporaryFolder.newFolder("allow-water-false-grid");
|
||||
write(duplicate, "dimensions/main.json", "{\"structures\":[{"
|
||||
+ "\"nativeStructures\":[{\"structure\":\"minecraft:ancient_city\"}]}]}");
|
||||
write(duplicate, "regions/river.json", "{\"structures\":[{\"allowWater\":false,"
|
||||
+ "\"nativeStructures\":[{\"structure\":\"minecraft:ancient_city\"}]}]}");
|
||||
|
||||
List<String> separateErrors = PackObjectSurfaceValidator.validateStructureGraph(separate);
|
||||
List<String> duplicateErrors = PackObjectSurfaceValidator.validateStructureGraph(duplicate);
|
||||
|
||||
assertTrue(separateErrors.toString(), separateErrors.stream().noneMatch(message -> message.contains("duplicates an anonymous placement grid")));
|
||||
assertTrue(duplicateErrors.toString(), duplicateErrors.stream().anyMatch(message -> message.contains("duplicates an anonymous placement grid")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsDuplicateEditableStructureKeysIgnoringCase() throws Exception {
|
||||
File pack = temporaryFolder.newFolder("duplicate-editable-key");
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
|
||||
@ClassRule
|
||||
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
|
||||
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "86ef7692e01b99a240bb4a4d86186eab1aaec81b98e7e87859fd61f8ced972a8";
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "89641e077a85bec8a27681f2ce6166150cc37277bc6f58793081b669432782f2";
|
||||
|
||||
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
|
||||
IrisDimension.class,
|
||||
|
||||
+1
-1
@@ -198,7 +198,7 @@ public class NativeStructurePlacementPlannerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void riverInTheStartChunkLeavesTheDecisionToThePieces() {
|
||||
public void waterAroundAStartColumnAboveItsHeadLeavesTheDecisionToThePieces() {
|
||||
Engine engine = engine(77L, -64, 384, 150);
|
||||
Map<Long, WaterRole> roles = new HashMap<>();
|
||||
waterComplex(engine, roles, false);
|
||||
|
||||
-2
@@ -88,7 +88,6 @@ public class IrisObjectPlacementToPlacementTest {
|
||||
source.setAllowedCollisions(allowedCollisions);
|
||||
source.setForbiddenCollisions(forbiddenCollisions);
|
||||
source.setForcePlace(true);
|
||||
source.setForcedByStructure(true);
|
||||
|
||||
IrisObjectPlacement copy = source.toPlacement("objects/replaced");
|
||||
|
||||
@@ -133,6 +132,5 @@ public class IrisObjectPlacementToPlacementTest {
|
||||
assertSame(allowedCollisions, copy.getAllowedCollisions());
|
||||
assertSame(forbiddenCollisions, copy.getForbiddenCollisions());
|
||||
assertTrue(copy.isForcePlace());
|
||||
assertTrue(copy.isForcedByStructure());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package art.arcane.iris.structure.object;
|
||||
|
||||
import art.arcane.iris.generation.block.TileData;
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||
import art.arcane.iris.generation.mantle.ObjectContinuationBundle;
|
||||
import art.arcane.iris.integration.Identifier;
|
||||
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
||||
@@ -32,6 +35,7 @@ import art.arcane.volmlib.util.matter.Matter;
|
||||
import art.arcane.volmlib.util.matter.IrisMatter;
|
||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||
import art.arcane.volmlib.util.matter.MatterSlice;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
@@ -50,6 +54,7 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -206,6 +211,56 @@ public class IrisStaticObjectLayerTest {
|
||||
verify(tiles).set(15, 0, 15, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void staticObjectOverPlannedRiverOrPondWaterWritesEveryBlock() {
|
||||
for (WaterRole role : List.of(WaterRole.CHANNEL, WaterRole.POND)) {
|
||||
IrisObject object = object("through-water", 3, 3, 1);
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
object.getBlocks().put(new IrisBlockVector(x, y, 0), state("minecraft:stone"));
|
||||
}
|
||||
}
|
||||
IrisStaticObjectLayer layer = compile(entry("through-water", 8, 0, 8));
|
||||
Engine engine = mock(Engine.class);
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
||||
ChunkWaterRaster raster = mock(ChunkWaterRaster.class);
|
||||
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
|
||||
ProceduralStream<Double> heads = mock(ProceduralStream.class);
|
||||
ProceduralStream<Integer> floors = mock(ProceduralStream.class);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
when(complex.getHydrologyRuntime()).thenReturn(runtime);
|
||||
when(complex.getWaterRoleStream()).thenReturn(roles);
|
||||
when(complex.getWaterHeadStream()).thenReturn(heads);
|
||||
when(complex.getRoundedHeighteightStream()).thenReturn(floors);
|
||||
when(runtime.enabled()).thenReturn(true);
|
||||
when(runtime.raster(anyInt(), anyInt())).thenReturn(raster);
|
||||
when(raster.role(anyInt(), anyInt())).thenReturn(role);
|
||||
when(raster.waterHead(anyInt(), anyInt())).thenReturn(70);
|
||||
when(raster.terrainHeight(anyInt(), anyInt())).thenReturn(60);
|
||||
when(roles.get(anyDouble(), anyDouble())).thenReturn(role);
|
||||
when(heads.getDouble(anyDouble(), anyDouble())).thenReturn(70D);
|
||||
when(floors.get(anyDouble(), anyDouble())).thenReturn(60);
|
||||
EngineMantle engineMantle = mock(EngineMantle.class);
|
||||
Mantle<Matter> mantle = mock(Mantle.class);
|
||||
MantleChunk<Matter> chunk = mock(MantleChunk.class);
|
||||
when(engine.getMantle()).thenReturn(engineMantle);
|
||||
when(engineMantle.getMantle()).thenReturn(mantle);
|
||||
when(mantle.useChunk(anyInt(), anyInt())).thenReturn(chunk);
|
||||
when(chunk.getOrCreate(anyInt())).thenReturn(mock(Matter.class));
|
||||
Hunk<NativeBlockState> output = Hunk.newArrayHunk(16, 384, 16);
|
||||
|
||||
layer.apply(engine, 0, 0, output);
|
||||
|
||||
for (int x = 7; x <= 9; x++) {
|
||||
for (int y = 63; y <= 65; y++) {
|
||||
assertSame(role + " " + x + "," + y, state("minecraft:stone"), output.get(x, y, 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transitionRejectsWholeRotatedPlacementBeforeChunkWrites() {
|
||||
IrisObject object = object("rotated", 1, 1, 5);
|
||||
|
||||
+12
-1
@@ -131,7 +131,7 @@ public class PlacementModuleSurfaceSupportTest {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
world.column(1, 0, WaterRole.CHANNEL, 8, 12);
|
||||
|
||||
for (IrisObjectPlacement placement : List.of(underwater(), onwater(), forced())) {
|
||||
for (IrisObjectPlacement placement : List.of(underwater(), onwater())) {
|
||||
HydrologyWaterFixture.Placer placer = world.placer();
|
||||
|
||||
assertEquals(-1, place(HydrologyWaterFixture.raft(), placer, placement));
|
||||
@@ -139,6 +139,17 @@ public class PlacementModuleSurfaceSupportTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forcedObjectsPlaceOnWaterAtAnotherHeadAndOnDams() {
|
||||
world.water(WaterRole.CHANNEL, 9, 13);
|
||||
world.column(1, 0, WaterRole.CHANNEL, 8, 12);
|
||||
world.column(0, 1, WaterRole.DAM, 8, 12);
|
||||
HydrologyWaterFixture.Placer placer = world.placer();
|
||||
|
||||
assertTrue(place(HydrologyWaterFixture.raft(), placer, forced()) >= 0);
|
||||
assertFalse(placer.writes().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void waterObjectsNeverPlaceOnProvisionalHydrology() {
|
||||
world.water(WaterRole.POND, 7, 13);
|
||||
|
||||
+165
@@ -47,6 +47,7 @@ import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -54,6 +55,7 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
@@ -500,6 +502,169 @@ public class IrisStructureLocatorContractTest {
|
||||
assertNotNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forcedSinglePiecesPlaceInTheMiddleOfARiver() {
|
||||
Engine engine = submergedEngine(WaterRole.CHANNEL, false, -2032, 2032);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
|
||||
|
||||
assertNull("an unforced structure stays off a submerged start",
|
||||
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
placement.setUnderwater(true);
|
||||
assertNull("an unforced structure keeps the 10% limit",
|
||||
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
placement.setUnderwater(false);
|
||||
|
||||
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||
|
||||
assertNotNull("a forced piece places on a river column and over a river footprint",
|
||||
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forcedSurfacePiecesPlaceOnOpenSea() {
|
||||
Engine engine = submergedEngine(WaterRole.NONE, false, -2032, 2032);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
|
||||
assertFalse(placement.isUnderwater());
|
||||
|
||||
assertNull("an unforced structure stays off the sea",
|
||||
IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
|
||||
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||
|
||||
assertNotNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unforcedMultiPieceStartsStayOffSeaColumns() {
|
||||
Engine engine = submergedEngine(WaterRole.NONE, false, -2032, 2032);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
|
||||
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||
registerTwoPieceGraph(engine.getData(), structure, "test:density");
|
||||
|
||||
placement.setUnderwater(true);
|
||||
IrisStructureLocator.ResolvedPlacement allowed = IrisStructureLocator.resolvePlacement(engine, placement, 3, 4);
|
||||
assertNotNull(allowed);
|
||||
assertEquals(2, allowed.pieces().size());
|
||||
placement.setUnderwater(false);
|
||||
|
||||
assertNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void undergroundPiecesKeepTheSubmergedCheck() {
|
||||
for (ObjectPlaceMode mode : List.of(ObjectPlaceMode.ORGANIC_STILT, ObjectPlaceMode.CEILING_HANG)) {
|
||||
Engine engine = submergedEngine(WaterRole.CHANNEL, true, -40, -20);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
|
||||
structure.setPlaceMode(mode);
|
||||
|
||||
assertFalse(placement.forcesPieces(structure, 1));
|
||||
assertNull(mode.name(), IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anUnforcedStructureNeverAssemblesOnASubmergedStart() {
|
||||
Engine engine = submergedEngine(WaterRole.NONE, false, -2032, 2032);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
|
||||
structure.setStartPool("test:missing-pool");
|
||||
|
||||
assertNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aForcedModeStructureWithABrokenGraphThrowsOnASubmergedStart() {
|
||||
Engine engine = submergedEngine(WaterRole.NONE, false, -2032, 2032);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
|
||||
structure.setPlaceMode(ObjectPlaceMode.CENTER_HEIGHT);
|
||||
structure.setStartPool("test:missing-pool");
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aMissingStructureOnASubmergedStartReturnsNull() {
|
||||
Engine engine = submergedEngine(WaterRole.NONE, false, -2032, 2032);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
placement.getStructures().clear();
|
||||
placement.getStructures().add("test:missing-structure");
|
||||
|
||||
assertNull(IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void brokenReferencesOnADryStartStillThrow() {
|
||||
Engine engine = submergedEngine(WaterRole.NONE, false, -2032, 2032);
|
||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(180);
|
||||
IrisStructurePlacement placement = engine.getDimension().getStructures().get(0);
|
||||
IrisStructure structure = engine.getData().load(IrisStructure.class, "test:density", false);
|
||||
structure.setStartPool("test:missing-pool");
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
|
||||
placement.getStructures().clear();
|
||||
placement.getStructures().add("test:missing-structure");
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> IrisStructureLocator.resolvePlacement(engine, placement, 3, 4));
|
||||
}
|
||||
|
||||
private Engine submergedEngine(WaterRole role, boolean underground, int placementMin, int placementMax) {
|
||||
Engine engine = densityEngine(1.0, underground, -64, 384, placementMin, placementMax);
|
||||
IrisObject object = engine.getData().load(IrisObject.class, "test:density/object", false);
|
||||
when(object.getW()).thenReturn(10);
|
||||
when(object.getD()).thenReturn(10);
|
||||
IrisComplex complex = mock(IrisComplex.class);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
when(complex.allowsNewGenerationFootprint(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<Double> waterHead = mock(ProceduralStream.class);
|
||||
when(complex.getWaterHeadStream()).thenReturn(waterHead);
|
||||
when(waterHead.get(anyDouble(), anyDouble())).thenReturn(124D);
|
||||
when(waterHead.getDouble(anyDouble(), anyDouble())).thenReturn(124D);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
|
||||
when(complex.getWaterRoleStream()).thenReturn(roles);
|
||||
when(roles.get(anyDouble(), anyDouble())).thenReturn(role);
|
||||
@SuppressWarnings("unchecked")
|
||||
ProceduralStream<Integer> beds = mock(ProceduralStream.class);
|
||||
when(beds.get(anyDouble(), anyDouble())).thenReturn(120);
|
||||
when(complex.getRoundedHeighteightStream()).thenReturn(beds);
|
||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(120);
|
||||
when(engine.getDimension().getFluidHeight()).thenReturn(63);
|
||||
return engine;
|
||||
}
|
||||
|
||||
private void registerTwoPieceGraph(IrisData data, IrisStructure structure, String prefix) {
|
||||
registerSinglePieceGraph(data, structure, prefix);
|
||||
String targetPool = prefix + "/target";
|
||||
String targetPiece = prefix + "/target-piece";
|
||||
IrisJigsawPiece start = data.load(IrisJigsawPiece.class, prefix + "/piece", false);
|
||||
start.setRotatable(false);
|
||||
start.getConnectors().add(new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(0, 0, 0))
|
||||
.setDirection(IrisDirection.EAST_POSITIVE_X)
|
||||
.setPool(targetPool)
|
||||
.setName("source")
|
||||
.setTargetName("door"));
|
||||
IrisJigsawPiece target = new IrisJigsawPiece().setObject(prefix + "/object").setRotatable(false);
|
||||
target.getConnectors().add(new IrisJigsawConnector()
|
||||
.setPosition(new IrisPosition(0, 0, 0))
|
||||
.setDirection(IrisDirection.WEST_NEGATIVE_X)
|
||||
.setPool(targetPool)
|
||||
.setName("door")
|
||||
.setTargetName("unused"));
|
||||
IrisJigsawPool pool = new IrisJigsawPool();
|
||||
pool.getPieces().add(new IrisJigsawPieceEntry(targetPiece, 1));
|
||||
when(data.load(IrisJigsawPool.class, targetPool, false)).thenReturn(pool);
|
||||
when(data.load(IrisJigsawPiece.class, targetPiece, false)).thenReturn(target);
|
||||
structure.setMaxDepth(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void undergroundIrisStructuresIgnoreRiversAbove() {
|
||||
Engine engine = densityEngine(1.0, true, -64, 384, -40, -20);
|
||||
|
||||
@@ -80,8 +80,8 @@ public class IrisRiverSchemaTest {
|
||||
assertTrue(section, properties.getJSONObject(section).has("$ref"));
|
||||
}
|
||||
assertEquals("array", tier.getJSONObject("halfWidth").getString("type"));
|
||||
assertEquals(2, tier.getJSONObject("waterfallMinimumDrop").getInt("minimum"));
|
||||
assertEquals(64, tier.getJSONObject("waterfallMinimumDrop").getInt("maximum"));
|
||||
assertEquals(2, tier.getJSONObject("waterfallMinDrop").getInt("minimum"));
|
||||
assertEquals(64, tier.getJSONObject("waterfallMinDrop").getInt("maximum"));
|
||||
assertEquals(64, tier.getJSONObject("bankBand").getInt("maximum"));
|
||||
assertEquals(0.05D, tier.getJSONObject("depthRatio").getDouble("minimum"), 0D);
|
||||
assertEquals(List.of("SMOOTH", "LINEAR", "CONCAVE", "TERRACED", "CLIFF"),
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class DeltaCoast {
|
||||
IrisHydrology config = config(channels);
|
||||
for (IrisHydrologyTier tier : config.getTiers()) {
|
||||
tier.setCascades(false);
|
||||
tier.setWaterfallMinimumDrop(2);
|
||||
tier.setWaterfallMinDrop(2);
|
||||
}
|
||||
return HydrologySettings.compile(config, SEED, SEA_LEVEL, MIN_Y, MAX_Y);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public final class WaterScene {
|
||||
halfWidth[point] = tier.minHalfWidth();
|
||||
depth[point] = tier.depth(tier.minHalfWidth());
|
||||
int drop = point == 0 ? 0 : grades[point - 1] - grades[point];
|
||||
style[point] = drop >= tier.waterfallMinimumDrop() ? ReachStyle.WATERFALL
|
||||
style[point] = drop >= tier.waterfallMinDrop() ? ReachStyle.WATERFALL
|
||||
: drop >= 2 ? ReachStyle.CASCADE : drop == 1 ? ReachStyle.RIFFLE : ReachStyle.RUN;
|
||||
}
|
||||
return new Reach(id, tier, 0L, xs, zs, grades, halfWidth, depth, style, 1000f);
|
||||
|
||||
Reference in new issue
Block a user