mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Inherit parent biome policy
- IrisHydrologyPolicy.inherited walks the column's biome lineage (child, then the parents it grew inside), then region, then dimension - IrisComplex.baseBiomeLineage recovers the per-column child chain from the implosion and fails closed if it disagrees with the base biome - BiomeLineages limits chain recovery to biomes a policy-bearing biome can implode into and interns lineages for identity caches - Terrain source, shore biomes and water decorators resolve by lineage; cave pools keep the cave biome alone - Datapack river areas enumerate each region's child chains and RiverLimits attributes inherited values to the parent - Policy description names the parent step; schema digest recaptured
This commit is contained in:
1 parent
95fa3ce105
commit
ff0a95a6fd
18 files changed
+460
-140
No files matched your search
@@ -108,11 +108,17 @@ final class EngineFixture implements AutoCloseable {
|
||||
+ ",\"seed\":" + Math.abs(key.hashCode()) + ",\"composite\":" + composite.strip() + "}");
|
||||
}
|
||||
|
||||
private static void biome(Path pack, String key, String generators, String extra) throws IOException {
|
||||
static void biome(Path pack, String key, String generators, String extra) throws IOException {
|
||||
Files.writeString(pack.resolve("biomes/" + key + ".json"), "{\"layers\":[{\"palette\":[{\"block\":\"minecraft:stone\"}]}],\"generators\":"
|
||||
+ generators + extra.strip() + "}");
|
||||
}
|
||||
|
||||
static void extend(Path pack, String key, String extra) throws IOException {
|
||||
Path file = pack.resolve("biomes/" + key + ".json");
|
||||
String json = Files.readString(file).strip();
|
||||
Files.writeString(file, json.substring(0, json.length() - 1) + extra.strip() + "}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
complex.close();
|
||||
|
||||
+69
@@ -3,6 +3,8 @@ package art.arcane.iris.generation.hydrology.engine;
|
||||
import art.arcane.iris.generation.bake.BakePlane;
|
||||
import art.arcane.iris.generation.bake.ChunkBakeCache;
|
||||
import art.arcane.iris.generation.bake.GeneratorEvaluations;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisFluidProfile;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||
import art.arcane.iris.generation.hydrology.grid.HeightLattice;
|
||||
@@ -10,6 +12,7 @@ import art.arcane.iris.generation.hydrology.grid.HydrologySampleBuffer;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.stream.ChunkFillableDoubleStream2D;
|
||||
import art.arcane.iris.generation.terrain.InferredType;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.testsupport.PlatformLeakGuard;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
@@ -175,6 +178,72 @@ public class IrisHydrologyTerrainSourceTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void childBiomesInheritTheParentPolicy() throws Exception {
|
||||
Path pack = EngineFixture.pack(temporaryFolder.newFolder().toPath(), false);
|
||||
EngineFixture.extend(pack, "peaks", ",\"hydrologyPolicy\":{\"pondDensity\":5,\"streams\":\"ALLOW\",\"fluid\":\"lava\"}");
|
||||
EngineFixture.extend(pack, "meadow", ",\"children\":[\"glade\"],\"childShrinkFactor\":2.5");
|
||||
EngineFixture.biome(pack, "glade", "[{\"generator\":\"plain\",\"min\":4,\"max\":10}]", "");
|
||||
int side = 96;
|
||||
int[] xs = new int[side * side];
|
||||
int[] zs = new int[side * side];
|
||||
for (int index = 0; index < xs.length; index++) {
|
||||
xs[index] = (index % side) * 9 - 432;
|
||||
zs[index] = (index / side) * 9 - 432;
|
||||
}
|
||||
pool = Executors.newFixedThreadPool(4);
|
||||
try (EngineFixture.Environment ignored = EngineFixture.environment(); EngineFixture fixture = new EngineFixture(pack)) {
|
||||
IrisHydrology config = new IrisHydrology().setEnabled(true).setPersist(false);
|
||||
config.getFluids().add(new IrisFluidProfile().setName("lava").setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:lava")));
|
||||
HydrologySettings settings = HydrologySettings.compile(config, EngineFixture.SEED, fixture.dimension.getFluidHeight(), 0,
|
||||
EngineFixture.HEIGHT);
|
||||
IrisHydrologyTerrainSource source = new IrisHydrologyTerrainSource(fixture.complex, fixture.dimension, settings, null, 1,
|
||||
HydrologyBinding.UNBOUND);
|
||||
HydrologySampleBuffer samples = new HydrologySampleBuffer(xs.length);
|
||||
source.sample(xs, zs, samples, false);
|
||||
HydrologySampleBuffer pooled = new HydrologySampleBuffer(xs.length);
|
||||
new IrisHydrologyTerrainSource(fixture.complex, fixture.dimension, settings, pool, 4, HydrologyBinding.UNBOUND).sample(xs, zs, pooled, false);
|
||||
assertSameSamples(samples, pooled, xs.length);
|
||||
Map<String, Integer> chains = new HashMap<>();
|
||||
for (int index = 0; index < xs.length; index++) {
|
||||
int x = xs[index];
|
||||
int z = zs[index];
|
||||
String chain = chain(fixture, x, z);
|
||||
boolean alpha = fixture.complex.getRegionStream().get(x, z).getLoadKey().equals("alpha");
|
||||
boolean peaks = chain.contains("peaks");
|
||||
boolean meadow = chain.contains("meadow");
|
||||
String at = chain + "@" + (alpha ? "alpha" : "beta") + " " + x + "," + z;
|
||||
chains.merge(chain + "@" + (alpha ? "alpha" : "beta"), 1, Integer::sum);
|
||||
assertEquals(at, meadow ? 2f : 0.5f, samples.rainfall()[index], 0f);
|
||||
assertEquals(at, peaks ? 5f : alpha ? 3f : 1f, samples.pondDensity()[index], 0f);
|
||||
int permission = (peaks || !alpha ? HydrologySampleBuffer.ALLOW_STREAMS : 0) | (meadow ? 0 : HydrologySampleBuffer.ALLOW_PONDS);
|
||||
assertEquals(at, permission, samples.permission()[index]);
|
||||
String fluid = peaks ? "lava" : alpha ? "water" : null;
|
||||
assertEquals(at, fluid, samples.fluidProfile()[index]);
|
||||
assertEquals(at, fluid, source.channelFluid(x, z));
|
||||
}
|
||||
assertTrue("sampled chains " + chains, chains.containsKey("meadow<peaks@alpha") && chains.containsKey("glade<meadow<peaks@alpha")
|
||||
&& chains.containsKey("meadow@alpha") && chains.containsKey("meadow@beta") && chains.containsKey("glade<meadow@beta")
|
||||
&& chains.containsKey("peaks@alpha"));
|
||||
}
|
||||
}
|
||||
|
||||
private static String chain(EngineFixture fixture, int x, int z) {
|
||||
IrisBiome leaf = fixture.complex.getBaseBiomeStream().get(x, z);
|
||||
boolean sea = fixture.complex.getBridgeStream().get(x, z) == InferredType.SEA;
|
||||
IrisBiome root = (sea ? fixture.complex.getSeaBiomeStream() : fixture.complex.getLandBiomeStream()).get(x, z);
|
||||
String pair = root.getLoadKey() + ">" + leaf.getLoadKey();
|
||||
return switch (pair) {
|
||||
case "peaks>meadow" -> "meadow<peaks";
|
||||
case "peaks>glade" -> "glade<meadow<peaks";
|
||||
case "meadow>glade" -> "glade<meadow";
|
||||
default -> {
|
||||
assertEquals("a biome outside the child chains at " + x + "," + z, root.getLoadKey(), leaf.getLoadKey());
|
||||
yield leaf.getLoadKey();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void assertUnknownFluidRejected(EngineFixture fixture, HydrologySettings settings, int[] xs, int[] zs) {
|
||||
IrisRegion beta = fixture.data.getRegionLoader().load("beta");
|
||||
beta.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("slime"));
|
||||
|
||||
@@ -256,6 +256,18 @@ public class MantleCarvedTerrainTest {
|
||||
poolFluids(poolRoom(new Underground(plains, biome("carving/deep-magma", 24, "lava"), temperate, new IrisDimension())).generate(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void caveBiomesTakeNoFluidFromBiomesThatListThemAsChildren() {
|
||||
IrisBiome volcanic = biome("tropical/volcanic-plains", 0, "lava").setChildren(new KList<>("carving/hollow"));
|
||||
IrisBiome magma = biome("carving/magma", 0, "lava").setChildren(new KList<>("carving/hollow"));
|
||||
IrisBiome hollow = biome("carving/hollow", 0, null);
|
||||
|
||||
assertEquals("a cave biome under a surface parent that names lava", Set.of("water"),
|
||||
poolFluids(poolRoom(new Underground(volcanic, hollow, region("temperate", null), new IrisDimension())).generate(0)));
|
||||
assertEquals("the parent itself still fills its own pools", Set.of("lava"),
|
||||
poolFluids(poolRoom(new Underground(volcanic, magma, region("temperate", null), new IrisDimension())).generate(0)));
|
||||
}
|
||||
|
||||
private static Scene poolRoom(Underground underground) {
|
||||
Scene scene = new Scene(underground);
|
||||
Matter[] room = scene.chunk(0, 0);
|
||||
|
||||
+19
-15
@@ -75,23 +75,26 @@ public class HydrologyVegetationSourceTest {
|
||||
HydrologyVegetationSource source = HydrologyVegetationSource.create(dimension, settings, data, List.of(plain, marsh),
|
||||
List.of(meadow, bog, desert));
|
||||
|
||||
assertEquals("minecraft:fern", grown(source.decorators(river, meadow, plain)));
|
||||
assertEquals("minecraft:air", grown(source.decorators(stream, meadow, plain)));
|
||||
assertEquals("minecraft:short_grass", grown(source.decorators(null, meadow, plain)));
|
||||
assertEquals("minecraft:poppy", grown(source.decorators(river, meadow, marsh)));
|
||||
assertEquals("minecraft:poppy", grown(source.decorators(null, meadow, marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(source.decorators(river, bog, marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(source.decorators(null, bog, plain)));
|
||||
assertSame(HydrologyVegetation.Decorators.EMPTY, source.decorators(river, desert, marsh));
|
||||
assertEquals("minecraft:fern", grown(source.decorators(river, List.of(meadow), plain)));
|
||||
assertEquals("minecraft:air", grown(source.decorators(stream, List.of(meadow), plain)));
|
||||
assertEquals("minecraft:short_grass", grown(source.decorators(null, List.of(meadow), plain)));
|
||||
assertEquals("minecraft:poppy", grown(source.decorators(river, List.of(meadow), marsh)));
|
||||
assertEquals("minecraft:poppy", grown(source.decorators(null, List.of(meadow), marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(source.decorators(river, List.of(bog), marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(source.decorators(null, List.of(bog), plain)));
|
||||
assertSame(HydrologyVegetation.Decorators.EMPTY, source.decorators(river, List.of(desert), marsh));
|
||||
assertEquals("a child biome takes its parent's list", "minecraft:dandelion", grown(source.decorators(river, List.of(meadow, bog), plain)));
|
||||
assertSame("a child's own empty list wins over its parent", HydrologyVegetation.Decorators.EMPTY,
|
||||
source.decorators(river, List.of(desert, bog), plain));
|
||||
|
||||
dimension.setHydrologyPolicy(policy(shore("minecraft:dead_bush")));
|
||||
HydrologyVegetationSource dimensional = HydrologyVegetationSource.create(dimension, settings, data, List.of(plain, marsh),
|
||||
List.of(meadow, bog, desert));
|
||||
assertEquals("minecraft:dead_bush", grown(dimensional.decorators(river, meadow, plain)));
|
||||
assertEquals("minecraft:dead_bush", grown(dimensional.decorators(null, meadow, plain)));
|
||||
assertEquals("minecraft:poppy", grown(dimensional.decorators(river, meadow, marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(dimensional.decorators(river, bog, marsh)));
|
||||
assertSame(HydrologyVegetation.Decorators.EMPTY, HydrologyVegetationSource.NONE.decorators(river, bog, marsh));
|
||||
assertEquals("minecraft:dead_bush", grown(dimensional.decorators(river, List.of(meadow), plain)));
|
||||
assertEquals("minecraft:dead_bush", grown(dimensional.decorators(null, List.of(meadow), plain)));
|
||||
assertEquals("minecraft:poppy", grown(dimensional.decorators(river, List.of(meadow), marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(dimensional.decorators(river, List.of(bog), marsh)));
|
||||
assertSame(HydrologyVegetation.Decorators.EMPTY, HydrologyVegetationSource.NONE.decorators(river, List.of(bog), marsh));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -140,6 +143,7 @@ public class HydrologyVegetationSourceTest {
|
||||
HydrologyVegetationSource source = HydrologyVegetationSource.create(new IrisDimension(), settings, data, List.of(plain), List.of());
|
||||
IrisBiome unseen = new IrisBiome();
|
||||
unseen.setHydrologyPolicy(policy(shore("minecraft:dandelion")));
|
||||
List<IrisBiome> lineage = List.of(unseen);
|
||||
int threads = 8;
|
||||
CyclicBarrier start = new CyclicBarrier(threads);
|
||||
ExecutorService pool = Executors.newFixedThreadPool(threads);
|
||||
@@ -148,7 +152,7 @@ public class HydrologyVegetationSourceTest {
|
||||
for (int thread = 0; thread < threads; thread++) {
|
||||
results.add(pool.submit(() -> {
|
||||
start.await();
|
||||
return source.decorators(settings.tiers().get(1), unseen, plain);
|
||||
return source.decorators(settings.tiers().get(1), lineage, plain);
|
||||
}));
|
||||
}
|
||||
HydrologyVegetation.Decorators first = results.get(0).get(30, TimeUnit.SECONDS);
|
||||
@@ -156,7 +160,7 @@ public class HydrologyVegetationSourceTest {
|
||||
assertSame(first, result.get(30, TimeUnit.SECONDS));
|
||||
}
|
||||
assertEquals("minecraft:dandelion", grown(first));
|
||||
assertSame(first, source.decorators(null, unseen, plain));
|
||||
assertSame(first, source.decorators(null, lineage, plain));
|
||||
} finally {
|
||||
pool.shutdownNow();
|
||||
}
|
||||
|
||||
+25
-9
@@ -27,6 +27,7 @@ import org.junit.rules.TemporaryFolder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -135,14 +136,24 @@ public class IrisComplexSurfaceBiomeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shorePolicyInheritsBiomeThenRegionThenDimension() {
|
||||
public void shorePolicyInheritsBiomeThenParentsThenRegionThenDimension() {
|
||||
ShorePolicyPack pack = new ShorePolicyPack();
|
||||
assertEquals("dune", shoreSelect(pack, 1).getLoadKey());
|
||||
pack.region.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("sand")));
|
||||
assertEquals("sand", shoreSelect(pack, 4).getLoadKey());
|
||||
assertNull(shoreSelect(pack, 5));
|
||||
pack.inland.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("gravel")).setShoreBiomeWidth(8));
|
||||
assertEquals("gravel", shoreSelect(pack, 8).getLoadKey());
|
||||
IrisBiome parent = pack.biome("highland");
|
||||
parent.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("gravel")).setShoreBiomeWidth(6));
|
||||
IrisBiome grandparent = pack.biome("upland");
|
||||
grandparent.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("dune")).setShoreBiomeWidth(8));
|
||||
List<IrisBiome> child = List.of(pack.inland, parent, grandparent);
|
||||
assertEquals("gravel", shoreSelect(pack, child, 6).getLoadKey());
|
||||
assertNull(shoreSelect(pack, child, 7));
|
||||
parent.getHydrologyPolicy().setShoreBiomeWidth(null);
|
||||
assertEquals("gravel", shoreSelect(pack, child, 8).getLoadKey());
|
||||
pack.inland.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("sand")).setShoreBiomeWidth(8));
|
||||
assertEquals("sand", shoreSelect(pack, 8).getLoadKey());
|
||||
assertEquals("sand", shoreSelect(pack, child, 8).getLoadKey());
|
||||
assertSame(InferredType.SHORE, shoreSelect(pack, 8).getInferredType());
|
||||
}
|
||||
|
||||
@@ -152,8 +163,8 @@ public class IrisComplexSurfaceBiomeTest {
|
||||
pack.region.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>()));
|
||||
assertNull(shoreSelect(pack, 1));
|
||||
pack.region.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomeWidth(0));
|
||||
assertNull(new HydrologyShoreBiomes(pack.dimension, pack.data, 7L).select(pack.inland, pack.region, 0, 0, 1));
|
||||
assertNull(new HydrologyShoreBiomes(new IrisDimension(), pack.data, 7L).select(pack.inland, new IrisRegion(), 0, 0, 1));
|
||||
assertNull(new HydrologyShoreBiomes(pack.dimension, pack.data, 7L).select(List.of(pack.inland), pack.region, 0, 0, 1));
|
||||
assertNull(new HydrologyShoreBiomes(new IrisDimension(), pack.data, 7L).select(List.of(pack.inland), new IrisRegion(), 0, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,11 +173,12 @@ public class IrisComplexSurfaceBiomeTest {
|
||||
pack.region.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("sand", "dune", "gravel")));
|
||||
HydrologyShoreBiomes shores = new HydrologyShoreBiomes(pack.dimension, pack.data, 7L);
|
||||
HydrologyShoreBiomes again = new HydrologyShoreBiomes(pack.dimension, pack.data, 7L);
|
||||
List<IrisBiome> inland = List.of(pack.inland);
|
||||
Set<String> picked = new HashSet<>();
|
||||
for (int patch = -8; patch < 8; patch++) {
|
||||
IrisBiome first = shores.select(pack.inland, pack.region, patch * 64, 0, 2);
|
||||
assertEquals(first.getLoadKey(), shores.select(pack.inland, pack.region, patch * 64 + 63, 63, 2).getLoadKey());
|
||||
assertEquals(first.getLoadKey(), again.select(pack.inland, pack.region, patch * 64 + 17, 40, 1).getLoadKey());
|
||||
IrisBiome first = shores.select(inland, pack.region, patch * 64, 0, 2);
|
||||
assertEquals(first.getLoadKey(), shores.select(inland, pack.region, patch * 64 + 63, 63, 2).getLoadKey());
|
||||
assertEquals(first.getLoadKey(), again.select(inland, pack.region, patch * 64 + 17, 40, 1).getLoadKey());
|
||||
picked.add(first.getLoadKey());
|
||||
}
|
||||
assertTrue(picked.toString(), picked.size() > 1);
|
||||
@@ -181,7 +193,11 @@ public class IrisComplexSurfaceBiomeTest {
|
||||
}
|
||||
|
||||
private static IrisBiome shoreSelect(ShorePolicyPack pack, int distance) {
|
||||
return new HydrologyShoreBiomes(pack.dimension, pack.data, 7L).select(pack.inland, pack.region, 10, 20, distance);
|
||||
return shoreSelect(pack, List.of(pack.inland), distance);
|
||||
}
|
||||
|
||||
private static IrisBiome shoreSelect(ShorePolicyPack pack, List<IrisBiome> lineage, int distance) {
|
||||
return new HydrologyShoreBiomes(pack.dimension, pack.data, 7L).select(lineage, pack.region, 10, 20, distance);
|
||||
}
|
||||
|
||||
private static final class ShorePolicyPack {
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ import java.lang.reflect.Field;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -101,7 +102,7 @@ public class IrisEngineGenerationRuntimeScopeTest {
|
||||
when(historical.target.getWorld().getHeight()).thenReturn(384);
|
||||
IrisBiome biome = new IrisBiome();
|
||||
IrisRegion region = new IrisRegion();
|
||||
when(historicalComplex.getBaseBiomeStream()).thenReturn(ProceduralStream.of((x, z) -> biome, Interpolated.of(value -> 0D, value -> biome)));
|
||||
when(historicalComplex.baseBiomeLineage(anyInt(), anyInt())).thenReturn(List.of(biome));
|
||||
when(historicalComplex.getRegionStream()).thenReturn(ProceduralStream.of((x, z) -> region, Interpolated.of(value -> 0D, value -> region)));
|
||||
when(historicalComplex.getBridgeStream()).thenReturn(ProceduralStream.of((x, z) -> InferredType.LAND,
|
||||
Interpolated.of(value -> 0D, value -> InferredType.LAND)));
|
||||
|
||||
+37
-20
@@ -187,9 +187,9 @@ public class RiverCompilerTest {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
IrisBiome volcano = biome("tropical/volcanoes", new IrisHydrologyPolicy().setFluid("lava"));
|
||||
List<RiverCompiler.Area> areas = List.of(
|
||||
new RiverCompiler.Area(region("tropical", null), volcano),
|
||||
new RiverCompiler.Area(region("hot", null), volcano),
|
||||
new RiverCompiler.Area(region("hot", null), biome("plains", null)));
|
||||
new RiverCompiler.Area(region("tropical", null), List.of(volcano)),
|
||||
new RiverCompiler.Area(region("hot", null), List.of(volcano)),
|
||||
new RiverCompiler.Area(region("hot", null), List.of(biome("plains", null))));
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), withLava(overworldHydrology()), areas, diagnostics);
|
||||
|
||||
@@ -201,6 +201,23 @@ public class RiverCompilerTest {
|
||||
assertTrue(fluids.getFirst().message(), fluids.getFirst().message().contains("minecraft:water"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void childBiomesInheritTheParentLava() {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
IrisBiome plains = biome("tropical/volcanic-plains", new IrisHydrologyPolicy().setFluid("lava"));
|
||||
IrisBiome cone = biome("tropical/cone", new IrisHydrologyPolicy().setRainfall(1.0));
|
||||
IrisBiome spring = biome("tropical/spring", new IrisHydrologyPolicy().setFluid("water"));
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), withLava(overworldHydrology()), List.of(
|
||||
new RiverCompiler.Area(region("tropical", null), List.of(cone, plains)),
|
||||
new RiverCompiler.Area(region("tropical", null), List.of(spring, plains))), diagnostics);
|
||||
|
||||
List<ExportDiagnostic> fluids = limited(diagnostics, ExportLimit.RIVER_FLUID);
|
||||
assertEquals(diagnostics.toString(), 1, fluids.size());
|
||||
assertEquals("biomes/tropical/volcanic-plains", fluids.getFirst().resource());
|
||||
assertTrue(fluids.getFirst().message(), fluids.getFirst().message().contains("'lava'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lavaTiersReportTheirFluidAndSeamOnTheHydrology() {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
@@ -211,7 +228,7 @@ public class RiverCompilerTest {
|
||||
tier.setFluid("lava");
|
||||
}
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region("region", null), biome("plains", null))), diagnostics);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region("region", null), List.of(biome("plains", null)))), diagnostics);
|
||||
|
||||
List<ExportDiagnostic> fluids = limited(diagnostics, ExportLimit.RIVER_FLUID);
|
||||
assertEquals(diagnostics.toString(), 1, fluids.size());
|
||||
@@ -226,7 +243,7 @@ public class RiverCompilerTest {
|
||||
new IrisFluidProfile().setSeam("mud"),
|
||||
new IrisFluidProfile().setName("mud").setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:mud"))));
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region("region", null), biome("plains", null))), diagnostics);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region("region", null), List.of(biome("plains", null)))), diagnostics);
|
||||
|
||||
List<ExportDiagnostic> fluids = limited(diagnostics, ExportLimit.RIVER_FLUID);
|
||||
assertEquals(diagnostics.toString(), 1, fluids.size());
|
||||
@@ -237,7 +254,7 @@ public class RiverCompilerTest {
|
||||
@Test
|
||||
public void unknownPolicyFluidFailsTheExport() {
|
||||
IrisBiome acid = biome("acid-lake", new IrisHydrologyPolicy().setFluid("acid"));
|
||||
List<RiverCompiler.Area> areas = List.of(new RiverCompiler.Area(region("region", null), acid));
|
||||
List<RiverCompiler.Area> areas = List.of(new RiverCompiler.Area(region("region", null), List.of(acid)));
|
||||
|
||||
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
|
||||
() -> compile(new Field.Const(SEA_LEVEL + 2.0), overworldHydrology(), areas, new ArrayList<>()));
|
||||
@@ -264,7 +281,7 @@ public class RiverCompilerTest {
|
||||
public void fluidsMatchingTheExportedFluidReportNothing() {
|
||||
List<ExportDiagnostic> water = new ArrayList<>();
|
||||
IrisBiome wet = biome("plains", new IrisHydrologyPolicy().setFluid("water"));
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), withLava(overworldHydrology()), List.of(new RiverCompiler.Area(region("region", null), wet)), water);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), withLava(overworldHydrology()), List.of(new RiverCompiler.Area(region("region", null), List.of(wet))), water);
|
||||
|
||||
List<ExportDiagnostic> lava = new ArrayList<>();
|
||||
IrisHydrology molten = withLava(overworldHydrology());
|
||||
@@ -273,7 +290,7 @@ public class RiverCompilerTest {
|
||||
}
|
||||
IrisDimension nether = dimension(molten, new IrisHydrologyPolicy().setFluid("lava"));
|
||||
nether.setFluidPalette(new IrisMaterialPalette().qclear().qadd("lava"));
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), nether, List.of(new RiverCompiler.Area(region("region", null), biome("plains", null))),
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), nether, List.of(new RiverCompiler.Area(region("region", null), List.of(biome("plains", null)))),
|
||||
registry(), DataVersion.V26_3, lava);
|
||||
|
||||
assertTrue(water.toString(), limited(water, ExportLimit.RIVER_FLUID).isEmpty());
|
||||
@@ -288,7 +305,7 @@ public class RiverCompilerTest {
|
||||
IrisBiome neutral = biome("plains", new IrisHydrologyPolicy().setRainfall(1.0));
|
||||
IrisDimension dimension = dimension(overworldHydrology(), new IrisHydrologyPolicy().setRainfall(1.2));
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), dimension, List.of(new RiverCompiler.Area(hot, deep), new RiverCompiler.Area(hot, neutral)),
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), dimension, List.of(new RiverCompiler.Area(hot, List.of(deep)), new RiverCompiler.Area(hot, List.of(neutral))),
|
||||
registry(), DataVersion.V26_3, diagnostics);
|
||||
|
||||
List<ExportDiagnostic> policies = limited(diagnostics, ExportLimit.RIVER_POLICY);
|
||||
@@ -301,11 +318,11 @@ public class RiverCompilerTest {
|
||||
public void wetAndDryZonesReportAClimateDiagnostic() {
|
||||
List<ExportDiagnostic> zoned = new ArrayList<>();
|
||||
IrisHydrology hydrology = overworldHydrology().setClimate(new IrisHydrologyClimate().setEnabled(true));
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region("region", null), biome("plains", null))), zoned);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region("region", null), List.of(biome("plains", null)))), zoned);
|
||||
|
||||
List<ExportDiagnostic> exempt = new ArrayList<>();
|
||||
IrisRegion everywhere = region("region", new IrisHydrologyPolicy().setClimateZones(false));
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(everywhere, biome("plains", null))), exempt);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(everywhere, List.of(biome("plains", null)))), exempt);
|
||||
|
||||
List<ExportDiagnostic> climate = limited(zoned, ExportLimit.RIVER_CLIMATE);
|
||||
assertEquals(zoned.toString(), 1, climate.size());
|
||||
@@ -318,8 +335,8 @@ public class RiverCompilerTest {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
IrisDimension dimension = dimension(overworldHydrology(), new IrisHydrologyPolicy().setShoreBiomes(new KList<>("shore/beach")));
|
||||
List<RiverCompiler.Area> areas = List.of(
|
||||
new RiverCompiler.Area(region("banked", new IrisHydrologyPolicy().setShoreBiomeWidth(4)), biome("plains", null)),
|
||||
new RiverCompiler.Area(region("bare", null), biome("plains", null)));
|
||||
new RiverCompiler.Area(region("banked", new IrisHydrologyPolicy().setShoreBiomeWidth(4)), List.of(biome("plains", null))),
|
||||
new RiverCompiler.Area(region("bare", null), List.of(biome("plains", null))));
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), dimension, areas, registry(), DataVersion.V26_3, diagnostics);
|
||||
|
||||
@@ -339,10 +356,10 @@ public class RiverCompilerTest {
|
||||
IrisBiome barren = biome("desert", new IrisHydrologyPolicy().setDecorators(new KList<>()));
|
||||
IrisRegion region = region("region", null);
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region, reeds), new RiverCompiler.Area(region, barren)), diagnostics);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region, List.of(reeds)), new RiverCompiler.Area(region, List.of(barren))), diagnostics);
|
||||
|
||||
List<ExportDiagnostic> plain = new ArrayList<>();
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region, biome("plains", null))), plain);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region, List.of(biome("plains", null)))), plain);
|
||||
|
||||
assertEquals(List.of("biomes/swamp"), limited(diagnostics, ExportLimit.RIVER_DECORATOR).stream().map(ExportDiagnostic::resource).toList());
|
||||
assertEquals(List.of("dimensions/rivers/hydrology"), limited(plain, ExportLimit.RIVER_DECORATOR).stream().map(ExportDiagnostic::resource).toList());
|
||||
@@ -396,10 +413,10 @@ public class RiverCompilerTest {
|
||||
IrisRegion hot = region("hot", new IrisHydrologyPolicy().setRainfall(0.5).setShoreBiomes(new KList<>("hot/beach")).setShoreBiomeWidth(3));
|
||||
IrisRegion wet = region("wet", new IrisHydrologyPolicy().setRainfall(2.0));
|
||||
List<RiverCompiler.Area> areas = List.of(
|
||||
new RiverCompiler.Area(hot, biome("volcano", new IrisHydrologyPolicy().setFluid("lava"))),
|
||||
new RiverCompiler.Area(hot, biome("deep", new IrisHydrologyPolicy().setStreams(IrisHydrologyPermission.BLOCK))),
|
||||
new RiverCompiler.Area(wet, biome("marsh", new IrisHydrologyPolicy().setDecorators(new KList<>(seagrass())))),
|
||||
new RiverCompiler.Area(wet, biome("plains", null)));
|
||||
new RiverCompiler.Area(hot, List.of(biome("volcano", new IrisHydrologyPolicy().setFluid("lava")))),
|
||||
new RiverCompiler.Area(hot, List.of(biome("deep", new IrisHydrologyPolicy().setStreams(IrisHydrologyPermission.BLOCK)))),
|
||||
new RiverCompiler.Area(wet, List.of(biome("marsh", new IrisHydrologyPolicy().setDecorators(new KList<>(seagrass()))))),
|
||||
new RiverCompiler.Area(wet, List.of(biome("plains", null))));
|
||||
List<RiverCompiler.Area> reversed = new ArrayList<>(areas);
|
||||
Collections.reverse(reversed);
|
||||
List<ExportDiagnostic> forward = new ArrayList<>();
|
||||
@@ -461,7 +478,7 @@ public class RiverCompilerTest {
|
||||
}
|
||||
|
||||
private static Field compile(Field natural, IrisHydrology hydrology, NoiseRegistry registry, DataVersion target, List<ExportDiagnostic> diagnostics) {
|
||||
return compile(natural, dimension(hydrology, null), List.of(new RiverCompiler.Area(region("region", null), biome("plains", null))),
|
||||
return compile(natural, dimension(hydrology, null), List.of(new RiverCompiler.Area(region("region", null), List.of(biome("plains", null)))),
|
||||
registry, target, diagnostics);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
|
||||
@ClassRule
|
||||
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
|
||||
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "cc8006323ee6ce8f8cda87ddb7daf2e73fbb832937c9fce0afe4b71c1f1eae37";
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "2bc12e41634c3b0e9c943543c3687fd6da6d8e6b6d5eb5a29d6d6242bbd356fa";
|
||||
|
||||
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
|
||||
IrisDimension.class,
|
||||
|
||||
Reference in new issue
Block a user