mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +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
+3
-2
@@ -19,6 +19,7 @@ import art.arcane.iris.pack.datapack.export.lower.ExportCapabilities;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class RiverCompiler {
|
||||
public static final String CARVED_HEIGHT = "height/carved";
|
||||
@@ -61,7 +62,7 @@ public final class RiverCompiler {
|
||||
this.diagnostics = Objects.requireNonNull(diagnostics, "diagnostics");
|
||||
}
|
||||
|
||||
public Field compile(Field height, IrisDimension dimension, List<Area> areas, NoiseRegistry registry, ExportCapabilities capabilities) {
|
||||
public Field compile(Field height, IrisDimension dimension, Supplier<List<Area>> areas, NoiseRegistry registry, ExportCapabilities capabilities) {
|
||||
Objects.requireNonNull(height, "height");
|
||||
Objects.requireNonNull(areas, "areas");
|
||||
IrisHydrology hydrology = dimension.getHydrology();
|
||||
@@ -76,7 +77,7 @@ public final class RiverCompiler {
|
||||
return height;
|
||||
}
|
||||
report(ExportLimit.RIVER_DRAINAGE, resource, "Rivers follow seeded noise channels instead of drainage: tributaries cross instead of joining and widths follow elevation");
|
||||
diagnostics.addAll(RiverLimits.diagnostics(dimension, settings, areas, resource));
|
||||
diagnostics.addAll(RiverLimits.diagnostics(dimension, settings, areas.get(), resource));
|
||||
Field elevation = FieldMacros.sum(List.of(height, new Field.Const(-fluidHeight)));
|
||||
Carving carving = new Carving(elevation, variation(registry), bankNoise(settings.deformation(), registry), settings.deformation(), registry, capabilities);
|
||||
List<HydrologyTier> tiers = settings.tiers();
|
||||
|
||||
+7
-4
@@ -140,12 +140,15 @@ final class RiverLimits {
|
||||
}
|
||||
|
||||
private void fluid(Owner owner, String name) {
|
||||
if (exported(settings.fluids().get(name))) {
|
||||
String seam = settings.seams().get(name);
|
||||
if (!exported(settings.fluids().get(name))) {
|
||||
String subject = seam == null ? "Fluid '" + name + "' is" : "Fluid '" + name + "' and its seam '" + seam + "' are";
|
||||
add(ExportLimit.RIVER_FLUID, owner, name, subject + " not exported: rivers fill with " + exportFluid + " up to fluidHeight");
|
||||
return;
|
||||
}
|
||||
String seam = settings.seams().get(name);
|
||||
String subject = seam == null ? "Fluid '" + name + "' is" : "Fluid '" + name + "' and its seam '" + seam + "' are";
|
||||
add(ExportLimit.RIVER_FLUID, owner, name, subject + " not exported: rivers fill with " + exportFluid + " up to fluidHeight");
|
||||
if (seam != null) {
|
||||
add(ExportLimit.RIVER_FLUID, owner, name, "Seam '" + seam + "' of fluid '" + name + "' is not exported: rivers have no seam band at their edges");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean exported(IrisMaterialPalette palette) {
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public final class RiverStage implements CompileStage {
|
||||
@Override
|
||||
public void apply(PackCompileContext context) {
|
||||
Field natural = context.naturalHeight();
|
||||
Field carved = new RiverCompiler(context.diagnostics()).compile(natural, context.dimension(), areas(context), context.noises(), context.capabilities());
|
||||
Field carved = new RiverCompiler(context.diagnostics()).compile(natural, context.dimension(), () -> areas(context), context.noises(), context.capabilities());
|
||||
context.setCarvedHeight(carved);
|
||||
context.setSurfaceEstimate(FieldMacros.substitute(carved, natural, context.climateHeight(), ESTIMATE_TAG));
|
||||
}
|
||||
|
||||
+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