mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Inherit parent biome policy
- IrisHydrologyPolicy.inherited walks the column's biome lineage (child, then the parents it grew inside), then region, then dimension - IrisComplex.baseBiomeLineage recovers the per-column child chain from the implosion and fails closed if it disagrees with the base biome - BiomeLineages limits chain recovery to biomes a policy-bearing biome can implode into and interns lineages for identity caches - Terrain source, shore biomes and water decorators resolve by lineage; cave pools keep the cave biome alone - Datapack river areas enumerate each region's child chains and RiverLimits attributes inherited values to the parent - Policy description names the parent step; schema digest recaptured
This commit is contained in:
1 parent
95fa3ce105
commit
ff0a95a6fd
18 files changed
+460
-140
No files matched your search
+9
-5
@@ -14,11 +14,12 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@Description("Hydrology settings for a dimension, region or biome. A value left unset is inherited from the region, then from the dimension.")
|
||||
@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 {
|
||||
@MinNumber(0)
|
||||
@@ -57,11 +58,14 @@ 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 <T> T inherited(IrisBiome biome, IrisRegion region, IrisDimension dimension, Function<IrisHydrologyPolicy, T> field) {
|
||||
T value = value(biome == null ? null : biome.getHydrologyPolicy(), field);
|
||||
if (value == null) {
|
||||
value = value(region == null ? null : region.getHydrologyPolicy(), field);
|
||||
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);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
T value = value(region == null ? null : region.getHydrologyPolicy(), field);
|
||||
return value != null ? value : value(dimension == null ? null : dimension.getHydrologyPolicy(), field);
|
||||
}
|
||||
|
||||
|
||||
+28
-26
@@ -38,7 +38,6 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
private final ExecutorService pool;
|
||||
private final int parallelism;
|
||||
private final ProceduralStream<IrisRegion> regions;
|
||||
private final ProceduralStream<IrisBiome> biomes;
|
||||
private final ProceduralStream<InferredType> continents;
|
||||
private final BiomeBuffetLayout buffet;
|
||||
private final IrisBiome focus;
|
||||
@@ -55,7 +54,6 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
this.pool = pool;
|
||||
this.parallelism = Math.max(1, parallelism);
|
||||
this.regions = Objects.requireNonNull(complex.getRegionStream(), "region stream");
|
||||
this.biomes = Objects.requireNonNull(complex.getBaseBiomeStream(), "base biome stream");
|
||||
this.continents = Objects.requireNonNull(complex.getBridgeStream(), "continent stream");
|
||||
this.buffet = complex.getBiomeBuffet();
|
||||
this.focus = complex.getFocusBiome();
|
||||
@@ -88,7 +86,7 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
public String channelFluid(int x, int z) {
|
||||
ChunkBakeCache.enterSparse();
|
||||
try {
|
||||
return policy(biomes.get(x, z), regions.get(x, z)).fluid();
|
||||
return policy(complex.baseBiomeLineage(x, z), regions.get(x, z)).fluid();
|
||||
} finally {
|
||||
ChunkBakeCache.exitSparse();
|
||||
}
|
||||
@@ -164,7 +162,7 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
if (!Double.isFinite(height)) {
|
||||
throw new IllegalStateException("Hydrology " + (baseOnly ? "base" : "natural") + " height at " + x + "," + z + " is " + height);
|
||||
}
|
||||
Policy policy = policy(biomes.get(x, z), regions.get(x, z));
|
||||
Policy policy = policy(complex.baseBiomeLineage(x, z), regions.get(x, z));
|
||||
out.height()[index] = (float) height;
|
||||
out.ocean()[index] = StrictMath.round(height) < settings.seaLevel() && oceanIntent(x, z);
|
||||
float wet = policy.climateZones() ? wetness(x, z) : 1f;
|
||||
@@ -185,13 +183,13 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
return type == InferredType.SEA;
|
||||
}
|
||||
|
||||
private Policy policy(IrisBiome biome, IrisRegion region) {
|
||||
PolicyKey key = new PolicyKey(biome, region);
|
||||
private Policy policy(List<IrisBiome> biomes, IrisRegion region) {
|
||||
PolicyKey key = new PolicyKey(biomes, region);
|
||||
Policy known = policies.get(key);
|
||||
if (known != null) {
|
||||
return known;
|
||||
}
|
||||
Policy resolved = resolve(biome, region);
|
||||
Policy resolved = resolve(biomes, region);
|
||||
if (policies.size() >= POLICY_CAPACITY) {
|
||||
policies.clear();
|
||||
}
|
||||
@@ -199,23 +197,23 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
return raced == null ? resolved : raced;
|
||||
}
|
||||
|
||||
private Policy resolve(IrisBiome biome, IrisRegion region) {
|
||||
double rainfall = inherited(biome, region, IrisHydrologyPolicy::getRainfall, 1D);
|
||||
double pondDensity = inherited(biome, region, IrisHydrologyPolicy::getPondDensity, 1D);
|
||||
IrisHydrologyPermission streams = inherited(biome, region, IrisHydrologyPolicy::getStreams, IrisHydrologyPermission.ALLOW);
|
||||
IrisHydrologyPermission ponds = inherited(biome, region, IrisHydrologyPolicy::getPonds, IrisHydrologyPermission.ALLOW);
|
||||
String fluid = inherited(biome, region, IrisHydrologyPolicy::getFluid, null);
|
||||
boolean climateZones = inherited(biome, region, IrisHydrologyPolicy::getClimateZones, Boolean.TRUE);
|
||||
requireMultiplier("rainfall", rainfall, biome, region);
|
||||
requireMultiplier("pondDensity", pondDensity, biome, region);
|
||||
private Policy resolve(List<IrisBiome> biomes, IrisRegion region) {
|
||||
double rainfall = inherited(biomes, region, IrisHydrologyPolicy::getRainfall, 1D);
|
||||
double pondDensity = inherited(biomes, region, IrisHydrologyPolicy::getPondDensity, 1D);
|
||||
IrisHydrologyPermission streams = inherited(biomes, region, IrisHydrologyPolicy::getStreams, IrisHydrologyPermission.ALLOW);
|
||||
IrisHydrologyPermission ponds = inherited(biomes, region, IrisHydrologyPolicy::getPonds, IrisHydrologyPermission.ALLOW);
|
||||
String fluid = inherited(biomes, region, IrisHydrologyPolicy::getFluid, null);
|
||||
boolean climateZones = inherited(biomes, region, IrisHydrologyPolicy::getClimateZones, Boolean.TRUE);
|
||||
requireMultiplier("rainfall", rainfall, biomes, region);
|
||||
requireMultiplier("pondDensity", pondDensity, biomes, region);
|
||||
if (fluid != null) {
|
||||
settings.requireFillingFluid(fluid, "the hydrology policy for " + where(biome, region));
|
||||
settings.requireFillingFluid(fluid, "the hydrology policy for " + where(biomes, region));
|
||||
}
|
||||
return new Policy((float) rainfall, (float) pondDensity, permission(streams, ponds), fluid, climateZones);
|
||||
}
|
||||
|
||||
private <T> T inherited(IrisBiome biome, IrisRegion region, Function<IrisHydrologyPolicy, T> field, T fallback) {
|
||||
T value = IrisHydrologyPolicy.inherited(biome, region, dimension, field);
|
||||
private <T> T inherited(List<IrisBiome> biomes, IrisRegion region, Function<IrisHydrologyPolicy, T> field, T fallback) {
|
||||
T value = IrisHydrologyPolicy.inherited(biomes, region, dimension, field);
|
||||
return value == null ? fallback : value;
|
||||
}
|
||||
|
||||
@@ -225,29 +223,33 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
return (byte) bits;
|
||||
}
|
||||
|
||||
private static void requireMultiplier(String field, double value, IrisBiome biome, IrisRegion region) {
|
||||
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(biome, region) + " must be a finite value of 0 or more, got "
|
||||
throw new IllegalArgumentException("Hydrology policy " + field + " for " + where(biomes, region) + " must be a finite value of 0 or more, got "
|
||||
+ value);
|
||||
}
|
||||
}
|
||||
|
||||
private static String where(IrisBiome biome, IrisRegion region) {
|
||||
return "biome " + (biome == null ? "none" : biome.getLoadKey()) + " in region " + (region == null ? "none" : region.getLoadKey());
|
||||
private static String where(List<IrisBiome> biomes, IrisRegion region) {
|
||||
StringBuilder where = new StringBuilder("biome ").append(biomes.isEmpty() ? "none" : biomes.getFirst().getLoadKey());
|
||||
for (int index = 1; index < biomes.size(); index++) {
|
||||
where.append(" inside ").append(biomes.get(index).getLoadKey());
|
||||
}
|
||||
return where.append(" in region ").append(region == null ? "none" : region.getLoadKey()).toString();
|
||||
}
|
||||
|
||||
private record Policy(float rainfall, float pondDensity, byte permission, String fluid, boolean climateZones) {
|
||||
}
|
||||
|
||||
private record PolicyKey(IrisBiome biome, IrisRegion region) {
|
||||
private record PolicyKey(List<IrisBiome> biomes, IrisRegion region) {
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof PolicyKey key && key.biome == biome && key.region == region;
|
||||
return other instanceof PolicyKey key && key.biomes == biomes && key.region == region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * System.identityHashCode(biome) + System.identityHashCode(region);
|
||||
return 31 * System.identityHashCode(biomes) + System.identityHashCode(region);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
||||
IrisBiome biome = engine.getCaveBiomeBelowSurface(x, y, z);
|
||||
IrisRegion region = complex.getRegionStream().get(x, z);
|
||||
requireFinal(revision, x, z);
|
||||
return IrisHydrologyPolicy.inherited(biome, region, dimension, IrisHydrologyPolicy::getFluid);
|
||||
return IrisHydrologyPolicy.inherited(biome == null ? List.of() : List.of(biome), region, dimension, IrisHydrologyPolicy::getFluid);
|
||||
}
|
||||
|
||||
private static Collection<SeaInlet> inlets(HydrologyRuntime runtime, int chunkX, int chunkZ) {
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.block.DataProvider;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
final class BiomeLineages {
|
||||
private final Set<String> heirs;
|
||||
private final Object lock = new Object();
|
||||
private volatile IdentityHashMap<IrisBiome, List<IrisBiome>> roots = new IdentityHashMap<>();
|
||||
private volatile Map<Chain, List<IrisBiome>> chains = new HashMap<>();
|
||||
|
||||
private BiomeLineages(Set<String> heirs) {
|
||||
this.heirs = heirs;
|
||||
}
|
||||
|
||||
static BiomeLineages compile(Collection<IrisBiome> biomes, DataProvider provider) {
|
||||
Set<String> heirs = new HashSet<>();
|
||||
for (IrisBiome biome : biomes) {
|
||||
if (biome.getHydrologyPolicy() != null) {
|
||||
addDescendants(biome, provider, heirs);
|
||||
}
|
||||
}
|
||||
return new BiomeLineages(heirs);
|
||||
}
|
||||
|
||||
boolean inherits(IrisBiome biome) {
|
||||
return heirs.contains(biome.getLoadKey());
|
||||
}
|
||||
|
||||
List<IrisBiome> root(IrisBiome biome) {
|
||||
List<IrisBiome> known = roots.get(biome);
|
||||
if (known != null) {
|
||||
return known;
|
||||
}
|
||||
synchronized (lock) {
|
||||
List<IrisBiome> raced = roots.get(biome);
|
||||
if (raced != null) {
|
||||
return raced;
|
||||
}
|
||||
List<IrisBiome> created = List.of(biome);
|
||||
IdentityHashMap<IrisBiome, List<IrisBiome>> next = new IdentityHashMap<>(roots);
|
||||
next.put(biome, created);
|
||||
roots = next;
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
||||
List<IrisBiome> chain(IrisBiome[] leafFirst) {
|
||||
if (leafFirst.length == 1) {
|
||||
return root(leafFirst[0]);
|
||||
}
|
||||
Chain key = new Chain(leafFirst);
|
||||
List<IrisBiome> known = chains.get(key);
|
||||
if (known != null) {
|
||||
return known;
|
||||
}
|
||||
synchronized (lock) {
|
||||
List<IrisBiome> raced = chains.get(key);
|
||||
if (raced != null) {
|
||||
return raced;
|
||||
}
|
||||
List<IrisBiome> created = List.of(leafFirst);
|
||||
Map<Chain, List<IrisBiome>> next = new HashMap<>(chains);
|
||||
next.put(key, created);
|
||||
chains = next;
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
||||
private static void addDescendants(IrisBiome parent, DataProvider provider, Set<String> heirs) {
|
||||
Set<IrisBiome> visited = Collections.newSetFromMap(new IdentityHashMap<>());
|
||||
ArrayDeque<IrisBiome> pending = new ArrayDeque<>();
|
||||
addChildren(parent, provider, pending);
|
||||
while (!pending.isEmpty()) {
|
||||
IrisBiome child = pending.poll();
|
||||
if (visited.add(child)) {
|
||||
heirs.add(child.getLoadKey());
|
||||
addChildren(child, provider, pending);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addChildren(IrisBiome parent, DataProvider provider, ArrayDeque<IrisBiome> pending) {
|
||||
for (IrisBiome child : parent.getRealChildren(provider)) {
|
||||
if (child != null) {
|
||||
pending.add(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record Chain(IrisBiome[] biomes) {
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof Chain chain) || chain.biomes.length != biomes.length) {
|
||||
return false;
|
||||
}
|
||||
for (int index = 0; index < biomes.length; index++) {
|
||||
if (chain.biomes[index] != biomes[index]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 1;
|
||||
for (IrisBiome biome : biomes) {
|
||||
hash = 31 * hash + System.identityHashCode(biome);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ final class HydrologyShoreBiomes {
|
||||
private final IrisData data;
|
||||
private final long seed;
|
||||
private final Object policyLock = new Object();
|
||||
private volatile IdentityHashMap<IrisBiome, IdentityHashMap<IrisRegion, Policy>> policies = new IdentityHashMap<>();
|
||||
private volatile IdentityHashMap<List<IrisBiome>, IdentityHashMap<IrisRegion, Policy>> policies = new IdentityHashMap<>();
|
||||
private int policyCount;
|
||||
|
||||
HydrologyShoreBiomes(IrisDimension dimension, IrisData data, long seed) {
|
||||
@@ -31,8 +31,8 @@ final class HydrologyShoreBiomes {
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
IrisBiome select(IrisBiome biome, IrisRegion region, int x, int z, int shoreDistance) {
|
||||
Policy policy = policy(biome, region);
|
||||
IrisBiome select(List<IrisBiome> lineage, IrisRegion region, int x, int z, int shoreDistance) {
|
||||
Policy policy = policy(lineage, region);
|
||||
IrisBiome[] biomes = policy.biomes();
|
||||
if (shoreDistance > policy.width() || biomes.length == 0) {
|
||||
return null;
|
||||
@@ -44,39 +44,39 @@ final class HydrologyShoreBiomes {
|
||||
return biomes[(int) Long.remainderUnsigned(patch, biomes.length)];
|
||||
}
|
||||
|
||||
private Policy policy(IrisBiome biome, IrisRegion region) {
|
||||
IdentityHashMap<IrisRegion, Policy> regions = policies.get(biome);
|
||||
private Policy policy(List<IrisBiome> lineage, IrisRegion region) {
|
||||
IdentityHashMap<IrisRegion, Policy> regions = policies.get(lineage);
|
||||
Policy known = regions == null ? null : regions.get(region);
|
||||
return known != null ? known : remember(biome, region, resolve(biome, region));
|
||||
return known != null ? known : remember(lineage, region, resolve(lineage, region));
|
||||
}
|
||||
|
||||
private Policy remember(IrisBiome biome, IrisRegion region, Policy resolved) {
|
||||
private Policy remember(List<IrisBiome> lineage, IrisRegion region, Policy resolved) {
|
||||
synchronized (policyLock) {
|
||||
IdentityHashMap<IrisRegion, Policy> current = policies.get(biome);
|
||||
IdentityHashMap<IrisRegion, Policy> current = policies.get(lineage);
|
||||
Policy raced = current == null ? null : current.get(region);
|
||||
if (raced != null) {
|
||||
return raced;
|
||||
}
|
||||
boolean full = policyCount >= CAPACITY;
|
||||
IdentityHashMap<IrisBiome, IdentityHashMap<IrisRegion, Policy>> next = full ? new IdentityHashMap<>() : new IdentityHashMap<>(policies);
|
||||
IdentityHashMap<List<IrisBiome>, IdentityHashMap<IrisRegion, Policy>> next = full ? new IdentityHashMap<>() : new IdentityHashMap<>(policies);
|
||||
IdentityHashMap<IrisRegion, Policy> regions = full || current == null ? new IdentityHashMap<>() : new IdentityHashMap<>(current);
|
||||
regions.put(region, resolved);
|
||||
next.put(biome, regions);
|
||||
next.put(lineage, regions);
|
||||
policyCount = full ? 1 : policyCount + 1;
|
||||
policies = next;
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
|
||||
private Policy resolve(IrisBiome biome, IrisRegion region) {
|
||||
Integer width = IrisHydrologyPolicy.inherited(biome, region, dimension, IrisHydrologyPolicy::getShoreBiomeWidth);
|
||||
List<String> keys = IrisHydrologyPolicy.inherited(biome, region, dimension, IrisHydrologyPolicy::getShoreBiomes);
|
||||
private Policy resolve(List<IrisBiome> lineage, IrisRegion region) {
|
||||
Integer width = IrisHydrologyPolicy.inherited(lineage, region, dimension, IrisHydrologyPolicy::getShoreBiomeWidth);
|
||||
List<String> keys = IrisHydrologyPolicy.inherited(lineage, region, dimension, IrisHydrologyPolicy::getShoreBiomes);
|
||||
if (width == null || width <= 0 || keys == null || keys.isEmpty()) {
|
||||
return NONE;
|
||||
}
|
||||
IrisBiome[] biomes = new IrisBiome[keys.size()];
|
||||
for (int index = 0; index < biomes.length; index++) {
|
||||
biomes[index] = load(keys.get(index), biome, region).withInferredType(InferredType.SHORE);
|
||||
biomes[index] = load(keys.get(index), lineage.isEmpty() ? null : lineage.getFirst(), region).withInferredType(InferredType.SHORE);
|
||||
}
|
||||
return new Policy(biomes, width);
|
||||
}
|
||||
|
||||
+12
-12
@@ -26,7 +26,7 @@ final class HydrologyVegetationSource {
|
||||
private final Object lock = new Object();
|
||||
private boolean planted;
|
||||
private volatile IdentityHashMap<List<IrisDecorator>, HydrologyVegetation.Decorators> compiled = new IdentityHashMap<>();
|
||||
private volatile IdentityHashMap<IrisBiome, IdentityHashMap<IrisRegion, Resolved>> overrides = new IdentityHashMap<>();
|
||||
private volatile IdentityHashMap<List<IrisBiome>, IdentityHashMap<IrisRegion, Resolved>> overrides = new IdentityHashMap<>();
|
||||
|
||||
private HydrologyVegetationSource(IrisData data, IrisDimension dimension, Map<HydrologyTier, HydrologyVegetation.Decorators> tiers,
|
||||
HydrologyVegetation.Decorators ponds) {
|
||||
@@ -62,11 +62,11 @@ final class HydrologyVegetationSource {
|
||||
return planted;
|
||||
}
|
||||
|
||||
HydrologyVegetation.Decorators decorators(HydrologyTier tier, IrisBiome biome, IrisRegion region) {
|
||||
HydrologyVegetation.Decorators decorators(HydrologyTier tier, List<IrisBiome> lineage, IrisRegion region) {
|
||||
if (data == null) {
|
||||
return HydrologyVegetation.Decorators.EMPTY;
|
||||
}
|
||||
Resolved override = override(biome, region);
|
||||
Resolved override = override(lineage, region);
|
||||
if (override.decorators() != null) {
|
||||
return override.decorators();
|
||||
}
|
||||
@@ -80,28 +80,28 @@ final class HydrologyVegetationSource {
|
||||
return known;
|
||||
}
|
||||
|
||||
private Resolved override(IrisBiome biome, IrisRegion region) {
|
||||
IdentityHashMap<IrisRegion, Resolved> regions = overrides.get(biome);
|
||||
private Resolved override(List<IrisBiome> lineage, IrisRegion region) {
|
||||
IdentityHashMap<IrisRegion, Resolved> regions = overrides.get(lineage);
|
||||
Resolved known = regions == null ? null : regions.get(region);
|
||||
return known != null ? known : remember(biome, region, resolve(biome, region));
|
||||
return known != null ? known : remember(lineage, region, resolve(lineage, region));
|
||||
}
|
||||
|
||||
private Resolved resolve(IrisBiome biome, IrisRegion region) {
|
||||
List<IrisDecorator> decorators = IrisHydrologyPolicy.inherited(biome, region, dimension, IrisHydrologyPolicy::getDecorators);
|
||||
private Resolved resolve(List<IrisBiome> lineage, IrisRegion region) {
|
||||
List<IrisDecorator> decorators = IrisHydrologyPolicy.inherited(lineage, region, dimension, IrisHydrologyPolicy::getDecorators);
|
||||
return decorators == null ? Resolved.INHERIT : new Resolved(compiled(decorators, LAZY_POLICY));
|
||||
}
|
||||
|
||||
private Resolved remember(IrisBiome biome, IrisRegion region, Resolved resolved) {
|
||||
private Resolved remember(List<IrisBiome> lineage, IrisRegion region, Resolved resolved) {
|
||||
synchronized (lock) {
|
||||
IdentityHashMap<IrisRegion, Resolved> current = overrides.get(biome);
|
||||
IdentityHashMap<IrisRegion, Resolved> current = overrides.get(lineage);
|
||||
Resolved raced = current == null ? null : current.get(region);
|
||||
if (raced != null) {
|
||||
return raced;
|
||||
}
|
||||
IdentityHashMap<IrisBiome, IdentityHashMap<IrisRegion, Resolved>> next = new IdentityHashMap<>(overrides);
|
||||
IdentityHashMap<List<IrisBiome>, IdentityHashMap<IrisRegion, Resolved>> next = new IdentityHashMap<>(overrides);
|
||||
IdentityHashMap<IrisRegion, Resolved> regions = current == null ? new IdentityHashMap<>() : new IdentityHashMap<>(current);
|
||||
regions.put(region, resolved);
|
||||
next.put(biome, regions);
|
||||
next.put(lineage, regions);
|
||||
overrides = next;
|
||||
return resolved;
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(exclude = {"data", "gridBoundsCache", "sharedCornerBounds", "sharedBaseHeights", "sharedBoundsBiomes", "regionBounds", "contextRegionStream", "terrainProgram", "bakeCache", "regionSource", "baseBiomeSource", "caveSource", "rockSource", "fluidSource", "childStyleSeed", "inferredByType", "naturalHeightSource", "naturalTrueBiomeSource", "trueBiomeSource", "frozenInterpolators", "frozenGenerators", "inferredBiomeStreams", "imageMapRuntime", "terrainEngine", "terrain3D", "hydrologyRuntime", "shoreBiomes", "waterVegetation", "effectiveChunks"})
|
||||
@ToString(exclude = {"data", "gridBoundsCache", "sharedCornerBounds", "sharedBaseHeights", "sharedBoundsBiomes", "regionBounds", "contextRegionStream", "terrainProgram", "bakeCache", "regionSource", "baseBiomeSource", "caveSource", "rockSource", "fluidSource", "childStyleSeed", "inferredByType", "naturalHeightSource", "naturalTrueBiomeSource", "trueBiomeSource", "frozenInterpolators", "frozenGenerators", "inferredBiomeStreams", "imageMapRuntime", "terrainEngine", "terrain3D", "hydrologyRuntime", "shoreBiomes", "waterVegetation", "effectiveChunks"})
|
||||
@EqualsAndHashCode(exclude = {"data", "gridBoundsCache", "sharedCornerBounds", "sharedBaseHeights", "sharedBoundsBiomes", "regionBounds", "contextRegionStream", "terrainProgram", "bakeCache", "regionSource", "baseBiomeSource", "caveSource", "rockSource", "fluidSource", "childStyleSeed", "inferredByType", "naturalHeightSource", "naturalTrueBiomeSource", "trueBiomeSource", "frozenInterpolators", "frozenGenerators", "inferredBiomeStreams", "imageMapRuntime", "terrainEngine", "terrain3D", "hydrologyRuntime", "shoreBiomes", "waterVegetation", "effectiveChunks", "biomeLineages"})
|
||||
@ToString(exclude = {"data", "gridBoundsCache", "sharedCornerBounds", "sharedBaseHeights", "sharedBoundsBiomes", "regionBounds", "contextRegionStream", "terrainProgram", "bakeCache", "regionSource", "baseBiomeSource", "caveSource", "rockSource", "fluidSource", "childStyleSeed", "inferredByType", "naturalHeightSource", "naturalTrueBiomeSource", "trueBiomeSource", "frozenInterpolators", "frozenGenerators", "inferredBiomeStreams", "imageMapRuntime", "terrainEngine", "terrain3D", "hydrologyRuntime", "shoreBiomes", "waterVegetation", "effectiveChunks", "biomeLineages"})
|
||||
public class IrisComplex implements DataProvider {
|
||||
private static final NoiseBounds ZERO_NOISE_BOUNDS = new NoiseBounds(0D, 0D);
|
||||
private static final long NEGATIVE_ZERO_BITS = Double.doubleToRawLongBits(-0D);
|
||||
@@ -147,6 +147,7 @@ public class IrisComplex implements DataProvider {
|
||||
IrisGenerator::getLoadKey,
|
||||
Comparator.nullsFirst(Comparator.naturalOrder())
|
||||
);
|
||||
private static final int CHILD_HOPS = 4;
|
||||
private static final ThreadLocal<TerrainBatchScratch> BATCH_SCRATCH = ThreadLocal.withInitial(TerrainBatchScratch::new);
|
||||
private static final InferredType[] INFERRED_BIOME_PREPARATION_ORDER = {
|
||||
InferredType.LAND,
|
||||
@@ -277,6 +278,9 @@ public class IrisComplex implements DataProvider {
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient HydrologyShoreBiomes shoreBiomes;
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient BiomeLineages biomeLineages;
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient SubterrainPlanner subterrainPlanner;
|
||||
private transient IrisImageMapRuntime imageMapRuntime;
|
||||
@@ -494,6 +498,7 @@ public class IrisComplex implements DataProvider {
|
||||
Interpolated.of(value -> 0D, value -> null));
|
||||
naturalTrueBiomeStream = new BakedStream<>(bakeCache, BakePlane.NATURAL_TRUE_BIOME, naturalTrueBiomeSource);
|
||||
shoreBiomes = new HydrologyShoreBiomes(engine.getDimension(), data, engine.getSeedManager().getBodies());
|
||||
biomeLineages = BiomeLineages.compile(focusedBiomes == null ? baseCapableBiomes(preparedRegions) : List.of(), this);
|
||||
hydrologyRuntime = HydrologyRuntime.create(engine, this);
|
||||
waterFluidStreams = hydrologyRuntime.enabled() ? createWaterFluidStreams(hydrologyRuntime.settings().fluids(), hydrologyRuntime.settings().seams().values()) : Map.of();
|
||||
pondMaterials = hydrologyRuntime.enabled() ? hydrologyRuntime.settings().ponds().materials() : null;
|
||||
@@ -1400,7 +1405,16 @@ public class IrisComplex implements DataProvider {
|
||||
return HydrologyVegetation.Decorators.EMPTY;
|
||||
}
|
||||
HydrologyTier tier = chunkRasterAt(x, z).tier(x & 15, z & 15);
|
||||
return waterVegetation.decorators(tier, baseBiomeStream.get(x, z), regionStream.get(x, z));
|
||||
return waterVegetation.decorators(tier, baseBiomeLineage(x, z), regionStream.get(x, z));
|
||||
}
|
||||
|
||||
public List<IrisBiome> baseBiomeLineage(int x, int z) {
|
||||
IrisBiome biome = baseBiomeStream.get(x, z);
|
||||
if (!biomeLineages.inherits(biome)
|
||||
|| imageMapRuntime.has(IrisImageMapApplication.BIOME) && imageMapRuntime.sampleBiome(x, z) != null) {
|
||||
return biomeLineages.root(biome);
|
||||
}
|
||||
return childLineage(biome, x, z);
|
||||
}
|
||||
|
||||
private ChunkWaterRaster chunkRasterAt(int blockX, int blockZ) {
|
||||
@@ -1810,7 +1824,7 @@ public class IrisComplex implements DataProvider {
|
||||
|| seamWeight(blockX, blockZ) == 0D) {
|
||||
return null;
|
||||
}
|
||||
IrisBiome shore = shoreBiomes.select(baseBiomeStream.get(x, z), regionStream.get(x, z), blockX, blockZ, distance);
|
||||
IrisBiome shore = shoreBiomes.select(baseBiomeLineage(blockX, blockZ), regionStream.get(x, z), blockX, blockZ, distance);
|
||||
return shore == null ? null : implode(shore, x, z);
|
||||
}
|
||||
|
||||
@@ -2486,7 +2500,7 @@ public class IrisComplex implements DataProvider {
|
||||
return b;
|
||||
}
|
||||
|
||||
return implode(b, x, z, 3);
|
||||
return implode(b, x, z, CHILD_HOPS - 1);
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, double x, double z, int max) {
|
||||
@@ -2498,15 +2512,42 @@ public class IrisComplex implements DataProvider {
|
||||
return b;
|
||||
}
|
||||
|
||||
CNG childCell = b.getChildrenGenerator(childStyleSeed, b.getChildShrinkFactor());
|
||||
ChildSelectionPlan childSelectionPlan = resolveChildSelectionPlan(b);
|
||||
IrisBiome biome = childSelectionPlan.select(childCell, x, z).withInferredType(b.getInferredType());
|
||||
IrisBiome biome = pickChild(b, x, z);
|
||||
if (biome == b && hasFixedNoise(b.getChildStyle())) {
|
||||
return biome;
|
||||
}
|
||||
return implode(biome, x, z, max - 1);
|
||||
}
|
||||
|
||||
private IrisBiome pickChild(IrisBiome parent, double x, double z) {
|
||||
CNG childCell = parent.getChildrenGenerator(childStyleSeed, parent.getChildShrinkFactor());
|
||||
return resolveChildSelectionPlan(parent).select(childCell, x, z).withInferredType(parent.getInferredType());
|
||||
}
|
||||
|
||||
private List<IrisBiome> childLineage(IrisBiome biome, int x, int z) {
|
||||
IrisBiome[] rootFirst = new IrisBiome[CHILD_HOPS + 1];
|
||||
IrisBiome current = inferredByType.get(bridgeStream.get(x, z)).get(x, z);
|
||||
rootFirst[0] = current;
|
||||
int size = 1;
|
||||
for (int hop = 0; hop < CHILD_HOPS && !current.getChildren().isEmpty(); hop++) {
|
||||
IrisBiome picked = pickChild(current, x, z);
|
||||
if (picked == current) {
|
||||
break;
|
||||
}
|
||||
rootFirst[size++] = picked;
|
||||
current = picked;
|
||||
}
|
||||
if (current != biome) {
|
||||
throw new IllegalStateException("The child chain at " + x + "," + z + " ends at biome " + current.getLoadKey()
|
||||
+ ", but the base biome there is " + biome.getLoadKey());
|
||||
}
|
||||
IrisBiome[] leafFirst = new IrisBiome[size];
|
||||
for (int index = 0; index < size; index++) {
|
||||
leafFirst[index] = rootFirst[size - 1 - index];
|
||||
}
|
||||
return biomeLineages.chain(leafFirst);
|
||||
}
|
||||
|
||||
static boolean hasFixedNaturalBiomeNoise(IrisDimension dimension, Iterable<IrisBiome> biomes) {
|
||||
if (!hasFixedNoise(dimension.getRegionStyle()) || !hasFixedNoise(dimension.getContinentalStyle())
|
||||
|| !hasFixedNoise(dimension.getLandBiomeStyle()) || !hasFixedNoise(dimension.getSeaBiomeStyle())) {
|
||||
|
||||
+5
-2
@@ -292,10 +292,13 @@ public final class RiverCompiler {
|
||||
return new Field.Binary(Field.BinaryOp.MAX, first, second);
|
||||
}
|
||||
|
||||
public record Area(IrisRegion region, IrisBiome biome) {
|
||||
public record Area(IrisRegion region, List<IrisBiome> biomes) {
|
||||
public Area {
|
||||
Objects.requireNonNull(region, "region");
|
||||
Objects.requireNonNull(biome, "biome");
|
||||
biomes = List.copyOf(biomes);
|
||||
if (biomes.isEmpty()) {
|
||||
throw new IllegalArgumentException("A river area in region " + region.getLoadKey() + " needs a biome");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -1,5 +1,6 @@
|
||||
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.IrisDecorator;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPermission;
|
||||
@@ -165,9 +166,11 @@ final class RiverLimits {
|
||||
}
|
||||
|
||||
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);
|
||||
for (IrisBiome biome : area.biomes()) {
|
||||
T value = value(biome.getHydrologyPolicy(), field);
|
||||
if (value != null) {
|
||||
return new Sourced<>(new Owner(Owner.BIOME, "biomes/" + biome.getLoadKey()), value);
|
||||
}
|
||||
}
|
||||
T region = value(area.region().getHydrologyPolicy(), field);
|
||||
if (region != null) {
|
||||
|
||||
+40
-22
@@ -7,11 +7,9 @@ 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;
|
||||
@@ -20,6 +18,7 @@ import java.util.TreeMap;
|
||||
|
||||
public final class RiverStage implements CompileStage {
|
||||
private static final String ESTIMATE_TAG = "estimate";
|
||||
private static final int MAX_CHILD_HOPS = 4;
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
@@ -46,32 +45,51 @@ public final class RiverStage implements CompileStage {
|
||||
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));
|
||||
for (List<IrisBiome> lineage : lineages(region, data, exported)) {
|
||||
areas.add(new RiverCompiler.Area(region, lineage));
|
||||
}
|
||||
}
|
||||
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;
|
||||
private static Collection<List<IrisBiome>> lineages(IrisRegion region, IrisData data, Set<String> exported) {
|
||||
List<String> roots = new ArrayList<>();
|
||||
roots.addAll(region.getLandBiomes());
|
||||
roots.addAll(region.getSeaBiomes());
|
||||
roots.addAll(region.getShoreBiomes());
|
||||
SortedMap<String, List<IrisBiome>> lineages = new TreeMap<>();
|
||||
for (String key : roots) {
|
||||
IrisBiome root = exportedBiome(key, data, exported);
|
||||
if (root != null) {
|
||||
addLineages(List.of(root), data, exported, lineages);
|
||||
}
|
||||
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();
|
||||
return lineages.values();
|
||||
}
|
||||
|
||||
private static void addLineages(List<IrisBiome> leafFirst, IrisData data, Set<String> exported, SortedMap<String, List<IrisBiome>> lineages) {
|
||||
StringBuilder key = new StringBuilder(leafFirst.getFirst().getLoadKey());
|
||||
for (int index = 1; index < leafFirst.size(); index++) {
|
||||
key.append('<').append(leafFirst.get(index).getLoadKey());
|
||||
}
|
||||
if (lineages.putIfAbsent(key.toString(), leafFirst) != null || leafFirst.size() > MAX_CHILD_HOPS) {
|
||||
return;
|
||||
}
|
||||
IrisBiome leaf = leafFirst.getFirst();
|
||||
for (String childKey : leaf.getChildren()) {
|
||||
IrisBiome child = exportedBiome(childKey, data, exported);
|
||||
if (child == null || child.getLoadKey().equals(leaf.getLoadKey())) {
|
||||
continue;
|
||||
}
|
||||
List<IrisBiome> lineage = new ArrayList<>(leafFirst.size() + 1);
|
||||
lineage.add(child);
|
||||
lineage.addAll(leafFirst);
|
||||
addLineages(List.copyOf(lineage), data, exported, lineages);
|
||||
}
|
||||
}
|
||||
|
||||
private static IrisBiome exportedBiome(String key, IrisData data, Set<String> exported) {
|
||||
IrisBiome biome = key == null ? null : data.getBiomeLoader().load(key);
|
||||
return biome == null || biome.isCompatExcluded() || !exported.contains(biome.getLoadKey()) ? null : biome;
|
||||
}
|
||||
}
|
||||
@@ -108,11 +108,17 @@ final class EngineFixture implements AutoCloseable {
|
||||
+ ",\"seed\":" + Math.abs(key.hashCode()) + ",\"composite\":" + composite.strip() + "}");
|
||||
}
|
||||
|
||||
private static void biome(Path pack, String key, String generators, String extra) throws IOException {
|
||||
static void biome(Path pack, String key, String generators, String extra) throws IOException {
|
||||
Files.writeString(pack.resolve("biomes/" + key + ".json"), "{\"layers\":[{\"palette\":[{\"block\":\"minecraft:stone\"}]}],\"generators\":"
|
||||
+ generators + extra.strip() + "}");
|
||||
}
|
||||
|
||||
static void extend(Path pack, String key, String extra) throws IOException {
|
||||
Path file = pack.resolve("biomes/" + key + ".json");
|
||||
String json = Files.readString(file).strip();
|
||||
Files.writeString(file, json.substring(0, json.length() - 1) + extra.strip() + "}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
complex.close();
|
||||
|
||||
+69
@@ -3,6 +3,8 @@ package art.arcane.iris.generation.hydrology.engine;
|
||||
import art.arcane.iris.generation.bake.BakePlane;
|
||||
import art.arcane.iris.generation.bake.ChunkBakeCache;
|
||||
import art.arcane.iris.generation.bake.GeneratorEvaluations;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisFluidProfile;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||
import art.arcane.iris.generation.hydrology.grid.HeightLattice;
|
||||
@@ -10,6 +12,7 @@ import art.arcane.iris.generation.hydrology.grid.HydrologySampleBuffer;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.stream.ChunkFillableDoubleStream2D;
|
||||
import art.arcane.iris.generation.terrain.InferredType;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.testsupport.PlatformLeakGuard;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
@@ -175,6 +178,72 @@ public class IrisHydrologyTerrainSourceTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void childBiomesInheritTheParentPolicy() throws Exception {
|
||||
Path pack = EngineFixture.pack(temporaryFolder.newFolder().toPath(), false);
|
||||
EngineFixture.extend(pack, "peaks", ",\"hydrologyPolicy\":{\"pondDensity\":5,\"streams\":\"ALLOW\",\"fluid\":\"lava\"}");
|
||||
EngineFixture.extend(pack, "meadow", ",\"children\":[\"glade\"],\"childShrinkFactor\":2.5");
|
||||
EngineFixture.biome(pack, "glade", "[{\"generator\":\"plain\",\"min\":4,\"max\":10}]", "");
|
||||
int side = 96;
|
||||
int[] xs = new int[side * side];
|
||||
int[] zs = new int[side * side];
|
||||
for (int index = 0; index < xs.length; index++) {
|
||||
xs[index] = (index % side) * 9 - 432;
|
||||
zs[index] = (index / side) * 9 - 432;
|
||||
}
|
||||
pool = Executors.newFixedThreadPool(4);
|
||||
try (EngineFixture.Environment ignored = EngineFixture.environment(); EngineFixture fixture = new EngineFixture(pack)) {
|
||||
IrisHydrology config = new IrisHydrology().setEnabled(true).setPersist(false);
|
||||
config.getFluids().add(new IrisFluidProfile().setName("lava").setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:lava")));
|
||||
HydrologySettings settings = HydrologySettings.compile(config, EngineFixture.SEED, fixture.dimension.getFluidHeight(), 0,
|
||||
EngineFixture.HEIGHT);
|
||||
IrisHydrologyTerrainSource source = new IrisHydrologyTerrainSource(fixture.complex, fixture.dimension, settings, null, 1,
|
||||
HydrologyBinding.UNBOUND);
|
||||
HydrologySampleBuffer samples = new HydrologySampleBuffer(xs.length);
|
||||
source.sample(xs, zs, samples, false);
|
||||
HydrologySampleBuffer pooled = new HydrologySampleBuffer(xs.length);
|
||||
new IrisHydrologyTerrainSource(fixture.complex, fixture.dimension, settings, pool, 4, HydrologyBinding.UNBOUND).sample(xs, zs, pooled, false);
|
||||
assertSameSamples(samples, pooled, xs.length);
|
||||
Map<String, Integer> chains = new HashMap<>();
|
||||
for (int index = 0; index < xs.length; index++) {
|
||||
int x = xs[index];
|
||||
int z = zs[index];
|
||||
String chain = chain(fixture, x, z);
|
||||
boolean alpha = fixture.complex.getRegionStream().get(x, z).getLoadKey().equals("alpha");
|
||||
boolean peaks = chain.contains("peaks");
|
||||
boolean meadow = chain.contains("meadow");
|
||||
String at = chain + "@" + (alpha ? "alpha" : "beta") + " " + x + "," + z;
|
||||
chains.merge(chain + "@" + (alpha ? "alpha" : "beta"), 1, Integer::sum);
|
||||
assertEquals(at, meadow ? 2f : 0.5f, samples.rainfall()[index], 0f);
|
||||
assertEquals(at, peaks ? 5f : alpha ? 3f : 1f, samples.pondDensity()[index], 0f);
|
||||
int permission = (peaks || !alpha ? HydrologySampleBuffer.ALLOW_STREAMS : 0) | (meadow ? 0 : HydrologySampleBuffer.ALLOW_PONDS);
|
||||
assertEquals(at, permission, samples.permission()[index]);
|
||||
String fluid = peaks ? "lava" : alpha ? "water" : null;
|
||||
assertEquals(at, fluid, samples.fluidProfile()[index]);
|
||||
assertEquals(at, fluid, source.channelFluid(x, z));
|
||||
}
|
||||
assertTrue("sampled chains " + chains, chains.containsKey("meadow<peaks@alpha") && chains.containsKey("glade<meadow<peaks@alpha")
|
||||
&& chains.containsKey("meadow@alpha") && chains.containsKey("meadow@beta") && chains.containsKey("glade<meadow@beta")
|
||||
&& chains.containsKey("peaks@alpha"));
|
||||
}
|
||||
}
|
||||
|
||||
private static String chain(EngineFixture fixture, int x, int z) {
|
||||
IrisBiome leaf = fixture.complex.getBaseBiomeStream().get(x, z);
|
||||
boolean sea = fixture.complex.getBridgeStream().get(x, z) == InferredType.SEA;
|
||||
IrisBiome root = (sea ? fixture.complex.getSeaBiomeStream() : fixture.complex.getLandBiomeStream()).get(x, z);
|
||||
String pair = root.getLoadKey() + ">" + leaf.getLoadKey();
|
||||
return switch (pair) {
|
||||
case "peaks>meadow" -> "meadow<peaks";
|
||||
case "peaks>glade" -> "glade<meadow<peaks";
|
||||
case "meadow>glade" -> "glade<meadow";
|
||||
default -> {
|
||||
assertEquals("a biome outside the child chains at " + x + "," + z, root.getLoadKey(), leaf.getLoadKey());
|
||||
yield leaf.getLoadKey();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void assertUnknownFluidRejected(EngineFixture fixture, HydrologySettings settings, int[] xs, int[] zs) {
|
||||
IrisRegion beta = fixture.data.getRegionLoader().load("beta");
|
||||
beta.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("slime"));
|
||||
|
||||
@@ -256,6 +256,18 @@ public class MantleCarvedTerrainTest {
|
||||
poolFluids(poolRoom(new Underground(plains, biome("carving/deep-magma", 24, "lava"), temperate, new IrisDimension())).generate(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void caveBiomesTakeNoFluidFromBiomesThatListThemAsChildren() {
|
||||
IrisBiome volcanic = biome("tropical/volcanic-plains", 0, "lava").setChildren(new KList<>("carving/hollow"));
|
||||
IrisBiome magma = biome("carving/magma", 0, "lava").setChildren(new KList<>("carving/hollow"));
|
||||
IrisBiome hollow = biome("carving/hollow", 0, null);
|
||||
|
||||
assertEquals("a cave biome under a surface parent that names lava", Set.of("water"),
|
||||
poolFluids(poolRoom(new Underground(volcanic, hollow, region("temperate", null), new IrisDimension())).generate(0)));
|
||||
assertEquals("the parent itself still fills its own pools", Set.of("lava"),
|
||||
poolFluids(poolRoom(new Underground(volcanic, magma, region("temperate", null), new IrisDimension())).generate(0)));
|
||||
}
|
||||
|
||||
private static Scene poolRoom(Underground underground) {
|
||||
Scene scene = new Scene(underground);
|
||||
Matter[] room = scene.chunk(0, 0);
|
||||
|
||||
+19
-15
@@ -75,23 +75,26 @@ public class HydrologyVegetationSourceTest {
|
||||
HydrologyVegetationSource source = HydrologyVegetationSource.create(dimension, settings, data, List.of(plain, marsh),
|
||||
List.of(meadow, bog, desert));
|
||||
|
||||
assertEquals("minecraft:fern", grown(source.decorators(river, meadow, plain)));
|
||||
assertEquals("minecraft:air", grown(source.decorators(stream, meadow, plain)));
|
||||
assertEquals("minecraft:short_grass", grown(source.decorators(null, meadow, plain)));
|
||||
assertEquals("minecraft:poppy", grown(source.decorators(river, meadow, marsh)));
|
||||
assertEquals("minecraft:poppy", grown(source.decorators(null, meadow, marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(source.decorators(river, bog, marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(source.decorators(null, bog, plain)));
|
||||
assertSame(HydrologyVegetation.Decorators.EMPTY, source.decorators(river, desert, marsh));
|
||||
assertEquals("minecraft:fern", grown(source.decorators(river, List.of(meadow), plain)));
|
||||
assertEquals("minecraft:air", grown(source.decorators(stream, List.of(meadow), plain)));
|
||||
assertEquals("minecraft:short_grass", grown(source.decorators(null, List.of(meadow), plain)));
|
||||
assertEquals("minecraft:poppy", grown(source.decorators(river, List.of(meadow), marsh)));
|
||||
assertEquals("minecraft:poppy", grown(source.decorators(null, List.of(meadow), marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(source.decorators(river, List.of(bog), marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(source.decorators(null, List.of(bog), plain)));
|
||||
assertSame(HydrologyVegetation.Decorators.EMPTY, source.decorators(river, List.of(desert), marsh));
|
||||
assertEquals("a child biome takes its parent's list", "minecraft:dandelion", grown(source.decorators(river, List.of(meadow, bog), plain)));
|
||||
assertSame("a child's own empty list wins over its parent", HydrologyVegetation.Decorators.EMPTY,
|
||||
source.decorators(river, List.of(desert, bog), plain));
|
||||
|
||||
dimension.setHydrologyPolicy(policy(shore("minecraft:dead_bush")));
|
||||
HydrologyVegetationSource dimensional = HydrologyVegetationSource.create(dimension, settings, data, List.of(plain, marsh),
|
||||
List.of(meadow, bog, desert));
|
||||
assertEquals("minecraft:dead_bush", grown(dimensional.decorators(river, meadow, plain)));
|
||||
assertEquals("minecraft:dead_bush", grown(dimensional.decorators(null, meadow, plain)));
|
||||
assertEquals("minecraft:poppy", grown(dimensional.decorators(river, meadow, marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(dimensional.decorators(river, bog, marsh)));
|
||||
assertSame(HydrologyVegetation.Decorators.EMPTY, HydrologyVegetationSource.NONE.decorators(river, bog, marsh));
|
||||
assertEquals("minecraft:dead_bush", grown(dimensional.decorators(river, List.of(meadow), plain)));
|
||||
assertEquals("minecraft:dead_bush", grown(dimensional.decorators(null, List.of(meadow), plain)));
|
||||
assertEquals("minecraft:poppy", grown(dimensional.decorators(river, List.of(meadow), marsh)));
|
||||
assertEquals("minecraft:dandelion", grown(dimensional.decorators(river, List.of(bog), marsh)));
|
||||
assertSame(HydrologyVegetation.Decorators.EMPTY, HydrologyVegetationSource.NONE.decorators(river, List.of(bog), marsh));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -140,6 +143,7 @@ public class HydrologyVegetationSourceTest {
|
||||
HydrologyVegetationSource source = HydrologyVegetationSource.create(new IrisDimension(), settings, data, List.of(plain), List.of());
|
||||
IrisBiome unseen = new IrisBiome();
|
||||
unseen.setHydrologyPolicy(policy(shore("minecraft:dandelion")));
|
||||
List<IrisBiome> lineage = List.of(unseen);
|
||||
int threads = 8;
|
||||
CyclicBarrier start = new CyclicBarrier(threads);
|
||||
ExecutorService pool = Executors.newFixedThreadPool(threads);
|
||||
@@ -148,7 +152,7 @@ public class HydrologyVegetationSourceTest {
|
||||
for (int thread = 0; thread < threads; thread++) {
|
||||
results.add(pool.submit(() -> {
|
||||
start.await();
|
||||
return source.decorators(settings.tiers().get(1), unseen, plain);
|
||||
return source.decorators(settings.tiers().get(1), lineage, plain);
|
||||
}));
|
||||
}
|
||||
HydrologyVegetation.Decorators first = results.get(0).get(30, TimeUnit.SECONDS);
|
||||
@@ -156,7 +160,7 @@ public class HydrologyVegetationSourceTest {
|
||||
assertSame(first, result.get(30, TimeUnit.SECONDS));
|
||||
}
|
||||
assertEquals("minecraft:dandelion", grown(first));
|
||||
assertSame(first, source.decorators(null, unseen, plain));
|
||||
assertSame(first, source.decorators(null, lineage, plain));
|
||||
} finally {
|
||||
pool.shutdownNow();
|
||||
}
|
||||
|
||||
+25
-9
@@ -27,6 +27,7 @@ import org.junit.rules.TemporaryFolder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -135,14 +136,24 @@ public class IrisComplexSurfaceBiomeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shorePolicyInheritsBiomeThenRegionThenDimension() {
|
||||
public void shorePolicyInheritsBiomeThenParentsThenRegionThenDimension() {
|
||||
ShorePolicyPack pack = new ShorePolicyPack();
|
||||
assertEquals("dune", shoreSelect(pack, 1).getLoadKey());
|
||||
pack.region.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("sand")));
|
||||
assertEquals("sand", shoreSelect(pack, 4).getLoadKey());
|
||||
assertNull(shoreSelect(pack, 5));
|
||||
pack.inland.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("gravel")).setShoreBiomeWidth(8));
|
||||
assertEquals("gravel", shoreSelect(pack, 8).getLoadKey());
|
||||
IrisBiome parent = pack.biome("highland");
|
||||
parent.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("gravel")).setShoreBiomeWidth(6));
|
||||
IrisBiome grandparent = pack.biome("upland");
|
||||
grandparent.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("dune")).setShoreBiomeWidth(8));
|
||||
List<IrisBiome> child = List.of(pack.inland, parent, grandparent);
|
||||
assertEquals("gravel", shoreSelect(pack, child, 6).getLoadKey());
|
||||
assertNull(shoreSelect(pack, child, 7));
|
||||
parent.getHydrologyPolicy().setShoreBiomeWidth(null);
|
||||
assertEquals("gravel", shoreSelect(pack, child, 8).getLoadKey());
|
||||
pack.inland.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("sand")).setShoreBiomeWidth(8));
|
||||
assertEquals("sand", shoreSelect(pack, 8).getLoadKey());
|
||||
assertEquals("sand", shoreSelect(pack, child, 8).getLoadKey());
|
||||
assertSame(InferredType.SHORE, shoreSelect(pack, 8).getInferredType());
|
||||
}
|
||||
|
||||
@@ -152,8 +163,8 @@ public class IrisComplexSurfaceBiomeTest {
|
||||
pack.region.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>()));
|
||||
assertNull(shoreSelect(pack, 1));
|
||||
pack.region.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomeWidth(0));
|
||||
assertNull(new HydrologyShoreBiomes(pack.dimension, pack.data, 7L).select(pack.inland, pack.region, 0, 0, 1));
|
||||
assertNull(new HydrologyShoreBiomes(new IrisDimension(), pack.data, 7L).select(pack.inland, new IrisRegion(), 0, 0, 1));
|
||||
assertNull(new HydrologyShoreBiomes(pack.dimension, pack.data, 7L).select(List.of(pack.inland), pack.region, 0, 0, 1));
|
||||
assertNull(new HydrologyShoreBiomes(new IrisDimension(), pack.data, 7L).select(List.of(pack.inland), new IrisRegion(), 0, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,11 +173,12 @@ public class IrisComplexSurfaceBiomeTest {
|
||||
pack.region.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("sand", "dune", "gravel")));
|
||||
HydrologyShoreBiomes shores = new HydrologyShoreBiomes(pack.dimension, pack.data, 7L);
|
||||
HydrologyShoreBiomes again = new HydrologyShoreBiomes(pack.dimension, pack.data, 7L);
|
||||
List<IrisBiome> inland = List.of(pack.inland);
|
||||
Set<String> picked = new HashSet<>();
|
||||
for (int patch = -8; patch < 8; patch++) {
|
||||
IrisBiome first = shores.select(pack.inland, pack.region, patch * 64, 0, 2);
|
||||
assertEquals(first.getLoadKey(), shores.select(pack.inland, pack.region, patch * 64 + 63, 63, 2).getLoadKey());
|
||||
assertEquals(first.getLoadKey(), again.select(pack.inland, pack.region, patch * 64 + 17, 40, 1).getLoadKey());
|
||||
IrisBiome first = shores.select(inland, pack.region, patch * 64, 0, 2);
|
||||
assertEquals(first.getLoadKey(), shores.select(inland, pack.region, patch * 64 + 63, 63, 2).getLoadKey());
|
||||
assertEquals(first.getLoadKey(), again.select(inland, pack.region, patch * 64 + 17, 40, 1).getLoadKey());
|
||||
picked.add(first.getLoadKey());
|
||||
}
|
||||
assertTrue(picked.toString(), picked.size() > 1);
|
||||
@@ -181,7 +193,11 @@ public class IrisComplexSurfaceBiomeTest {
|
||||
}
|
||||
|
||||
private static IrisBiome shoreSelect(ShorePolicyPack pack, int distance) {
|
||||
return new HydrologyShoreBiomes(pack.dimension, pack.data, 7L).select(pack.inland, pack.region, 10, 20, distance);
|
||||
return shoreSelect(pack, List.of(pack.inland), distance);
|
||||
}
|
||||
|
||||
private static IrisBiome shoreSelect(ShorePolicyPack pack, List<IrisBiome> lineage, int distance) {
|
||||
return new HydrologyShoreBiomes(pack.dimension, pack.data, 7L).select(lineage, pack.region, 10, 20, distance);
|
||||
}
|
||||
|
||||
private static final class ShorePolicyPack {
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ import java.lang.reflect.Field;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -101,7 +102,7 @@ public class IrisEngineGenerationRuntimeScopeTest {
|
||||
when(historical.target.getWorld().getHeight()).thenReturn(384);
|
||||
IrisBiome biome = new IrisBiome();
|
||||
IrisRegion region = new IrisRegion();
|
||||
when(historicalComplex.getBaseBiomeStream()).thenReturn(ProceduralStream.of((x, z) -> biome, Interpolated.of(value -> 0D, value -> biome)));
|
||||
when(historicalComplex.baseBiomeLineage(anyInt(), anyInt())).thenReturn(List.of(biome));
|
||||
when(historicalComplex.getRegionStream()).thenReturn(ProceduralStream.of((x, z) -> region, Interpolated.of(value -> 0D, value -> region)));
|
||||
when(historicalComplex.getBridgeStream()).thenReturn(ProceduralStream.of((x, z) -> InferredType.LAND,
|
||||
Interpolated.of(value -> 0D, value -> InferredType.LAND)));
|
||||
|
||||
+37
-20
@@ -187,9 +187,9 @@ public class RiverCompilerTest {
|
||||
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)));
|
||||
new RiverCompiler.Area(region("tropical", null), List.of(volcano)),
|
||||
new RiverCompiler.Area(region("hot", null), List.of(volcano)),
|
||||
new RiverCompiler.Area(region("hot", null), List.of(biome("plains", null))));
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), withLava(overworldHydrology()), areas, diagnostics);
|
||||
|
||||
@@ -201,6 +201,23 @@ public class RiverCompilerTest {
|
||||
assertTrue(fluids.getFirst().message(), fluids.getFirst().message().contains("minecraft:water"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void childBiomesInheritTheParentLava() {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
IrisBiome plains = biome("tropical/volcanic-plains", new IrisHydrologyPolicy().setFluid("lava"));
|
||||
IrisBiome cone = biome("tropical/cone", new IrisHydrologyPolicy().setRainfall(1.0));
|
||||
IrisBiome spring = biome("tropical/spring", new IrisHydrologyPolicy().setFluid("water"));
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), withLava(overworldHydrology()), List.of(
|
||||
new RiverCompiler.Area(region("tropical", null), List.of(cone, plains)),
|
||||
new RiverCompiler.Area(region("tropical", null), List.of(spring, plains))), diagnostics);
|
||||
|
||||
List<ExportDiagnostic> fluids = limited(diagnostics, ExportLimit.RIVER_FLUID);
|
||||
assertEquals(diagnostics.toString(), 1, fluids.size());
|
||||
assertEquals("biomes/tropical/volcanic-plains", fluids.getFirst().resource());
|
||||
assertTrue(fluids.getFirst().message(), fluids.getFirst().message().contains("'lava'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lavaTiersReportTheirFluidAndSeamOnTheHydrology() {
|
||||
List<ExportDiagnostic> diagnostics = new ArrayList<>();
|
||||
@@ -211,7 +228,7 @@ public class RiverCompilerTest {
|
||||
tier.setFluid("lava");
|
||||
}
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region("region", null), biome("plains", null))), diagnostics);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region("region", null), List.of(biome("plains", null)))), diagnostics);
|
||||
|
||||
List<ExportDiagnostic> fluids = limited(diagnostics, ExportLimit.RIVER_FLUID);
|
||||
assertEquals(diagnostics.toString(), 1, fluids.size());
|
||||
@@ -226,7 +243,7 @@ public class RiverCompilerTest {
|
||||
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);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region("region", null), List.of(biome("plains", null)))), diagnostics);
|
||||
|
||||
List<ExportDiagnostic> fluids = limited(diagnostics, ExportLimit.RIVER_FLUID);
|
||||
assertEquals(diagnostics.toString(), 1, fluids.size());
|
||||
@@ -237,7 +254,7 @@ public class RiverCompilerTest {
|
||||
@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));
|
||||
List<RiverCompiler.Area> areas = List.of(new RiverCompiler.Area(region("region", null), List.of(acid)));
|
||||
|
||||
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
|
||||
() -> compile(new Field.Const(SEA_LEVEL + 2.0), overworldHydrology(), areas, new ArrayList<>()));
|
||||
@@ -264,7 +281,7 @@ public class RiverCompilerTest {
|
||||
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);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), withLava(overworldHydrology()), List.of(new RiverCompiler.Area(region("region", null), List.of(wet))), water);
|
||||
|
||||
List<ExportDiagnostic> lava = new ArrayList<>();
|
||||
IrisHydrology molten = withLava(overworldHydrology());
|
||||
@@ -273,7 +290,7 @@ public class RiverCompilerTest {
|
||||
}
|
||||
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))),
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), nether, List.of(new RiverCompiler.Area(region("region", null), List.of(biome("plains", null)))),
|
||||
registry(), DataVersion.V26_3, lava);
|
||||
|
||||
assertTrue(water.toString(), limited(water, ExportLimit.RIVER_FLUID).isEmpty());
|
||||
@@ -288,7 +305,7 @@ public class RiverCompilerTest {
|
||||
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)),
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), dimension, List.of(new RiverCompiler.Area(hot, List.of(deep)), new RiverCompiler.Area(hot, List.of(neutral))),
|
||||
registry(), DataVersion.V26_3, diagnostics);
|
||||
|
||||
List<ExportDiagnostic> policies = limited(diagnostics, ExportLimit.RIVER_POLICY);
|
||||
@@ -301,11 +318,11 @@ public class RiverCompilerTest {
|
||||
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);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region("region", null), List.of(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);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(everywhere, List.of(biome("plains", null)))), exempt);
|
||||
|
||||
List<ExportDiagnostic> climate = limited(zoned, ExportLimit.RIVER_CLIMATE);
|
||||
assertEquals(zoned.toString(), 1, climate.size());
|
||||
@@ -318,8 +335,8 @@ public class RiverCompilerTest {
|
||||
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)));
|
||||
new RiverCompiler.Area(region("banked", new IrisHydrologyPolicy().setShoreBiomeWidth(4)), List.of(biome("plains", null))),
|
||||
new RiverCompiler.Area(region("bare", null), List.of(biome("plains", null))));
|
||||
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), dimension, areas, registry(), DataVersion.V26_3, diagnostics);
|
||||
|
||||
@@ -339,10 +356,10 @@ public class RiverCompilerTest {
|
||||
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);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region, List.of(reeds)), new RiverCompiler.Area(region, List.of(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);
|
||||
compile(new Field.Const(SEA_LEVEL + 2.0), hydrology, List.of(new RiverCompiler.Area(region, List.of(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());
|
||||
@@ -396,10 +413,10 @@ public class RiverCompilerTest {
|
||||
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)));
|
||||
new RiverCompiler.Area(hot, List.of(biome("volcano", new IrisHydrologyPolicy().setFluid("lava")))),
|
||||
new RiverCompiler.Area(hot, List.of(biome("deep", new IrisHydrologyPolicy().setStreams(IrisHydrologyPermission.BLOCK)))),
|
||||
new RiverCompiler.Area(wet, List.of(biome("marsh", new IrisHydrologyPolicy().setDecorators(new KList<>(seagrass()))))),
|
||||
new RiverCompiler.Area(wet, List.of(biome("plains", null))));
|
||||
List<RiverCompiler.Area> reversed = new ArrayList<>(areas);
|
||||
Collections.reverse(reversed);
|
||||
List<ExportDiagnostic> forward = new ArrayList<>();
|
||||
@@ -461,7 +478,7 @@ 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))),
|
||||
return compile(natural, dimension(hydrology, null), List.of(new RiverCompiler.Area(region("region", null), List.of(biome("plains", null)))),
|
||||
registry, target, diagnostics);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
|
||||
@ClassRule
|
||||
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
|
||||
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "cc8006323ee6ce8f8cda87ddb7daf2e73fbb832937c9fce0afe4b71c1f1eae37";
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "2bc12e41634c3b0e9c943543c3687fd6da6d8e6b6d5eb5a29d6d6242bbd356fa";
|
||||
|
||||
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
|
||||
IrisDimension.class,
|
||||
|
||||
Reference in new issue
Block a user