mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Report seams and defer areas
- RIVER_FLUID reports the seam of a river fluid whose blocks match the exported dimension fluid - River export areas are built only after the hydrology enabled and density checks pass - Tests cover matching-fluid seams, an unknown policy fluid failing the export, deferred area building, and the stage's exported-biome filter with child traversal
This commit is contained in:
1 parent
8e048944ec
commit
549eaa7e20
5 files changed
+84
-7
No files matched your search
+48
@@ -35,9 +35,11 @@ import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class RiverCompilerTest {
|
||||
@@ -217,6 +219,47 @@ public class RiverCompilerTest {
|
||||
assertTrue(fluids.getFirst().message(), fluids.getFirst().message().contains("'obsidian'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void waterSeamsReportADiagnostic() {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
IrisHydrology hydrology = overworldHydrology().setFluids(new KList<>(
|
||||
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);
|
||||
|
||||
List<ExportDiagnostic> fluids = limited(diagnostics, ExportLimit.RIVER_FLUID);
|
||||
assertEquals(diagnostics.toString(), 1, fluids.size());
|
||||
assertEquals("dimensions/rivers/hydrology", fluids.getFirst().resource());
|
||||
assertTrue(fluids.getFirst().message(), fluids.getFirst().message().contains("Seam 'mud' of fluid 'water'"));
|
||||
}
|
||||
|
||||
@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));
|
||||
|
||||
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
|
||||
() -> compile(new Field.Const(SEA_LEVEL + 2.0), overworldHydrology(), areas, new ArrayList<>()));
|
||||
|
||||
assertTrue(failure.getMessage(), failure.getMessage().contains("'acid'"));
|
||||
assertTrue(failure.getMessage(), failure.getMessage().contains("biomes/acid-lake"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void areasAreBuiltOnlyWhenRiversExport() {
|
||||
Supplier<List<RiverCompiler.Area>> refused = () -> {
|
||||
throw new AssertionError("areas built without exported rivers");
|
||||
};
|
||||
for (IrisHydrology hydrology : new IrisHydrology[]{null, overworldHydrology().setEnabled(false), overworldHydrology().setDensity(0.0)}) {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), dimension(hydrology, null), refused, registry(), DataVersion.V26_3, diagnostics);
|
||||
|
||||
assertTrue(diagnostics.toString(), limited(diagnostics, ExportLimit.RIVER_DRAINAGE).isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fluidsMatchingTheExportedFluidReportNothing() {
|
||||
List<ExportDiagnostic> water = new ArrayList<>();
|
||||
@@ -428,6 +471,11 @@ public class RiverCompilerTest {
|
||||
|
||||
private static Field compile(Field natural, IrisDimension dimension, List<RiverCompiler.Area> areas, NoiseRegistry registry, DataVersion target,
|
||||
List<ExportDiagnostic> diagnostics) {
|
||||
return compile(natural, dimension, () -> areas, registry, target, diagnostics);
|
||||
}
|
||||
|
||||
private static Field compile(Field natural, IrisDimension dimension, Supplier<List<RiverCompiler.Area>> areas, NoiseRegistry registry,
|
||||
DataVersion target, List<ExportDiagnostic> diagnostics) {
|
||||
return new RiverCompiler(diagnostics).compile(natural, dimension, areas, registry, ExportCapabilities.forTarget(target));
|
||||
}
|
||||
|
||||
|
||||
+25
@@ -8,6 +8,7 @@ import art.arcane.iris.pack.datapack.export.WorldgenExportRequest;
|
||||
import art.arcane.iris.pack.datapack.export.compile.DimensionStage;
|
||||
import art.arcane.iris.pack.datapack.export.compile.PackCompileContext;
|
||||
import art.arcane.iris.pack.datapack.export.compile.PackCompiler;
|
||||
import art.arcane.iris.pack.datapack.export.compile.biome.BiomeCodes;
|
||||
import art.arcane.iris.pack.datapack.export.ir.Axis;
|
||||
import art.arcane.iris.pack.datapack.export.ir.ExportDiagnostic;
|
||||
import art.arcane.iris.pack.datapack.export.ir.ExportLimit;
|
||||
@@ -24,6 +25,7 @@ import org.junit.rules.TemporaryFolder;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -87,6 +89,29 @@ public class RiverStageTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stageReadsExportedSurfaceBiomesAndTheirChildren() throws Exception {
|
||||
File pack = pack(true);
|
||||
CompatTestPlatform.write(pack, "regions/region.json", "{\"landBiomes\":[\"a\",\"b\"],\"caveBiomes\":[\"e\"]}");
|
||||
TerrainTestPacks.biome(pack, "a", "{\"name\":\"A\",\"generators\":[" + TerrainTestPacks.link("hills", 0, 40) + "],\"children\":[\"c\",\"d\"]}");
|
||||
TerrainTestPacks.biome(pack, "c", "{\"name\":\"C\",\"hydrologyPolicy\":{\"rainfall\":1.5}}");
|
||||
TerrainTestPacks.biome(pack, "d", "{\"name\":\"D\",\"hydrologyPolicy\":{\"streams\":\"BLOCK\"}}");
|
||||
TerrainTestPacks.biome(pack, "e", "{\"name\":\"E\",\"hydrologyPolicy\":{\"rainfall\":2.0}}");
|
||||
IrisData data = IrisData.openRuntime(pack);
|
||||
try {
|
||||
PackCompileContext context = terrainContext(data, DataVersion.V26_3);
|
||||
BiomeCodes codes = context.baseBiomeCodes();
|
||||
context.setBiomeCodes(new BiomeCodes(codes.surfaceCode(), codes.caveCode(), codes.class3d(), codes.layout(), Map.of(
|
||||
TerrainTestSupport.NAMESPACE + ":a", "a", TerrainTestSupport.NAMESPACE + ":b", "b", TerrainTestSupport.NAMESPACE + ":c", "c")));
|
||||
|
||||
new RiverStage().apply(context);
|
||||
|
||||
assertEquals(List.of("biomes/c"), resources(context.diagnostics(), ExportLimit.RIVER_POLICY));
|
||||
} finally {
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aquiferSurfaceCarvesTheClimateHeight() throws Exception {
|
||||
IrisData data = IrisData.openRuntime(pack(true));
|
||||
|
||||
Reference in new issue
Block a user