mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 09:15:27 +00:00
Merge underground lava
- Deep lava pools, cave springs and the cave fluid probe from hydro/f3 - Recaptured the settings fingerprint and schema digest for the combined code
This commit is contained in:
31 files changed
+1608
-40
No files matched your search
+2
-1
@@ -4,5 +4,6 @@ public enum HydrologyCaveAction {
|
||||
WET_SOURCE,
|
||||
DRY_AIR,
|
||||
SEAL_GUARD,
|
||||
POOL_SOURCE
|
||||
POOL_SOURCE,
|
||||
SPRING_SOURCE
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public final class HydrologyCaveCell {
|
||||
}
|
||||
this.fluidProfileKey = fluidProfileKey.trim();
|
||||
this.cavern = switch (action) {
|
||||
case WET_SOURCE, POOL_SOURCE -> new MatterCavern(true, "", LIQUID_FLUID);
|
||||
case WET_SOURCE, POOL_SOURCE, SPRING_SOURCE -> new MatterCavern(true, "", LIQUID_FLUID);
|
||||
case DRY_AIR -> new MatterCavern(true, "", LIQUID_FORCED_AIR);
|
||||
case SEAL_GUARD -> null;
|
||||
};
|
||||
@@ -31,7 +31,7 @@ public final class HydrologyCaveCell {
|
||||
}
|
||||
|
||||
public boolean isWet() {
|
||||
return action == HydrologyCaveAction.WET_SOURCE || action == HydrologyCaveAction.POOL_SOURCE;
|
||||
return action == HydrologyCaveAction.WET_SOURCE || action == HydrologyCaveAction.POOL_SOURCE || action == HydrologyCaveAction.SPRING_SOURCE;
|
||||
}
|
||||
|
||||
public MatterCavern asCavern() {
|
||||
|
||||
@@ -50,4 +50,12 @@ public class IrisCavePools {
|
||||
@Required
|
||||
@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";
|
||||
|
||||
@Description("Name of the fluid profile that fills pools at or below deepFluidMaxY. Unset keeps the same fluid at every depth. A hydrology policy that names a fluid still replaces it.")
|
||||
private String deepFluid;
|
||||
|
||||
@MinNumber(-2032)
|
||||
@MaxNumber(2031)
|
||||
@Description("Highest world Y that deepFluid fills. No pool crosses this height: a pool rising from below stops at it.")
|
||||
private int deepFluidMaxY = -128;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package art.arcane.iris.generation.hydrology.config;
|
||||
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.Required;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@Description("Seep points in carved cave walls. Each holds one source block that the game's fluid physics spreads once the chunk is loaded.")
|
||||
@Data
|
||||
public class IrisCaveSprings {
|
||||
@Description("Places springs in cave walls.")
|
||||
private boolean enabled = false;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(2)
|
||||
@Description("Candidate spring sites per chunk.")
|
||||
private double density = 0.05D;
|
||||
|
||||
@Required
|
||||
@Description("Name of the fluid profile a spring runs with. The hydrology policy fluid of the cave biome at the seep replaces it, then that of its region, then that of the dimension.")
|
||||
private String fluid = "lava";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(256)
|
||||
@Description("Fewest blocks of ground kept between the surface and a spring, its opening and the cave it runs into.")
|
||||
private int minDepthBelowSurface = 16;
|
||||
}
|
||||
+4
-1
@@ -7,7 +7,7 @@ import lombok.experimental.Accessors;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@Description("Water below the surface: flooded passages that run inland from the sea, and pools on cave floors.")
|
||||
@Description("Water below the surface: flooded passages that run inland from the sea, pools on cave floors, and springs in cave walls.")
|
||||
@Data
|
||||
public class IrisHydrologyUnderground {
|
||||
@Description("Flooded passages at sea level that run inland from coastal cliffs.")
|
||||
@@ -15,4 +15,7 @@ public class IrisHydrologyUnderground {
|
||||
|
||||
@Description("Standing water on the floors of carved caves.")
|
||||
private IrisCavePools cavePools = new IrisCavePools();
|
||||
|
||||
@Description("Seep points in cave walls with one source block that the game's fluid physics spreads.")
|
||||
private IrisCaveSprings caveSprings = new IrisCaveSprings();
|
||||
}
|
||||
+1
-1
@@ -156,7 +156,7 @@ public final class HydrologyRuntime {
|
||||
engine.getHeight());
|
||||
requireBiomeFluids(dimension.getReachableBiomes(engine), settings);
|
||||
boolean caveFluidPolicies = requireCaveFluids(dimension, dimension.getAllRegions(engine), dimension.getReachableCaveBiomes(engine), settings)
|
||||
&& settings.underground().cavePools().enabled();
|
||||
&& (settings.underground().cavePools().enabled() || settings.underground().caveSprings().enabled());
|
||||
if (settings.density() == 0D) {
|
||||
return DISABLED;
|
||||
}
|
||||
|
||||
+40
-5
@@ -4,6 +4,7 @@ import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorationPart;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorator;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisCavePools;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisCaveSprings;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisFluidProfile;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyClimate;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
@@ -62,6 +63,10 @@ public final class HydrologySettings {
|
||||
public static final int MAX_CAVE_POOL_RADIUS = 15;
|
||||
private static final int CAVE_POOL_SPAN = 2 * MAX_CAVE_POOL_RADIUS + 1;
|
||||
private static final int MAX_CAVE_POOL_AREA = CAVE_POOL_SPAN * CAVE_POOL_SPAN;
|
||||
private static final int MIN_DEEP_FLUID_Y = -2032;
|
||||
private static final int MAX_DEEP_FLUID_Y = 2031;
|
||||
private static final double MAX_SPRING_DENSITY = 2D;
|
||||
private static final int MAX_SPRING_DEPTH = 256;
|
||||
private static final int MAX_LAKE_AREA = LakeCandidate.MAX_EXTENT * LakeCandidate.MAX_EXTENT;
|
||||
private static final int MAX_PREFETCH_RINGS = 4;
|
||||
private static final int MAX_SEEDED_DENSITY = 64;
|
||||
@@ -356,7 +361,7 @@ public final class HydrologySettings {
|
||||
}
|
||||
|
||||
private Underground underground(IrisHydrologyUnderground config) {
|
||||
return new Underground(seaInlets(config.getSeaInlets()), cavePools(config.getCavePools()));
|
||||
return new Underground(seaInlets(config.getSeaInlets()), cavePools(config.getCavePools()), caveSprings(config.getCaveSprings()));
|
||||
}
|
||||
|
||||
private SeaInlets seaInlets(IrisSeaInlets config) {
|
||||
@@ -411,7 +416,22 @@ public final class HydrologySettings {
|
||||
return new CavePools(config.isEnabled(), (float) config.getDensity(), config.getMinArea(), config.getMaxArea(),
|
||||
config.getMaxDepth(), config.getRadius(),
|
||||
intRange(config.getFreeboard(), "underground.cavePools.freeboard", RangeFloor.NON_NEGATIVE),
|
||||
config.getFluid());
|
||||
config.getFluid(), blankToNull(config.getDeepFluid()), config.getDeepFluidMaxY());
|
||||
}
|
||||
|
||||
private static CaveSprings caveSprings(IrisCaveSprings config) {
|
||||
if (config.isEnabled()) {
|
||||
if (!(Double.isFinite(config.getDensity()) && config.getDensity() >= 0D && config.getDensity() <= MAX_SPRING_DENSITY)) {
|
||||
throw new IllegalArgumentException("Hydrology underground.caveSprings.density must stay within 0.." + MAX_SPRING_DENSITY
|
||||
+ ", got " + config.getDensity());
|
||||
}
|
||||
requireWithin(config.getMinDepthBelowSurface(), 0, MAX_SPRING_DEPTH, "underground.caveSprings.minDepthBelowSurface");
|
||||
}
|
||||
return new CaveSprings(config.isEnabled(), (float) config.getDensity(), config.getFluid(), config.getMinDepthBelowSurface());
|
||||
}
|
||||
|
||||
private static String blankToNull(String value) {
|
||||
return value == null || value.isBlank() ? null : value;
|
||||
}
|
||||
|
||||
private static Map<String, IrisMaterialPalette> fluids(List<IrisFluidProfile> profiles) {
|
||||
@@ -610,6 +630,9 @@ public final class HydrologySettings {
|
||||
if (!pools.enabled()) {
|
||||
return;
|
||||
}
|
||||
if (pools.deepFluid() != null) {
|
||||
requireWithin(pools.deepFluidMaxY(), MIN_DEEP_FLUID_Y, MAX_DEEP_FLUID_Y, "underground.cavePools.deepFluidMaxY");
|
||||
}
|
||||
if (pools.freeboard().max() >= pools.maxDepth()) {
|
||||
throw new IllegalArgumentException("Hydrology underground.cavePools.freeboard max " + pools.freeboard().max()
|
||||
+ " must stay below maxDepth " + pools.maxDepth());
|
||||
@@ -657,6 +680,12 @@ public final class HydrologySettings {
|
||||
}
|
||||
requireFillingFluid(ponds.fluid(), "ponds.fluid");
|
||||
requireFillingFluid(underground.cavePools().fluid(), "underground.cavePools.fluid");
|
||||
if (underground.cavePools().deepFluid() != null) {
|
||||
requireFillingFluid(underground.cavePools().deepFluid(), "underground.cavePools.deepFluid");
|
||||
}
|
||||
if (underground.caveSprings().enabled()) {
|
||||
requireFillingFluid(underground.caveSprings().fluid(), "underground.caveSprings.fluid");
|
||||
}
|
||||
}
|
||||
|
||||
public void requireFillingFluid(String name, String field) {
|
||||
@@ -731,11 +760,14 @@ public final class HydrologySettings {
|
||||
private void addUnderground(Fingerprint hash) {
|
||||
SeaInlets inlets = underground.seaInlets();
|
||||
CavePools pools = underground.cavePools();
|
||||
CaveSprings springs = underground.caveSprings();
|
||||
hash.add(inlets.enabled()).add(inlets.spacing()).add(inlets.minimumCliffHeight()).add(inlets.length())
|
||||
.add(inlets.halfWidth()).add(inlets.depth()).add(inlets.headroom()).add(inlets.roofClearance())
|
||||
.add(inlets.chamberRadius())
|
||||
.add(pools.enabled()).add(pools.density()).add(pools.minArea()).add(pools.maxArea())
|
||||
.add(pools.maxDepth()).add(pools.radius()).add(pools.freeboard()).add(pools.fluid());
|
||||
.add(pools.maxDepth()).add(pools.radius()).add(pools.freeboard()).add(pools.fluid())
|
||||
.add(pools.deepFluid()).add(pools.deepFluidMaxY())
|
||||
.add(springs.enabled()).add(springs.density()).add(springs.fluid()).add(springs.minDepthBelowSurface());
|
||||
}
|
||||
|
||||
private void addFluids(Fingerprint hash) {
|
||||
@@ -801,10 +833,13 @@ public final class HydrologySettings {
|
||||
}
|
||||
|
||||
public record CavePools(boolean enabled, float density, int minArea, int maxArea, int maxDepth, int radius,
|
||||
IntRange freeboard, String fluid) {
|
||||
IntRange freeboard, String fluid, String deepFluid, int deepFluidMaxY) {
|
||||
}
|
||||
|
||||
public record Underground(SeaInlets seaInlets, CavePools cavePools) {
|
||||
public record CaveSprings(boolean enabled, float density, String fluid, int minDepthBelowSurface) {
|
||||
}
|
||||
|
||||
public record Underground(SeaInlets seaInlets, CavePools cavePools, CaveSprings caveSprings) {
|
||||
}
|
||||
|
||||
private enum RangeFloor {
|
||||
|
||||
@@ -6,4 +6,6 @@ public interface CarvedTerrain {
|
||||
int surface(int x, int z);
|
||||
|
||||
String caveFluid(int x, int y, int z);
|
||||
|
||||
boolean structureNear(int x, int y, int z);
|
||||
}
|
||||
+18
-3
@@ -5,6 +5,7 @@ import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||
import art.arcane.iris.generation.hydrology.grid.CellHash;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.mantle.MantleWriter;
|
||||
import art.arcane.volmlib.util.matter.slices.UpdateMatter;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
|
||||
@@ -33,11 +34,18 @@ public final class CavePoolFiller {
|
||||
private final HydrologySettings.CavePools pools;
|
||||
private final Set<String> fluids;
|
||||
private final float density;
|
||||
private final int deepLine;
|
||||
|
||||
public CavePoolFiller(HydrologySettings settings) {
|
||||
public CavePoolFiller(HydrologySettings settings, int worldMinimumY) {
|
||||
this.pools = settings.underground().cavePools();
|
||||
this.fluids = settings.fluids().keySet();
|
||||
this.density = settings.density();
|
||||
this.deepLine = pools.deepFluidMaxY() - worldMinimumY;
|
||||
int height = settings.maxY() - settings.minY();
|
||||
if (pools.enabled() && pools.deepFluid() != null && (deepLine < 0 || deepLine >= height)) {
|
||||
throw new IllegalStateException("Hydrology underground.cavePools.deepFluidMaxY " + pools.deepFluidMaxY()
|
||||
+ " is outside this world, which spans Y " + worldMinimumY + " to " + (worldMinimumY + height - 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void fill(int chunkX, int chunkZ, Supplier<? extends CarvedTerrain> terrain, MantleWriter writer, long seed) {
|
||||
@@ -167,9 +175,13 @@ public final class CavePoolFiller {
|
||||
}
|
||||
int y = unpackY(cell);
|
||||
HydrologyCaveCell existing = writer.getDataIfPresent(x, y, z, HydrologyCaveCell.class);
|
||||
if (existing == null || replacesSharedWall(existing, value)) {
|
||||
boolean spring = existing != null && existing.action() == HydrologyCaveAction.SPRING_SOURCE;
|
||||
if (existing == null || spring || replacesSharedWall(existing, value)) {
|
||||
writer.setData(x, y, z, value);
|
||||
}
|
||||
if (spring) {
|
||||
writer.setData(x, y, z, UpdateMatter.OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +192,10 @@ public final class CavePoolFiller {
|
||||
|
||||
private String fluid(CarvedTerrain carved, int x, int y, int z) {
|
||||
String policy = carved.caveFluid(x, y, z);
|
||||
return policy != null ? policy : pools.fluid();
|
||||
if (policy != null) {
|
||||
return policy;
|
||||
}
|
||||
return pools.deepFluid() != null && y <= deepLine ? pools.deepFluid() : pools.fluid();
|
||||
}
|
||||
|
||||
private String siteFluid(CarvedTerrain carved, int x, int y, int z) {
|
||||
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
package art.arcane.iris.generation.hydrology.underground;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveAction;
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||
import art.arcane.iris.generation.hydrology.grid.CellHash;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.mantle.MantleWriter;
|
||||
import art.arcane.volmlib.util.matter.slices.UpdateMatter;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class CaveSpringPlacer {
|
||||
private static final int FLOW_REACH = HydrologySettings.MAX_CAVE_POOL_RADIUS;
|
||||
private static final int FLOW_LIMIT = 4096;
|
||||
private static final long SALT_SITES = 0x535052495445L;
|
||||
private static final long SALT_DENSITY = 0x535052444e53L;
|
||||
private static final long SALT_COLUMN = 0x535052434f4cL;
|
||||
private static final long SALT_SEEP = 0x5350525345L << 20;
|
||||
private static final int[] SIDE_X = {1, -1, 0, 0};
|
||||
private static final int[] SIDE_Z = {0, 0, 1, -1};
|
||||
|
||||
private final HydrologySettings.CaveSprings springs;
|
||||
private final Set<String> fluids;
|
||||
private final float density;
|
||||
|
||||
public CaveSpringPlacer(HydrologySettings settings) {
|
||||
this.springs = settings.underground().caveSprings();
|
||||
this.fluids = settings.fluids().keySet();
|
||||
this.density = settings.density();
|
||||
}
|
||||
|
||||
public void place(int chunkX, int chunkZ, Supplier<? extends CarvedTerrain> terrain, MantleWriter writer, long seed) {
|
||||
if (!springs.enabled() || springs.density() == 0f || density == 0f) {
|
||||
return;
|
||||
}
|
||||
int attempts = attempts(seed, chunkX, chunkZ);
|
||||
for (int attempt = 0; attempt < attempts; attempt++) {
|
||||
if (density < 1f && CellHash.unit(CellHash.mix(seed, SALT_DENSITY + attempt, chunkX, chunkZ)) >= density) {
|
||||
continue;
|
||||
}
|
||||
CarvedTerrain carved = terrain.get();
|
||||
long column = CellHash.mix(seed, SALT_COLUMN + attempt, chunkX, chunkZ);
|
||||
int x = (chunkX << 4) + (int) (column & 15);
|
||||
int z = (chunkZ << 4) + (int) ((column >>> 4) & 15);
|
||||
int y = seep(carved, x, z, seed);
|
||||
if (y >= 0 && contained(carved, x, y, z) && !carved.structureNear(x, y, z)) {
|
||||
write(chunkX, chunkZ, x, y, z, new HydrologyCaveCell(HydrologyCaveAction.SPRING_SOURCE, fluid(carved, x, y, z)), writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int attempts(long seed, int chunkX, int chunkZ) {
|
||||
double sites = springs.density();
|
||||
int whole = (int) sites;
|
||||
return whole + (CellHash.unit(CellHash.mix(seed, SALT_SITES, chunkX, chunkZ)) < sites - whole ? 1 : 0);
|
||||
}
|
||||
|
||||
private int seep(CarvedTerrain carved, int x, int z, long seed) {
|
||||
int top = carved.surface(x, z) - springs.minDepthBelowSurface();
|
||||
int chosen = -1;
|
||||
long chosenHash = Long.MAX_VALUE;
|
||||
CaveVoxel below = carved.voxel(x, 1, z);
|
||||
CaveVoxel voxel = carved.voxel(x, 2, z);
|
||||
for (int y = 2; y <= top; y++) {
|
||||
CaveVoxel above = carved.voxel(x, y + 1, z);
|
||||
if (below == CaveVoxel.SOLID && voxel == CaveVoxel.SOLID && above == CaveVoxel.SOLID && opens(carved, x, y, z)) {
|
||||
long hash = CellHash.mix(seed, SALT_SEEP + y, x, z);
|
||||
if (hash < chosenHash) {
|
||||
chosenHash = hash;
|
||||
chosen = y;
|
||||
}
|
||||
}
|
||||
below = voxel;
|
||||
voxel = above;
|
||||
}
|
||||
return chosen;
|
||||
}
|
||||
|
||||
private static boolean opens(CarvedTerrain carved, int x, int y, int z) {
|
||||
for (int side = 0; side < 4; side++) {
|
||||
int sideX = x + SIDE_X[side];
|
||||
int sideZ = z + SIDE_Z[side];
|
||||
if (carved.voxel(sideX, y, sideZ) == CaveVoxel.AIR && carved.voxel(sideX, y - 1, sideZ) == CaveVoxel.AIR) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean contained(CarvedTerrain carved, int seepX, int seepY, int seepZ) {
|
||||
LongOpenHashSet visited = new LongOpenHashSet();
|
||||
LongArrayFIFOQueue queue = new LongArrayFIFOQueue();
|
||||
for (int side = 0; side < 4; side++) {
|
||||
int sideX = seepX + SIDE_X[side];
|
||||
int sideZ = seepZ + SIDE_Z[side];
|
||||
CaveVoxel voxel = carved.voxel(sideX, seepY, sideZ);
|
||||
if (voxel == CaveVoxel.FOREIGN) {
|
||||
return false;
|
||||
}
|
||||
if (voxel == CaveVoxel.AIR) {
|
||||
if (!roofed(carved, sideX, seepY, sideZ)) {
|
||||
return false;
|
||||
}
|
||||
long cell = pack(sideX, seepY, sideZ);
|
||||
visited.add(cell);
|
||||
queue.enqueue(cell);
|
||||
}
|
||||
}
|
||||
while (!queue.isEmpty() && visited.size() <= FLOW_LIMIT) {
|
||||
long cell = queue.dequeueLong();
|
||||
int x = unpackX(cell);
|
||||
int y = unpackY(cell);
|
||||
int z = unpackZ(cell);
|
||||
if (y > carved.surface(x, z) - springs.minDepthBelowSurface()) {
|
||||
return false;
|
||||
}
|
||||
for (int next = 0; next < 5; next++) {
|
||||
int nextX = next < 4 ? x + SIDE_X[next] : x;
|
||||
int nextY = next < 4 ? y : y - 1;
|
||||
int nextZ = next < 4 ? z + SIDE_Z[next] : z;
|
||||
if (Math.abs(nextX - seepX) > FLOW_REACH || Math.abs(nextZ - seepZ) > FLOW_REACH) {
|
||||
continue;
|
||||
}
|
||||
CaveVoxel voxel = carved.voxel(nextX, nextY, nextZ);
|
||||
if (voxel == CaveVoxel.FOREIGN) {
|
||||
return false;
|
||||
}
|
||||
if (voxel == CaveVoxel.AIR && visited.add(pack(nextX, nextY, nextZ))) {
|
||||
queue.enqueue(pack(nextX, nextY, nextZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean roofed(CarvedTerrain carved, int x, int startY, int z) {
|
||||
int y = startY + 1;
|
||||
CaveVoxel voxel = carved.voxel(x, y, z);
|
||||
while (voxel == CaveVoxel.AIR) {
|
||||
voxel = carved.voxel(x, ++y, z);
|
||||
}
|
||||
return voxel == CaveVoxel.SOLID;
|
||||
}
|
||||
|
||||
private String fluid(CarvedTerrain carved, int x, int y, int z) {
|
||||
String policy = carved.caveFluid(x, y, z);
|
||||
String fluid = policy != null ? policy : springs.fluid();
|
||||
if (!fluids.contains(fluid)) {
|
||||
throw new IllegalStateException("Cave spring at " + x + "," + y + "," + z + " names fluid '" + fluid
|
||||
+ "', which is not one of the hydrology fluids " + fluids);
|
||||
}
|
||||
return fluid;
|
||||
}
|
||||
|
||||
private static void write(int chunkX, int chunkZ, int x, int y, int z, HydrologyCaveCell source, MantleWriter writer) {
|
||||
writer.withChunkFence(chunkX, chunkZ, () -> {
|
||||
if (writer.getDataIfPresent(x, y, z, HydrologyCaveCell.class) == null) {
|
||||
writer.setData(x, y, z, source);
|
||||
writer.setData(x, y, z, UpdateMatter.ON);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static long pack(int x, int y, int z) {
|
||||
return ((long) (x + (1 << 25)) << 38) | ((long) (z + (1 << 25)) << 12) | y;
|
||||
}
|
||||
|
||||
private static int unpackX(long cell) {
|
||||
return (int) (cell >>> 38) - (1 << 25);
|
||||
}
|
||||
|
||||
private static int unpackZ(long cell) {
|
||||
return (int) ((cell >>> 12) & ((1L << 26) - 1)) - (1 << 25);
|
||||
}
|
||||
|
||||
private static int unpackY(long cell) {
|
||||
return (int) (cell & 4095);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ 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.structure.placement.StructurePlacementScope;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.NativeStructureVolume;
|
||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
@@ -29,6 +31,8 @@ import java.util.Map;
|
||||
final class MantleCarvedTerrain implements CarvedTerrain {
|
||||
private static final int SPAN = 48;
|
||||
private static final int UNKNOWN = Integer.MIN_VALUE;
|
||||
private static final int STRUCTURE_REACH_CHUNKS = 8;
|
||||
private static final int IMPORTED_STRUCTURE_REACH = 32;
|
||||
|
||||
private final MantleWriter writer;
|
||||
private final IrisComplex complex;
|
||||
@@ -120,6 +124,31 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
||||
return IrisHydrologyPolicy.inherited(biome == null ? List.of() : List.of(biome), region, dimension, IrisHydrologyPolicy::getFluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean structureNear(int x, int y, int z) {
|
||||
if (dimension.getTerrainTransform() != null) {
|
||||
return true;
|
||||
}
|
||||
long revision = ProvisionalSampling.revision();
|
||||
boolean near = importedStructureNear(x, y, z) || StructurePlacementScope.startsNear(engine, chunkX, chunkZ, STRUCTURE_REACH_CHUNKS);
|
||||
requireFinal(revision, chunkX << 4, chunkZ << 4);
|
||||
return near;
|
||||
}
|
||||
|
||||
private boolean importedStructureNear(int x, int y, int z) {
|
||||
int minX = x - IMPORTED_STRUCTURE_REACH;
|
||||
int minZ = z - IMPORTED_STRUCTURE_REACH;
|
||||
int maxX = x + IMPORTED_STRUCTURE_REACH;
|
||||
int maxZ = z + IMPORTED_STRUCTURE_REACH;
|
||||
int maxY = y + minimumY + 1;
|
||||
for (NativeStructureVolume volume : engine.getNativeStructureVolumes(minX, minZ, maxX, maxZ)) {
|
||||
if (volume.intersects(minX, minimumY, minZ, maxX, maxY, maxZ)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Collection<SeaInlet> inlets(HydrologyRuntime runtime, int chunkX, int chunkZ) {
|
||||
Map<Long, SeaInlet> inlets = new LinkedHashMap<>();
|
||||
for (int offsetZ = -1; offsetZ <= 1; offsetZ++) {
|
||||
|
||||
+24
-10
@@ -4,11 +4,14 @@ import art.arcane.iris.generation.context.ChunkContext;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyUnderground;
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
import art.arcane.iris.generation.hydrology.raster.FluidSeams;
|
||||
import art.arcane.iris.generation.hydrology.underground.CarvedTerrain;
|
||||
import art.arcane.iris.generation.hydrology.underground.CavePoolFiller;
|
||||
import art.arcane.iris.generation.hydrology.underground.CaveSpringPlacer;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInletRasterizer;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
@@ -23,6 +26,7 @@ import art.arcane.volmlib.util.matter.slices.UpdateMatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@ComponentFlag(ReservedFlag.RIVER_HYDROLOGY)
|
||||
public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
@@ -44,12 +48,12 @@ public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
|
||||
@Override
|
||||
protected int computeRadius() {
|
||||
return poolsActive() ? CavePoolFiller.REACH : 0;
|
||||
return caveWaterActive() ? CavePoolFiller.REACH : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInputRadius() {
|
||||
return poolsActive() ? CavePoolFiller.REACH : 0;
|
||||
return caveWaterActive() ? CavePoolFiller.REACH : 0;
|
||||
}
|
||||
|
||||
public static boolean isEnabledFor(IrisDimension dimension) {
|
||||
@@ -58,15 +62,18 @@ public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
&& !dimension.getDisabledComponents().contains(ReservedFlag.RIVER_HYDROLOGY);
|
||||
}
|
||||
|
||||
private static boolean poolsEnabledFor(IrisDimension dimension) {
|
||||
return isEnabledFor(dimension) && dimension.isCarvingEnabled() && !dimension.getDisabledComponents().contains(ReservedFlag.CARVED)
|
||||
&& dimension.getHydrology().getUnderground().getCavePools().isEnabled();
|
||||
private static boolean caveWaterEnabledFor(IrisDimension dimension) {
|
||||
if (!isEnabledFor(dimension) || !dimension.isCarvingEnabled() || dimension.getDisabledComponents().contains(ReservedFlag.CARVED)) {
|
||||
return false;
|
||||
}
|
||||
IrisHydrologyUnderground underground = dimension.getHydrology().getUnderground();
|
||||
return underground.getCavePools().isEnabled() || underground.getCaveSprings().isEnabled();
|
||||
}
|
||||
|
||||
private boolean poolsActive() {
|
||||
private boolean caveWaterActive() {
|
||||
EngineMantle mantle = getEngineMantle();
|
||||
Engine engine = mantle == null ? null : mantle.getEngine();
|
||||
return engine != null && engine.getDimension() != null && poolsEnabledFor(engine.getDimension());
|
||||
return engine != null && engine.getDimension() != null && caveWaterEnabledFor(engine.getDimension());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,11 +92,18 @@ public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
}
|
||||
}
|
||||
generateFalls(writer, complex, runtime, own, chunkX, chunkZ);
|
||||
if (poolsActive()) {
|
||||
if (caveWaterActive()) {
|
||||
HydrologySettings settings = runtime.settings();
|
||||
Engine engine = getEngineMantle().getEngine();
|
||||
new CavePoolFiller(settings).fill(chunkX, chunkZ, () -> new MantleCarvedTerrain(writer, complex, engine, chunkX, chunkZ), writer,
|
||||
settings.seed());
|
||||
CarvedTerrain[] opened = new CarvedTerrain[1];
|
||||
Supplier<CarvedTerrain> carved = () -> {
|
||||
if (opened[0] == null) {
|
||||
opened[0] = new MantleCarvedTerrain(writer, complex, engine, chunkX, chunkZ);
|
||||
}
|
||||
return opened[0];
|
||||
};
|
||||
new CavePoolFiller(settings, engine.getWorld().minHeight()).fill(chunkX, chunkZ, carved, writer, settings.seed());
|
||||
new CaveSpringPlacer(settings).place(chunkX, chunkZ, carved, writer, settings.seed());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -418,7 +418,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
return null;
|
||||
}
|
||||
return switch (hydrology.action()) {
|
||||
case WET_SOURCE, POOL_SOURCE -> fluid;
|
||||
case WET_SOURCE, POOL_SOURCE, SPRING_SOURCE -> fluid;
|
||||
case DRY_AIR -> air;
|
||||
case SEAL_GUARD -> normalizeWaterlogging(current, null);
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyTier;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyWetness;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.hydrology.underground.CavePoolFiller;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.generation.terrain.ShoreBiomeLineages;
|
||||
@@ -111,8 +112,9 @@ final class PackHydrologyValidator {
|
||||
|
||||
private static boolean validateCompile(String path, IrisDimension dimension, List<String> errors) {
|
||||
try {
|
||||
HydrologySettings.compile(dimension.getHydrology(), 0L, dimension.getFluidHeight(), 0,
|
||||
HydrologySettings settings = HydrologySettings.compile(dimension.getHydrology(), 0L, dimension.getFluidHeight(), 0,
|
||||
dimension.getMaxHeight() - dimension.getMinHeight());
|
||||
new CavePoolFiller(settings, dimension.getMinHeight());
|
||||
return true;
|
||||
} catch (RuntimeException failure) {
|
||||
errors.add(path + " does not compile: " + reason(failure));
|
||||
|
||||
@@ -49,6 +49,20 @@ public final class StructurePlacementScope {
|
||||
return placements;
|
||||
}
|
||||
|
||||
public static boolean startsNear(Engine engine, int chunkX, int chunkZ, int reachChunks) {
|
||||
long seed = engine.getSeedManager().getMantle();
|
||||
for (int startZ = chunkZ - reachChunks; startZ <= chunkZ + reachChunks; startZ++) {
|
||||
for (int startX = chunkX - reachChunks; startX <= chunkX + reachChunks; startX++) {
|
||||
for (IrisStructurePlacement placement : placementsAt(engine, startX, startZ)) {
|
||||
if (placement.getDistribution() != null && StructurePlacementGrid.startsInChunk(placement, startX, startZ, seed)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ScopeIndex scopeIndex(Engine engine) {
|
||||
int revision = engine.getCacheID();
|
||||
synchronized (SCOPE_INDEXES) {
|
||||
|
||||
@@ -46,6 +46,7 @@ public final class HydrologyCaveMatter extends RawMatter<HydrologyCaveCell> {
|
||||
case DRY_AIR -> 3;
|
||||
case SEAL_GUARD -> 4;
|
||||
case POOL_SOURCE -> 5;
|
||||
case SPRING_SOURCE -> 6;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,6 +56,7 @@ public final class HydrologyCaveMatter extends RawMatter<HydrologyCaveCell> {
|
||||
case 3 -> HydrologyCaveAction.DRY_AIR;
|
||||
case 4 -> HydrologyCaveAction.SEAL_GUARD;
|
||||
case 5 -> HydrologyCaveAction.POOL_SOURCE;
|
||||
case 6 -> HydrologyCaveAction.SPRING_SOURCE;
|
||||
default -> throw new IOException("Unknown hydrology cave action code " + code);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user