Child lineage review fixes

- Terrain source test samples a self-cycle and a two-cycle child graph and checks every lineage link and inherited value
- Shore biome lookups skip the lineage unless some policy sets a positive shoreBiomeWidth
- IrisBiome.CHILD_HOPS is the one child hop limit for implosion and datapack river areas
- A missing shore biome error names the biome, region or dimension that lists it
This commit is contained in:
Brian Neumann-Fopiano committed 2026-11-02 01:15:37 -05:00
1 parent ff0a95a6fd
commit f7ddd68d26
6 files changed
+178 -38

No files matched your search

@@ -92,6 +92,7 @@ import java.util.Objects;
@Data
@EqualsAndHashCode(callSuper = false)
public class IrisBiome extends IrisRegistrant implements Rarity {
public static final int CHILD_HOPS = 4;
private static final int BIOME_GENERATOR_CACHE_SIZE = 8;
private static final int CHILDREN_SEED_SALT = 2137;
@@ -8,6 +8,7 @@ import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.generation.terrain.IrisRegion;
import art.arcane.iris.pack.loading.IrisData;
import java.util.Collection;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Objects;
@@ -31,6 +32,23 @@ final class HydrologyShoreBiomes {
this.seed = seed;
}
static boolean banded(IrisDimension dimension, Collection<IrisRegion> regions, Collection<IrisBiome> biomes) {
if (banded(dimension.getHydrologyPolicy())) {
return true;
}
for (IrisRegion region : regions) {
if (region != null && banded(region.getHydrologyPolicy())) {
return true;
}
}
for (IrisBiome biome : biomes) {
if (biome != null && banded(biome.getHydrologyPolicy())) {
return true;
}
}
return false;
}
IrisBiome select(List<IrisBiome> lineage, IrisRegion region, int x, int z, int shoreDistance) {
Policy policy = policy(lineage, region);
IrisBiome[] biomes = policy.biomes();
@@ -76,20 +94,38 @@ final class HydrologyShoreBiomes {
}
IrisBiome[] biomes = new IrisBiome[keys.size()];
for (int index = 0; index < biomes.length; index++) {
biomes[index] = load(keys.get(index), lineage.isEmpty() ? null : lineage.getFirst(), region).withInferredType(InferredType.SHORE);
biomes[index] = load(keys.get(index), lineage, region).withInferredType(InferredType.SHORE);
}
return new Policy(biomes, width);
}
private IrisBiome load(String key, IrisBiome biome, IrisRegion region) {
private IrisBiome load(String key, List<IrisBiome> lineage, IrisRegion region) {
IrisBiome loaded = key == null || key.isBlank() || data == null ? null : data.getBiomeLoader().load(key);
if (loaded == null) {
throw new IllegalStateException("Hydrology shore biome '" + key + "' for biome " + (biome == null ? "none" : biome.getLoadKey())
+ " in region " + (region == null ? "none" : region.getLoadKey()) + " does not exist");
throw new IllegalStateException("Hydrology shore biome '" + key + "' listed by " + listedBy(lineage, region) + " for biome "
+ (lineage.isEmpty() ? "none" : lineage.getFirst().getLoadKey()) + " in region " + (region == null ? "none" : region.getLoadKey())
+ " does not exist");
}
return loaded;
}
private String listedBy(List<IrisBiome> lineage, IrisRegion region) {
for (IrisBiome biome : lineage) {
if (lists(biome.getHydrologyPolicy())) {
return "biome " + biome.getLoadKey();
}
}
return region != null && lists(region.getHydrologyPolicy()) ? "region " + region.getLoadKey() : "dimension " + dimension.getLoadKey();
}
private static boolean lists(IrisHydrologyPolicy policy) {
return policy != null && policy.getShoreBiomes() != null;
}
private static boolean banded(IrisHydrologyPolicy policy) {
return policy != null && policy.getShoreBiomeWidth() != null && policy.getShoreBiomeWidth() > 0;
}
private record Policy(IrisBiome[] biomes, int width) {
}
}
@@ -147,7 +147,6 @@ 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,
@@ -281,6 +280,9 @@ public class IrisComplex implements DataProvider {
@Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE)
private final transient BiomeLineages biomeLineages;
@Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE)
private final transient boolean shoreBands;
@Setter(AccessLevel.NONE)
private final transient SubterrainPlanner subterrainPlanner;
private transient IrisImageMapRuntime imageMapRuntime;
@@ -502,8 +504,11 @@ public class IrisComplex implements DataProvider {
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;
KList<IrisRegion> policyRegions = hydrologyRuntime.enabled() ? engine.getDimension().getAllRegions(engine) : new KList<>();
KList<IrisBiome> policyBiomes = hydrologyRuntime.enabled() ? engine.getDimension().getReachableBiomes(engine) : new KList<>();
waterVegetation = hydrologyRuntime.enabled() ? HydrologyVegetationSource.create(engine.getDimension(), hydrologyRuntime.settings(), data,
engine.getDimension().getAllRegions(engine), engine.getDimension().getReachableBiomes(engine)) : HydrologyVegetationSource.NONE;
policyRegions, policyBiomes) : HydrologyVegetationSource.NONE;
shoreBands = hydrologyRuntime.enabled() && HydrologyShoreBiomes.banded(engine.getDimension(), policyRegions, policyBiomes);
heightStream = new BakedHeightStream(bakeCache, () -> terrainEngine.getPlatformHooks().isMainThread(),
this::resolveHydrologyTerrainHeight, this::resolveHydrologyTerrainHeight);
roundedHeighteightStream = GenerationStreams.contextInjecting(heightStream, engine, (c, x, z) -> c.getHeight().getDouble(x, z))
@@ -1824,6 +1829,9 @@ public class IrisComplex implements DataProvider {
|| seamWeight(blockX, blockZ) == 0D) {
return null;
}
if (!shoreBands) {
return null;
}
IrisBiome shore = shoreBiomes.select(baseBiomeLineage(blockX, blockZ), regionStream.get(x, z), blockX, blockZ, distance);
return shore == null ? null : implode(shore, x, z);
}
@@ -2500,7 +2508,7 @@ public class IrisComplex implements DataProvider {
return b;
}
return implode(b, x, z, CHILD_HOPS - 1);
return implode(b, x, z, IrisBiome.CHILD_HOPS - 1);
}
private IrisBiome implode(IrisBiome b, double x, double z, int max) {
@@ -2525,11 +2533,11 @@ public class IrisComplex implements DataProvider {
}
private List<IrisBiome> childLineage(IrisBiome biome, int x, int z) {
IrisBiome[] rootFirst = new IrisBiome[CHILD_HOPS + 1];
IrisBiome[] rootFirst = new IrisBiome[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++) {
for (int hop = 0; hop < IrisBiome.CHILD_HOPS && !current.getChildren().isEmpty(); hop++) {
IrisBiome picked = pickChild(current, x, z);
if (picked == current) {
break;
@@ -18,7 +18,6 @@ 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() {
@@ -72,7 +71,7 @@ public final class RiverStage implements CompileStage {
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) {
if (lineages.putIfAbsent(key.toString(), leafFirst) != null || leafFirst.size() > IrisBiome.CHILD_HOPS) {
return;
}
IrisBiome leaf = leafFirst.getFirst();