Shore lists need a width

- Warn in pack validate when a hydrologyPolicy.shoreBiomes list has no shoreBiomeWidth above 0 applying to it, naming the dimension, region or biome that lists it
- Resolve the shore band through IrisHydrologyPolicy.shoreBand for both runtime placement and reachability
- Walk region biome lineages in ShoreBiomeLineages so reachable biomes include only shore biomes a width places
- Make HydrologyShoreTargets.placesAny use the placed shore biomes, so the locator ignores lists without a width
- Take the dimension in IrisRegion.getAllBiomeIds and getAllBiomes and gate their shore biomes on hydrology
- Drop region biome additions the package compilers already get from the dimension's reachable biomes
- Seed unset region colours from the natural biome ids
- State in the shoreBiomes description that a width is required, and recapture the schema digest
This commit is contained in:
Brian Neumann-Fopiano committed 2026-11-02 03:43:29 -05:00
1 parent 5ef47f016e
commit ca431452fe
18 files changed
+395 -96

No files matched your search

@@ -51,7 +51,7 @@ public class IrisHydrologyPolicy {
@RegistryListResource(IrisBiome.class)
@ArrayType(type = String.class)
@Description("Biomes placed along the water's edge in this area. An empty list clears the inherited biomes.")
@Description("Biomes placed along the water's edge in this area, in a band as wide as shoreBiomeWidth. Without a shoreBiomeWidth above 0 the list places nothing. An empty list clears the inherited biomes.")
private KList<String> shoreBiomes = null;
@MinNumber(0)
@@ -67,6 +67,12 @@ public class IrisHydrologyPolicy {
return value >= 0D && value <= MAX_MULTIPLIER;
}
public static ShoreBand shoreBand(List<IrisBiome> biomes, IrisRegion region, IrisDimension dimension) {
Integer width = inherited(biomes, region, dimension, IrisHydrologyPolicy::getShoreBiomeWidth);
KList<String> keys = inherited(biomes, region, dimension, IrisHydrologyPolicy::getShoreBiomes);
return width == null || width <= 0 || keys == null || keys.isEmpty() ? null : new ShoreBand(width, keys);
}
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);
@@ -81,4 +87,7 @@ public class IrisHydrologyPolicy {
private static <T> T value(IrisHydrologyPolicy policy, Function<IrisHydrologyPolicy, T> field) {
return policy == null ? null : field.apply(policy);
}
public record ShoreBand(int width, List<String> biomes) {
}
}
@@ -1,12 +1,10 @@
package art.arcane.iris.generation.locator;
import art.arcane.iris.generation.biome.IrisBiome;
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.IrisComplex;
import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.generation.terrain.IrisRegion;
import art.arcane.iris.generation.terrain.ShoreBiomeLineages;
import java.util.Set;
@@ -31,28 +29,8 @@ final class HydrologyShoreTargets {
static boolean placesAny(Engine engine, Set<String> targets) {
IrisDimension dimension = engine.getDimension();
if (places(engine, dimension.getHydrologyPolicy(), targets)) {
return true;
}
for (IrisRegion region : dimension.getAllRegions(engine)) {
if (region != null && places(engine, region.getHydrologyPolicy(), targets)) {
return true;
}
}
for (IrisBiome biome : dimension.getReachableBiomes(engine)) {
if (biome != null && places(engine, biome.getHydrologyPolicy(), targets)) {
return true;
}
}
return false;
}
private static boolean places(Engine engine, IrisHydrologyPolicy policy, Set<String> targets) {
if (policy == null || policy.getShoreBiomes() == null) {
return false;
}
for (String key : policy.getShoreBiomes()) {
if (key != null && HintedLocator.closureContains(engine, key, targets)) {
for (String key : ShoreBiomeLineages.placed(dimension, dimension.getAllRegions(engine), engine)) {
if (HintedLocator.closureContains(engine, key, targets)) {
return true;
}
}
@@ -897,7 +897,7 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
.map(IrisRegistrant::getLoadKey)
.collect(Collectors.toSet());
Set<String> regionKeys = getDimension().getAllRegions(this).stream()
.filter((i) -> i.getAllBiomeIds().stream().anyMatch(biomeKeys::contains)
.filter((i) -> i.getAllBiomeIds(getDimension(), this).stream().anyMatch(biomeKeys::contains)
|| containsObjectPlacement(i.getObjects(), normalizedObjectKey, data))
.map(IrisRegistrant::getLoadKey)
.collect(Collectors.toSet());
@@ -87,16 +87,16 @@ final class HydrologyShoreBiomes {
}
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()) {
IrisHydrologyPolicy.ShoreBand band = IrisHydrologyPolicy.shoreBand(lineage, region, dimension);
if (band == null) {
return NONE;
}
List<String> keys = band.biomes();
IrisBiome[] biomes = new IrisBiome[keys.size()];
for (int index = 0; index < biomes.length; index++) {
biomes[index] = load(keys.get(index), lineage, region).withInferredType(InferredType.SHORE);
}
return new Policy(biomes, width);
return new Policy(biomes, band.width());
}
private IrisBiome load(String key, List<IrisBiome> lineage, IrisRegion region) {
@@ -582,12 +582,12 @@ public class IrisDimension extends IrisRegistrant {
String biomeKey = Objects.requireNonNull(biome, "focus biome").getLoadKey();
KList<IrisRegion> available = getAllRegions(provider);
for (IrisRegion region : available) {
if (region.getAllBiomeIds().contains(biomeKey)) {
if (region.getAllBiomeIds(this, provider).contains(biomeKey)) {
return region;
}
}
for (IrisRegion region : available) {
for (IrisBiome member : region.getAllBiomes(provider)) {
for (IrisBiome member : region.getAllBiomes(this, provider)) {
if (biomeKey.equals(member.getLoadKey())) {
return region;
}
@@ -698,29 +698,15 @@ public class IrisDimension extends IrisRegistrant {
Deque<String> pending = new ArrayDeque<>();
addReachableBiomeKey(pending, getFocus());
boolean hydrologyPoliciesActive = hydrology != null && hydrology.isEnabled();
if (hydrologyPoliciesActive && hydrologyPolicy != null) {
addReachableBiomeKeys(pending, hydrologyPolicy.getShoreBiomes());
}
for (IrisRegion region : getAllRegions(g)) {
KList<IrisRegion> regions = getAllRegions(g);
for (IrisRegion region : regions) {
if (region == null) {
continue;
}
addReachableBiomeKeys(pending,
hydrologyPoliciesActive ? region.getAllBiomeIds() : region.getNaturalBiomeIds());
}
for (IrisImageMapBinding binding : getImageMaps()) {
if (binding == null || binding.getApplication() != IrisImageMapApplication.BIOME) {
continue;
}
IrisImageMap map = data.getImageMapLoader().load(binding.getMap());
if (map == null) {
continue;
}
for (String target : imageMapTargets(map)) {
addReachableBiomeKey(pending, localImageMapTarget(target));
}
addReachableBiomeKeys(pending, region.getNaturalBiomeIds());
}
addReachableBiomeKeys(pending, ShoreBiomeLineages.placed(this, regions, g));
addReachableBiomeKeys(pending, getImageMapBiomeKeys(g));
KList<IrisDimensionCarvingEntry> carvingEntries = getCarving();
if (carvingEntries != null) {
@@ -764,9 +750,6 @@ public class IrisDimension extends IrisRegistrant {
biomes.put(loadKey, biome);
addReachableBiomeKeys(pending, biome.getChildren());
addReachableBiomeKey(pending, biome.getCarvingBiome());
if (hydrologyPoliciesActive && biome.getHydrologyPolicy() != null) {
addReachableBiomeKeys(pending, biome.getHydrologyPolicy().getShoreBiomes());
}
KList<IrisFloatingChildBiomes> floatingChildren = biome.getFloatingChildBiomes();
if (floatingChildren == null) {
@@ -809,6 +792,27 @@ public class IrisDimension extends IrisRegistrant {
return new KList<>(biomes.values());
}
public Set<String> getImageMapBiomeKeys(DataProvider g) {
Set<String> keys = new LinkedHashSet<>();
IrisData data = g == null ? null : g.getData();
if (data == null) {
return keys;
}
for (IrisImageMapBinding binding : getImageMaps()) {
if (binding == null || binding.getApplication() != IrisImageMapApplication.BIOME) {
continue;
}
IrisImageMap map = data.getImageMapLoader().load(binding.getMap());
if (map == null) {
continue;
}
for (String target : imageMapTargets(map)) {
keys.add(localImageMapTarget(target));
}
}
return keys;
}
private Set<String> imageMapTargets(IrisImageMap map) {
Set<String> targets = new LinkedHashSet<>();
if (map.getColors() != null) {
@@ -297,11 +297,9 @@ public class IrisRegion extends IrisRegistrant implements Rarity {
return getShoreHeightGenerator().fitDouble(shoreHeightMin, shoreHeightMax, x / shoreHeightZoom, z / shoreHeightZoom);
}
public KSet<String> getAllBiomeIds() {
public KSet<String> getAllBiomeIds(IrisDimension dimension, DataProvider g) {
KSet<String> names = getNaturalBiomeIds();
if (hydrologyPolicy != null && hydrologyPolicy.getShoreBiomes() != null) {
names.addAll(hydrologyPolicy.getShoreBiomes());
}
names.addAll(ShoreBiomeLineages.placedIn(dimension, this, g));
return names;
}
@@ -314,15 +312,15 @@ public class IrisRegion extends IrisRegistrant implements Rarity {
return names;
}
public KList<IrisBiome> getAllBiomes(DataProvider g) {
return resolveBiomes(g, getAllBiomeIds(), true);
public KList<IrisBiome> getAllBiomes(IrisDimension dimension, DataProvider g) {
return resolveBiomes(g, getAllBiomeIds(dimension, g));
}
public KList<IrisBiome> getNaturalBiomes(DataProvider g) {
return resolveBiomes(g, getNaturalBiomeIds(), false);
return resolveBiomes(g, getNaturalBiomeIds());
}
private KList<IrisBiome> resolveBiomes(DataProvider g, KSet<String> biomeIds, boolean includeShoreBiomes) {
private KList<IrisBiome> resolveBiomes(DataProvider g, KSet<String> biomeIds) {
KMap<String, IrisBiome> b = new KMap<>();
KSet<String> names = biomeIds.copy();
@@ -348,9 +346,6 @@ public class IrisRegion extends IrisRegistrant implements Rarity {
names.add(biome.getCarvingBiome());
b.put(biome.getLoadKey(), biome);
names.addAll(biome.getChildren());
if (includeShoreBiomes && biome.getHydrologyPolicy() != null && biome.getHydrologyPolicy().getShoreBiomes() != null) {
names.addAll(biome.getHydrologyPolicy().getShoreBiomes());
}
}
}
@@ -428,7 +423,7 @@ public class IrisRegion extends IrisRegistrant implements Rarity {
public Color getColor(DataProvider dataProvider, RenderType type) {
return this.cacheColor.aquire(() -> {
if (this.color == null) {
Random rand = new Random(getName().hashCode() + getAllBiomeIds().hashCode());
Random rand = new Random(getName().hashCode() + getNaturalBiomeIds().hashCode());
RandomColor randomColor = new RandomColor(rand);
KList<IrisBiome> biomes = getRealLandBiomes(dataProvider);
@@ -0,0 +1,119 @@
package art.arcane.iris.generation.terrain;
import art.arcane.iris.generation.biome.IrisBiome;
import art.arcane.iris.generation.block.DataProvider;
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.volmlib.util.collection.KSet;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.BiConsumer;
public final class ShoreBiomeLineages {
private ShoreBiomeLineages() {
}
public static KSet<String> placed(IrisDimension dimension, Collection<IrisRegion> regions, DataProvider provider) {
KSet<String> keys = new KSet<>();
if (enabled(dimension)) {
visit(dimension, regions, provider, (lineage, region) -> addPlaced(keys, lineage, region, dimension));
}
return keys;
}
static KSet<String> placedIn(IrisDimension dimension, IrisRegion region, DataProvider provider) {
KSet<String> keys = new KSet<>();
IrisData data = provider == null ? null : provider.getData();
if (enabled(dimension) && data != null && data.getBiomeLoader() != null) {
visitRegion(region, data, (lineage, area) -> addPlaced(keys, lineage, area, dimension));
}
return keys;
}
public static void visit(IrisDimension dimension, Collection<IrisRegion> regions, DataProvider provider,
BiConsumer<List<IrisBiome>, IrisRegion> visitor) {
IrisData data = provider == null ? null : provider.getData();
if (data == null || data.getBiomeLoader() == null) {
return;
}
for (IrisRegion region : regions) {
if (region != null) {
visitRegion(region, data, visitor);
}
}
List<IrisBiome> direct = new ArrayList<>();
for (String key : dimension.getImageMapBiomeKeys(provider)) {
addLoaded(direct, data, key);
}
addLoaded(direct, data, dimension.getFocus());
for (IrisBiome biome : direct) {
List<IrisBiome> lineage = List.of(biome);
for (IrisRegion region : regions) {
if (region != null) {
visitor.accept(lineage, region);
}
}
visitor.accept(lineage, null);
}
}
private static boolean enabled(IrisDimension dimension) {
IrisHydrology hydrology = dimension.getHydrology();
return hydrology != null && hydrology.isEnabled();
}
private static void visitRegion(IrisRegion region, IrisData data, BiConsumer<List<IrisBiome>, IrisRegion> visitor) {
List<IrisBiome> roots = new ArrayList<>();
for (String key : region.getLandBiomes()) {
addLoaded(roots, data, key);
}
for (String key : region.getSeaBiomes()) {
addLoaded(roots, data, key);
}
ArrayDeque<IrisBiome> chain = new ArrayDeque<>();
for (IrisBiome root : roots) {
descend(root, chain, region, data, visitor);
}
}
private static void descend(IrisBiome biome, ArrayDeque<IrisBiome> chain, IrisRegion region, IrisData data,
BiConsumer<List<IrisBiome>, IrisRegion> visitor) {
chain.addFirst(biome);
visitor.accept(List.copyOf(chain), region);
if (chain.size() <= IrisBiome.CHILD_HOPS) {
List<IrisBiome> children = new ArrayList<>();
for (String key : biome.getChildren()) {
addLoaded(children, data, key);
}
for (IrisBiome child : children) {
if (child != biome) {
descend(child, chain, region, data, visitor);
}
}
}
chain.removeFirst();
}
private static void addLoaded(List<IrisBiome> biomes, IrisData data, String key) {
IrisBiome biome = key == null || key.isBlank() ? null : data.getBiomeLoader().load(key);
if (biome != null && !biome.isCompatExcluded()) {
biomes.add(biome);
}
}
private static void addPlaced(KSet<String> keys, List<IrisBiome> lineage, IrisRegion region, IrisDimension dimension) {
IrisHydrologyPolicy.ShoreBand band = IrisHydrologyPolicy.shoreBand(lineage, region, dimension);
if (band == null) {
return;
}
for (String key : band.biomes()) {
if (key != null && !key.isBlank()) {
keys.add(key);
}
}
}
}
@@ -10,6 +10,7 @@ import art.arcane.iris.generation.hydrology.config.IrisHydrologyWetness;
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.generation.terrain.IrisRegion;
import art.arcane.iris.generation.terrain.ShoreBiomeLineages;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.IrisPlatforms;
@@ -19,10 +20,14 @@ import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.IdentityHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
final class PackHydrologyValidator {
private static final String CONFIG = "hydrology";
@@ -97,6 +102,7 @@ final class PackHydrologyValidator {
}
warnMantleOff("Dimension '" + dimensionKey + "'", loadedDimension, findings.warnings());
validatePolicies(path, dimensionKey, loaded, loadedDimension, new PolicyFluids(fluids, seams), errors);
warnShoreBiomesWithoutWidth(dimensionKey, loaded, loadedDimension, findings.warnings());
if (errors.size() == reported && validateCompile(path, loadedDimension, errors)) {
validateDecoratorBlocks(path, loaded, loadedDimension.getHydrology(), errors);
}
@@ -308,6 +314,46 @@ final class PackHydrologyValidator {
}
}
private static void warnShoreBiomesWithoutWidth(String dimensionKey, IrisData data, IrisDimension dimension, List<String> warnings) {
List<IrisRegion> regions = new ArrayList<>(dimension.getAllRegions(() -> data));
regions.sort(Comparator.comparing(IrisRegion::getLoadKey, Comparator.nullsFirst(Comparator.naturalOrder())));
Set<IrisHydrologyPolicy> widened = Collections.newSetFromMap(new IdentityHashMap<>());
Map<String, IrisBiome> lineageBiomes = new TreeMap<>();
ShoreBiomeLineages.visit(dimension, regions, () -> data, (lineage, region) -> {
Integer width = IrisHydrologyPolicy.inherited(lineage, region, dimension, IrisHydrologyPolicy::getShoreBiomeWidth);
boolean wide = width != null && width > 0;
for (IrisBiome biome : lineage) {
if (biome.getLoadKey() != null) {
lineageBiomes.putIfAbsent(biome.getLoadKey(), biome);
}
if (wide && biome.getHydrologyPolicy() != null) {
widened.add(biome.getHydrologyPolicy());
}
}
if (wide && region != null && region.getHydrologyPolicy() != null) {
widened.add(region.getHydrologyPolicy());
}
if (wide && dimension.getHydrologyPolicy() != null) {
widened.add(dimension.getHydrologyPolicy());
}
});
warnShoreBiomesWithoutWidth("Dimension '" + dimensionKey + "'", dimension.getHydrologyPolicy(), widened, warnings);
for (IrisRegion region : regions) {
warnShoreBiomesWithoutWidth("Region '" + region.getLoadKey() + "'", region.getHydrologyPolicy(), widened, warnings);
}
for (IrisBiome biome : lineageBiomes.values()) {
warnShoreBiomesWithoutWidth("Biome '" + biome.getLoadKey() + "'", biome.getHydrologyPolicy(), widened, warnings);
}
}
private static void warnShoreBiomesWithoutWidth(String scope, IrisHydrologyPolicy policy, Set<IrisHydrologyPolicy> widened,
List<String> warnings) {
if (policy != null && policy.getShoreBiomes() != null && !policy.getShoreBiomes().isEmpty() && !widened.contains(policy)) {
warnings.add(scope + "." + POLICY + ".shoreBiomes lists shore biomes, but no shoreBiomeWidth above 0 applies to them,"
+ " so none are placed.");
}
}
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 + ".");
@@ -104,7 +104,7 @@ public final class ExportedBiomes {
if (region == null) {
continue;
}
for (IrisBiome biome : region.getAllBiomes(() -> context.data())) {
for (IrisBiome biome : region.getAllBiomes(context.dimension(), () -> context.data())) {
if (biome != null && biome.getLoadKey() != null) {
regions.putIfAbsent(biome.getLoadKey(), region);
}
@@ -139,7 +139,6 @@ public class IrisPackageCompiler {
exportedDimension.getEntitySpawners().forEach((sp) ->
addIfPresent(spawners, dm.getSpawnerLoader().load(sp)));
}
regions.forEach((i) -> biomes.addAll(i.getAllBiomes(() -> dm)));
regions.forEach((r) -> r.getLoot().getTables().forEach((i) -> addIfPresent(loot, dm.getLootLoader().load(i))));
regions.forEach((r) -> r.getEntitySpawners().forEach((sp) -> addIfPresent(spawners, dm.getSpawnerLoader().load(sp))));
biomes.forEach((i) -> i.getGenerators().forEach((j) -> addIfPresent(generators, j.getCachedGenerator(() -> dm))));