mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 10:14:36 +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,
|
||||
|
||||
Reference in new issue
Block a user