mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-03 03:31:32 +00:00
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:
1 parent
5ef47f016e
commit
ca431452fe
18 files changed
+395
-96
No files matched your search
-5
@@ -998,11 +998,6 @@ public final class ModdedStudioCommands {
|
|||||||
if (region == null) {
|
if (region == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
region.getAllBiomes(() -> dm).forEach((IrisBiome biome) -> {
|
|
||||||
if (biome != null && biome.getLoadKey() != null) {
|
|
||||||
biomeKeys.add(biome.getLoadKey());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
lootKeys.addAll(region.getLoot().getTables());
|
lootKeys.addAll(region.getLoot().getTables());
|
||||||
spawnerKeys.addAll(region.getEntitySpawners());
|
spawnerKeys.addAll(region.getEntitySpawners());
|
||||||
collectStructureKeys(structureKeys, region.getStructures());
|
collectStructureKeys(structureKeys, region.getStructures());
|
||||||
|
|||||||
+10
-1
@@ -51,7 +51,7 @@ public class IrisHydrologyPolicy {
|
|||||||
|
|
||||||
@RegistryListResource(IrisBiome.class)
|
@RegistryListResource(IrisBiome.class)
|
||||||
@ArrayType(type = String.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;
|
private KList<String> shoreBiomes = null;
|
||||||
|
|
||||||
@MinNumber(0)
|
@MinNumber(0)
|
||||||
@@ -67,6 +67,12 @@ public class IrisHydrologyPolicy {
|
|||||||
return value >= 0D && value <= MAX_MULTIPLIER;
|
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) {
|
public static <T> T inherited(List<IrisBiome> biomes, IrisRegion region, IrisDimension dimension, Function<IrisHydrologyPolicy, T> field) {
|
||||||
for (int index = 0; index < biomes.size(); index++) {
|
for (int index = 0; index < biomes.size(); index++) {
|
||||||
T value = value(biomes.get(index).getHydrologyPolicy(), field);
|
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) {
|
private static <T> T value(IrisHydrologyPolicy policy, Function<IrisHydrologyPolicy, T> field) {
|
||||||
return policy == null ? null : field.apply(policy);
|
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;
|
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.hydrology.engine.HydrologyRuntime;
|
||||||
import art.arcane.iris.generation.runtime.Engine;
|
import art.arcane.iris.generation.runtime.Engine;
|
||||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
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;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -31,28 +29,8 @@ final class HydrologyShoreTargets {
|
|||||||
|
|
||||||
static boolean placesAny(Engine engine, Set<String> targets) {
|
static boolean placesAny(Engine engine, Set<String> targets) {
|
||||||
IrisDimension dimension = engine.getDimension();
|
IrisDimension dimension = engine.getDimension();
|
||||||
if (places(engine, dimension.getHydrologyPolicy(), targets)) {
|
for (String key : ShoreBiomeLineages.placed(dimension, dimension.getAllRegions(engine), engine)) {
|
||||||
return true;
|
if (HintedLocator.closureContains(engine, key, targets)) {
|
||||||
}
|
|
||||||
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)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -897,7 +897,7 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
|||||||
.map(IrisRegistrant::getLoadKey)
|
.map(IrisRegistrant::getLoadKey)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
Set<String> regionKeys = getDimension().getAllRegions(this).stream()
|
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))
|
|| containsObjectPlacement(i.getObjects(), normalizedObjectKey, data))
|
||||||
.map(IrisRegistrant::getLoadKey)
|
.map(IrisRegistrant::getLoadKey)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|||||||
@@ -87,16 +87,16 @@ final class HydrologyShoreBiomes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Policy resolve(List<IrisBiome> lineage, IrisRegion region) {
|
private Policy resolve(List<IrisBiome> lineage, IrisRegion region) {
|
||||||
Integer width = IrisHydrologyPolicy.inherited(lineage, region, dimension, IrisHydrologyPolicy::getShoreBiomeWidth);
|
IrisHydrologyPolicy.ShoreBand band = IrisHydrologyPolicy.shoreBand(lineage, region, dimension);
|
||||||
List<String> keys = IrisHydrologyPolicy.inherited(lineage, region, dimension, IrisHydrologyPolicy::getShoreBiomes);
|
if (band == null) {
|
||||||
if (width == null || width <= 0 || keys == null || keys.isEmpty()) {
|
|
||||||
return NONE;
|
return NONE;
|
||||||
}
|
}
|
||||||
|
List<String> keys = band.biomes();
|
||||||
IrisBiome[] biomes = new IrisBiome[keys.size()];
|
IrisBiome[] biomes = new IrisBiome[keys.size()];
|
||||||
for (int index = 0; index < biomes.length; index++) {
|
for (int index = 0; index < biomes.length; index++) {
|
||||||
biomes[index] = load(keys.get(index), lineage, region).withInferredType(InferredType.SHORE);
|
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) {
|
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();
|
String biomeKey = Objects.requireNonNull(biome, "focus biome").getLoadKey();
|
||||||
KList<IrisRegion> available = getAllRegions(provider);
|
KList<IrisRegion> available = getAllRegions(provider);
|
||||||
for (IrisRegion region : available) {
|
for (IrisRegion region : available) {
|
||||||
if (region.getAllBiomeIds().contains(biomeKey)) {
|
if (region.getAllBiomeIds(this, provider).contains(biomeKey)) {
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (IrisRegion region : available) {
|
for (IrisRegion region : available) {
|
||||||
for (IrisBiome member : region.getAllBiomes(provider)) {
|
for (IrisBiome member : region.getAllBiomes(this, provider)) {
|
||||||
if (biomeKey.equals(member.getLoadKey())) {
|
if (biomeKey.equals(member.getLoadKey())) {
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
@@ -698,29 +698,15 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
|
|
||||||
Deque<String> pending = new ArrayDeque<>();
|
Deque<String> pending = new ArrayDeque<>();
|
||||||
addReachableBiomeKey(pending, getFocus());
|
addReachableBiomeKey(pending, getFocus());
|
||||||
boolean hydrologyPoliciesActive = hydrology != null && hydrology.isEnabled();
|
KList<IrisRegion> regions = getAllRegions(g);
|
||||||
if (hydrologyPoliciesActive && hydrologyPolicy != null) {
|
for (IrisRegion region : regions) {
|
||||||
addReachableBiomeKeys(pending, hydrologyPolicy.getShoreBiomes());
|
|
||||||
}
|
|
||||||
for (IrisRegion region : getAllRegions(g)) {
|
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
addReachableBiomeKeys(pending,
|
addReachableBiomeKeys(pending, region.getNaturalBiomeIds());
|
||||||
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, ShoreBiomeLineages.placed(this, regions, g));
|
||||||
|
addReachableBiomeKeys(pending, getImageMapBiomeKeys(g));
|
||||||
|
|
||||||
KList<IrisDimensionCarvingEntry> carvingEntries = getCarving();
|
KList<IrisDimensionCarvingEntry> carvingEntries = getCarving();
|
||||||
if (carvingEntries != null) {
|
if (carvingEntries != null) {
|
||||||
@@ -764,9 +750,6 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
biomes.put(loadKey, biome);
|
biomes.put(loadKey, biome);
|
||||||
addReachableBiomeKeys(pending, biome.getChildren());
|
addReachableBiomeKeys(pending, biome.getChildren());
|
||||||
addReachableBiomeKey(pending, biome.getCarvingBiome());
|
addReachableBiomeKey(pending, biome.getCarvingBiome());
|
||||||
if (hydrologyPoliciesActive && biome.getHydrologyPolicy() != null) {
|
|
||||||
addReachableBiomeKeys(pending, biome.getHydrologyPolicy().getShoreBiomes());
|
|
||||||
}
|
|
||||||
|
|
||||||
KList<IrisFloatingChildBiomes> floatingChildren = biome.getFloatingChildBiomes();
|
KList<IrisFloatingChildBiomes> floatingChildren = biome.getFloatingChildBiomes();
|
||||||
if (floatingChildren == null) {
|
if (floatingChildren == null) {
|
||||||
@@ -809,6 +792,27 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
return new KList<>(biomes.values());
|
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) {
|
private Set<String> imageMapTargets(IrisImageMap map) {
|
||||||
Set<String> targets = new LinkedHashSet<>();
|
Set<String> targets = new LinkedHashSet<>();
|
||||||
if (map.getColors() != null) {
|
if (map.getColors() != null) {
|
||||||
|
|||||||
@@ -297,11 +297,9 @@ public class IrisRegion extends IrisRegistrant implements Rarity {
|
|||||||
return getShoreHeightGenerator().fitDouble(shoreHeightMin, shoreHeightMax, x / shoreHeightZoom, z / shoreHeightZoom);
|
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();
|
KSet<String> names = getNaturalBiomeIds();
|
||||||
if (hydrologyPolicy != null && hydrologyPolicy.getShoreBiomes() != null) {
|
names.addAll(ShoreBiomeLineages.placedIn(dimension, this, g));
|
||||||
names.addAll(hydrologyPolicy.getShoreBiomes());
|
|
||||||
}
|
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,15 +312,15 @@ public class IrisRegion extends IrisRegistrant implements Rarity {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getAllBiomes(DataProvider g) {
|
public KList<IrisBiome> getAllBiomes(IrisDimension dimension, DataProvider g) {
|
||||||
return resolveBiomes(g, getAllBiomeIds(), true);
|
return resolveBiomes(g, getAllBiomeIds(dimension, g));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getNaturalBiomes(DataProvider 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<>();
|
KMap<String, IrisBiome> b = new KMap<>();
|
||||||
KSet<String> names = biomeIds.copy();
|
KSet<String> names = biomeIds.copy();
|
||||||
|
|
||||||
@@ -348,9 +346,6 @@ public class IrisRegion extends IrisRegistrant implements Rarity {
|
|||||||
names.add(biome.getCarvingBiome());
|
names.add(biome.getCarvingBiome());
|
||||||
b.put(biome.getLoadKey(), biome);
|
b.put(biome.getLoadKey(), biome);
|
||||||
names.addAll(biome.getChildren());
|
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) {
|
public Color getColor(DataProvider dataProvider, RenderType type) {
|
||||||
return this.cacheColor.aquire(() -> {
|
return this.cacheColor.aquire(() -> {
|
||||||
if (this.color == null) {
|
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);
|
RandomColor randomColor = new RandomColor(rand);
|
||||||
|
|
||||||
KList<IrisBiome> biomes = getRealLandBiomes(dataProvider);
|
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.hydrology.plan.HydrologySettings;
|
||||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
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.pack.loading.IrisData;
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.iris.spi.IrisPlatforms;
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
@@ -19,10 +20,14 @@ import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
final class PackHydrologyValidator {
|
final class PackHydrologyValidator {
|
||||||
private static final String CONFIG = "hydrology";
|
private static final String CONFIG = "hydrology";
|
||||||
@@ -97,6 +102,7 @@ final class PackHydrologyValidator {
|
|||||||
}
|
}
|
||||||
warnMantleOff("Dimension '" + dimensionKey + "'", loadedDimension, findings.warnings());
|
warnMantleOff("Dimension '" + dimensionKey + "'", loadedDimension, findings.warnings());
|
||||||
validatePolicies(path, dimensionKey, loaded, loadedDimension, new PolicyFluids(fluids, seams), errors);
|
validatePolicies(path, dimensionKey, loaded, loadedDimension, new PolicyFluids(fluids, seams), errors);
|
||||||
|
warnShoreBiomesWithoutWidth(dimensionKey, loaded, loadedDimension, findings.warnings());
|
||||||
if (errors.size() == reported && validateCompile(path, loadedDimension, errors)) {
|
if (errors.size() == reported && validateCompile(path, loadedDimension, errors)) {
|
||||||
validateDecoratorBlocks(path, loaded, loadedDimension.getHydrology(), 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) {
|
private static void requireMultiplier(String field, Double value, List<String> errors) {
|
||||||
if (value != null && !IrisHydrologyPolicy.validMultiplier(value)) {
|
if (value != null && !IrisHydrologyPolicy.validMultiplier(value)) {
|
||||||
errors.add(field + " must be a finite value from 0 to " + (int) IrisHydrologyPolicy.MAX_MULTIPLIER + ", got " + 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) {
|
if (region == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (IrisBiome biome : region.getAllBiomes(() -> context.data())) {
|
for (IrisBiome biome : region.getAllBiomes(context.dimension(), () -> context.data())) {
|
||||||
if (biome != null && biome.getLoadKey() != null) {
|
if (biome != null && biome.getLoadKey() != null) {
|
||||||
regions.putIfAbsent(biome.getLoadKey(), region);
|
regions.putIfAbsent(biome.getLoadKey(), region);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ public class IrisPackageCompiler {
|
|||||||
exportedDimension.getEntitySpawners().forEach((sp) ->
|
exportedDimension.getEntitySpawners().forEach((sp) ->
|
||||||
addIfPresent(spawners, dm.getSpawnerLoader().load(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.getLoot().getTables().forEach((i) -> addIfPresent(loot, dm.getLootLoader().load(i))));
|
||||||
regions.forEach((r) -> r.getEntitySpawners().forEach((sp) -> addIfPresent(spawners, dm.getSpawnerLoader().load(sp))));
|
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))));
|
biomes.forEach((i) -> i.getGenerators().forEach((j) -> addIfPresent(generators, j.getCachedGenerator(() -> dm))));
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package art.arcane.iris.generation.locator;
|
package art.arcane.iris.generation.locator;
|
||||||
|
|
||||||
import art.arcane.iris.generation.biome.IrisBiome;
|
import art.arcane.iris.generation.biome.IrisBiome;
|
||||||
|
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||||
import art.arcane.iris.generation.image.IrisImageMapApplication;
|
import art.arcane.iris.generation.image.IrisImageMapApplication;
|
||||||
@@ -132,11 +133,15 @@ public class BiomeSearchFilterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hydrologyColumnsAreAdmittedForShoreBiomesThePolicyPlaces() {
|
public void hydrologyColumnsAreAdmittedForShoreBiomesThePolicyPlaces() {
|
||||||
stubRegions();
|
IrisRegion host = region("host");
|
||||||
when(complex.getRegionStream()).thenReturn(constantStream(region("host")));
|
host.setLandBiomes(keys("land_root"));
|
||||||
|
stubBiome(biome("land_root"));
|
||||||
|
stubRegions(host);
|
||||||
|
when(complex.getRegionStream()).thenReturn(constantStream(host));
|
||||||
HydrologyRuntime hydrology = enabledHydrology();
|
HydrologyRuntime hydrology = enabledHydrology();
|
||||||
when(complex.getHydrologyRuntime()).thenReturn(hydrology);
|
when(complex.getHydrologyRuntime()).thenReturn(hydrology);
|
||||||
when(dimension.getHydrologyPolicy()).thenReturn(new IrisHydrologyPolicy().setShoreBiomes(keys("river_root")));
|
when(dimension.getHydrology()).thenReturn(new IrisHydrology().setEnabled(true));
|
||||||
|
when(dimension.getHydrologyPolicy()).thenReturn(new IrisHydrologyPolicy().setShoreBiomes(keys("river_root")).setShoreBiomeWidth(4));
|
||||||
IrisBiome river = biome("river_root");
|
IrisBiome river = biome("river_root");
|
||||||
river.setChildren(keys("target"));
|
river.setChildren(keys("target"));
|
||||||
stubBiome(river);
|
stubBiome(river);
|
||||||
@@ -150,11 +155,15 @@ public class BiomeSearchFilterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hydrologyIsNotConsultedForBiomesNoHydrologyPolicyPlaces() {
|
public void hydrologyIsNotConsultedForBiomesNoHydrologyPolicyPlaces() {
|
||||||
stubRegions();
|
IrisRegion host = region("host");
|
||||||
when(complex.getRegionStream()).thenReturn(constantStream(region("host")));
|
host.setLandBiomes(keys("land_root"));
|
||||||
|
stubBiome(biome("land_root"));
|
||||||
|
stubRegions(host);
|
||||||
|
when(complex.getRegionStream()).thenReturn(constantStream(host));
|
||||||
HydrologyRuntime hydrology = enabledHydrology();
|
HydrologyRuntime hydrology = enabledHydrology();
|
||||||
when(complex.getHydrologyRuntime()).thenReturn(hydrology);
|
when(complex.getHydrologyRuntime()).thenReturn(hydrology);
|
||||||
when(dimension.getHydrologyPolicy()).thenReturn(new IrisHydrologyPolicy().setShoreBiomes(keys("river_root")));
|
when(dimension.getHydrology()).thenReturn(new IrisHydrology().setEnabled(true));
|
||||||
|
when(dimension.getHydrologyPolicy()).thenReturn(new IrisHydrologyPolicy().setShoreBiomes(keys("river_root")).setShoreBiomeWidth(4));
|
||||||
stubBiome(biome("river_root"));
|
stubBiome(biome("river_root"));
|
||||||
when(engine.answersFromNaturalTerrain(anyInt(), anyInt())).thenReturn(false);
|
when(engine.answersFromNaturalTerrain(anyInt(), anyInt())).thenReturn(false);
|
||||||
|
|
||||||
@@ -166,10 +175,14 @@ public class BiomeSearchFilterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void disabledHydrologyIsNeverConsultedForPolicyShoreBiomes() {
|
public void disabledHydrologyIsNeverConsultedForPolicyShoreBiomes() {
|
||||||
stubRegions();
|
IrisRegion host = region("host");
|
||||||
when(complex.getRegionStream()).thenReturn(constantStream(region("host")));
|
host.setLandBiomes(keys("land_root"));
|
||||||
|
stubBiome(biome("land_root"));
|
||||||
|
stubRegions(host);
|
||||||
|
when(complex.getRegionStream()).thenReturn(constantStream(host));
|
||||||
when(complex.getHydrologyRuntime()).thenReturn(mock(HydrologyRuntime.class));
|
when(complex.getHydrologyRuntime()).thenReturn(mock(HydrologyRuntime.class));
|
||||||
when(dimension.getHydrologyPolicy()).thenReturn(new IrisHydrologyPolicy().setShoreBiomes(keys("target")));
|
when(dimension.getHydrology()).thenReturn(new IrisHydrology().setEnabled(true));
|
||||||
|
when(dimension.getHydrologyPolicy()).thenReturn(new IrisHydrologyPolicy().setShoreBiomes(keys("target")).setShoreBiomeWidth(4));
|
||||||
stubBiome(biome("target"));
|
stubBiome(biome("target"));
|
||||||
when(engine.answersFromNaturalTerrain(anyInt(), anyInt())).thenReturn(false);
|
when(engine.answersFromNaturalTerrain(anyInt(), anyInt())).thenReturn(false);
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import art.arcane.iris.generation.biome.IrisBiome;
|
|||||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||||
|
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||||
import art.arcane.iris.world.history.GenerationSemanticIndex;
|
import art.arcane.iris.world.history.GenerationSemanticIndex;
|
||||||
import art.arcane.iris.spi.IrisPlatform;
|
import art.arcane.iris.spi.IrisPlatform;
|
||||||
@@ -283,9 +284,14 @@ public class HintedLocatorTest {
|
|||||||
|
|
||||||
HydrologyShoreTargets placed = new HydrologyShoreTargets(Set.of(riverShore.getLoadKey()));
|
HydrologyShoreTargets placed = new HydrologyShoreTargets(Set.of(riverShore.getLoadKey()));
|
||||||
HydrologyShoreTargets unplaced = new HydrologyShoreTargets(Set.of(riverShore.getLoadKey()));
|
HydrologyShoreTargets unplaced = new HydrologyShoreTargets(Set.of(riverShore.getLoadKey()));
|
||||||
when(dimension.getHydrologyPolicy()).thenReturn(new IrisHydrologyPolicy().setShoreBiomes(keys(riverShore.getLoadKey())));
|
IrisRegion host = region("host");
|
||||||
stubRegions();
|
host.setLandBiomes(keys(plains.getLoadKey()));
|
||||||
|
when(dimension.getHydrology()).thenReturn(new IrisHydrology().setEnabled(true));
|
||||||
|
when(dimension.getHydrologyPolicy()).thenReturn(new IrisHydrologyPolicy()
|
||||||
|
.setShoreBiomes(keys(riverShore.getLoadKey())).setShoreBiomeWidth(4));
|
||||||
|
stubRegions(host);
|
||||||
stubBiome(riverShore);
|
stubBiome(riverShore);
|
||||||
|
stubBiome(plains);
|
||||||
|
|
||||||
assertTrue(Locator.chunkContainsSurfaceBiome(engine, new Position2(2, 0), riverShore.getLoadKey(), placed));
|
assertTrue(Locator.chunkContainsSurfaceBiome(engine, new Position2(2, 0), riverShore.getLoadKey(), placed));
|
||||||
assertFalse(Locator.chunkContainsSurfaceBiome(engine, new Position2(8, 0), riverShore.getLoadKey(), placed));
|
assertFalse(Locator.chunkContainsSurfaceBiome(engine, new Position2(8, 0), riverShore.getLoadKey(), placed));
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package art.arcane.iris.generation.locator;
|
||||||
|
|
||||||
|
import art.arcane.iris.generation.biome.IrisBiome;
|
||||||
|
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||||
|
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||||
|
import art.arcane.iris.generation.runtime.Engine;
|
||||||
|
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||||
|
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||||
|
import art.arcane.iris.pack.loading.IrisData;
|
||||||
|
import art.arcane.iris.pack.loading.ResourceLoader;
|
||||||
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
public class HydrologyShoreTargetsTest {
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void listsWithoutWidthPlaceNothing() {
|
||||||
|
IrisDimension dimension = new IrisDimension()
|
||||||
|
.setRegions(new KList<>("coast"))
|
||||||
|
.setHydrology(new IrisHydrology().setEnabled(true))
|
||||||
|
.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("beach")));
|
||||||
|
IrisRegion coast = new IrisRegion()
|
||||||
|
.setLandBiomes(new KList<>("plains"))
|
||||||
|
.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("dune")));
|
||||||
|
coast.setLoadKey("coast");
|
||||||
|
IrisData data = mock(IrisData.class);
|
||||||
|
ResourceLoader<IrisRegion> regionLoader = mock(ResourceLoader.class);
|
||||||
|
ResourceLoader<IrisBiome> biomeLoader = mock(ResourceLoader.class);
|
||||||
|
when(data.getRegionLoader()).thenReturn(regionLoader);
|
||||||
|
when(data.getBiomeLoader()).thenReturn(biomeLoader);
|
||||||
|
when(regionLoader.load("coast")).thenReturn(coast);
|
||||||
|
when(biomeLoader.load("plains")).thenReturn(biome("plains"));
|
||||||
|
when(biomeLoader.load("beach")).thenReturn(biome("beach"));
|
||||||
|
when(biomeLoader.load("dune")).thenReturn(biome("dune"));
|
||||||
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
|
when(engine.getData()).thenReturn(data);
|
||||||
|
|
||||||
|
assertFalse(HydrologyShoreTargets.placesAny(engine, Set.of("beach")));
|
||||||
|
assertFalse(HydrologyShoreTargets.placesAny(engine, Set.of("dune")));
|
||||||
|
|
||||||
|
dimension.getHydrologyPolicy().setShoreBiomeWidth(3);
|
||||||
|
assertTrue(HydrologyShoreTargets.placesAny(engine, Set.of("dune")));
|
||||||
|
assertFalse(HydrologyShoreTargets.placesAny(engine, Set.of("beach")));
|
||||||
|
|
||||||
|
coast.getHydrologyPolicy().setShoreBiomeWidth(0);
|
||||||
|
assertFalse(HydrologyShoreTargets.placesAny(engine, Set.of("dune")));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IrisBiome biome(String key) {
|
||||||
|
IrisBiome biome = new IrisBiome();
|
||||||
|
biome.setLoadKey(key);
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
-4
@@ -1,6 +1,7 @@
|
|||||||
package art.arcane.iris.generation.terrain;
|
package art.arcane.iris.generation.terrain;
|
||||||
|
|
||||||
import art.arcane.iris.generation.biome.IrisBiome;
|
import art.arcane.iris.generation.biome.IrisBiome;
|
||||||
|
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||||
|
|
||||||
import art.arcane.iris.pack.loading.IrisData;
|
import art.arcane.iris.pack.loading.IrisData;
|
||||||
@@ -18,6 +19,7 @@ import java.util.stream.Collectors;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
import static org.junit.Assert.assertNotSame;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -51,11 +53,12 @@ public class IrisDimensionFocusRegionTest {
|
|||||||
biome("wilds").setChildren(new KList<>("highlands"));
|
biome("wilds").setChildren(new KList<>("highlands"));
|
||||||
IrisBiome highlands = biome("highlands").setChildren(new KList<>("wilds"))
|
IrisBiome highlands = biome("highlands").setChildren(new KList<>("wilds"))
|
||||||
.setCarvingBiome("chalk-gardens")
|
.setCarvingBiome("chalk-gardens")
|
||||||
.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("shore")));
|
.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("shore")).setShoreBiomeWidth(4));
|
||||||
IrisBiome chalk = biome("chalk-gardens").setChildren(new KList<>("chalk-child"));
|
IrisBiome chalk = biome("chalk-gardens").setChildren(new KList<>("chalk-child"));
|
||||||
IrisBiome chalkChild = biome("chalk-child");
|
IrisBiome chalkChild = biome("chalk-child");
|
||||||
IrisBiome shore = biome("shore").setChildren(new KList<>("shore-child"));
|
IrisBiome shore = biome("shore").setChildren(new KList<>("shore-child"));
|
||||||
IrisBiome shoreChild = biome("shore-child").setCarvingBiome("wilds");
|
IrisBiome shoreChild = biome("shore-child").setCarvingBiome("wilds");
|
||||||
|
dimension.setHydrology(new IrisHydrology().setEnabled(true));
|
||||||
|
|
||||||
for (IrisBiome focus : List.of(highlands, chalk, chalkChild, shore, shoreChild)) {
|
for (IrisBiome focus : List.of(highlands, chalk, chalkChild, shore, shoreChild)) {
|
||||||
assertSame(tropical, dimension.resolveFocusRegion(focus, () -> data));
|
assertSame(tropical, dimension.resolveFocusRegion(focus, () -> data));
|
||||||
@@ -73,16 +76,21 @@ public class IrisDimensionFocusRegionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hydrologyPolicyShoreBiomesBelongToTheirRegion() {
|
public void placedHydrologyShoreBiomesBelongToTheirRegion() {
|
||||||
IrisRegion tropical = region("tropical").setLandBiomes(new KList<>("wilds"))
|
IrisRegion tropical = region("tropical").setLandBiomes(new KList<>("wilds", "dunes"))
|
||||||
.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("beach")));
|
.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("beach")));
|
||||||
biome("wilds").setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("reef")));
|
biome("wilds").setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("reef")));
|
||||||
|
biome("dunes");
|
||||||
IrisBiome beach = biome("beach");
|
IrisBiome beach = biome("beach");
|
||||||
IrisBiome reef = biome("reef");
|
IrisBiome reef = biome("reef");
|
||||||
|
dimension.setHydrology(new IrisHydrology().setEnabled(true));
|
||||||
|
|
||||||
|
assertNotSame(tropical, dimension.resolveFocusRegion(beach, () -> data));
|
||||||
|
assertNotSame(tropical, dimension.resolveFocusRegion(reef, () -> data));
|
||||||
|
tropical.getHydrologyPolicy().setShoreBiomeWidth(3);
|
||||||
assertSame(tropical, dimension.resolveFocusRegion(beach, () -> data));
|
assertSame(tropical, dimension.resolveFocusRegion(beach, () -> data));
|
||||||
assertSame(tropical, dimension.resolveFocusRegion(reef, () -> data));
|
assertSame(tropical, dimension.resolveFocusRegion(reef, () -> data));
|
||||||
assertEquals(Set.of("wilds"), tropical.getNaturalBiomes(() -> data).stream()
|
assertEquals(Set.of("wilds", "dunes"), tropical.getNaturalBiomes(() -> data).stream()
|
||||||
.map(IrisBiome::getLoadKey).collect(Collectors.toSet()));
|
.map(IrisBiome::getLoadKey).collect(Collectors.toSet()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+39
-6
@@ -204,12 +204,12 @@ public class IrisDimensionReachableBiomesTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void includesHydrologyPolicyShoreBiomesOnlyWhileHydrologyIsEnabled() {
|
public void includesHydrologyShoreBiomesOnlyWhereAWidthPlacesThem() {
|
||||||
IrisDimension dimension = new IrisDimension()
|
IrisDimension dimension = new IrisDimension()
|
||||||
.setRegions(new KList<>("reachable"))
|
.setRegions(new KList<>("reachable"))
|
||||||
.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("dimension-shore")));
|
.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("dimension-shore")));
|
||||||
IrisRegion reachable = new IrisRegion()
|
IrisRegion reachable = new IrisRegion()
|
||||||
.setLandBiomes(new KList<>("root"))
|
.setLandBiomes(new KList<>("root", "plain"))
|
||||||
.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("region-shore")));
|
.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("region-shore")));
|
||||||
IrisBiome root = biome("root").setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("biome-shore")));
|
IrisBiome root = biome("root").setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("biome-shore")));
|
||||||
IrisBiome regionShore = biome("region-shore").setChildren(new KList<>("shore-child"));
|
IrisBiome regionShore = biome("region-shore").setChildren(new KList<>("shore-child"));
|
||||||
@@ -221,16 +221,49 @@ public class IrisDimensionReachableBiomesTest {
|
|||||||
when(data.getBiomeLoader()).thenReturn(biomeLoader);
|
when(data.getBiomeLoader()).thenReturn(biomeLoader);
|
||||||
when(regionLoader.load("reachable")).thenReturn(reachable);
|
when(regionLoader.load("reachable")).thenReturn(reachable);
|
||||||
when(biomeLoader.load("root")).thenReturn(root);
|
when(biomeLoader.load("root")).thenReturn(root);
|
||||||
|
when(biomeLoader.load("plain")).thenReturn(biome("plain"));
|
||||||
when(biomeLoader.load("dimension-shore")).thenReturn(biome("dimension-shore"));
|
when(biomeLoader.load("dimension-shore")).thenReturn(biome("dimension-shore"));
|
||||||
when(biomeLoader.load("region-shore")).thenReturn(regionShore);
|
when(biomeLoader.load("region-shore")).thenReturn(regionShore);
|
||||||
when(biomeLoader.load("shore-child")).thenReturn(biome("shore-child"));
|
when(biomeLoader.load("shore-child")).thenReturn(biome("shore-child"));
|
||||||
when(biomeLoader.load("biome-shore")).thenReturn(biome("biome-shore"));
|
when(biomeLoader.load("biome-shore")).thenReturn(biome("biome-shore"));
|
||||||
|
|
||||||
assertEquals(Set.of("root"), reachableKeys(dimension, data));
|
assertEquals(Set.of("root", "plain"), reachableKeys(dimension, data));
|
||||||
dimension.setHydrology(new IrisHydrology().setEnabled(false));
|
|
||||||
assertEquals(Set.of("root"), reachableKeys(dimension, data));
|
|
||||||
dimension.setHydrology(new IrisHydrology().setEnabled(true));
|
dimension.setHydrology(new IrisHydrology().setEnabled(true));
|
||||||
assertEquals(Set.of("root", "dimension-shore", "region-shore", "shore-child", "biome-shore"), reachableKeys(dimension, data));
|
assertEquals(Set.of("root", "plain"), reachableKeys(dimension, data));
|
||||||
|
dimension.getHydrologyPolicy().setShoreBiomeWidth(3);
|
||||||
|
assertEquals(Set.of("root", "plain", "region-shore", "shore-child", "biome-shore"), reachableKeys(dimension, data));
|
||||||
|
dimension.setHydrology(new IrisHydrology().setEnabled(false));
|
||||||
|
assertEquals(Set.of("root", "plain"), reachableKeys(dimension, data));
|
||||||
|
dimension.setHydrology(new IrisHydrology().setEnabled(true));
|
||||||
|
reachable.getHydrologyPolicy().setShoreBiomeWidth(0);
|
||||||
|
assertEquals(Set.of("root", "plain"), reachableKeys(dimension, data));
|
||||||
|
root.getHydrologyPolicy().setShoreBiomeWidth(2);
|
||||||
|
assertEquals(Set.of("root", "plain", "biome-shore"), reachableKeys(dimension, data));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void aParentWidthReachesTheShoreListOfItsChildren() {
|
||||||
|
IrisDimension dimension = new IrisDimension()
|
||||||
|
.setRegions(new KList<>("reachable"))
|
||||||
|
.setHydrology(new IrisHydrology().setEnabled(true));
|
||||||
|
IrisRegion reachable = new IrisRegion().setLandBiomes(new KList<>("parent"));
|
||||||
|
IrisBiome parent = biome("parent").setChildren(new KList<>("child"));
|
||||||
|
IrisBiome child = biome("child").setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomes(new KList<>("child-shore")));
|
||||||
|
|
||||||
|
IrisData data = mock(IrisData.class);
|
||||||
|
ResourceLoader<IrisRegion> regionLoader = mock(ResourceLoader.class);
|
||||||
|
ResourceLoader<IrisBiome> biomeLoader = mock(ResourceLoader.class);
|
||||||
|
when(data.getRegionLoader()).thenReturn(regionLoader);
|
||||||
|
when(data.getBiomeLoader()).thenReturn(biomeLoader);
|
||||||
|
when(regionLoader.load("reachable")).thenReturn(reachable);
|
||||||
|
when(biomeLoader.load("parent")).thenReturn(parent);
|
||||||
|
when(biomeLoader.load("child")).thenReturn(child);
|
||||||
|
when(biomeLoader.load("child-shore")).thenReturn(biome("child-shore"));
|
||||||
|
|
||||||
|
assertEquals(Set.of("parent", "child"), reachableKeys(dimension, data));
|
||||||
|
parent.setHydrologyPolicy(new IrisHydrologyPolicy().setShoreBiomeWidth(5));
|
||||||
|
assertEquals(Set.of("parent", "child", "child-shore"), reachableKeys(dimension, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -606,6 +606,38 @@ public class PackHydrologyValidatorTest {
|
|||||||
+ " and cascades, sea inlets and cave pools are not generated."), validation.warnings());
|
+ " and cascades, sea inlets and cave pools are not generated."), validation.warnings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shoreBiomesWithoutWidthWarn() throws Exception {
|
||||||
|
PackHydrologyValidator.Validation unset = validate(shorePack(""));
|
||||||
|
PackHydrologyValidator.Validation widened = validate(shorePack(", \"shoreBiomeWidth\": 3"));
|
||||||
|
|
||||||
|
assertTrue(unset.errors().toString(), unset.errors().isEmpty());
|
||||||
|
assertEquals(List.of(
|
||||||
|
"Dimension 'main'.hydrologyPolicy.shoreBiomes lists shore biomes, but no shoreBiomeWidth above 0 applies to them,"
|
||||||
|
+ " so none are placed.",
|
||||||
|
"Region 'region'.hydrologyPolicy.shoreBiomes lists shore biomes, but no shoreBiomeWidth above 0 applies to them,"
|
||||||
|
+ " so none are placed.",
|
||||||
|
"Biome 'dune'.hydrologyPolicy.shoreBiomes lists shore biomes, but no shoreBiomeWidth above 0 applies to them,"
|
||||||
|
+ " so none are placed."), unset.warnings());
|
||||||
|
assertTrue(widened.errors().toString(), widened.errors().isEmpty());
|
||||||
|
assertTrue(widened.warnings().toString(), widened.warnings().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
private File shorePack(String dimensionWidth) throws Exception {
|
||||||
|
File pack = pack(dimension(WATER_ONLY, "\"hydrologyPolicy\": {\"shoreBiomes\": [\"beach\"]" + dimensionWidth + "},"));
|
||||||
|
write(pack, "regions/region.json", """
|
||||||
|
{"landBiomes": ["biome", "dune", "bare"], "hydrologyPolicy": {"shoreBiomes": ["beach"]}}
|
||||||
|
""");
|
||||||
|
write(pack, "biomes/dune.json", """
|
||||||
|
{"name": "Dune", "hydrologyPolicy": {"shoreBiomes": ["beach"]}}
|
||||||
|
""");
|
||||||
|
write(pack, "biomes/bare.json", """
|
||||||
|
{"name": "Bare", "hydrologyPolicy": {"shoreBiomes": []}}
|
||||||
|
""");
|
||||||
|
write(pack, "biomes/beach.json", "{\"name\": \"Beach\"}");
|
||||||
|
return pack;
|
||||||
|
}
|
||||||
|
|
||||||
private PackHydrologyValidator.Validation validate(File pack) {
|
private PackHydrologyValidator.Validation validate(File pack) {
|
||||||
File[] dimensions = new File(pack, "dimensions").listFiles(
|
File[] dimensions = new File(pack, "dimensions").listFiles(
|
||||||
file -> file.isFile() && file.getName().endsWith(".json"));
|
file -> file.isFile() && file.getName().endsWith(".json"));
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
|
|||||||
@ClassRule
|
@ClassRule
|
||||||
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
|
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
|
||||||
|
|
||||||
private static final String EXPECTED_SCHEMA_DIGEST = "33c7287d91f9b38d96e156aa3eb317331befaa2092cf848d04cdbd0e3e7a3cd6";
|
private static final String EXPECTED_SCHEMA_DIGEST = "a07a6f50e6df895cf7d11a50245bfb3e987c5be2f527e45da86ade9826cd6f3a";
|
||||||
|
|
||||||
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
|
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
|
||||||
IrisDimension.class,
|
IrisDimension.class,
|
||||||
|
|||||||
Reference in new issue
Block a user