mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Report datapack hydrology limits
- Datapack export warns with RIVER_FLUID when a tier or hydrology policy fluid differs from the dimension fluid, naming its seam - Hydrology policy rainfall and streams BLOCK report RIVER_POLICY on the dimension, region or biome that sets them - Wet and dry climate zones report RIVER_CLIMATE unless every exported area opts out - Shore biomes with a width report RIVER_SHORE_BIOME, and tier or policy water decorators report RIVER_DECORATOR - Enabled sea inlets and cave pools report SEA_INLET and CAVE_POOL - River stage resolves policies per region and exported surface biome, reporting each limit once per scope in a fixed order - Dimension stage shares its fluid block resolution with the river limits
This commit is contained in:
1 parent
81b47a8f9b
commit
8e048944ec
7 files changed
+570
-11
No files matched your search
+13
-7
@@ -34,7 +34,7 @@ public final class DimensionStage implements CompileStage {
|
||||
dimension.getLogicalHeight(),
|
||||
dimension.getFluidHeight() + minY,
|
||||
paletteBlock(dimension.getRockPalette(), DEFAULT_ROCK, "rock"),
|
||||
paletteBlock(dimension.getFluidPalette(), DEFAULT_FLUID, "fluid"),
|
||||
fluidBlock(dimension),
|
||||
new JsonObject(),
|
||||
context.diagnostics());
|
||||
IrisDimensionType type = new IrisDimensionType(
|
||||
@@ -55,6 +55,17 @@ public final class DimensionStage implements CompileStage {
|
||||
typeJson));
|
||||
}
|
||||
|
||||
public static String fluidBlock(IrisDimension dimension) {
|
||||
return paletteBlock(dimension.getFluidPalette(), DEFAULT_FLUID, "fluid");
|
||||
}
|
||||
|
||||
public static String blockId(String raw) {
|
||||
String block = raw == null ? "" : raw.trim().toLowerCase(Locale.ROOT);
|
||||
int properties = block.indexOf('[');
|
||||
String id = properties < 0 ? block : block.substring(0, properties);
|
||||
return id.indexOf(':') < 0 ? "minecraft:" + id : id;
|
||||
}
|
||||
|
||||
private static IrisDimensionTypeOptions typeOptions(IrisDimension dimension) {
|
||||
IrisDimensionTypeOptions options = dimension.getDimensionOptions();
|
||||
return dimension.isFullbright() ? options.copy().ambientLight(FULLBRIGHT_AMBIENT_LIGHT) : options;
|
||||
@@ -65,11 +76,6 @@ public final class DimensionStage implements CompileStage {
|
||||
if (entries == null || entries.isEmpty() || entries.getFirst() == null) {
|
||||
return fallback;
|
||||
}
|
||||
String raw = entries.getFirst().getBlock();
|
||||
String block = raw == null ? "" : raw.trim().toLowerCase(Locale.ROOT);
|
||||
int properties = block.indexOf('[');
|
||||
String id = properties < 0 ? block : block.substring(0, properties);
|
||||
String namespaced = id.indexOf(':') < 0 ? "minecraft:" + id : id;
|
||||
return VanillaResourceIdentifier.requireIdentifier(namespaced, "dimension " + role + " block");
|
||||
return VanillaResourceIdentifier.requireIdentifier(blockId(entries.getFirst().getBlock()), "dimension " + role + " block");
|
||||
}
|
||||
}
|
||||
+12
-1
@@ -1,10 +1,12 @@
|
||||
package art.arcane.iris.pack.datapack.export.compile.terrain;
|
||||
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisBankStyle;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.pack.datapack.export.compile.noise.NoiseRegistry;
|
||||
import art.arcane.iris.pack.datapack.export.ir.CostClass;
|
||||
import art.arcane.iris.pack.datapack.export.ir.ExportDiagnostic;
|
||||
@@ -59,8 +61,9 @@ public final class RiverCompiler {
|
||||
this.diagnostics = Objects.requireNonNull(diagnostics, "diagnostics");
|
||||
}
|
||||
|
||||
public Field compile(Field height, IrisDimension dimension, NoiseRegistry registry, ExportCapabilities capabilities) {
|
||||
public Field compile(Field height, IrisDimension dimension, List<Area> areas, NoiseRegistry registry, ExportCapabilities capabilities) {
|
||||
Objects.requireNonNull(height, "height");
|
||||
Objects.requireNonNull(areas, "areas");
|
||||
IrisHydrology hydrology = dimension.getHydrology();
|
||||
if (hydrology == null || !hydrology.isEnabled()) {
|
||||
return height;
|
||||
@@ -73,6 +76,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));
|
||||
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();
|
||||
@@ -287,6 +291,13 @@ public final class RiverCompiler {
|
||||
return new Field.Binary(Field.BinaryOp.MAX, first, second);
|
||||
}
|
||||
|
||||
public record Area(IrisRegion region, IrisBiome biome) {
|
||||
public Area {
|
||||
Objects.requireNonNull(region, "region");
|
||||
Objects.requireNonNull(biome, "biome");
|
||||
}
|
||||
}
|
||||
|
||||
private record Carving(Field elevation, Field variation, Field bankNoise, HydrologySettings.Deformation deformation,
|
||||
NoiseRegistry registry, ExportCapabilities capabilities) {
|
||||
}
|
||||
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
package art.arcane.iris.pack.datapack.export.compile.terrain;
|
||||
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorator;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPermission;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.pack.datapack.export.compile.DimensionStage;
|
||||
import art.arcane.iris.pack.datapack.export.ir.ExportDiagnostic;
|
||||
import art.arcane.iris.pack.datapack.export.ir.ExportLimit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
final class RiverLimits {
|
||||
private static final double NEUTRAL_RAINFALL = 1.0;
|
||||
private static final Comparator<Finding> ORDER = Comparator.comparing(Finding::limit)
|
||||
.thenComparingInt(finding -> finding.owner().rank())
|
||||
.thenComparing(finding -> finding.owner().resource())
|
||||
.thenComparing(Finding::subject);
|
||||
|
||||
private final IrisDimension dimension;
|
||||
private final HydrologySettings settings;
|
||||
private final Owner hydrology;
|
||||
private final Owner dimensionPolicy;
|
||||
private final String exportFluid;
|
||||
private final SortedMap<Finding, String> findings = new TreeMap<>(ORDER);
|
||||
|
||||
private RiverLimits(IrisDimension dimension, HydrologySettings settings, String resource) {
|
||||
this.dimension = dimension;
|
||||
this.settings = settings;
|
||||
this.hydrology = new Owner(Owner.HYDROLOGY, resource);
|
||||
this.dimensionPolicy = new Owner(Owner.DIMENSION, "dimensions/" + dimension.getLoadKey());
|
||||
this.exportFluid = DimensionStage.fluidBlock(dimension);
|
||||
}
|
||||
|
||||
static List<ExportDiagnostic> diagnostics(IrisDimension dimension, HydrologySettings settings, List<RiverCompiler.Area> areas, String resource) {
|
||||
RiverLimits limits = new RiverLimits(dimension, settings, resource);
|
||||
for (RiverCompiler.Area area : areas) {
|
||||
limits.inspect(area);
|
||||
}
|
||||
limits.inspectUnderground();
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>(limits.findings.size());
|
||||
for (Map.Entry<Finding, String> entry : limits.findings.entrySet()) {
|
||||
Finding finding = entry.getKey();
|
||||
diagnostics.add(new ExportDiagnostic(ExportDiagnostic.Severity.WARNING, finding.limit(), finding.owner().resource(), entry.getValue()));
|
||||
}
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
private void inspect(RiverCompiler.Area area) {
|
||||
inspectFluid(area);
|
||||
inspectPolicy(area);
|
||||
inspectClimate(area);
|
||||
inspectShore(area);
|
||||
inspectDecorators(area);
|
||||
}
|
||||
|
||||
private void inspectUnderground() {
|
||||
if (settings.underground().seaInlets().enabled()) {
|
||||
add(ExportLimit.SEA_INLET, hydrology, "", "Sea inlets are not exported: coastal cliffs have no flooded passages");
|
||||
}
|
||||
if (settings.underground().cavePools().enabled() && settings.underground().cavePools().density() > 0.0F) {
|
||||
add(ExportLimit.CAVE_POOL, hydrology, "", "Cave pools are not exported: cave floors hold no standing water of their own");
|
||||
}
|
||||
}
|
||||
|
||||
private void inspectFluid(RiverCompiler.Area area) {
|
||||
Sourced<String> fluid = sourced(area, IrisHydrologyPolicy::getFluid);
|
||||
if (fluid != null) {
|
||||
settings.requireFillingFluid(fluid.value(), "the hydrology policy of " + fluid.owner().resource());
|
||||
fluid(fluid.owner(), fluid.value());
|
||||
return;
|
||||
}
|
||||
for (HydrologyTier tier : settings.tiers()) {
|
||||
fluid(hydrology, tier.fluid());
|
||||
}
|
||||
}
|
||||
|
||||
private void inspectPolicy(RiverCompiler.Area area) {
|
||||
Sourced<Double> rainfall = sourced(area, IrisHydrologyPolicy::getRainfall);
|
||||
if (rainfall != null && rainfall.value() != NEUTRAL_RAINFALL) {
|
||||
add(ExportLimit.RIVER_POLICY, rainfall.owner(), "rainfall",
|
||||
"Hydrology policy rainfall is not exported: rivers form at the dimension density here");
|
||||
}
|
||||
Sourced<IrisHydrologyPermission> streams = sourced(area, IrisHydrologyPolicy::getStreams);
|
||||
if (streams != null && streams.value() == IrisHydrologyPermission.BLOCK) {
|
||||
add(ExportLimit.RIVER_POLICY, streams.owner(), "streams",
|
||||
"Hydrology policy streams BLOCK is not exported: rivers start here as they do elsewhere");
|
||||
}
|
||||
}
|
||||
|
||||
private void inspectClimate(RiverCompiler.Area area) {
|
||||
HydrologySettings.Climate climate = settings.climate();
|
||||
if (!climate.enabled() || climate.dryness() <= 0.0F || climate.dryRainfall() >= 1.0F) {
|
||||
return;
|
||||
}
|
||||
Sourced<Boolean> zones = sourced(area, IrisHydrologyPolicy::getClimateZones);
|
||||
if (zones == null || zones.value()) {
|
||||
add(ExportLimit.RIVER_CLIMATE, hydrology, "", "Wet and dry zones are not exported: rivers start in dry zones as they do in wet ones");
|
||||
}
|
||||
}
|
||||
|
||||
private void inspectShore(RiverCompiler.Area area) {
|
||||
Sourced<Integer> width = sourced(area, IrisHydrologyPolicy::getShoreBiomeWidth);
|
||||
Sourced<List<String>> biomes = sourced(area, IrisHydrologyPolicy::getShoreBiomes);
|
||||
if (width == null || width.value() <= 0 || biomes == null || biomes.value().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
add(ExportLimit.RIVER_SHORE_BIOME, biomes.owner(), "",
|
||||
"Hydrology shore biomes are not exported: the water's edge keeps the biome around it");
|
||||
}
|
||||
|
||||
private void inspectDecorators(RiverCompiler.Area area) {
|
||||
Sourced<List<IrisDecorator>> decorators = sourced(area, IrisHydrologyPolicy::getDecorators);
|
||||
if (decorators != null) {
|
||||
if (!decorators.value().isEmpty()) {
|
||||
decorators(decorators.owner());
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (HydrologyTier tier : settings.tiers()) {
|
||||
if (tier.decorators() != null && !tier.decorators().isEmpty()) {
|
||||
decorators(hydrology);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void decorators(Owner owner) {
|
||||
add(ExportLimit.RIVER_DECORATOR, owner, "", "Hydrology decorators are not exported: rivers grow no water plants of their own");
|
||||
}
|
||||
|
||||
private void fluid(Owner owner, String name) {
|
||||
if (exported(settings.fluids().get(name))) {
|
||||
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");
|
||||
}
|
||||
|
||||
private boolean exported(IrisMaterialPalette palette) {
|
||||
for (IrisBlockData block : palette.getPalette()) {
|
||||
if (!exportFluid.equals(DimensionStage.blockId(block.getBlock()))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void add(ExportLimit limit, Owner owner, String subject, String message) {
|
||||
findings.putIfAbsent(new Finding(limit, owner, subject), message);
|
||||
}
|
||||
|
||||
private <T> Sourced<T> sourced(RiverCompiler.Area area, Function<IrisHydrologyPolicy, T> field) {
|
||||
T biome = value(area.biome().getHydrologyPolicy(), field);
|
||||
if (biome != null) {
|
||||
return new Sourced<>(new Owner(Owner.BIOME, "biomes/" + area.biome().getLoadKey()), biome);
|
||||
}
|
||||
T region = value(area.region().getHydrologyPolicy(), field);
|
||||
if (region != null) {
|
||||
return new Sourced<>(new Owner(Owner.REGION, "regions/" + area.region().getLoadKey()), region);
|
||||
}
|
||||
T inherited = value(dimension.getHydrologyPolicy(), field);
|
||||
return inherited == null ? null : new Sourced<>(dimensionPolicy, inherited);
|
||||
}
|
||||
|
||||
private static <T> T value(IrisHydrologyPolicy policy, Function<IrisHydrologyPolicy, T> field) {
|
||||
return policy == null ? null : field.apply(policy);
|
||||
}
|
||||
|
||||
private record Owner(int rank, String resource) {
|
||||
private static final int HYDROLOGY = 0;
|
||||
private static final int DIMENSION = 1;
|
||||
private static final int REGION = 2;
|
||||
private static final int BIOME = 3;
|
||||
}
|
||||
|
||||
private record Finding(ExportLimit limit, Owner owner, String subject) {
|
||||
}
|
||||
|
||||
private record Sourced<T>(Owner owner, T value) {
|
||||
}
|
||||
}
|
||||
+56
-1
@@ -1,8 +1,22 @@
|
||||
package art.arcane.iris.pack.datapack.export.compile.terrain;
|
||||
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.pack.datapack.export.compile.CompileStage;
|
||||
import art.arcane.iris.pack.datapack.export.compile.PackCompileContext;
|
||||
import art.arcane.iris.pack.datapack.export.ir.Field;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public final class RiverStage implements CompileStage {
|
||||
private static final String ESTIMATE_TAG = "estimate";
|
||||
@@ -15,8 +29,49 @@ 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(), 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));
|
||||
}
|
||||
|
||||
private static List<RiverCompiler.Area> areas(PackCompileContext context) {
|
||||
IrisData data = context.data();
|
||||
Set<String> exported = new HashSet<>(context.baseBiomeCodes().loadKeyByBiomeId().values());
|
||||
List<IrisRegion> regions = new ArrayList<>();
|
||||
for (IrisRegion region : data.getRegionLoader().loadAll(context.dimension().getRegions())) {
|
||||
if (!region.isCompatExcluded()) {
|
||||
regions.add(region);
|
||||
}
|
||||
}
|
||||
regions.sort(Comparator.comparing(IrisRegion::getLoadKey));
|
||||
List<RiverCompiler.Area> areas = new ArrayList<>();
|
||||
for (IrisRegion region : regions) {
|
||||
for (IrisBiome biome : surfaceBiomes(region, data, exported)) {
|
||||
areas.add(new RiverCompiler.Area(region, biome));
|
||||
}
|
||||
}
|
||||
return areas;
|
||||
}
|
||||
|
||||
private static Collection<IrisBiome> surfaceBiomes(IrisRegion region, IrisData data, Set<String> exported) {
|
||||
Deque<String> pending = new ArrayDeque<>();
|
||||
pending.addAll(region.getLandBiomes());
|
||||
pending.addAll(region.getSeaBiomes());
|
||||
pending.addAll(region.getShoreBiomes());
|
||||
Set<String> visited = new HashSet<>();
|
||||
SortedMap<String, IrisBiome> biomes = new TreeMap<>();
|
||||
while (!pending.isEmpty()) {
|
||||
String key = pending.removeFirst();
|
||||
if (key == null || !visited.add(key)) {
|
||||
continue;
|
||||
}
|
||||
IrisBiome biome = data.getBiomeLoader().load(key);
|
||||
if (biome == null || biome.isCompatExcluded() || !exported.contains(biome.getLoadKey())) {
|
||||
continue;
|
||||
}
|
||||
biomes.put(biome.getLoadKey(), biome);
|
||||
pending.addAll(biome.getChildren());
|
||||
}
|
||||
return biomes.values();
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,13 @@ public enum ExportLimit {
|
||||
OBJECT_BOUNDS,
|
||||
RIVER_DRAINAGE,
|
||||
ELEVATED_WATER,
|
||||
RIVER_FLUID,
|
||||
RIVER_POLICY,
|
||||
RIVER_CLIMATE,
|
||||
RIVER_SHORE_BIOME,
|
||||
RIVER_DECORATOR,
|
||||
SEA_INLET,
|
||||
CAVE_POOL,
|
||||
DATAPACK_VERSION,
|
||||
DATAPACK_COLLISION,
|
||||
DATAPACK_FILE,
|
||||
|
||||
+263
-2
@@ -1,10 +1,21 @@
|
||||
package art.arcane.iris.pack.datapack.export.compile.terrain;
|
||||
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorationPart;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorator;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisBankStyle;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisFluidProfile;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyClimate;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyDeformation;
|
||||
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.IrisHydrologyUnderground;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.pack.datapack.DataVersion;
|
||||
import art.arcane.iris.pack.datapack.export.compile.noise.NoiseRegistry;
|
||||
import art.arcane.iris.pack.datapack.export.ir.Axis;
|
||||
@@ -20,6 +31,7 @@ import art.arcane.volmlib.util.collection.KList;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -163,10 +175,210 @@ public class RiverCompilerTest {
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), overworldHydrology(), registry(), DataVersion.V26_3, diagnostics);
|
||||
|
||||
assertEquals(List.of(ExportLimit.ELEVATED_WATER, ExportLimit.RIVER_DRAINAGE), diagnostics.stream().map(ExportDiagnostic::limit).toList());
|
||||
assertEquals(List.of(ExportLimit.ELEVATED_WATER, ExportLimit.RIVER_DRAINAGE, ExportLimit.SEA_INLET, ExportLimit.CAVE_POOL),
|
||||
diagnostics.stream().map(ExportDiagnostic::limit).toList());
|
||||
assertEquals("dimensions/rivers/hydrology", diagnostics.getFirst().resource());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lavaRiversReportADiagnostic() {
|
||||
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)));
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), withLava(overworldHydrology()), areas, diagnostics);
|
||||
|
||||
List<ExportDiagnostic> fluids = limited(diagnostics, ExportLimit.RIVER_FLUID);
|
||||
assertEquals(diagnostics.toString(), 1, fluids.size());
|
||||
assertEquals("biomes/tropical/volcanoes", fluids.getFirst().resource());
|
||||
assertEquals(ExportDiagnostic.Severity.WARNING, fluids.getFirst().severity());
|
||||
assertTrue(fluids.getFirst().message(), fluids.getFirst().message().contains("'lava'"));
|
||||
assertTrue(fluids.getFirst().message(), fluids.getFirst().message().contains("minecraft:water"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lavaTiersReportTheirFluidAndSeamOnTheHydrology() {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
IrisHydrology hydrology = withLava(overworldHydrology());
|
||||
hydrology.getFluids().getLast().setSeam("obsidian");
|
||||
hydrology.getFluids().add(new IrisFluidProfile().setName("obsidian").setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:obsidian")));
|
||||
for (IrisHydrologyTier tier : hydrology.getTiers()) {
|
||||
tier.setFluid("lava");
|
||||
}
|
||||
|
||||
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("'obsidian'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
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);
|
||||
|
||||
List<ExportDiagnostic> lava = new ArrayList<>();
|
||||
IrisHydrology molten = withLava(overworldHydrology());
|
||||
for (IrisHydrologyTier tier : molten.getTiers()) {
|
||||
tier.setFluid("lava");
|
||||
}
|
||||
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))),
|
||||
registry(), DataVersion.V26_3, lava);
|
||||
|
||||
assertTrue(water.toString(), limited(water, ExportLimit.RIVER_FLUID).isEmpty());
|
||||
assertTrue(lava.toString(), limited(lava, ExportLimit.RIVER_FLUID).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rainfallAndBlockedStreamsReportPolicyDiagnostics() {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
IrisRegion hot = region("hot", new IrisHydrologyPolicy().setRainfall(1.4));
|
||||
IrisBiome deep = biome("ocean/deep", new IrisHydrologyPolicy().setStreams(IrisHydrologyPermission.BLOCK));
|
||||
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)),
|
||||
registry(), DataVersion.V26_3, diagnostics);
|
||||
|
||||
List<ExportDiagnostic> policies = limited(diagnostics, ExportLimit.RIVER_POLICY);
|
||||
assertEquals(List.of("regions/hot", "biomes/ocean/deep"), policies.stream().map(ExportDiagnostic::resource).toList());
|
||||
assertTrue(policies.getFirst().message(), policies.getFirst().message().contains("rainfall"));
|
||||
assertTrue(policies.getLast().message(), policies.getLast().message().contains("BLOCK"));
|
||||
}
|
||||
|
||||
@Test
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
List<ExportDiagnostic> climate = limited(zoned, ExportLimit.RIVER_CLIMATE);
|
||||
assertEquals(zoned.toString(), 1, climate.size());
|
||||
assertEquals("dimensions/rivers/hydrology", climate.getFirst().resource());
|
||||
assertTrue(exempt.toString(), limited(exempt, ExportLimit.RIVER_CLIMATE).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shoreBiomesWithAWidthReportADiagnostic() {
|
||||
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)));
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), dimension, areas, registry(), DataVersion.V26_3, diagnostics);
|
||||
|
||||
List<ExportDiagnostic> widthless = new ArrayList<>();
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), dimension, List.of(areas.getLast()), registry(), DataVersion.V26_3, widthless);
|
||||
|
||||
assertEquals(List.of("dimensions/rivers"), limited(diagnostics, ExportLimit.RIVER_SHORE_BIOME).stream().map(ExportDiagnostic::resource).toList());
|
||||
assertTrue(widthless.toString(), limited(widthless, ExportLimit.RIVER_SHORE_BIOME).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void waterDecoratorsReportADiagnostic() {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
IrisHydrology hydrology = overworldHydrology();
|
||||
hydrology.getTiers().getFirst().setDecorators(new KList<>(seagrass()));
|
||||
IrisBiome reeds = biome("swamp", new IrisHydrologyPolicy().setDecorators(new KList<>(seagrass())));
|
||||
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);
|
||||
|
||||
List<ExportDiagnostic> plain = new ArrayList<>();
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region, 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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void seaInletsReportADiagnostic() {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
IrisHydrology hydrology = overworldHydrology();
|
||||
hydrology.getUnderground().getCavePools().setEnabled(false);
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, registry(), DataVersion.V26_3, diagnostics);
|
||||
|
||||
assertEquals(1, limited(diagnostics, ExportLimit.SEA_INLET).size());
|
||||
assertEquals("dimensions/rivers/hydrology", limited(diagnostics, ExportLimit.SEA_INLET).getFirst().resource());
|
||||
assertTrue(diagnostics.toString(), limited(diagnostics, ExportLimit.CAVE_POOL).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cavePoolsReportADiagnostic() {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
IrisHydrology hydrology = overworldHydrology();
|
||||
hydrology.getUnderground().getSeaInlets().setEnabled(false);
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, registry(), DataVersion.V26_3, diagnostics);
|
||||
|
||||
assertEquals(1, limited(diagnostics, ExportLimit.CAVE_POOL).size());
|
||||
assertEquals("dimensions/rivers/hydrology", limited(diagnostics, ExportLimit.CAVE_POOL).getFirst().resource());
|
||||
assertTrue(diagnostics.toString(), limited(diagnostics, ExportLimit.SEA_INLET).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unusedHydrologyFeaturesReportNoLimits() {
|
||||
List<ExportDiagnostic> plain = new ArrayList<>();
|
||||
IrisHydrology hydrology = withLava(overworldHydrology()).setUnderground(underground(false));
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, registry(), DataVersion.V26_3, plain);
|
||||
|
||||
List<ExportDiagnostic> dry = new ArrayList<>();
|
||||
IrisHydrology still = overworldHydrology().setDensity(0.0).setClimate(new IrisHydrologyClimate().setEnabled(true));
|
||||
still.getTiers().getFirst().setDecorators(new KList<>(seagrass()));
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), still, registry(), DataVersion.V26_3, dry);
|
||||
|
||||
assertEquals(List.of(ExportLimit.ELEVATED_WATER, ExportLimit.RIVER_DRAINAGE), plain.stream().map(ExportDiagnostic::limit).toList());
|
||||
assertEquals(List.of(ExportLimit.ELEVATED_WATER), dry.stream().map(ExportDiagnostic::limit).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void limitOrderIgnoresAreaOrder() {
|
||||
IrisHydrology hydrology = withLava(overworldHydrology()).setClimate(new IrisHydrologyClimate().setEnabled(true));
|
||||
hydrology.getTiers().getFirst().setDecorators(new KList<>(seagrass()));
|
||||
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)));
|
||||
List<RiverCompiler.Area> reversed = new ArrayList<>(areas);
|
||||
Collections.reverse(reversed);
|
||||
List<ExportDiagnostic> forward = new ArrayList<>();
|
||||
List<ExportDiagnostic> backward = new ArrayList<>();
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, areas, forward);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, reversed, backward);
|
||||
|
||||
assertEquals(forward, backward);
|
||||
assertEquals(List.of(ExportLimit.ELEVATED_WATER, ExportLimit.RIVER_DRAINAGE,
|
||||
ExportLimit.RIVER_FLUID,
|
||||
ExportLimit.RIVER_POLICY, ExportLimit.RIVER_POLICY, ExportLimit.RIVER_POLICY,
|
||||
ExportLimit.RIVER_CLIMATE,
|
||||
ExportLimit.RIVER_SHORE_BIOME,
|
||||
ExportLimit.RIVER_DECORATOR, ExportLimit.RIVER_DECORATOR,
|
||||
ExportLimit.SEA_INLET, ExportLimit.CAVE_POOL), forward.stream().map(ExportDiagnostic::limit).toList());
|
||||
assertEquals(List.of("regions/hot", "regions/wet", "biomes/deep"),
|
||||
limited(forward, ExportLimit.RIVER_POLICY).stream().map(ExportDiagnostic::resource).toList());
|
||||
assertEquals(List.of("dimensions/rivers/hydrology", "biomes/marsh"),
|
||||
limited(forward, ExportLimit.RIVER_DECORATOR).stream().map(ExportDiagnostic::resource).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expensiveChildrenOnlyBehindMuxOrGate() {
|
||||
IrisHydrology hydrology = hydrology(
|
||||
@@ -206,11 +418,60 @@ 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))),
|
||||
registry, target, diagnostics);
|
||||
}
|
||||
|
||||
private static Field compile(Field natural, IrisHydrology hydrology, List<RiverCompiler.Area> areas, List<ExportDiagnostic> diagnostics) {
|
||||
return compile(natural, dimension(hydrology, null), areas, registry(), DataVersion.V26_3, diagnostics);
|
||||
}
|
||||
|
||||
private static Field compile(Field natural, IrisDimension dimension, List<RiverCompiler.Area> areas, NoiseRegistry registry, DataVersion target,
|
||||
List<ExportDiagnostic> diagnostics) {
|
||||
return new RiverCompiler(diagnostics).compile(natural, dimension, areas, registry, ExportCapabilities.forTarget(target));
|
||||
}
|
||||
|
||||
private static IrisDimension dimension(IrisHydrology hydrology, IrisHydrologyPolicy policy) {
|
||||
IrisDimension dimension = new IrisDimension();
|
||||
dimension.setLoadKey("rivers");
|
||||
dimension.setFluidHeight(SEA_LEVEL);
|
||||
dimension.setHydrology(hydrology);
|
||||
return new RiverCompiler(diagnostics).compile(natural, dimension, registry, ExportCapabilities.forTarget(target));
|
||||
dimension.setHydrologyPolicy(policy);
|
||||
return dimension;
|
||||
}
|
||||
|
||||
private static IrisRegion region(String key, IrisHydrologyPolicy policy) {
|
||||
IrisRegion region = new IrisRegion();
|
||||
region.setLoadKey(key);
|
||||
region.setHydrologyPolicy(policy);
|
||||
return region;
|
||||
}
|
||||
|
||||
private static IrisBiome biome(String key, IrisHydrologyPolicy policy) {
|
||||
IrisBiome biome = new IrisBiome();
|
||||
biome.setLoadKey(key);
|
||||
biome.setHydrologyPolicy(policy);
|
||||
return biome;
|
||||
}
|
||||
|
||||
private static List<ExportDiagnostic> limited(List<ExportDiagnostic> diagnostics, ExportLimit limit) {
|
||||
return diagnostics.stream().filter(diagnostic -> diagnostic.limit() == limit).toList();
|
||||
}
|
||||
|
||||
private static IrisDecorator seagrass() {
|
||||
return new IrisDecorator().setPartOf(IrisDecorationPart.SEA_FLOOR).setPalette(new KList<>(new IrisBlockData("minecraft:seagrass")));
|
||||
}
|
||||
|
||||
private static IrisHydrologyUnderground underground(boolean enabled) {
|
||||
IrisHydrologyUnderground underground = new IrisHydrologyUnderground();
|
||||
underground.getSeaInlets().setEnabled(enabled);
|
||||
underground.getCavePools().setEnabled(enabled);
|
||||
return underground;
|
||||
}
|
||||
|
||||
private static IrisHydrology withLava(IrisHydrology hydrology) {
|
||||
IrisFluidProfile lava = new IrisFluidProfile().setName("lava").setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:lava"));
|
||||
return hydrology.setFluids(new KList<>(new IrisFluidProfile(), lava));
|
||||
}
|
||||
|
||||
private static double sample(Field field, Map<String, NoiseDef> noises, DataVersion target, int x, int z) {
|
||||
|
||||
+26
@@ -65,6 +65,28 @@ public class RiverStageTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stageReportsTheHydrologyPoliciesOfExportedBiomes() throws Exception {
|
||||
File pack = pack(false);
|
||||
String fluids = "\"fluids\":[{\"name\":\"water\"},{\"name\":\"lava\",\"palette\":{\"palette\":[{\"block\":\"minecraft:lava\"}]}}]";
|
||||
CompatTestPlatform.write(pack, "dimensions/" + TerrainTestPacks.DIMENSION + ".json",
|
||||
"{\"regions\":[\"region\"],\"hydrology\":{\"enabled\":true,\"density\":0.5," + fluids + "}}");
|
||||
CompatTestPlatform.write(pack, "regions/region.json", "{\"landBiomes\":[\"a\",\"b\"],\"hydrologyPolicy\":{\"rainfall\":1.5}}");
|
||||
TerrainTestPacks.biome(pack, "a", "{\"name\":\"A\",\"generators\":[" + TerrainTestPacks.link("hills", 0, 40) + "],"
|
||||
+ "\"hydrologyPolicy\":{\"fluid\":\"lava\"}}");
|
||||
IrisData data = IrisData.openRuntime(pack);
|
||||
try {
|
||||
PackCompileContext context = terrainContext(data, DataVersion.V26_3);
|
||||
|
||||
new RiverStage().apply(context);
|
||||
|
||||
assertEquals(List.of("biomes/a"), resources(context.diagnostics(), ExportLimit.RIVER_FLUID));
|
||||
assertEquals(List.of("regions/region"), resources(context.diagnostics(), ExportLimit.RIVER_POLICY));
|
||||
} finally {
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aquiferSurfaceCarvesTheClimateHeight() throws Exception {
|
||||
IrisData data = IrisData.openRuntime(pack(true));
|
||||
@@ -149,6 +171,10 @@ public class RiverStageTest {
|
||||
return pack;
|
||||
}
|
||||
|
||||
private static List<String> resources(List<ExportDiagnostic> diagnostics, ExportLimit limit) {
|
||||
return diagnostics.stream().filter(diagnostic -> diagnostic.limit() == limit).map(ExportDiagnostic::resource).toList();
|
||||
}
|
||||
|
||||
private static PackCompileContext terrainContext(IrisData data, DataVersion target) {
|
||||
PackCompileContext context = context(data, target);
|
||||
new DimensionStage().apply(context);
|
||||
|
||||
Reference in new issue
Block a user