mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-02 10:44:49 +00:00
Inherit cave pool fluids
- Cave pools resolve fluid from the cave biome, then region, then dimension - Engine.getCaveBiomeBelowSurface returns no biome where caves fall back to the surface - caveFluidPolicies turns on only for cave biome, region or dimension fluids - IrisDimension.getReachableCaveBiomes lists region cave biomes and carving bands - Recapture the schema digest for the cavePools.fluid description
This commit is contained in:
1 parent
701b3191eb
commit
1e41c9eca0
10 files changed
+261
-51
No files matched your search
@@ -48,6 +48,6 @@ public class IrisCavePools {
|
|||||||
private KList<Integer> freeboard = new KList<>(0, 1);
|
private KList<Integer> freeboard = new KList<>(0, 1);
|
||||||
|
|
||||||
@Required
|
@Required
|
||||||
@Description("Name of the fluid profile that fills cave pools. A cave biome's hydrology policy fluid replaces it.")
|
@Description("Name of the fluid profile that fills cave pools. The hydrology policy fluid of the cave biome at the pool replaces it, then that of its region, then that of the dimension. A surface biome's policy never fills cave pools.")
|
||||||
private String fluid = "water";
|
private String fluid = "water";
|
||||||
}
|
}
|
||||||
+19
-11
@@ -30,6 +30,7 @@ import art.arcane.iris.generation.runtime.IrisComplex;
|
|||||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||||
import art.arcane.iris.generation.runtime.PreparedHydrologyCacheIdentity;
|
import art.arcane.iris.generation.runtime.PreparedHydrologyCacheIdentity;
|
||||||
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.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.iris.world.IrisWorld;
|
import art.arcane.iris.world.IrisWorld;
|
||||||
|
|
||||||
@@ -148,7 +149,7 @@ public final class HydrologyRuntime {
|
|||||||
HydrologySettings settings = HydrologySettings.compile(config, engine.getSeedManager().getBodies(), dimension.getFluidHeight(), 0,
|
HydrologySettings settings = HydrologySettings.compile(config, engine.getSeedManager().getBodies(), dimension.getFluidHeight(), 0,
|
||||||
engine.getHeight());
|
engine.getHeight());
|
||||||
boolean caveFluidPolicies = settings.underground().cavePools().enabled()
|
boolean caveFluidPolicies = settings.underground().cavePools().enabled()
|
||||||
&& requireBiomeFluids(dimension.getReachableBiomes(engine), settings);
|
&& requireCaveFluids(dimension, dimension.getAllRegions(engine), dimension.getReachableCaveBiomes(engine), settings);
|
||||||
if (settings.density() == 0D) {
|
if (settings.density() == 0D) {
|
||||||
return DISABLED;
|
return DISABLED;
|
||||||
}
|
}
|
||||||
@@ -165,20 +166,27 @@ public final class HydrologyRuntime {
|
|||||||
identity -> store(world, dimensionKey, settings, identity), caveFluidPolicies);
|
identity -> store(world, dimensionKey, settings, identity), caveFluidPolicies);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean requireBiomeFluids(Collection<IrisBiome> biomes, HydrologySettings settings) {
|
static boolean requireCaveFluids(IrisDimension dimension, Collection<IrisRegion> regions, Collection<IrisBiome> caveBiomes,
|
||||||
boolean named = false;
|
HydrologySettings settings) {
|
||||||
for (IrisBiome biome : biomes) {
|
boolean named = requireFluid(dimension.getHydrologyPolicy(), "dimension '" + dimension.getLoadKey() + "'", settings);
|
||||||
IrisHydrologyPolicy policy = biome == null ? null : biome.getHydrologyPolicy();
|
for (IrisRegion region : regions) {
|
||||||
String fluid = policy == null ? null : policy.getFluid();
|
named |= requireFluid(region.getHydrologyPolicy(), "region '" + region.getLoadKey() + "'", settings);
|
||||||
if (fluid == null) {
|
}
|
||||||
continue;
|
for (IrisBiome biome : caveBiomes) {
|
||||||
}
|
named |= requireFluid(biome.getHydrologyPolicy(), "biome '" + biome.getLoadKey() + "'", settings);
|
||||||
settings.requireFillingFluid(fluid, "biome '" + biome.getLoadKey() + "' hydrologyPolicy.fluid");
|
|
||||||
named = true;
|
|
||||||
}
|
}
|
||||||
return named;
|
return named;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean requireFluid(IrisHydrologyPolicy policy, String owner, HydrologySettings settings) {
|
||||||
|
String fluid = policy == null ? null : policy.getFluid();
|
||||||
|
if (fluid == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
settings.requireFillingFluid(fluid, owner + " hydrologyPolicy.fluid");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean caveFluidPolicies() {
|
public boolean caveFluidPolicies() {
|
||||||
return caveFluidPolicies;
|
return caveFluidPolicies;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import art.arcane.iris.generation.runtime.IrisComplex;
|
|||||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||||
import art.arcane.iris.generation.subterrain.SubterrainPlan;
|
import art.arcane.iris.generation.subterrain.SubterrainPlan;
|
||||||
import art.arcane.iris.generation.subterrain.SubterrainPlanner;
|
import art.arcane.iris.generation.subterrain.SubterrainPlanner;
|
||||||
|
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||||
|
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||||
import art.arcane.iris.generation.terrain.Terrain3DColumn;
|
import art.arcane.iris.generation.terrain.Terrain3DColumn;
|
||||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||||
@@ -31,6 +33,7 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
|||||||
private final MantleWriter writer;
|
private final MantleWriter writer;
|
||||||
private final IrisComplex complex;
|
private final IrisComplex complex;
|
||||||
private final Engine engine;
|
private final Engine engine;
|
||||||
|
private final IrisDimension dimension;
|
||||||
private final int chunkX;
|
private final int chunkX;
|
||||||
private final int chunkZ;
|
private final int chunkZ;
|
||||||
private final int originX;
|
private final int originX;
|
||||||
@@ -54,12 +57,13 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
|||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
this.complex = complex;
|
this.complex = complex;
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
|
this.dimension = engine.getDimension();
|
||||||
this.chunkX = chunkX;
|
this.chunkX = chunkX;
|
||||||
this.chunkZ = chunkZ;
|
this.chunkZ = chunkZ;
|
||||||
this.originX = (chunkX - 1) << 4;
|
this.originX = (chunkX - 1) << 4;
|
||||||
this.originZ = (chunkZ - 1) << 4;
|
this.originZ = (chunkZ - 1) << 4;
|
||||||
this.height = writer.getMantle().getWorldHeight();
|
this.height = writer.getMantle().getWorldHeight();
|
||||||
this.caveLavaHeight = engine.getDimension().getCaveLavaHeight();
|
this.caveLavaHeight = dimension.getCaveLavaHeight();
|
||||||
this.minimumY = engine.getWorld().minHeight();
|
this.minimumY = engine.getWorld().minHeight();
|
||||||
HydrologyRuntime runtime = complex.getHydrologyRuntime();
|
HydrologyRuntime runtime = complex.getHydrologyRuntime();
|
||||||
this.caveFluids = runtime.caveFluidPolicies();
|
this.caveFluids = runtime.caveFluidPolicies();
|
||||||
@@ -110,10 +114,10 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
long revision = ProvisionalSampling.revision();
|
long revision = ProvisionalSampling.revision();
|
||||||
IrisBiome biome = engine.getCaveBiome(x, y, z);
|
IrisBiome biome = engine.getCaveBiomeBelowSurface(x, y, z);
|
||||||
|
IrisRegion region = complex.getRegionStream().get(x, z);
|
||||||
requireFinal(revision, x, z);
|
requireFinal(revision, x, z);
|
||||||
IrisHydrologyPolicy policy = biome == null ? null : biome.getHydrologyPolicy();
|
return IrisHydrologyPolicy.inherited(biome, region, dimension, IrisHydrologyPolicy::getFluid);
|
||||||
return policy == null ? null : policy.getFluid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Collection<SeaInlet> inlets(HydrologyRuntime runtime, int chunkX, int chunkZ) {
|
private static Collection<SeaInlet> inlets(HydrologyRuntime runtime, int chunkX, int chunkZ) {
|
||||||
|
|||||||
@@ -478,8 +478,8 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
|||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
default IrisBiome getCaveBiome(int x, int z) {
|
default IrisBiome getCaveBiome(int x, int z) {
|
||||||
IrisBiome biome = getComplex().getCaveBiomeStream().get(x, z);
|
IrisBiome biome = regionCaveBiome(x, z);
|
||||||
return biome == null || biome.getLoadKey() == null ? getSurfaceBiome(x, z) : biome;
|
return biome == null ? getSurfaceBiome(x, z) : biome;
|
||||||
}
|
}
|
||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
@@ -489,13 +489,9 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
|||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
default IrisBiome getCaveBiome(int x, int y, int z, IrisDimensionCarvingResolver.State state) {
|
default IrisBiome getCaveBiome(int x, int y, int z, IrisDimensionCarvingResolver.State state) {
|
||||||
IrisBiome featureBiome = getSubterrainBiome(x, y, z);
|
IrisBiome placedBiome = placedCaveBiome(x, y, z, state);
|
||||||
if (featureBiome != null) {
|
if (placedBiome != null) {
|
||||||
return featureBiome;
|
return placedBiome;
|
||||||
}
|
|
||||||
IrisBiome configuredBiome = resolveConfiguredCaveBiome(x, y, z, state);
|
|
||||||
if (configuredBiome != null) {
|
|
||||||
return configuredBiome;
|
|
||||||
}
|
}
|
||||||
boolean naturalFallback = answersFromNaturalTerrain(x, z);
|
boolean naturalFallback = answersFromNaturalTerrain(x, z);
|
||||||
IrisBiome surfaceBiome = caveDepthSurfaceBiome(x, z, naturalFallback);
|
IrisBiome surfaceBiome = caveDepthSurfaceBiome(x, z, naturalFallback);
|
||||||
@@ -503,6 +499,26 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
|||||||
return resolveDepthCaveBiome(x, y, z, surfaceBiome, surfaceY);
|
return resolveDepthCaveBiome(x, y, z, surfaceBiome, surfaceY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BlockCoordinates
|
||||||
|
default IrisBiome getCaveBiomeBelowSurface(int x, int y, int z) {
|
||||||
|
IrisBiome placedBiome = placedCaveBiome(x, y, z, null);
|
||||||
|
if (placedBiome != null) {
|
||||||
|
return placedBiome;
|
||||||
|
}
|
||||||
|
IrisBiome caveBiome = regionCaveBiome(x, z);
|
||||||
|
return caveBiome == null ? null : depthCaveBiome(caveBiome, y, null, caveDepthSurfaceY(x, z, answersFromNaturalTerrain(x, z)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IrisBiome regionCaveBiome(int x, int z) {
|
||||||
|
IrisBiome biome = getComplex().getCaveBiomeStream().get(x, z);
|
||||||
|
return biome == null || biome.getLoadKey() == null ? null : biome;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IrisBiome placedCaveBiome(int x, int y, int z, IrisDimensionCarvingResolver.State state) {
|
||||||
|
IrisBiome featureBiome = getSubterrainBiome(x, y, z);
|
||||||
|
return featureBiome != null ? featureBiome : resolveConfiguredCaveBiome(x, y, z, state);
|
||||||
|
}
|
||||||
|
|
||||||
private IrisBiome caveDepthSurfaceBiome(int x, int z, boolean naturalFallback) {
|
private IrisBiome caveDepthSurfaceBiome(int x, int z, boolean naturalFallback) {
|
||||||
if (naturalFallback) {
|
if (naturalFallback) {
|
||||||
return getComplex().naturalSurfaceBiome(x, z);
|
return getComplex().naturalSurfaceBiome(x, z);
|
||||||
@@ -525,15 +541,8 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
|||||||
IrisBiome surfaceBiome,
|
IrisBiome surfaceBiome,
|
||||||
int surfaceY
|
int surfaceY
|
||||||
) {
|
) {
|
||||||
IrisBiome featureBiome = getSubterrainBiome(x, y, z);
|
IrisBiome placedBiome = placedCaveBiome(x, y, z, state);
|
||||||
if (featureBiome != null) {
|
return placedBiome != null ? placedBiome : resolveDepthCaveBiome(x, y, z, surfaceBiome, surfaceY);
|
||||||
return featureBiome;
|
|
||||||
}
|
|
||||||
IrisBiome configuredBiome = resolveConfiguredCaveBiome(x, y, z, state);
|
|
||||||
if (configuredBiome != null) {
|
|
||||||
return configuredBiome;
|
|
||||||
}
|
|
||||||
return resolveDepthCaveBiome(x, y, z, surfaceBiome, surfaceY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisBiome resolveConfiguredCaveBiome(
|
private IrisBiome resolveConfiguredCaveBiome(
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ import java.util.Collection;
|
|||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -785,6 +786,29 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
return biomes.v();
|
return biomes.v();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KList<IrisBiome> getReachableCaveBiomes(DataProvider g) {
|
||||||
|
IrisData data = g == null ? null : g.getData();
|
||||||
|
if (data == null || data.getBiomeLoader() == null) {
|
||||||
|
return new KList<>();
|
||||||
|
}
|
||||||
|
Map<String, IrisBiome> biomes = new LinkedHashMap<>();
|
||||||
|
for (IrisRegion region : getAllRegions(g)) {
|
||||||
|
for (IrisBiome biome : region.getRealCaveBiomes(g)) {
|
||||||
|
biomes.putIfAbsent(biome.getLoadKey(), biome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KList<IrisDimensionCarvingEntry> carvingEntries = getCarving();
|
||||||
|
if (carvingEntries != null) {
|
||||||
|
for (IrisDimensionCarvingEntry entry : carvingEntries) {
|
||||||
|
IrisBiome biome = entry == null || !entry.isEnabled() ? null : entry.getRealBiome(data);
|
||||||
|
if (biome != null) {
|
||||||
|
biomes.putIfAbsent(biome.getLoadKey(), biome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new KList<>(biomes.values());
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|||||||
+19
-8
@@ -29,6 +29,7 @@ import art.arcane.iris.generation.runtime.IrisComplex;
|
|||||||
import art.arcane.iris.generation.runtime.PreparedHydrologyCacheIdentity;
|
import art.arcane.iris.generation.runtime.PreparedHydrologyCacheIdentity;
|
||||||
import art.arcane.iris.generation.runtime.SeedManager;
|
import art.arcane.iris.generation.runtime.SeedManager;
|
||||||
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.spi.LogLevel;
|
import art.arcane.iris.spi.LogLevel;
|
||||||
import art.arcane.iris.testsupport.FakeHydrology;
|
import art.arcane.iris.testsupport.FakeHydrology;
|
||||||
import art.arcane.iris.testsupport.PlatformLeakGuard;
|
import art.arcane.iris.testsupport.PlatformLeakGuard;
|
||||||
@@ -848,17 +849,27 @@ public class HydrologyRuntimeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void biomeFluidPoliciesAreCheckedWhenTheEngineLoads() {
|
public void caveFluidPoliciesAreCheckedWhenTheEngineLoads() {
|
||||||
|
IrisDimension dimension = new IrisDimension();
|
||||||
|
IrisRegion region = new IrisRegion();
|
||||||
IrisBiome plain = new IrisBiome();
|
IrisBiome plain = new IrisBiome();
|
||||||
IrisBiome flooded = new IrisBiome();
|
IrisBiome flooded = new IrisBiome().setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("water"));
|
||||||
flooded.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("water"));
|
IrisBiome magma = new IrisBiome().setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("magma"));
|
||||||
IrisBiome magma = new IrisBiome();
|
|
||||||
magma.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("magma"));
|
|
||||||
|
|
||||||
assertFalse(HydrologyRuntime.requireBiomeFluids(List.of(plain), settings()));
|
assertFalse(HydrologyRuntime.requireCaveFluids(dimension, List.of(region), List.of(plain), settings()));
|
||||||
assertTrue(HydrologyRuntime.requireBiomeFluids(List.of(plain, flooded), settings()));
|
assertTrue(HydrologyRuntime.requireCaveFluids(dimension, List.of(region), List.of(plain, flooded), settings()));
|
||||||
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
|
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
|
||||||
() -> HydrologyRuntime.requireBiomeFluids(List.of(plain, magma), settings()));
|
() -> HydrologyRuntime.requireCaveFluids(dimension, List.of(region), List.of(plain, magma), settings()));
|
||||||
|
assertTrue(failure.getMessage(), failure.getMessage().contains("'magma'"));
|
||||||
|
|
||||||
|
region.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("water"));
|
||||||
|
assertTrue(HydrologyRuntime.requireCaveFluids(dimension, List.of(region), List.of(plain), settings()));
|
||||||
|
region.setHydrologyPolicy(null);
|
||||||
|
dimension.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("water"));
|
||||||
|
assertTrue(HydrologyRuntime.requireCaveFluids(dimension, List.of(region), List.of(plain), settings()));
|
||||||
|
dimension.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("magma"));
|
||||||
|
failure = assertThrows(IllegalArgumentException.class,
|
||||||
|
() -> HydrologyRuntime.requireCaveFluids(dimension, List.of(region), List.of(plain), settings()));
|
||||||
assertTrue(failure.getMessage(), failure.getMessage().contains("'magma'"));
|
assertTrue(failure.getMessage(), failure.getMessage().contains("'magma'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package art.arcane.iris.generation.mantle;
|
|||||||
import art.arcane.iris.generation.biome.IrisBiome;
|
import art.arcane.iris.generation.biome.IrisBiome;
|
||||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveAction;
|
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveAction;
|
||||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||||
|
import art.arcane.iris.generation.hydrology.config.IrisFluidProfile;
|
||||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
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;
|
||||||
@@ -12,12 +13,15 @@ import art.arcane.iris.generation.hydrology.underground.CaveVoxel;
|
|||||||
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||||
import art.arcane.iris.generation.hydrology.underground.SeaInletRasterizer;
|
import art.arcane.iris.generation.hydrology.underground.SeaInletRasterizer;
|
||||||
import art.arcane.iris.generation.runtime.Engine;
|
import art.arcane.iris.generation.runtime.Engine;
|
||||||
|
import art.arcane.iris.generation.runtime.EnginePlatformHooks;
|
||||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||||
import art.arcane.iris.generation.subterrain.SubterrainCell;
|
import art.arcane.iris.generation.subterrain.SubterrainCell;
|
||||||
import art.arcane.iris.generation.subterrain.SubterrainPlan;
|
import art.arcane.iris.generation.subterrain.SubterrainPlan;
|
||||||
import art.arcane.iris.generation.subterrain.SubterrainPlanner;
|
import art.arcane.iris.generation.subterrain.SubterrainPlanner;
|
||||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||||
|
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||||
|
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||||
import art.arcane.iris.generation.terrain.Terrain3DColumn;
|
import art.arcane.iris.generation.terrain.Terrain3DColumn;
|
||||||
import art.arcane.iris.world.IrisWorld;
|
import art.arcane.iris.world.IrisWorld;
|
||||||
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
import art.arcane.iris.world.storage.matter.IrisMatterSupport;
|
||||||
@@ -31,13 +35,18 @@ import art.arcane.volmlib.util.matter.IrisMatter;
|
|||||||
import art.arcane.volmlib.util.matter.Matter;
|
import art.arcane.volmlib.util.matter.Matter;
|
||||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||||
|
import art.arcane.volmlib.util.stream.interpolation.Interpolated;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationHandler;
|
||||||
|
import java.lang.reflect.Proxy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@@ -78,8 +87,8 @@ public class MantleCarvedTerrainTest {
|
|||||||
sections[1].<PreObjectMatterCell>slice(PreObjectMatterCell.class).set(9, 4, 9, PreObjectMatterCell.cavern(null));
|
sections[1].<PreObjectMatterCell>slice(PreObjectMatterCell.class).set(9, 4, 9, PreObjectMatterCell.cavern(null));
|
||||||
IrisBiome flooded = new IrisBiome();
|
IrisBiome flooded = new IrisBiome();
|
||||||
flooded.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("lava"));
|
flooded.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("lava"));
|
||||||
when(scene.engine.getCaveBiome(1, 20, 1)).thenReturn(flooded);
|
when(scene.engine.getCaveBiomeBelowSurface(1, 20, 1)).thenReturn(flooded);
|
||||||
when(scene.engine.getCaveBiome(5, 20, 5)).thenReturn(new IrisBiome());
|
when(scene.engine.getCaveBiomeBelowSurface(5, 20, 5)).thenReturn(new IrisBiome());
|
||||||
|
|
||||||
MantleCarvedTerrain carved = scene.carved();
|
MantleCarvedTerrain carved = scene.carved();
|
||||||
|
|
||||||
@@ -214,6 +223,80 @@ public class MantleCarvedTerrainTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shallowPoolsUnderVolcanicSurfacesStayWater() {
|
||||||
|
IrisBiome volcanoes = biome("tropical/volcanoes", 0, "lava");
|
||||||
|
IrisRegion tropical = region("tropical", null);
|
||||||
|
Scene shallow = poolRoom(new Underground(volcanoes, biome("carving/hollow", 24, null), tropical, new IrisDimension()));
|
||||||
|
Scene uncovered = poolRoom(new Underground(volcanoes, new IrisBiome(), tropical, new IrisDimension()));
|
||||||
|
|
||||||
|
assertNull("above the cave biome's depth", shallow.carved().caveFluid(7, 23, 7));
|
||||||
|
assertNull("in a region without cave biomes", uncovered.carved().caveFluid(7, 23, 7));
|
||||||
|
assertEquals(Set.of("water"), poolFluids(shallow.generate(0)));
|
||||||
|
assertEquals(Set.of("water"), poolFluids(uncovered.generate(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void caveBiomeFluidSwitchesPools() {
|
||||||
|
IrisBiome plains = biome("temperate/plains", 0, null);
|
||||||
|
IrisBiome hollow = biome("carving/hollow", 0, null);
|
||||||
|
IrisRegion temperate = region("temperate", null);
|
||||||
|
IrisRegion volcanic = region("volcanic", "lava");
|
||||||
|
IrisDimension molten = new IrisDimension().setHydrologyPolicy(new IrisHydrologyPolicy().setFluid("lava"));
|
||||||
|
|
||||||
|
assertEquals("the cave biome's own fluid", Set.of("lava"),
|
||||||
|
poolFluids(poolRoom(new Underground(plains, biome("carving/magma", 0, "lava"), temperate, new IrisDimension())).generate(0)));
|
||||||
|
assertEquals("the region's fluid under a cave biome without one", Set.of("lava"),
|
||||||
|
poolFluids(poolRoom(new Underground(plains, hollow, volcanic, new IrisDimension())).generate(0)));
|
||||||
|
assertEquals("the dimension's fluid under a region without one", Set.of("lava"),
|
||||||
|
poolFluids(poolRoom(new Underground(plains, hollow, temperate, molten)).generate(0)));
|
||||||
|
assertEquals("the cave biome's fluid before the region and the dimension", Set.of("water"),
|
||||||
|
poolFluids(poolRoom(new Underground(plains, biome("carving/spring", 0, "water"), volcanic, molten)).generate(0)));
|
||||||
|
assertEquals("a cave biome's fluid only where the cave biome reaches", Set.of("water"),
|
||||||
|
poolFluids(poolRoom(new Underground(plains, biome("carving/deep-magma", 24, "lava"), temperate, new IrisDimension())).generate(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Scene poolRoom(Underground underground) {
|
||||||
|
Scene scene = new Scene(underground);
|
||||||
|
Matter[] room = scene.chunk(0, 0);
|
||||||
|
for (int x = 1; x <= 14; x++) {
|
||||||
|
for (int z = 1; z <= 14; z++) {
|
||||||
|
for (int y = 22; y <= 30; y++) {
|
||||||
|
cavern(room, x, y, z, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Set<String> poolFluids(Map<Long, HydrologyCaveCell> written) {
|
||||||
|
Set<String> fluids = new HashSet<>();
|
||||||
|
for (HydrologyCaveCell cell : written.values()) {
|
||||||
|
if (cell.action() == HydrologyCaveAction.POOL_SOURCE) {
|
||||||
|
fluids.add(cell.fluidProfileKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fluids;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IrisBiome biome(String key, int caveMinDepth, String fluid) {
|
||||||
|
IrisBiome biome = new IrisBiome().setCaveMinDepthBelowSurface(caveMinDepth);
|
||||||
|
biome.setLoadKey(key);
|
||||||
|
if (fluid != null) {
|
||||||
|
biome.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid(fluid));
|
||||||
|
}
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IrisRegion region(String key, String fluid) {
|
||||||
|
IrisRegion region = new IrisRegion();
|
||||||
|
region.setLoadKey(key);
|
||||||
|
if (fluid != null) {
|
||||||
|
region.setHydrologyPolicy(new IrisHydrologyPolicy().setFluid(fluid));
|
||||||
|
}
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
private static Scene inletScene() {
|
private static Scene inletScene() {
|
||||||
Scene scene = new Scene();
|
Scene scene = new Scene();
|
||||||
Matter[] room = scene.chunk(0, 0);
|
Matter[] room = scene.chunk(0, 0);
|
||||||
@@ -263,24 +346,62 @@ public class MantleCarvedTerrainTest {
|
|||||||
sections[y >> 4].<MatterCavern>slice(MatterCavern.class).set(x & 15, y & 15, z & 15, new MatterCavern(true, "", liquid));
|
sections[y >> 4].<MatterCavern>slice(MatterCavern.class).set(x & 15, y & 15, z & 15, new MatterCavern(true, "", liquid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private record Underground(IrisBiome surface, IrisBiome cave, IrisRegion region, IrisDimension dimension) {
|
||||||
|
private Engine engine(IrisComplex complex) {
|
||||||
|
IrisWorld world = mock(IrisWorld.class);
|
||||||
|
EnginePlatformHooks hooks = new EnginePlatformHooks() {
|
||||||
|
};
|
||||||
|
return (Engine) Proxy.newProxyInstance(Engine.class.getClassLoader(), new Class<?>[]{Engine.class},
|
||||||
|
(proxy, method, arguments) -> switch (method.getName()) {
|
||||||
|
case "getComplex" -> complex;
|
||||||
|
case "getDimension" -> dimension;
|
||||||
|
case "getWorld" -> world;
|
||||||
|
case "getPlatformHooks" -> hooks;
|
||||||
|
case "getData" -> null;
|
||||||
|
default -> InvocationHandler.invokeDefault(proxy, method, arguments);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final class Scene {
|
private static final class Scene {
|
||||||
private final Map<Long, MantleChunk<Matter>> chunks = new HashMap<>();
|
private final Map<Long, MantleChunk<Matter>> chunks = new HashMap<>();
|
||||||
private final Map<Long, Matter[]> sections = new HashMap<>();
|
private final Map<Long, Matter[]> sections = new HashMap<>();
|
||||||
private final MantleWriter writer = mock(MantleWriter.class);
|
private final MantleWriter writer = mock(MantleWriter.class);
|
||||||
private final IrisComplex complex = mock(IrisComplex.class);
|
private final IrisComplex complex = mock(IrisComplex.class);
|
||||||
private final Engine engine = mock(Engine.class);
|
private final Engine engine;
|
||||||
private final List<SeaInlet> inlets = new ArrayList<>();
|
private final List<SeaInlet> inlets = new ArrayList<>();
|
||||||
private final Map<Long, HydrologyCaveCell> cells = new HashMap<>();
|
private final Map<Long, HydrologyCaveCell> cells = new HashMap<>();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private Scene() {
|
private Scene() {
|
||||||
|
this.engine = mock(Engine.class);
|
||||||
|
when(engine.getDimension()).thenReturn(new IrisDimension());
|
||||||
|
when(engine.getWorld()).thenReturn(mock(IrisWorld.class));
|
||||||
|
wire();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Scene(Underground underground) {
|
||||||
|
this.engine = underground.engine(complex);
|
||||||
|
wire();
|
||||||
|
when(complex.getTrueBiomeStream()).thenReturn(constant(underground.surface()));
|
||||||
|
when(complex.getCaveBiomeStream()).thenReturn(constant(underground.cave()));
|
||||||
|
when(complex.getRegionStream()).thenReturn(constant(underground.region()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> ProceduralStream<T> constant(T value) {
|
||||||
|
return ProceduralStream.of((x, z) -> value, Interpolated.of(ignored -> 0D, ignored -> value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void wire() {
|
||||||
Mantle<Matter> mantle = mock(Mantle.class);
|
Mantle<Matter> mantle = mock(Mantle.class);
|
||||||
when(mantle.getWorldHeight()).thenReturn(HEIGHT);
|
when(mantle.getWorldHeight()).thenReturn(HEIGHT);
|
||||||
when(writer.getMantle()).thenReturn(mantle);
|
when(writer.getMantle()).thenReturn(mantle);
|
||||||
when(writer.acquireChunk(anyInt(), anyInt())).thenAnswer(invocation -> mantleChunk(invocation.getArgument(0), invocation.getArgument(1)));
|
when(writer.acquireChunk(anyInt(), anyInt())).thenAnswer(invocation -> mantleChunk(invocation.getArgument(0), invocation.getArgument(1)));
|
||||||
ProceduralStream<Double> heights = mock(ProceduralStream.class);
|
ProceduralStream<Double> heights = mock(ProceduralStream.class);
|
||||||
when(heights.getDouble(anyDouble(), anyDouble())).thenReturn(40.4D);
|
when(heights.getDouble(anyDouble(), anyDouble())).thenReturn(40.4D);
|
||||||
|
when(heights.get(anyDouble(), anyDouble())).thenReturn(40.4D);
|
||||||
when(complex.getHeightStream()).thenReturn(heights);
|
when(complex.getHeightStream()).thenReturn(heights);
|
||||||
|
when(complex.getRegionStream()).thenReturn(constant(new IrisRegion()));
|
||||||
when(complex.allowsMantleChunkWrite(anyInt(), anyInt())).thenReturn(true);
|
when(complex.allowsMantleChunkWrite(anyInt(), anyInt())).thenReturn(true);
|
||||||
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
HydrologyRuntime runtime = mock(HydrologyRuntime.class);
|
||||||
when(runtime.caveFluidPolicies()).thenReturn(true);
|
when(runtime.caveFluidPolicies()).thenReturn(true);
|
||||||
@@ -296,9 +417,6 @@ public class MantleCarvedTerrainTest {
|
|||||||
return null;
|
return null;
|
||||||
}).when(writer).withChunkFence(anyInt(), anyInt(), any(Runnable.class));
|
}).when(writer).withChunkFence(anyInt(), anyInt(), any(Runnable.class));
|
||||||
when(complex.getHydrologyRuntime()).thenReturn(runtime);
|
when(complex.getHydrologyRuntime()).thenReturn(runtime);
|
||||||
when(engine.getDimension()).thenReturn(new IrisDimension());
|
|
||||||
when(engine.getWorld()).thenReturn(mock(IrisWorld.class));
|
|
||||||
when(engine.getCaveBiome(anyInt(), anyInt(), anyInt())).thenReturn(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MantleCarvedTerrain carved() {
|
private MantleCarvedTerrain carved() {
|
||||||
@@ -317,6 +435,7 @@ public class MantleCarvedTerrainTest {
|
|||||||
|
|
||||||
private Map<Long, HydrologyCaveCell> generate(int... chunkZs) {
|
private Map<Long, HydrologyCaveCell> generate(int... chunkZs) {
|
||||||
IrisHydrology config = new IrisHydrology().setEnabled(true);
|
IrisHydrology config = new IrisHydrology().setEnabled(true);
|
||||||
|
config.getFluids().add(new IrisFluidProfile().setName("lava").setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:lava")));
|
||||||
config.getUnderground().getCavePools().setDensity(8D).setFreeboard(new KList<>(0, 0));
|
config.getUnderground().getCavePools().setDensity(8D).setFreeboard(new KList<>(0, 0));
|
||||||
HydrologySettings settings = HydrologySettings.compile(config, SEED, 63, 0, 384);
|
HydrologySettings settings = HydrologySettings.compile(config, SEED, 63, 0, 384);
|
||||||
SeaInletRasterizer rasterizer = new SeaInletRasterizer();
|
SeaInletRasterizer rasterizer = new SeaInletRasterizer();
|
||||||
|
|||||||
+2
-1
@@ -95,7 +95,8 @@ public class IrisEngineGenerationRuntimeScopeTest {
|
|||||||
when(historical.dimension.getHydrology()).thenReturn(new IrisHydrology().setEnabled(true).setPersist(false).setPrefetchRings(0));
|
when(historical.dimension.getHydrology()).thenReturn(new IrisHydrology().setEnabled(true).setPersist(false).setPrefetchRings(0));
|
||||||
when(historical.dimension.getFluidHeight()).thenReturn(40);
|
when(historical.dimension.getFluidHeight()).thenReturn(40);
|
||||||
when(historical.dimension.getLoadKey()).thenReturn("historical");
|
when(historical.dimension.getLoadKey()).thenReturn("historical");
|
||||||
when(historical.dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(historical.dimension.getAllRegions(any())).thenReturn(new KList<>());
|
||||||
|
when(historical.dimension.getReachableCaveBiomes(any())).thenReturn(new KList<>());
|
||||||
when(historical.target.getWorld().getHeight()).thenReturn(384);
|
when(historical.target.getWorld().getHeight()).thenReturn(384);
|
||||||
IrisBiome biome = new IrisBiome();
|
IrisBiome biome = new IrisBiome();
|
||||||
IrisRegion region = new IrisRegion();
|
IrisRegion region = new IrisRegion();
|
||||||
|
|||||||
+34
@@ -233,6 +233,40 @@ public class IrisDimensionReachableBiomesTest {
|
|||||||
assertEquals(Set.of("root", "dimension-shore", "region-shore", "shore-child", "biome-shore"), reachableKeys(dimension, data));
|
assertEquals(Set.of("root", "dimension-shore", "region-shore", "shore-child", "biome-shore"), reachableKeys(dimension, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void caveBiomesAreTheRegionCaveBiomesAndTheEnabledCarvingBands() {
|
||||||
|
IrisDimension dimension = new IrisDimension().setRegions(new KList<>("tropical"));
|
||||||
|
dimension.setCarving(new KList<>(
|
||||||
|
new IrisDimensionCarvingEntry().setId("deep").setBiome("deep-dark"),
|
||||||
|
new IrisDimensionCarvingEntry().setId("off").setEnabled(false).setBiome("disabled-band")));
|
||||||
|
IrisRegion tropical = new IrisRegion()
|
||||||
|
.setLandBiomes(new KList<>("volcanoes"))
|
||||||
|
.setShoreBiomes(new KList<>("beach"))
|
||||||
|
.setCaveBiomes(new KList<>("hollow", "magma", "missing"));
|
||||||
|
tropical.setLoadKey("tropical");
|
||||||
|
IrisBiome volcanoes = biome("volcanoes").setCarvingBiome("magma").setChildren(new KList<>("ash"));
|
||||||
|
|
||||||
|
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("tropical")).thenReturn(tropical);
|
||||||
|
when(biomeLoader.load("volcanoes")).thenReturn(volcanoes);
|
||||||
|
when(biomeLoader.load("ash")).thenReturn(biome("ash"));
|
||||||
|
when(biomeLoader.load("beach")).thenReturn(biome("beach"));
|
||||||
|
when(biomeLoader.load("hollow")).thenReturn(biome("hollow"));
|
||||||
|
when(biomeLoader.load("magma")).thenReturn(biome("magma"));
|
||||||
|
when(biomeLoader.load("deep-dark")).thenReturn(biome("deep-dark"));
|
||||||
|
when(biomeLoader.load("disabled-band")).thenReturn(biome("disabled-band"));
|
||||||
|
|
||||||
|
KList<IrisBiome> caves = dimension.getReachableCaveBiomes(() -> data);
|
||||||
|
|
||||||
|
assertEquals(Set.of("hollow", "magma", "deep-dark"), caves.stream().map(IrisBiome::getLoadKey).collect(Collectors.toSet()));
|
||||||
|
assertEquals(3, caves.size());
|
||||||
|
}
|
||||||
|
|
||||||
private static Set<String> reachableKeys(IrisDimension dimension, IrisData data) {
|
private static Set<String> reachableKeys(IrisDimension dimension, IrisData data) {
|
||||||
return dimension.getReachableBiomes(() -> data).stream()
|
return dimension.getReachableBiomes(() -> data).stream()
|
||||||
.map(IrisBiome::getLoadKey)
|
.map(IrisBiome::getLoadKey)
|
||||||
|
|||||||
@@ -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 = "d6a5c5f92c4487eb61ba8b540681e2e014f07943c527b39ae4f36fed33f53ca6";
|
private static final String EXPECTED_SCHEMA_DIGEST = "87e3f95ad75204881cdcf766e9a318b69ca9fb365fe0249de112edaa8461dd00";
|
||||||
|
|
||||||
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