mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Bound policy multipliers
- Reject a policy rainfall or pondDensity outside 0..16 when a column resolves it, naming the biome and region - Report a policy rainfall or pondDensity outside 0..16 at every scope in pack validation - Share the 0..16 bound between the schema, the terrain source and the validator through IrisHydrologyPolicy.MAX_MULTIPLIER - Size the window cup grid from a double product of seeded density and peak pond density
This commit is contained in:
1 parent
4000dfe659
commit
fa43b276f4
6 files changed
+82
-6
No files matched your search
+8
-2
@@ -22,13 +22,15 @@ import java.util.function.Function;
|
||||
@Description("Hydrology settings for a dimension, region or biome. A value a biome leaves unset is inherited from the biome it grows inside as a child, up through that biome's own parents, then from the region, then from the dimension.")
|
||||
@Data
|
||||
public class IrisHydrologyPolicy {
|
||||
public static final double MAX_MULTIPLIER = 16D;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@MaxNumber(MAX_MULTIPLIER)
|
||||
@Description("Multiplier on the water that falls in this area. Higher values grow more and larger streams and keep ponds fuller. With no value set anywhere it is 1.")
|
||||
private Double rainfall = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@MaxNumber(MAX_MULTIPLIER)
|
||||
@Description("Multiplier on how many ponds form in this area. With no value set anywhere it is 1.")
|
||||
private Double pondDensity = null;
|
||||
|
||||
@@ -61,6 +63,10 @@ public class IrisHydrologyPolicy {
|
||||
@Description("Plants for the rivers, streams, ponds and lakes in this area, replacing the decorators of the tiers and ponds there. Written like the tier and pond decorators: partOf SEA_FLOOR, SEA_SURFACE or SHORE_LINE. An empty list grows no plants here. With no value set anywhere, the tiers and ponds use their own decorators.")
|
||||
private KList<IrisDecorator> decorators = null;
|
||||
|
||||
public static boolean validMultiplier(double value) {
|
||||
return value >= 0D && value <= MAX_MULTIPLIER;
|
||||
}
|
||||
|
||||
public static <T> T inherited(List<IrisBiome> biomes, IrisRegion region, IrisDimension dimension, Function<IrisHydrologyPolicy, T> field) {
|
||||
for (int index = 0; index < biomes.size(); index++) {
|
||||
T value = value(biomes.get(index).getHydrologyPolicy(), field);
|
||||
|
||||
+3
-3
@@ -230,9 +230,9 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
}
|
||||
|
||||
private static void requireMultiplier(String field, double value, List<IrisBiome> biomes, IrisRegion region) {
|
||||
if (!Double.isFinite(value) || value < 0D) {
|
||||
throw new IllegalArgumentException("Hydrology policy " + field + " for " + where(biomes, region) + " must be a finite value of 0 or more, got "
|
||||
+ value);
|
||||
if (!IrisHydrologyPolicy.validMultiplier(value)) {
|
||||
throw new IllegalArgumentException("Hydrology policy " + field + " for " + where(biomes, region) + " must be a finite value from 0 to "
|
||||
+ (int) IrisHydrologyPolicy.MAX_MULTIPLIER + ", got " + value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ final class CupCarver {
|
||||
|
||||
private void windowCups(DemGrid raw, int wx, int wz, HydrologySampleBuffer samples, List<CupSet.Cup> out) {
|
||||
float density = settings.ponds().seeded().density();
|
||||
double expected = density * peakPondDensity(raw, wx, wz, samples);
|
||||
double expected = (double) density * peakPondDensity(raw, wx, wz, samples);
|
||||
if (!(expected > 0D)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -260,12 +260,20 @@ final class PackHydrologyValidator {
|
||||
if (policy.getDecorators() != null) {
|
||||
validateDecorators(field + ".decorators", policy.getDecorators(), data, errors);
|
||||
}
|
||||
requireMultiplier(field + ".rainfall", policy.getRainfall(), errors);
|
||||
requireMultiplier(field + ".pondDensity", policy.getPondDensity(), errors);
|
||||
IrisHydrologyWetness wetness = policy.getWetness();
|
||||
if (wetness != null && !(wetness.getMin() >= 0D && wetness.getMin() <= wetness.getMax() && wetness.getMax() <= 1D)) {
|
||||
errors.add(field + ".wetness must have 0 <= min <= max <= 1, got min " + wetness.getMin() + " and max " + wetness.getMax() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
private static void requireMultiplier(String field, Double value, List<String> errors) {
|
||||
if (value != null && !IrisHydrologyPolicy.validMultiplier(value)) {
|
||||
errors.add(field + " must be a finite value from 0 to " + (int) IrisHydrologyPolicy.MAX_MULTIPLIER + ", got " + value + ".");
|
||||
}
|
||||
}
|
||||
|
||||
private static void close(File packFolder, IrisData data, List<String> errors) {
|
||||
if (data == null) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user