mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Merge tiling
This commit is contained in:
commit
04649aedbc
17 files changed
+633
-290
No files matched your search
@@ -1405,11 +1405,6 @@ public class IrisComplex implements DataProvider {
|
||||
return tier == null ? pondMaterials : tier.materials();
|
||||
}
|
||||
|
||||
public boolean isTidalBank(int x, int z) {
|
||||
WaterRole role = resolveWaterRole(x, z);
|
||||
return (role == WaterRole.BANK || role == WaterRole.SHORE) && chunkRasterAt(x, z).tier(x & 15, z & 15) == hydrologyRuntime.settings().tidalTier();
|
||||
}
|
||||
|
||||
public HydrologyVegetation.Decorators resolveWaterDecorators(int x, int z) {
|
||||
if (!waterVegetation.planted()) {
|
||||
return HydrologyVegetation.Decorators.EMPTY;
|
||||
|
||||
@@ -51,7 +51,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
private static final BoundBlockState DIRT = BoundBlockState.of("minecraft:dirt");
|
||||
private static final BoundBlockState NETHERRACK = BoundBlockState.of("minecraft:netherrack");
|
||||
private static final int INLET_SEA_LAYERS = 1;
|
||||
private static final int TIDAL_BANK_SHALLOW_CUT = 16;
|
||||
@Getter
|
||||
private final RNG rng;
|
||||
|
||||
@@ -87,16 +86,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The palette index for a column that erosion cut {@code cut} blocks down into. The offset is
|
||||
* clamped to the deepest authored layer so an exposed bank shows soil rather than raw rock,
|
||||
* while a depth past the authored soil still runs off the end and falls through to rock. A
|
||||
* cut of zero collapses to {@code depth}, leaving every uncut column untouched.
|
||||
*/
|
||||
static int strataIndex(int depth, int cut, int paletteSize) {
|
||||
return depth + Math.min(cut, Math.max(0, paletteSize - 1 - depth));
|
||||
}
|
||||
|
||||
private static IrisMaterialPalette rolePalette(WaterRole role, IrisHydrologyMaterials materials) {
|
||||
if (materials == null) {
|
||||
return null;
|
||||
@@ -135,7 +124,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
return painted == null ? layerBlock : painted;
|
||||
}
|
||||
|
||||
private static NativeBlockState submergedSoil(NativeBlockState block) {
|
||||
public static NativeBlockState submergedSoil(NativeBlockState block) {
|
||||
if (block == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -235,9 +224,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
int terrainSpan = terrainColumn == null ? -1 : terrainColumn.spanCount() - 1;
|
||||
int layerSurfaceY = he;
|
||||
int layerCeilingY = 0;
|
||||
boolean exposeStrata = role != WaterRole.NONE && seaFloor;
|
||||
Terrain3DColumn naturalColumn = exposeStrata ? complex.naturalTerrainColumn(realX, realZ) : null;
|
||||
int cut = 0;
|
||||
boolean keepGravityAway = materials != null && !materials.isAllowGravityBlocks();
|
||||
IrisMaterialPalette rolePalette = rolePalette(role, materials);
|
||||
int paintDepth = rolePalette == null ? 0 : roleDepth(role, materials);
|
||||
@@ -310,16 +296,8 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
continue;
|
||||
}
|
||||
if (blocks == null) {
|
||||
if (exposeStrata) {
|
||||
int naturalSurfaceY = naturalColumn == null
|
||||
? complex.naturalTrueHeight(realX, realZ) : naturalColumn.surfaceY(layerSurfaceY);
|
||||
cut = Math.max(0, naturalSurfaceY - layerSurfaceY);
|
||||
}
|
||||
blocks = biome.generateLayers(dimension, realX, realZ, rng,
|
||||
layerSurfaceY + cut + 1 - bedrockFloor, layerSurfaceY + cut, data, complex);
|
||||
if (exposeStrata && cut <= TIDAL_BANK_SHALLOW_CUT && complex.isTidalBank(realX, realZ)) {
|
||||
cut = 0;
|
||||
}
|
||||
layerSurfaceY + 1 - bedrockFloor, layerSurfaceY, data, complex);
|
||||
}
|
||||
|
||||
int deepFloor = Math.max(bedrockFloor, layerCeilingY > 0 ? layerCeilingY + 2 : 0);
|
||||
@@ -340,9 +318,8 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
||||
continue;
|
||||
}
|
||||
|
||||
int strataIndex = strataIndex(depth, cut, blocks.size());
|
||||
NativeBlockState layerBlock = paintWaterMaterial(
|
||||
blocks.hasIndex(strataIndex) ? blocks.get(strataIndex) : null,
|
||||
blocks.hasIndex(depth) ? blocks.get(depth) : null,
|
||||
rolePalette, paintDepth, depth, rng, realX, i, realZ, data);
|
||||
if (submerged && layerSurfaceY == he) {
|
||||
layerBlock = submergedSoil(layerBlock);
|
||||
|
||||
@@ -14,6 +14,7 @@ import art.arcane.iris.structure.nativegen.NativeStructureStartPlan;
|
||||
import art.arcane.iris.structure.nativegen.NativeStructureVolumeIndex;
|
||||
import art.arcane.iris.structure.nativegen.StructureLocateSearch;
|
||||
import art.arcane.iris.structure.placement.IrisStructureLocator;
|
||||
import art.arcane.iris.structure.placement.IrisStructureStrata;
|
||||
import art.arcane.iris.structure.placement.IrisStructureWater;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockChangeSet;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockPositionPredicate;
|
||||
@@ -24,6 +25,7 @@ import art.arcane.volmlib.nativelib.terrain.structure.StructurePlacementDecision
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureReferencePolicy;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureSeaSurface;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureVolumePolicy;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureStrata;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureWater;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
@@ -133,6 +135,11 @@ public final class BukkitStructureStagePolicy implements StructureStagePolicy<
|
||||
return IrisStructureWater.world(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureStrata strata(Engine context) {
|
||||
return IrisStructureStrata.world(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntBinaryOperator worldgenHeight(Engine context, int runtimeMinY, boolean floor) {
|
||||
return (x, z) -> Engine.hostHeight(context, x, z, floor) + runtimeMinY + 1;
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package art.arcane.iris.structure.placement;
|
||||
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.decoration.IrisOreBands;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.stage.IrisTerrainNormalActuator;
|
||||
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureStrata;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.stream.interpolation.Interpolated;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class IrisStructureStrata implements StructureStrata {
|
||||
private static final ProceduralStream<Double> FLAT_GROUND = ProceduralStream.of((x, z) -> 0D, Interpolated.DOUBLE);
|
||||
|
||||
private final IrisComplex complex;
|
||||
private final IrisDimension dimension;
|
||||
private final IrisData data;
|
||||
private final RNG rng;
|
||||
private final int offsetY;
|
||||
private final int bedrockFloor;
|
||||
private final boolean hideOres;
|
||||
|
||||
private IrisStructureStrata(Engine engine) {
|
||||
complex = Objects.requireNonNull(engine.getComplex(), "Structure strata require a terrain complex");
|
||||
dimension = engine.getDimension();
|
||||
data = engine.getData();
|
||||
rng = new RNG(engine.getSeedManager().getTerrain());
|
||||
offsetY = engine.getMinHeight();
|
||||
bedrockFloor = dimension.isBedrock() ? 1 : 0;
|
||||
hideOres = dimension.isHideOresForHiddenOre();
|
||||
}
|
||||
|
||||
public static StructureStrata world(Engine engine) {
|
||||
return new IrisStructureStrata(engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Column column(int x, int z, int surfaceY, boolean submerged) {
|
||||
long revision = ProvisionalSampling.revision();
|
||||
IrisBiome biome = complex.getTrueBiomeStream().get(x, z);
|
||||
IrisRegion region = complex.getRegionStream().get(x, z);
|
||||
NativeBlockState rock = complex.getRockStream().get(x, z);
|
||||
NativeBlockState mapped = complex.getImageMapRuntime().sampleSurfaceBlock(x, z);
|
||||
if (ProvisionalSampling.revision() != revision && !complex.isPlatformMainThread()) {
|
||||
throw new ProvisionalAnswerException("Structure strata at " + x + "," + z
|
||||
+ " read a provisional answer; structures are only fitted over final terrain.");
|
||||
}
|
||||
int surface = surfaceY - offsetY;
|
||||
KList<NativeBlockState> layers = biome.generateLayersWithSlope(dimension, x, z, rng,
|
||||
surface + 1 - bedrockFloor, surface, data, FLAT_GROUND);
|
||||
return new StrataColumn(x, z, surface, submerged, layers, mapped, rock, biome, region);
|
||||
}
|
||||
|
||||
private final class StrataColumn implements Column {
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final int surface;
|
||||
private final boolean submerged;
|
||||
private final KList<NativeBlockState> layers;
|
||||
private final NativeBlockState mapped;
|
||||
private final NativeBlockState rock;
|
||||
private final IrisOreBands biomeSurface;
|
||||
private final IrisOreBands regionSurface;
|
||||
private final IrisOreBands dimensionSurface;
|
||||
private final IrisOreBands biomeUnderground;
|
||||
private final IrisOreBands regionUnderground;
|
||||
private final IrisOreBands dimensionUnderground;
|
||||
|
||||
private StrataColumn(int x, int z, int surface, boolean submerged, KList<NativeBlockState> layers,
|
||||
NativeBlockState mapped, NativeBlockState rock, IrisBiome biome, IrisRegion region) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.surface = surface;
|
||||
this.submerged = submerged;
|
||||
this.layers = layers;
|
||||
this.mapped = mapped;
|
||||
this.rock = rock;
|
||||
biomeSurface = hideOres ? IrisOreBands.EMPTY : biome.getSurfaceOreBands();
|
||||
regionSurface = hideOres ? IrisOreBands.EMPTY : region.getSurfaceOreBands();
|
||||
dimensionSurface = hideOres ? IrisOreBands.EMPTY : dimension.getSurfaceOreBands();
|
||||
biomeUnderground = hideOres ? IrisOreBands.EMPTY : biome.getUndergroundOreBands();
|
||||
regionUnderground = hideOres ? IrisOreBands.EMPTY : region.getUndergroundOreBands();
|
||||
dimensionUnderground = hideOres ? IrisOreBands.EMPTY : dimension.getUndergroundOreBands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NativeBlockState block(int y) {
|
||||
int internalY = y - offsetY;
|
||||
NativeBlockState ore = ore(biomeSurface, regionSurface, dimensionSurface, internalY);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
int depth = surface - internalY;
|
||||
if (depth == 0 && mapped != null) {
|
||||
return submerged ? IrisTerrainNormalActuator.submergedSoil(mapped) : mapped;
|
||||
}
|
||||
if (layers.hasIndex(depth)) {
|
||||
NativeBlockState layer = layers.get(depth);
|
||||
return submerged ? IrisTerrainNormalActuator.submergedSoil(layer) : layer;
|
||||
}
|
||||
ore = ore(biomeUnderground, regionUnderground, dimensionUnderground, internalY);
|
||||
return ore != null ? ore : rock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int soilDepth() {
|
||||
return layers.size();
|
||||
}
|
||||
|
||||
private NativeBlockState ore(IrisOreBands first, IrisOreBands second, IrisOreBands third, int internalY) {
|
||||
NativeBlockState ore = null;
|
||||
if (first.contains(internalY)) {
|
||||
ore = first.generate(x, internalY, z, rng, data, data == null ? null : data.getEngine());
|
||||
}
|
||||
if (ore == null && second.contains(internalY)) {
|
||||
ore = second.generate(x, internalY, z, rng, data, data == null ? null : data.getEngine());
|
||||
}
|
||||
if (ore == null && third.contains(internalY)) {
|
||||
ore = third.generate(x, internalY, z, rng, data, data == null ? null : data.getEngine());
|
||||
}
|
||||
return ore;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user