mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
iris:terrain ported onto IrisApi and listed in the built-ins jar; bedrock and exploded palettes become dimension settings; layers and palettes are shared classes of the exposed package
This commit is contained in:
1 parent
3ac31c573b
commit
12ec03d61c
29 files changed
+949
-516
No files matched your search
@@ -24,3 +24,7 @@ include art/arcane/iris/engine/modifier/DepositClump*.class
|
||||
include art/arcane/iris/engine/modifier/ResolvedDeposit*.class
|
||||
module art.arcane.iris.engine.actuator.DecorantModule
|
||||
include art/arcane/iris/engine/decorator/**
|
||||
module art.arcane.iris.engine.actuator.TerrainModule
|
||||
include art/arcane/iris/engine/actuator/Terrain*.class
|
||||
include art/arcane/iris/engine/actuator/ResolvedOre*.class
|
||||
include art/arcane/iris/engine/actuator/OreWarmUp*.class
|
||||
@@ -1,6 +1,5 @@
|
||||
art/arcane/iris/engine/actuator/**
|
||||
art/arcane/iris/engine/decorator/**
|
||||
art/arcane/iris/engine/terrain/**
|
||||
art/arcane/iris/engine/modifier/**
|
||||
art/arcane/iris/engine/mantle/components/**
|
||||
art/arcane/iris/engine/object/**
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
/** Whether a dimension has a layer of bedrock at its bottom, written as {@code "bedrock": false}. A dimension without the key has it. */
|
||||
@Desc("Should bedrock be generated or not.")
|
||||
@Feature(id = "iris:terrain/bedrock", name = "Bedrock", key = "bedrock", root = "bedrock", targets = Target.DIMENSION)
|
||||
public final class BedrockSettings implements IrisFeature {
|
||||
@Desc("Should bedrock be generated or not.")
|
||||
private boolean bedrock = true;
|
||||
|
||||
public BedrockSettings() {
|
||||
}
|
||||
|
||||
public boolean bedrock() {
|
||||
return bedrock;
|
||||
}
|
||||
}
|
||||
+81
-107
@@ -15,33 +15,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.terrain;
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.terrain.CaveCeilingLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.LayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.LockLayersMaxSettings;
|
||||
import art.arcane.iris.builtin.terrain.LayerBlocks;
|
||||
import art.arcane.iris.builtin.terrain.LockLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.PaletteLayer;
|
||||
import art.arcane.iris.builtin.terrain.SeaLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.WallSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisValues;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -61,73 +47,62 @@ public final class BiomeLayers {
|
||||
private static final int LOCKED_LAYERS_REFERENCE_HEIGHT = 512;
|
||||
private static final LayersSettings DEFAULT_LAYERS = new LayersSettings();
|
||||
private static final PaletteLayer NO_LAYER = PaletteLayer.withoutBlocks();
|
||||
|
||||
private static final class States {
|
||||
private static final PlatformBlockState BARRIER = B.getState("BARRIER");
|
||||
}
|
||||
private static final BlockState BARRIER = new BlockState("minecraft:barrier");
|
||||
|
||||
private final Supplier<LayerBlocks> layerBlocks;
|
||||
private final Supplier<NoiseFactory> noise;
|
||||
private final ModuleLog log;
|
||||
private final Map<PaletteLayer, ResolvedLayer> resolved = new ConcurrentHashMap<>();
|
||||
private final Map<LayersSettings, AtomicCache<KList<CNG>>> surfaceHeights = new ConcurrentHashMap<>();
|
||||
private final Map<SeaLayersSettings, AtomicCache<KList<CNG>>> seaHeights = new ConcurrentHashMap<>();
|
||||
private volatile Double busiestBiomeLayerCount;
|
||||
private final Map<LayersSettings, AtomicCache<KList<LayerNoise>>> surfaceHeights = new ConcurrentHashMap<>();
|
||||
private final Map<SeaLayersSettings, AtomicCache<KList<LayerNoise>>> seaHeights = new ConcurrentHashMap<>();
|
||||
private final Map<ResourceId, LayeredBiome> biomes = new ConcurrentHashMap<>();
|
||||
|
||||
/** The layers of the world {@code engine} generates now, reporting failures to {@code log}. */
|
||||
public static BiomeLayers of(Engine engine, ModuleLog log) {
|
||||
return engine.getGeneration().state(BiomeLayers.class,
|
||||
generating -> new BiomeLayers(() -> LayerBlocks.of(generating.getGeneration().world()), log));
|
||||
/** The layers of {@code world}. */
|
||||
public static BiomeLayers of(PackWorld world) {
|
||||
return world.state(BiomeLayers.class, generating -> new BiomeLayers(() -> LayerBlocks.of(generating), () -> generating.resources().noise(), generating.log()));
|
||||
}
|
||||
|
||||
/** The layers of a world whose layer blocks {@code layerBlocks} gives, asked for when a layer first picks a block. */
|
||||
public BiomeLayers(Supplier<LayerBlocks> layerBlocks, ModuleLog log) {
|
||||
/** The layers of a world whose layer blocks {@code layerBlocks} and noise {@code noise} give, asked for when a layer first needs them. */
|
||||
public BiomeLayers(Supplier<LayerBlocks> layerBlocks, Supplier<NoiseFactory> noise, ModuleLog log) {
|
||||
this.layerBlocks = layerBlocks;
|
||||
this.noise = noise;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/** {@code layer} ready for this world; its block picks are the world's {@link LayerBlocks}. */
|
||||
public ResolvedLayer resolve(PaletteLayer layer) {
|
||||
return resolved.computeIfAbsent(layer, declared -> ResolvedLayer.of(declared, layerBlocks));
|
||||
return resolved.computeIfAbsent(layer, declared -> ResolvedLayer.of(declared, layerBlocks, noise));
|
||||
}
|
||||
|
||||
/** What the biome {@code id} declares about its layers, read once from {@code settings}. */
|
||||
public LayeredBiome biome(ResourceId id, FeatureSettings settings) {
|
||||
LayeredBiome known = biomes.get(id);
|
||||
if (known != null) {
|
||||
return known;
|
||||
}
|
||||
return biomes.computeIfAbsent(id, ignored -> new LayeredBiome(
|
||||
settings.declaredBy(id, LayersSettings.class).orElse(null),
|
||||
settings.declaredBy(id, SeaLayersSettings.class).orElse(null),
|
||||
settings.declaredBy(id, CaveCeilingLayersSettings.class).orElse(null),
|
||||
settings.declaredBy(id, LockLayersSettings.class).orElse(null),
|
||||
settings.declaredBy(id, LockLayersMaxSettings.class).orElse(null),
|
||||
settings.declaredBy(id, WallSettings.class).orElse(null)));
|
||||
}
|
||||
|
||||
/** The biome's wall, which places no block when the biome declares none. */
|
||||
public ResolvedLayer wall(IrisBiome biome) {
|
||||
PaletteLayer layer = biome.getModuleSettings().find(WallSettings.class).map(WallSettings::layer).orElse(NO_LAYER);
|
||||
public ResolvedLayer wall(LayeredBiome biome) {
|
||||
PaletteLayer layer = biome.wall() == null ? NO_LAYER : biome.wall().layer();
|
||||
return resolve(layer);
|
||||
}
|
||||
|
||||
/** The layers of the biome's surface, top first. */
|
||||
public static List<PaletteLayer> layersOf(IrisBiome biome) {
|
||||
return surfaceSettings(biome).layers();
|
||||
}
|
||||
|
||||
/** The noise style of each layer of the biome's surface, top first, as Iris's generators know them. */
|
||||
public static List<NoiseStyle> layerStyles(IrisBiome biome) {
|
||||
return layersOf(biome).stream().map(layer -> IrisValues.generatorStyle(layer.style()).getStyle()).toList();
|
||||
}
|
||||
|
||||
/** The most layers any biome the dimension reaches has, which is what studio's layer load view compares a biome with. */
|
||||
public double busiestLayerCount(Engine engine) {
|
||||
Double cached = busiestBiomeLayerCount;
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
double busiest = 0D;
|
||||
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
|
||||
busiest = Math.max(busiest, layersOf(biome).size());
|
||||
}
|
||||
busiestBiomeLayerCount = busiest;
|
||||
return busiest;
|
||||
}
|
||||
|
||||
/** The blocks the biome's layers stack up to at the column, top first, at most {@code maxDepth} of them. */
|
||||
public KList<PlatformBlockState> generateLayers(IrisBiome biome, IrisDimension dimension, double wx, double wz, RNG random, int maxDepth, int height, IrisData data, IrisComplex complex) {
|
||||
public KList<BlockState> generateLayers(LayeredBiome biome, PaletteExplosion explosion, double wx, double wz, RNG random, int maxDepth, int height,
|
||||
ColumnSlope slope) {
|
||||
if (isLocked(biome)) {
|
||||
return generateLockedLayers(biome, wx, wz, random, maxDepth, height, complex);
|
||||
return generateLockedLayers(biome, wx, wz, random, maxDepth, height, slope);
|
||||
}
|
||||
|
||||
KList<PlatformBlockState> blocks = new KList<>();
|
||||
KList<BlockState> blocks = new KList<>();
|
||||
if (maxDepth <= 0) {
|
||||
return blocks;
|
||||
}
|
||||
@@ -138,10 +113,10 @@ public final class BiomeLayers {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
KList<CNG> heightNoises = surfaceHeightNoises(settings, random);
|
||||
KList<LayerNoise> heightNoises = surfaceHeightNoises(settings, random);
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
ResolvedLayer layer = resolve(layers.get(i));
|
||||
double depth = layerDepth(layer, heightNoises.get(i), wx, wz, complex);
|
||||
double depth = layerDepth(layer, heightNoises.get(i), wx, wz, slope);
|
||||
if (depth <= 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -151,26 +126,25 @@ public final class BiomeLayers {
|
||||
break;
|
||||
}
|
||||
|
||||
separateLayers(blocks, dimension, maxDepth);
|
||||
separateLayers(blocks, explosion, maxDepth);
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/** The blocks the biome's cave ceiling layers stack up to at the column, nearest the ceiling first, at most {@code maxDepth} of them. */
|
||||
public KList<PlatformBlockState> generateCeilingLayers(IrisBiome biome, IrisDimension dimension, double wx, double wz, RNG random, int maxDepth, int height, IrisData data, IrisComplex complex) {
|
||||
KList<PlatformBlockState> blocks = new KList<>();
|
||||
public KList<BlockState> generateCeilingLayers(LayeredBiome biome, PaletteExplosion explosion, double wx, double wz, RNG random, int maxDepth) {
|
||||
KList<BlockState> blocks = new KList<>();
|
||||
if (maxDepth <= 0) {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
List<PaletteLayer> ceilingLayers = biome.getModuleSettings().find(CaveCeilingLayersSettings.class)
|
||||
.map(CaveCeilingLayersSettings::layers).orElse(List.of());
|
||||
List<PaletteLayer> ceilingLayers = biome.ceilingLayers() == null ? List.of() : biome.ceilingLayers().layers();
|
||||
if (ceilingLayers.isEmpty()) {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
KList<CNG> heightNoises = surfaceHeightNoises(surfaceSettings(biome), random);
|
||||
KList<LayerNoise> heightNoises = surfaceHeightNoises(surfaceSettings(biome), random);
|
||||
// Ceiling layers reuse the surface-layer height noise, so entries beyond the surface layers have none; skip them.
|
||||
int usableLayers = Math.min(ceilingLayers.size(), heightNoises.size());
|
||||
for (int i = 0; i < usableLayers; i++) {
|
||||
@@ -185,22 +159,22 @@ public final class BiomeLayers {
|
||||
break;
|
||||
}
|
||||
|
||||
separateLayers(blocks, dimension, maxDepth);
|
||||
separateLayers(blocks, explosion, maxDepth);
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/** The blocks of the biome's sea layers at the column, from the water surface down, at most {@code maxDepth} of them. */
|
||||
public KList<PlatformBlockState> generateSeaLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepth, IrisData data) {
|
||||
KList<PlatformBlockState> blocks = new KList<>();
|
||||
SeaLayersSettings settings = biome.getModuleSettings().find(SeaLayersSettings.class).orElse(null);
|
||||
public KList<BlockState> generateSeaLayers(LayeredBiome biome, double wx, double wz, RNG random, int maxDepth) {
|
||||
KList<BlockState> blocks = new KList<>();
|
||||
SeaLayersSettings settings = biome.seaLayers();
|
||||
if (settings == null || settings.layers().isEmpty()) {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
List<PaletteLayer> layers = settings.layers();
|
||||
KList<CNG> heightNoises = seaHeightNoises(settings, random);
|
||||
KList<LayerNoise> heightNoises = seaHeightNoises(settings, random);
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
ResolvedLayer layer = resolve(layers.get(i));
|
||||
int depth = heightNoises.get(i).fit(layer.minHeight(), layer.maxHeight(), wx / layer.zoom(), wz / layer.zoom());
|
||||
@@ -217,9 +191,9 @@ public final class BiomeLayers {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private KList<PlatformBlockState> generateLockedLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepthLimit, int height, IrisComplex complex) {
|
||||
KList<PlatformBlockState> stacked = new KList<>();
|
||||
KList<PlatformBlockState> locked = new KList<>();
|
||||
private KList<BlockState> generateLockedLayers(LayeredBiome biome, double wx, double wz, RNG random, int maxDepthLimit, int height, ColumnSlope slope) {
|
||||
KList<BlockState> stacked = new KList<>();
|
||||
KList<BlockState> locked = new KList<>();
|
||||
int maxDepth = Math.min(maxDepthLimit, lockedLayersMax(biome));
|
||||
if (maxDepth <= 0) {
|
||||
return stacked;
|
||||
@@ -228,10 +202,10 @@ public final class BiomeLayers {
|
||||
LayersSettings settings = surfaceSettings(biome);
|
||||
List<PaletteLayer> layers = settings.layers();
|
||||
if (!layers.isEmpty()) {
|
||||
KList<CNG> heightNoises = surfaceHeightNoises(settings, random);
|
||||
KList<LayerNoise> heightNoises = surfaceHeightNoises(settings, random);
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
ResolvedLayer layer = resolve(layers.get(i));
|
||||
double depth = layerDepth(layer, heightNoises.get(i), wx, wz, complex);
|
||||
double depth = layerDepth(layer, heightNoises.get(i), wx, wz, slope);
|
||||
if (depth <= 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -252,7 +226,7 @@ public final class BiomeLayers {
|
||||
return locked;
|
||||
}
|
||||
|
||||
private void stackLayer(KList<PlatformBlockState> blocks, ResolvedLayer layer, int index, double depth, double wx, double wz, RNG random, int maxDepth) {
|
||||
private void stackLayer(KList<BlockState> blocks, ResolvedLayer layer, int index, double depth, double wx, double wz, RNG random, int maxDepth) {
|
||||
for (int j = 0; j < depth; j++) {
|
||||
if (blocks.size() >= maxDepth) {
|
||||
break;
|
||||
@@ -262,14 +236,14 @@ public final class BiomeLayers {
|
||||
}
|
||||
}
|
||||
|
||||
private void stackLayerUnlimited(KList<PlatformBlockState> blocks, ResolvedLayer layer, int index, double depth, double wx, double wz, RNG random) {
|
||||
private void stackLayerUnlimited(KList<BlockState> blocks, ResolvedLayer layer, int index, double depth, double wx, double wz, RNG random) {
|
||||
for (int j = 0; j < depth; j++) {
|
||||
addBlock(blocks, layer, index, j, wx, wz, random);
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds the layer's block {@code j} blocks down; a layer that fails to pick adds nothing. */
|
||||
private void addBlock(KList<PlatformBlockState> blocks, ResolvedLayer layer, int index, int j, double wx, double wz, RNG random) {
|
||||
private void addBlock(KList<BlockState> blocks, ResolvedLayer layer, int index, int j, double wx, double wz, RNG random) {
|
||||
double zoom = layer.zoom();
|
||||
try {
|
||||
blocks.add(layer.get(random, index + j, (wx + j) / zoom, j, (wz - j) / zoom));
|
||||
@@ -279,13 +253,13 @@ public final class BiomeLayers {
|
||||
}
|
||||
|
||||
/** The barrier blocks a dimension puts between layers to show them apart. */
|
||||
private void separateLayers(KList<PlatformBlockState> blocks, IrisDimension dimension, int maxDepth) {
|
||||
if (!dimension.isExplodeBiomePalettes()) {
|
||||
private void separateLayers(KList<BlockState> blocks, PaletteExplosion explosion, int maxDepth) {
|
||||
if (!explosion.exploded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0; j < dimension.getExplodeBiomePaletteSize(); j++) {
|
||||
blocks.add(States.BARRIER);
|
||||
for (int j = 0; j < explosion.size(); j++) {
|
||||
blocks.add(BARRIER);
|
||||
if (blocks.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
@@ -293,39 +267,39 @@ public final class BiomeLayers {
|
||||
}
|
||||
|
||||
/** How thick the layer is at the column: nothing where the slope is outside the layer's limits. */
|
||||
private double layerDepth(ResolvedLayer layer, CNG heightNoise, double wx, double wz, IrisComplex complex) {
|
||||
private double layerDepth(ResolvedLayer layer, LayerNoise heightNoise, double wx, double wz, ColumnSlope slope) {
|
||||
double depth = layerThickness(layer, heightNoise, wx, wz);
|
||||
SlopeClip slope = layer.slopeCondition();
|
||||
if (!slope.isDefault() && !slope.isValid(complex.getSlopeStream().get(wx, wz))) {
|
||||
SlopeClip clip = layer.slopeCondition();
|
||||
if (!clip.isDefault() && !clip.isValid(slope.at(wx, wz))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
||||
private double layerThickness(ResolvedLayer layer, CNG heightNoise, double wx, double wz) {
|
||||
private double layerThickness(ResolvedLayer layer, LayerNoise heightNoise, double wx, double wz) {
|
||||
double zoom = layer.zoom();
|
||||
return heightNoise.fit(layer.minHeight(), layer.maxHeight(), wx / zoom, wz / zoom);
|
||||
}
|
||||
|
||||
private KList<CNG> surfaceHeightNoises(LayersSettings settings, RNG rng) {
|
||||
AtomicCache<KList<CNG>> cache = surfaceHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
|
||||
private KList<LayerNoise> surfaceHeightNoises(LayersSettings settings, RNG rng) {
|
||||
AtomicCache<KList<LayerNoise>> cache = surfaceHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
|
||||
return heightNoises(cache, settings.layers(), SURFACE_HEIGHT_SEED, rng);
|
||||
}
|
||||
|
||||
private KList<CNG> seaHeightNoises(SeaLayersSettings settings, RNG rng) {
|
||||
AtomicCache<KList<CNG>> cache = seaHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
|
||||
private KList<LayerNoise> seaHeightNoises(SeaLayersSettings settings, RNG rng) {
|
||||
AtomicCache<KList<LayerNoise>> cache = seaHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
|
||||
return heightNoises(cache, settings.layers(), SEA_HEIGHT_SEED, rng);
|
||||
}
|
||||
|
||||
private KList<CNG> heightNoises(AtomicCache<KList<CNG>> cache, List<PaletteLayer> layers, int firstSeed, RNG rng) {
|
||||
KList<CNG> cached = cache.getIfPresent();
|
||||
private KList<LayerNoise> heightNoises(AtomicCache<KList<LayerNoise>> cache, List<PaletteLayer> layers, int firstSeed, RNG rng) {
|
||||
KList<LayerNoise> cached = cache.getIfPresent();
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return cache.aquire(() -> {
|
||||
KList<CNG> noises = new KList<>();
|
||||
KList<LayerNoise> noises = new KList<>();
|
||||
int seed = firstSeed;
|
||||
for (PaletteLayer layer : layers) {
|
||||
noises.add(resolve(layer).heightNoise(rng.nextParallelRNG((seed++) * seed * seed * seed)));
|
||||
@@ -334,15 +308,15 @@ public final class BiomeLayers {
|
||||
});
|
||||
}
|
||||
|
||||
private static LayersSettings surfaceSettings(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(LayersSettings.class).orElse(DEFAULT_LAYERS);
|
||||
private static LayersSettings surfaceSettings(LayeredBiome biome) {
|
||||
return biome.layers() == null ? DEFAULT_LAYERS : biome.layers();
|
||||
}
|
||||
|
||||
private static boolean isLocked(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(LockLayersSettings.class).map(LockLayersSettings::locked).orElse(false);
|
||||
private static boolean isLocked(LayeredBiome biome) {
|
||||
return biome.lock() != null && biome.lock().locked();
|
||||
}
|
||||
|
||||
private static int lockedLayersMax(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(LockLayersMaxSettings.class).map(LockLayersMaxSettings::layers).orElse(LockLayersMaxSettings.DEFAULT_LAYERS);
|
||||
private static int lockedLayersMax(LayeredBiome biome) {
|
||||
return biome.lockMax() == null ? LockLayersMaxSettings.DEFAULT_LAYERS : biome.lockMax().layers();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
/** The slope of the terrain at a column, asked only when a layer limits where it shows by slope. */
|
||||
@FunctionalInterface
|
||||
public interface ColumnSlope {
|
||||
double at(double worldX, double worldZ);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
|
||||
/** How many barrier blocks a dimension puts between layers when it explodes its biome palettes, written as {@code "explodeBiomePaletteSize": 3}. */
|
||||
@Desc("Customize the palette height explosion")
|
||||
@Feature(id = "iris:terrain/explode-palette-size", name = "Explode biome palette size", key = "explodeBiomePaletteSize", root = "size", targets = Target.DIMENSION)
|
||||
public final class ExplodeBiomePaletteSizeSettings implements IrisFeature {
|
||||
public static final int DEFAULT_SIZE = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(16)
|
||||
@Desc("Customize the palette height explosion")
|
||||
private int size = DEFAULT_SIZE;
|
||||
|
||||
public ExplodeBiomePaletteSizeSettings() {
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
/** Whether a dimension puts barrier blocks between the layers of its biomes to show them apart, written as {@code "explodeBiomePalettes": true}. */
|
||||
@Desc("Vertically split up the biome palettes with barrier blocks in between to visualize them. The gap size comes from explodeBiomePaletteSize.")
|
||||
@Feature(id = "iris:terrain/explode-palettes", name = "Explode biome palettes", key = "explodeBiomePalettes", root = "explode", targets = Target.DIMENSION)
|
||||
public final class ExplodeBiomePalettesSettings implements IrisFeature {
|
||||
@Desc("Vertically split up the biome palettes with barrier blocks in between to visualize them. The gap size comes from explodeBiomePaletteSize.")
|
||||
private boolean explode = false;
|
||||
|
||||
public ExplodeBiomePalettesSettings() {
|
||||
}
|
||||
|
||||
public boolean explode() {
|
||||
return explode;
|
||||
}
|
||||
}
|
||||
+9
-8
@@ -15,18 +15,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
package art.arcane.iris.engine.actuator;
|
||||
import java.util.List;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.HideOresSettings;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
/** The layers of a biome's surface, which studio's layer view counts. */
|
||||
public final class LayerLoad {
|
||||
private static final LayersSettings DEFAULT_LAYERS = new LayersSettings();
|
||||
|
||||
/** Whether a dimension hides its ores ({@code hideOresForHiddenOre}): the terrain places none and the perfection pass turns the rest into their base blocks. */
|
||||
public final class HiddenOres {
|
||||
private HiddenOres() {
|
||||
private LayerLoad() {
|
||||
}
|
||||
|
||||
public static boolean in(IrisDimension dimension) {
|
||||
return dimension.getModuleSettings().find(HideOresSettings.class).map(HideOresSettings::hide).orElse(false);
|
||||
/** The layers of the biome's surface, top first; a biome that declares no layers has the one layer of grass the settings default to. */
|
||||
public static List<PaletteLayer> layersOf(LayersSettings declared) {
|
||||
return (declared == null ? DEFAULT_LAYERS : declared).layers();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
|
||||
/** The noise that sets how thick a layer is: a number between a layer's limits at every column. */
|
||||
public final class LayerNoise {
|
||||
private final NoiseSampler noise;
|
||||
|
||||
LayerNoise(NoiseSampler noise) {
|
||||
this.noise = noise;
|
||||
}
|
||||
|
||||
/** The whole number between {@code min} and {@code max} the noise gives at the column. */
|
||||
public int fit(int min, int max, double x, double z) {
|
||||
if (min == max) {
|
||||
return min;
|
||||
}
|
||||
return (int) Math.round(min + noise.sample(x, z) * (max - min));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
|
||||
/**
|
||||
* What a biome declares about the layers of its ground: the layers of its surface, of its sea floor and of its cave ceilings, whether
|
||||
* they are locked to the highest height the biome reaches, and its wall. A setting the biome does not declare is null.
|
||||
*/
|
||||
public record LayeredBiome(LayersSettings layers, SeaLayersSettings seaLayers, CaveCeilingLayersSettings ceilingLayers,
|
||||
LockLayersSettings lock, LockLayersMaxSettings lockMax, WallSettings wall) {
|
||||
/** A biome that declares nothing about its layers: the one layer of grass the settings default to. */
|
||||
public static final LayeredBiome UNDECLARED = new LayeredBiome(null, null, null, null, null, null);
|
||||
}
|
||||
+7
-12
@@ -15,30 +15,25 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
package art.arcane.iris.engine.terrain;
|
||||
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** A palette's blocks as the platform's, the way terrain layers and palettes always picked from them. */
|
||||
/** A palette's blocks, the way terrain layers and palettes always picked from them. */
|
||||
final class PaletteBlocks {
|
||||
private PaletteBlocks() {
|
||||
}
|
||||
|
||||
/** The platform's block of each spec that has one, each repeated by its weight. */
|
||||
static List<PlatformBlockState> weighted(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
List<PlatformBlockState> weighted = new ArrayList<>();
|
||||
/** The block of each spec, each repeated by its weight. */
|
||||
static List<BlockState> weighted(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
List<BlockState> weighted = new ArrayList<>();
|
||||
for (BlockSpec spec : palette) {
|
||||
PlatformBlockState state = B.getState(registry.resolve(spec).key());
|
||||
if (state == null) {
|
||||
continue;
|
||||
}
|
||||
BlockState state = registry.resolve(spec);
|
||||
for (int n = 0; n < spec.weight(); n++) {
|
||||
weighted.add(state);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** Whether a dimension separates the layers of its biomes with barrier blocks to show them apart, and how many barriers it puts between them. */
|
||||
public record PaletteExplosion(boolean exploded, int size) {
|
||||
public static final PaletteExplosion NONE = new PaletteExplosion(false, ExplodeBiomePaletteSizeSettings.DEFAULT_SIZE);
|
||||
|
||||
/** What the dimension at the column of {@code settings} declares. */
|
||||
public static PaletteExplosion of(FeatureSettings settings, int worldX, int worldZ) {
|
||||
boolean exploded = dimensionValue(settings.at(ExplodeBiomePalettesSettings.class, worldX, worldZ), ExplodeBiomePalettesSettings::explode, false);
|
||||
int size = dimensionValue(settings.at(ExplodeBiomePaletteSizeSettings.class, worldX, worldZ), ExplodeBiomePaletteSizeSettings::size,
|
||||
ExplodeBiomePaletteSizeSettings.DEFAULT_SIZE);
|
||||
return new PaletteExplosion(exploded, size);
|
||||
}
|
||||
|
||||
private static <S extends com.volmit.IrisFeature, V> V dimensionValue(List<Entry<S>> entries, java.util.function.Function<S, V> read, V fallback) {
|
||||
return entries.stream().filter(entry -> entry.level() == com.volmit.FeatureAttachment.Target.DIMENSION).findFirst()
|
||||
.map(entry -> read.apply(entry.value())).orElse(fallback);
|
||||
}
|
||||
}
|
||||
+25
-23
@@ -15,42 +15,43 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.terrain;
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.terrain.LayerBlocks;
|
||||
import art.arcane.iris.builtin.terrain.PaletteLayer;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.noise.NoiseStyle;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* One {@link PaletteLayer} made ready for one world: its blocks as the platform's, and the noise that decides how thick
|
||||
* it is here, built when first asked for. Which block it picks where is the world's {@link LayerBlocks}, shared with
|
||||
* every other module that picks from the layer.
|
||||
* One {@link PaletteLayer} made ready for one world: its blocks, and the noise that decides how thick it is here, built when first
|
||||
* asked for. Which block it picks where is the world's {@link LayerBlocks}, shared with every other module that picks from the layer.
|
||||
*
|
||||
* <p>The thickness noise is built once, from the random of whoever asks first, as the layers of a biome always were.
|
||||
*/
|
||||
public final class ResolvedLayer {
|
||||
/** The style of the noise that sets a layer's thickness: Iris's signature noise. */
|
||||
private static final NoiseStyle THICKNESS_STYLE = NoiseStyle.of("IRIS");
|
||||
|
||||
private final PaletteLayer settings;
|
||||
private final Supplier<LayerBlocks> layerBlocks;
|
||||
private final AtomicCache<List<PlatformBlockState>> blocks = new AtomicCache<>();
|
||||
private final AtomicCache<CNG> heightNoise = new AtomicCache<>();
|
||||
private final Supplier<NoiseFactory> noise;
|
||||
private final AtomicCache<List<BlockState>> blocks = new AtomicCache<>();
|
||||
private final AtomicCache<LayerNoise> heightNoise = new AtomicCache<>();
|
||||
|
||||
private ResolvedLayer(PaletteLayer settings, Supplier<LayerBlocks> layerBlocks) {
|
||||
private ResolvedLayer(PaletteLayer settings, Supplier<LayerBlocks> layerBlocks, Supplier<NoiseFactory> noise) {
|
||||
this.settings = settings;
|
||||
this.layerBlocks = layerBlocks;
|
||||
this.noise = noise;
|
||||
}
|
||||
|
||||
/** {@code settings} ready for the world whose layer blocks {@code layerBlocks} gives, asked for when first needed. */
|
||||
static ResolvedLayer of(PaletteLayer settings, Supplier<LayerBlocks> layerBlocks) {
|
||||
return new ResolvedLayer(settings, layerBlocks);
|
||||
static ResolvedLayer of(PaletteLayer settings, Supplier<LayerBlocks> layerBlocks, Supplier<NoiseFactory> noise) {
|
||||
return new ResolvedLayer(settings, layerBlocks, noise);
|
||||
}
|
||||
|
||||
public PaletteLayer settings() {
|
||||
@@ -79,32 +80,33 @@ public final class ResolvedLayer {
|
||||
}
|
||||
|
||||
/** The noise that sets the layer's thickness, built from {@code rng} unless an earlier caller's is already kept. */
|
||||
public CNG heightNoise(RNG rng) {
|
||||
CNG cached = heightNoise.getIfPresent();
|
||||
public LayerNoise heightNoise(RNG rng) {
|
||||
LayerNoise cached = heightNoise.getIfPresent();
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return heightNoise.aquire(() -> CNG.signature(rng.nextParallelRNG(settings.minHeight() * settings.maxHeight() + blocks().size())));
|
||||
return heightNoise.aquire(() -> new LayerNoise(noise.get().sampler(THICKNESS_STYLE,
|
||||
rng.nextParallelRNG(settings.minHeight() * settings.maxHeight() + blocks().size()).getSeed())));
|
||||
}
|
||||
|
||||
/** The layer's block at the position, picked as {@link LayerBlocks#pick} says, or null when the palette has no block. */
|
||||
public PlatformBlockState get(RNG parent, int signature, double x, double y, double z) {
|
||||
public BlockState get(RNG parent, int signature, double x, double y, double z) {
|
||||
int index = layerBlocks.get().pick(settings, parent, signature, x, y, z);
|
||||
return index == LayerBlocks.NONE ? null : blocks().get(index);
|
||||
}
|
||||
|
||||
/** {@link #get(RNG, int, double, double, double)} for a layer asked once per column, such as a slab or a wall. */
|
||||
public PlatformBlockState get(RNG rng, double x, double y, double z) {
|
||||
public BlockState get(RNG rng, double x, double y, double z) {
|
||||
return get(rng, 0, x, y, z);
|
||||
}
|
||||
|
||||
private List<PlatformBlockState> blocks() {
|
||||
List<PlatformBlockState> cached = blocks.getIfPresent();
|
||||
private List<BlockState> blocks() {
|
||||
List<BlockState> cached = blocks.getIfPresent();
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
return blocks.aquire(() -> layerBlocks.get().blocks(settings).stream().map(block -> B.getState(block.key())).toList());
|
||||
return blocks.aquire(() -> layerBlocks.get().blocks(settings));
|
||||
}
|
||||
}
|
||||
+43
-37
@@ -15,21 +15,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.builtin.terrain;
|
||||
|
||||
package art.arcane.iris.engine.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.FluidPaletteSettings;
|
||||
import art.arcane.iris.builtin.terrain.RockPaletteSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisPackResources;
|
||||
import art.arcane.iris.engine.UpperDimensionContext;
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.UpperDimension;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -53,21 +51,23 @@ public final class TerrainPalettes {
|
||||
@FunctionalInterface
|
||||
public interface ColumnBlocks {
|
||||
/** The block at the column, or null when the palette has no block. */
|
||||
PlatformBlockState at(double x, double z);
|
||||
BlockState at(double x, double z);
|
||||
}
|
||||
|
||||
private final Engine engine;
|
||||
private final PackWorld world;
|
||||
private final long complexSeed;
|
||||
private final AtomicCache<ColumnBlocks> rock = new AtomicCache<>();
|
||||
private final AtomicCache<ColumnBlocks> fluid = new AtomicCache<>();
|
||||
private final Map<UpperDimensionContext, ColumnBlocks> upperRocks = new ConcurrentHashMap<>();
|
||||
private final Map<String, ColumnBlocks> upperRocks = new ConcurrentHashMap<>();
|
||||
|
||||
TerrainPalettes(Engine engine) {
|
||||
this.engine = engine;
|
||||
TerrainPalettes(PackWorld world) {
|
||||
this.world = world;
|
||||
this.complexSeed = IrisSeed.COMPLEX.of(world);
|
||||
}
|
||||
|
||||
/** The palettes of the world {@code engine} generates now. */
|
||||
public static TerrainPalettes of(Engine engine) {
|
||||
return engine.getGeneration().state(TerrainPalettes.class, TerrainPalettes::new);
|
||||
/** The palettes of {@code world}. */
|
||||
public static TerrainPalettes of(PackWorld world) {
|
||||
return world.state(TerrainPalettes.class, TerrainPalettes::new);
|
||||
}
|
||||
|
||||
/** Builds the rock and fluid noise now instead of when first asked for. */
|
||||
@@ -77,54 +77,60 @@ public final class TerrainPalettes {
|
||||
}
|
||||
|
||||
/** The rock at the column, below the biome's layers. */
|
||||
public PlatformBlockState rockAt(double x, double z) {
|
||||
public BlockState rockAt(double x, double z) {
|
||||
return rock().at(x, z);
|
||||
}
|
||||
|
||||
/** The fluid at the column, above the terrain up to the fluid height. */
|
||||
public PlatformBlockState fluidAt(double x, double z) {
|
||||
public BlockState fluidAt(double x, double z) {
|
||||
return fluid().at(x, z);
|
||||
}
|
||||
|
||||
/** The rock at the column of the upper dimension: the world's own when the upper dimension is the dimension itself. */
|
||||
public PlatformBlockState upperRockAt(UpperDimensionContext upper, double x, double z) {
|
||||
return upperRocks.computeIfAbsent(upper, this::upperRock).at(x, z);
|
||||
public BlockState upperRockAt(UpperDimension upper, double x, double z) {
|
||||
return upperRocks.computeIfAbsent(upper.key(), key -> upperRock(upper, x, z)).at(x, z);
|
||||
}
|
||||
|
||||
private ColumnBlocks rock() {
|
||||
return rock.aquireOrThrow(() -> columns(rockPalette(engine.getDimension()), complexRng().nextParallelRNG(ROCK_SIGNATURE), engine.getData()));
|
||||
return rock.aquireOrThrow(() -> columns(rockPalette(world.settings().declared(RockPaletteSettings.class)), complexRng().nextParallelRNG(ROCK_SIGNATURE),
|
||||
world.resources()));
|
||||
}
|
||||
|
||||
private ColumnBlocks fluid() {
|
||||
return fluid.aquireOrThrow(() -> columns(fluidPalette(engine.getDimension()), complexRng().nextParallelRNG(FLUID_SIGNATURE), engine.getData()));
|
||||
return fluid.aquireOrThrow(() -> columns(fluidPalette(world.settings().declared(FluidPaletteSettings.class)), complexRng().nextParallelRNG(FLUID_SIGNATURE),
|
||||
world.resources()));
|
||||
}
|
||||
|
||||
private RNG complexRng() {
|
||||
return new RNG(engine.getSeedManager().getComplex());
|
||||
return new RNG(complexSeed);
|
||||
}
|
||||
|
||||
private ColumnBlocks upperRock(UpperDimensionContext upper) {
|
||||
if (upper.isSelfReferencing()) {
|
||||
private ColumnBlocks upperRock(UpperDimension upper, double x, double z) {
|
||||
if (upper.isThisDimension()) {
|
||||
return rock();
|
||||
}
|
||||
|
||||
long seedOffset = upper.getDimension().getLoadKey().hashCode();
|
||||
RNG rng = new RNG(engine.getSeedManager().getComplex() ^ seedOffset);
|
||||
return columns(rockPalette(upper.getDimension()), rng.nextParallelRNG(ROCK_SIGNATURE), upper.getData());
|
||||
long seedOffset = upper.key().hashCode();
|
||||
RNG rng = new RNG(complexSeed ^ seedOffset);
|
||||
List<Entry<RockPaletteSettings>> declared = upper.settings().at(RockPaletteSettings.class, (int) x, (int) z);
|
||||
return columns(rockPalette(declared), rng.nextParallelRNG(ROCK_SIGNATURE), upper.resources());
|
||||
}
|
||||
|
||||
private static PaletteSpec rockPalette(IrisDimension dimension) {
|
||||
return dimension.getModuleSettings().find(RockPaletteSettings.class).orElseGet(RockPaletteSettings::new).palette();
|
||||
private static PaletteSpec rockPalette(List<Entry<RockPaletteSettings>> declared) {
|
||||
return dimensionLevel(declared).map(Entry::value).orElseGet(RockPaletteSettings::new).palette();
|
||||
}
|
||||
|
||||
private static PaletteSpec fluidPalette(IrisDimension dimension) {
|
||||
return dimension.getModuleSettings().find(FluidPaletteSettings.class).orElseGet(FluidPaletteSettings::new).palette();
|
||||
private static PaletteSpec fluidPalette(List<Entry<FluidPaletteSettings>> declared) {
|
||||
return dimensionLevel(declared).map(Entry::value).orElseGet(FluidPaletteSettings::new).palette();
|
||||
}
|
||||
|
||||
private static <S extends com.volmit.IrisFeature> java.util.Optional<Entry<S>> dimensionLevel(List<Entry<S>> declared) {
|
||||
return declared.stream().filter(entry -> entry.level() == Target.DIMENSION).findFirst();
|
||||
}
|
||||
|
||||
/** The palette's blocks over the columns, picked by its noise: the noise at a column, from 0 to 1, is how far down the weighted list the block is. */
|
||||
private static ColumnBlocks columns(PaletteSpec palette, RNG rng, IrisData data) {
|
||||
IrisPackResources resources = data.getPackResources();
|
||||
List<PlatformBlockState> blocks = PaletteBlocks.weighted(resources.blocks(), palette.palette());
|
||||
private static ColumnBlocks columns(PaletteSpec palette, RNG rng, PackResources resources) {
|
||||
List<BlockState> blocks = PaletteBlocks.weighted(resources.blocks(), palette.palette());
|
||||
if (blocks.isEmpty()) {
|
||||
return (x, z) -> null;
|
||||
}
|
||||
@@ -15,16 +15,18 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
/**
|
||||
@@ -35,36 +37,40 @@ import java.util.function.LongSupplier;
|
||||
final class OreWarmUp {
|
||||
private static final long ROOT_SEED_SALT = 7777L;
|
||||
|
||||
private final Engine engine;
|
||||
private final PackWorld world;
|
||||
private final TerrainOres ores;
|
||||
private final RNG root;
|
||||
private int warmed;
|
||||
|
||||
OreWarmUp(Engine engine) {
|
||||
this(engine, TerrainOres.of(engine));
|
||||
OreWarmUp(PackWorld world) {
|
||||
this(world, TerrainOres.of(world));
|
||||
}
|
||||
|
||||
OreWarmUp(Engine engine, TerrainOres ores) {
|
||||
this.engine = engine;
|
||||
OreWarmUp(PackWorld world, TerrainOres ores) {
|
||||
this.world = world;
|
||||
this.ores = ores;
|
||||
this.root = new RNG(engine.getSeedManager().getComponent() + ROOT_SEED_SALT);
|
||||
this.root = new RNG(IrisSeed.COMPONENT.of(world) + ROOT_SEED_SALT);
|
||||
}
|
||||
|
||||
void warm() {
|
||||
LongSupplier seeds = () -> root.nextParallelRNG(warmed++).getSeed();
|
||||
|
||||
KList<IrisBiome> biomes = engine.getAllBiomes();
|
||||
biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
|
||||
for (IrisBiome biome : biomes) {
|
||||
ores.of(biome).warm(seeds);
|
||||
}
|
||||
List<Entry<OreSettings>> declared = world.settings().declared(OreSettings.class);
|
||||
warmLevel(declared, Target.BIOME, seeds);
|
||||
warmLevel(declared, Target.REGION, seeds);
|
||||
warmLevel(declared, Target.DIMENSION, seeds);
|
||||
}
|
||||
|
||||
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
|
||||
regions.sort(Comparator.comparing(IrisRegion::getLoadKey));
|
||||
for (IrisRegion region : regions) {
|
||||
ores.of(region).warm(seeds);
|
||||
}
|
||||
/** The ores of every owner at {@code level}, ordered by the key of the biome, region or dimension that declares them. */
|
||||
private void warmLevel(List<Entry<OreSettings>> declared, Target level, LongSupplier seeds) {
|
||||
declared.stream()
|
||||
.filter(entry -> entry.level() == level)
|
||||
.sorted(Comparator.comparing((Entry<OreSettings> entry) -> key(entry.source())))
|
||||
.forEach(entry -> ores.of(entry.value()).warm(seeds));
|
||||
}
|
||||
|
||||
ores.of(engine.getDimension()).warm(seeds);
|
||||
private static String key(ResourceId source) {
|
||||
String path = source.path();
|
||||
return path.substring(path.indexOf('/') + 1);
|
||||
}
|
||||
}
|
||||
@@ -15,25 +15,23 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.OreGenerator;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.PaletteSampler;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* One {@link OreGenerator} made ready for one world: its palette resolved to the platform's blocks and the noise that
|
||||
* One {@link OreGenerator} made ready for one world: its palette resolved to blocks and the noise that
|
||||
* decides where it places ore, built from the seed it is warmed with or, when nothing warmed it, from the terrain seed
|
||||
* of its first use. The palette picks with the terrain seed. What the generator describes stays in the settings;
|
||||
* everything that needs the platform, the pack or the world seed is here.
|
||||
@@ -43,7 +41,7 @@ final class ResolvedOre {
|
||||
private final NoiseFactory noise;
|
||||
private final BlockRegistry blockRegistry;
|
||||
private final long terrainSeed;
|
||||
private final List<PlatformBlockState> blocks;
|
||||
private final List<BlockState> blocks;
|
||||
private final AtomicCache<NoiseSampler> chance = new AtomicCache<>();
|
||||
private final AtomicCache<PaletteSampler> palette = new AtomicCache<>();
|
||||
|
||||
@@ -51,7 +49,7 @@ final class ResolvedOre {
|
||||
* @param terrainSeed the seed the palette picks with, and the noise is built from when nothing warmed it first
|
||||
* @param blocks the palette as the platform's blocks, each repeated by its weight
|
||||
*/
|
||||
ResolvedOre(OreGenerator settings, NoiseFactory noise, BlockRegistry blockRegistry, long terrainSeed, List<PlatformBlockState> blocks) {
|
||||
ResolvedOre(OreGenerator settings, NoiseFactory noise, BlockRegistry blockRegistry, long terrainSeed, List<BlockState> blocks) {
|
||||
this.settings = settings;
|
||||
this.noise = noise;
|
||||
this.blockRegistry = blockRegistry;
|
||||
@@ -59,20 +57,16 @@ final class ResolvedOre {
|
||||
this.blocks = List.copyOf(blocks);
|
||||
}
|
||||
|
||||
/** {@code settings} ready for {@code engine}: its blocks resolved through the pack, its picks seeded with the terrain seed. */
|
||||
static ResolvedOre of(OreGenerator settings, Engine engine) {
|
||||
var resources = engine.getData().getPackResources();
|
||||
/** {@code settings} ready for a world with {@code resources}: its blocks resolved through the pack, its picks seeded with the terrain seed. */
|
||||
static ResolvedOre of(OreGenerator settings, PackResources resources, long terrainSeed) {
|
||||
BlockRegistry registry = resources.blocks();
|
||||
return new ResolvedOre(settings, resources.noise(), registry, engine.getSeedManager().getTerrain(), weighted(registry, settings.palette().palette()));
|
||||
return new ResolvedOre(settings, resources.noise(), registry, terrainSeed, weighted(registry, settings.palette().palette()));
|
||||
}
|
||||
|
||||
private static List<PlatformBlockState> weighted(BlockRegistry registry, List<BlockSpec> specs) {
|
||||
List<PlatformBlockState> weighted = new ArrayList<>();
|
||||
private static List<BlockState> weighted(BlockRegistry registry, List<BlockSpec> specs) {
|
||||
List<BlockState> weighted = new ArrayList<>();
|
||||
for (BlockSpec spec : specs) {
|
||||
PlatformBlockState state = B.getState(registry.resolve(spec).key());
|
||||
if (state == null) {
|
||||
continue;
|
||||
}
|
||||
BlockState state = registry.resolve(spec);
|
||||
for (int n = 0; n < spec.weight(); n++) {
|
||||
weighted.add(state);
|
||||
}
|
||||
@@ -98,7 +92,7 @@ final class ResolvedOre {
|
||||
}
|
||||
|
||||
/** The ore block at the position, or null when the position is out of the band, the chance noise is above the threshold or the palette has no block. */
|
||||
PlatformBlockState generate(int x, int y, int z) {
|
||||
BlockState generate(int x, int y, int z) {
|
||||
if (!settings.range().contains(y)) {
|
||||
return null;
|
||||
}
|
||||
@@ -120,7 +114,7 @@ final class ResolvedOre {
|
||||
return chance.aquire(() -> noise.sampler(settings.chanceStyle(), terrainSeed));
|
||||
}
|
||||
|
||||
private PlatformBlockState pick(int x, int y, int z) {
|
||||
private BlockState pick(int x, int y, int z) {
|
||||
if (blocks.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -128,6 +122,6 @@ final class ResolvedOre {
|
||||
return blocks.getFirst();
|
||||
}
|
||||
PaletteSampler sampler = palette.aquire(() -> blockRegistry.palette(settings.palette(), terrainSeed));
|
||||
return B.getState(sampler.at(x, y, z).key());
|
||||
return sampler.at(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.OreGenerator;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -49,12 +48,12 @@ final class ResolvedOres {
|
||||
this.undergroundBand = YBand.of(underground);
|
||||
}
|
||||
|
||||
/** {@code settings} ready for {@code engine}; generators the pack wrote as {@code null} are left out. */
|
||||
static ResolvedOres of(OreSettings settings, Engine engine) {
|
||||
/** {@code settings} ready for a world with {@code resources}; generators the pack wrote as {@code null} are left out. */
|
||||
static ResolvedOres of(OreSettings settings, PackResources resources, long terrainSeed) {
|
||||
List<ResolvedOre> ores = new ArrayList<>();
|
||||
for (OreGenerator generator : settings.generators()) {
|
||||
if (generator != null) {
|
||||
ores.add(ResolvedOre.of(generator, engine));
|
||||
ores.add(ResolvedOre.of(generator, resources, terrainSeed));
|
||||
}
|
||||
}
|
||||
return ores.isEmpty() ? NONE : new ResolvedOres(ores);
|
||||
@@ -77,17 +76,17 @@ final class ResolvedOres {
|
||||
}
|
||||
}
|
||||
|
||||
PlatformBlockState generateSurface(int x, int y, int z) {
|
||||
BlockState generateSurface(int x, int y, int z) {
|
||||
return firstOre(surface, x, y, z);
|
||||
}
|
||||
|
||||
PlatformBlockState generateUnderground(int x, int y, int z) {
|
||||
BlockState generateUnderground(int x, int y, int z) {
|
||||
return firstOre(underground, x, y, z);
|
||||
}
|
||||
|
||||
private static PlatformBlockState firstOre(List<ResolvedOre> ores, int x, int y, int z) {
|
||||
private static BlockState firstOre(List<ResolvedOre> ores, int x, int y, int z) {
|
||||
for (int index = 0; index < ores.size(); index++) {
|
||||
PlatformBlockState ore = ores.get(index).generate(x, y, z);
|
||||
BlockState ore = ores.get(index).generate(x, y, z);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
|
||||
@@ -15,51 +15,33 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.terrain.BedrockSettings;
|
||||
import art.arcane.iris.builtin.terrain.CaveCeilingLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.ExplodeBiomePaletteSizeSettings;
|
||||
import art.arcane.iris.builtin.terrain.ExplodeBiomePalettesSettings;
|
||||
import art.arcane.iris.builtin.terrain.FluidPaletteSettings;
|
||||
import art.arcane.iris.builtin.terrain.HideOresSettings;
|
||||
import art.arcane.iris.builtin.terrain.LayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.LockLayersMaxSettings;
|
||||
import art.arcane.iris.builtin.terrain.LockLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.iris.builtin.terrain.RockPaletteSettings;
|
||||
import art.arcane.iris.builtin.terrain.SeaLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.SlabSettings;
|
||||
import art.arcane.iris.builtin.terrain.WallSettings;
|
||||
import art.arcane.iris.builtin.terrain.HideOresSettings;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.IrisChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.UpperDimensionContext;
|
||||
import art.arcane.iris.engine.actuator.ResolvedOres.YBand;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.engine.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.iris.util.project.context.ChunkedDataCache;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleLifecycle;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.TerrainPalettes;
|
||||
|
||||
/**
|
||||
* Module {@code iris:terrain}: the chunk's ground, fluids and biome layers. Each column is filled from bedrock up
|
||||
* to its height and the fluid height with its biome's layers, with ore generators of the dimension, region and
|
||||
@@ -87,14 +69,16 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
registry.registerSettings(FluidPaletteSettings.class);
|
||||
registry.registerSettings(OreSettings.class);
|
||||
registry.registerSettings(HideOresSettings.class);
|
||||
registry.registerSettings(BedrockSettings.class);
|
||||
registry.registerSettings(ExplodeBiomePalettesSettings.class);
|
||||
registry.registerSettings(ExplodeBiomePaletteSizeSettings.class);
|
||||
registry.registerLifecycle(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warmUp(PackWorld world) {
|
||||
Engine engine = IrisPackWorld.of(world).engine();
|
||||
TerrainPalettes.of(engine).warm();
|
||||
new OreWarmUp(engine).warm();
|
||||
TerrainPalettes.of(world).warm();
|
||||
new OreWarmUp(world).warm();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,198 +87,6 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
}
|
||||
|
||||
private static void shape(ChunkStageContext context) {
|
||||
IrisChunk chunk = IrisChunk.current();
|
||||
ModuleLog log = context.log();
|
||||
chunk.state(TerrainShaper.class, generating -> new TerrainShaper(generating, log)).shape(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.context());
|
||||
}
|
||||
|
||||
/** What shaping terrain keeps for one engine runtime: the terrain stream's random. */
|
||||
static final class TerrainShaper {
|
||||
private static final PlatformBlockState BEDROCK = B.getState("BEDROCK");
|
||||
|
||||
private final Engine engine;
|
||||
private final TerrainPalettes palettes;
|
||||
private final BiomeLayers layers;
|
||||
private final TerrainOres ores;
|
||||
private final RNG rng;
|
||||
|
||||
TerrainShaper(Engine engine, ModuleLog log) {
|
||||
this(engine, TerrainPalettes.of(engine), BiomeLayers.of(engine, log), TerrainOres.of(engine));
|
||||
}
|
||||
|
||||
TerrainShaper(Engine engine, TerrainPalettes palettes, BiomeLayers layers, TerrainOres ores) {
|
||||
this.engine = engine;
|
||||
this.palettes = palettes;
|
||||
this.layers = layers;
|
||||
this.ores = ores;
|
||||
this.rng = new RNG(engine.getSeedManager().getTerrain());
|
||||
}
|
||||
|
||||
/** Fills the 16 x 16 columns of the chunk whose first block is {@code originX}, {@code originZ}, one slice along x at a time. */
|
||||
@BlockCoordinates
|
||||
void shape(int originX, int originZ, Hunk<PlatformBlockState> blocks, ChunkContext context) {
|
||||
PrecisionStopwatch stopwatch = PrecisionStopwatch.start();
|
||||
for (int sliceX = 0; sliceX < blocks.getWidth(); sliceX++) {
|
||||
shapeSliver(originX, originZ, sliceX, blocks, context);
|
||||
}
|
||||
engine.getMetrics().getTerrain().put(stopwatch.getMilliseconds());
|
||||
}
|
||||
|
||||
/** One plane from the sky to bedrock, one block thick along x. */
|
||||
@BlockCoordinates
|
||||
private void shapeSliver(int x, int z, int xf, Hunk<PlatformBlockState> h, ChunkContext context) {
|
||||
int chunkHeight = h.getHeight();
|
||||
int chunkDepth = h.getDepth();
|
||||
IrisDimension dimension = engine.getDimension();
|
||||
IrisData data = engine.getData();
|
||||
IrisComplex complex = engine.getComplex();
|
||||
RNG localRng = rng;
|
||||
int fluidHeight = dimension.getFluidHeight();
|
||||
int clampedFluidHeight = Math.min(chunkHeight, fluidHeight);
|
||||
boolean bedrockEnabled = dimension.isBedrock();
|
||||
boolean hideOres = HiddenOres.in(dimension);
|
||||
ChunkedDataCache<IrisBiome> biomeCache = context.getBiome();
|
||||
ChunkedDataCache<IrisRegion> regionCache = context.getRegion();
|
||||
int realX = xf + x;
|
||||
UpperDimensionContext upperContext = engine.getUpperContext();
|
||||
// Dimension-level ore lookups are chunk-invariant; resolving them per column paid
|
||||
// the settings lookup times 256 per chunk for a constant.
|
||||
ResolvedOres dimensionOres = hideOres ? ResolvedOres.NONE : ores.of(dimension);
|
||||
YBand dimensionSurfaceBand = dimensionOres.surfaceBand();
|
||||
YBand dimensionUndergroundBand = dimensionOres.undergroundBand();
|
||||
|
||||
for (int zf = 0; zf < chunkDepth; zf++) {
|
||||
int realZ = zf + z;
|
||||
IrisBiome biome = biomeCache.get(xf, zf);
|
||||
IrisRegion region = regionCache.get(xf, zf);
|
||||
int he = Math.min(chunkHeight, context.getRoundedHeight(xf, zf));
|
||||
int hf = Math.max(clampedFluidHeight, he);
|
||||
if (hf < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int topY = Math.min(hf, chunkHeight - 1);
|
||||
PlatformBlockState fluid = palettes.fluidAt(realX, realZ);
|
||||
PlatformBlockState rock = palettes.rockAt(realX, realZ);
|
||||
PlatformBlockState mappedSurfaceBlock = complex.getImageMapRuntime().sampleSurfaceBlock(realX, realZ);
|
||||
ResolvedOres biomeOres = hideOres ? ResolvedOres.NONE : ores.of(biome);
|
||||
ResolvedOres regionOres = hideOres ? ResolvedOres.NONE : ores.of(region);
|
||||
YBand biomeSurfaceBand = biomeOres.surfaceBand();
|
||||
YBand regionSurfaceBand = regionOres.surfaceBand();
|
||||
YBand biomeUndergroundBand = biomeOres.undergroundBand();
|
||||
YBand regionUndergroundBand = regionOres.undergroundBand();
|
||||
boolean hasSurfaceOres = biomeSurfaceBand.hasOres() || regionSurfaceBand.hasOres() || dimensionSurfaceBand.hasOres();
|
||||
boolean hasUndergroundOres = biomeUndergroundBand.hasOres() || regionUndergroundBand.hasOres() || dimensionUndergroundBand.hasOres();
|
||||
KList<PlatformBlockState> blocks = null;
|
||||
KList<PlatformBlockState> fblocks = null;
|
||||
|
||||
for (int i = topY; i >= 0; i--) {
|
||||
if (i == 0 && bedrockEnabled) {
|
||||
h.setRaw(xf, i, zf, BEDROCK);
|
||||
continue;
|
||||
}
|
||||
|
||||
PlatformBlockState ore = null;
|
||||
if (hasSurfaceOres) {
|
||||
if (biomeSurfaceBand.contains(i)) {
|
||||
ore = biomeOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && regionSurfaceBand.contains(i)) {
|
||||
ore = regionOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && dimensionSurfaceBand.contains(i)) {
|
||||
ore = dimensionOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
}
|
||||
if (ore != null) {
|
||||
h.setRaw(xf, i, zf, ore);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i > he && i <= hf) {
|
||||
int fdepth = hf - i;
|
||||
if (fblocks == null) {
|
||||
fblocks = layers.generateSeaLayers(biome, realX, realZ, localRng, hf - he, data);
|
||||
}
|
||||
|
||||
if (fblocks.hasIndex(fdepth)) {
|
||||
h.setRaw(xf, i, zf, fblocks.get(fdepth));
|
||||
} else {
|
||||
h.setRaw(xf, i, zf, fluid);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i <= he) {
|
||||
int depth = he - i;
|
||||
if (depth == 0 && mappedSurfaceBlock != null) {
|
||||
h.setRaw(xf, i, zf, mappedSurfaceBlock);
|
||||
continue;
|
||||
}
|
||||
if (blocks == null) {
|
||||
blocks = layers.generateLayers(biome, dimension, realX, realZ, localRng, he, he, data, complex);
|
||||
}
|
||||
|
||||
if (blocks.hasIndex(depth)) {
|
||||
h.setRaw(xf, i, zf, blocks.get(depth));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasUndergroundOres) {
|
||||
if (biomeUndergroundBand.contains(i)) {
|
||||
ore = biomeOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && regionUndergroundBand.contains(i)) {
|
||||
ore = regionOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && dimensionUndergroundBand.contains(i)) {
|
||||
ore = dimensionOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
}
|
||||
|
||||
if (ore != null) {
|
||||
h.setRaw(xf, i, zf, ore);
|
||||
} else {
|
||||
h.setRaw(xf, i, zf, rock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (upperContext != null) {
|
||||
int rawUpperSurface = upperContext.getUpperSurfaceY(realX, realZ);
|
||||
int upperGap = dimension.getUpperDimensionGap();
|
||||
int upperSurfaceY = Math.max(rawUpperSurface, he + upperGap);
|
||||
|
||||
if (upperSurfaceY < chunkHeight - 1) {
|
||||
IrisBiome upperBiome = upperContext.getUpperBiome(realX, realZ);
|
||||
PlatformBlockState upperRock = palettes.upperRockAt(upperContext, realX, realZ);
|
||||
PlatformBlockState upperMappedSurface = upperContext.getSurfaceBlock(realX, realZ);
|
||||
int upperThickness = chunkHeight - 1 - upperSurfaceY;
|
||||
KList<PlatformBlockState> upperBlocks = upperBiome != null
|
||||
? layers.generateLayers(upperBiome, upperContext.getDimension(),
|
||||
realX, realZ, localRng, upperThickness, upperThickness,
|
||||
upperContext.getData(), complex)
|
||||
: null;
|
||||
|
||||
for (int y = chunkHeight - 1; y >= upperSurfaceY; y--) {
|
||||
if (y == chunkHeight - 1 && bedrockEnabled) {
|
||||
h.setRaw(xf, y, zf, BEDROCK);
|
||||
continue;
|
||||
}
|
||||
if (y == upperSurfaceY && upperMappedSurface != null) {
|
||||
h.setRaw(xf, y, zf, upperMappedSurface);
|
||||
continue;
|
||||
}
|
||||
int depthFromFace = y - upperSurfaceY;
|
||||
if (upperBlocks != null && upperBlocks.hasIndex(depthFromFace)) {
|
||||
h.setRaw(xf, y, zf, upperBlocks.get(depthFromFace));
|
||||
} else {
|
||||
h.setRaw(xf, y, zf, upperRock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TerrainShaper.of(context.world()).shape(context);
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -30,24 +30,25 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* ({@link ResolvedOres}), built from their {@link OreSettings} when first asked for or ahead of generation by {@link OreWarmUp}.
|
||||
*/
|
||||
final class TerrainOres {
|
||||
private final Engine engine;
|
||||
private final PackResources resources;
|
||||
private final long terrainSeed;
|
||||
private final Map<OreSettings, ResolvedOres> resolved = new ConcurrentHashMap<>();
|
||||
|
||||
TerrainOres(Engine engine) {
|
||||
this.engine = engine;
|
||||
TerrainOres(PackWorld world) {
|
||||
this.resources = world.resources();
|
||||
this.terrainSeed = IrisSeed.TERRAIN.of(world);
|
||||
}
|
||||
|
||||
/** The ores of the world {@code engine} generates now. */
|
||||
static TerrainOres of(Engine engine) {
|
||||
return engine.getGeneration().state(TerrainOres.class, TerrainOres::new);
|
||||
/** The ores of {@code world}. */
|
||||
static TerrainOres of(PackWorld world) {
|
||||
return world.state(TerrainOres.class, TerrainOres::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ore generators {@code owner}, a dimension, region or biome, declares; {@link ResolvedOres#NONE} when it declares none. The
|
||||
* terrain asks this for two owners per column, so a resolved set is read without taking the map's lock.
|
||||
* The ore generators {@code settings}, those a dimension, region or biome declares, make ready; {@link ResolvedOres#NONE} when it
|
||||
* declares none. The terrain asks this for two owners per column, so a resolved set is read without taking the map's lock.
|
||||
*/
|
||||
ResolvedOres of(IrisRegistrant owner) {
|
||||
OreSettings settings = owner.getModuleSettings().find(OreSettings.class).orElse(null);
|
||||
ResolvedOres of(OreSettings settings) {
|
||||
if (settings == null) {
|
||||
return ResolvedOres.NONE;
|
||||
}
|
||||
@@ -55,6 +56,6 @@ final class TerrainOres {
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
}
|
||||
return resolved.computeIfAbsent(settings, declared -> ResolvedOres.of(declared, engine));
|
||||
return resolved.computeIfAbsent(settings, declared -> ResolvedOres.of(declared, resources, terrainSeed));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.terrain.BedrockSettings;
|
||||
import art.arcane.iris.builtin.terrain.HideOresSettings;
|
||||
import art.arcane.iris.builtin.terrain.OreSettings;
|
||||
import art.arcane.iris.engine.actuator.ResolvedOres.YBand;
|
||||
import art.arcane.iris.builtin.terrain.BiomeLayers;
|
||||
import art.arcane.iris.builtin.terrain.ColumnSlope;
|
||||
import art.arcane.iris.builtin.terrain.LayeredBiome;
|
||||
import art.arcane.iris.builtin.terrain.PaletteExplosion;
|
||||
import art.arcane.iris.builtin.terrain.TerrainPalettes;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import com.volmit.world.UpperDimension;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.function.Function;
|
||||
|
||||
/** What shaping terrain keeps for one world: the terrain stream's random and the palettes, layers and ores the columns are filled from. */
|
||||
final class TerrainShaper {
|
||||
private static final BlockState BEDROCK = new BlockState("minecraft:bedrock");
|
||||
private static final int CHUNK_CENTRE = 7;
|
||||
|
||||
private final TerrainPalettes palettes;
|
||||
private final BiomeLayers layers;
|
||||
private final TerrainOres ores;
|
||||
private final RNG rng;
|
||||
private final boolean levelsBelowTheDimensionDeclareOres;
|
||||
|
||||
static TerrainShaper of(PackWorld world) {
|
||||
return world.state(TerrainShaper.class, TerrainShaper::new);
|
||||
}
|
||||
|
||||
TerrainShaper(PackWorld world) {
|
||||
this(world, TerrainPalettes.of(world), BiomeLayers.of(world), TerrainOres.of(world));
|
||||
}
|
||||
|
||||
TerrainShaper(PackWorld world, TerrainPalettes palettes, BiomeLayers layers, TerrainOres ores) {
|
||||
this.palettes = palettes;
|
||||
this.layers = layers;
|
||||
this.ores = ores;
|
||||
this.rng = new RNG(IrisSeed.TERRAIN.of(world));
|
||||
this.levelsBelowTheDimensionDeclareOres = world.settings().declared(OreSettings.class).stream()
|
||||
.anyMatch(entry -> entry.level() != Target.DIMENSION);
|
||||
}
|
||||
|
||||
/** Fills the 16 x 16 columns of the chunk, one slice along x at a time. */
|
||||
void shape(ChunkStageContext context) {
|
||||
Chunk chunk = new Chunk(context);
|
||||
for (int sliceX = 0; sliceX < chunk.blocks.getWidth(); sliceX++) {
|
||||
shapeSliver(chunk, sliceX);
|
||||
}
|
||||
}
|
||||
|
||||
/** One plane from the sky to bedrock, one block thick along x. */
|
||||
private void shapeSliver(Chunk chunk, int xf) {
|
||||
Hunk<BlockState> h = chunk.blocks;
|
||||
int chunkHeight = h.getHeight();
|
||||
int chunkDepth = h.getDepth();
|
||||
int realX = xf + chunk.originX;
|
||||
|
||||
for (int zf = 0; zf < chunkDepth; zf++) {
|
||||
int realZ = zf + chunk.originZ;
|
||||
int he = Math.min(chunkHeight, (int) Math.round(chunk.terrain.surfaceY(realX, realZ)));
|
||||
int hf = Math.max(chunk.clampedFluidHeight, he);
|
||||
if (hf < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int topY = Math.min(hf, chunkHeight - 1);
|
||||
BlockState fluid = palettes.fluidAt(realX, realZ);
|
||||
BlockState rock = palettes.rockAt(realX, realZ);
|
||||
BlockState mappedSurfaceBlock = chunk.terrain.surfaceBlock(realX, realZ).orElse(null);
|
||||
LayeredBiome biome = layers.biome(chunk.terrain.surfaceBiome(realX, realZ), chunk.settings);
|
||||
ColumnOres columnOres = chunk.oresAt(realX, realZ);
|
||||
ResolvedOres biomeOres = columnOres.biome;
|
||||
ResolvedOres regionOres = columnOres.region;
|
||||
YBand biomeSurfaceBand = biomeOres.surfaceBand();
|
||||
YBand regionSurfaceBand = regionOres.surfaceBand();
|
||||
YBand biomeUndergroundBand = biomeOres.undergroundBand();
|
||||
YBand regionUndergroundBand = regionOres.undergroundBand();
|
||||
ResolvedOres dimensionOres = chunk.dimensionOres;
|
||||
YBand dimensionSurfaceBand = dimensionOres.surfaceBand();
|
||||
YBand dimensionUndergroundBand = dimensionOres.undergroundBand();
|
||||
boolean hasSurfaceOres = biomeSurfaceBand.hasOres() || regionSurfaceBand.hasOres() || dimensionSurfaceBand.hasOres();
|
||||
boolean hasUndergroundOres = biomeUndergroundBand.hasOres() || regionUndergroundBand.hasOres() || dimensionUndergroundBand.hasOres();
|
||||
KList<BlockState> blocks = null;
|
||||
KList<BlockState> fblocks = null;
|
||||
|
||||
for (int i = topY; i >= 0; i--) {
|
||||
if (i == 0 && chunk.bedrockEnabled) {
|
||||
place(h, xf, i, zf, BEDROCK);
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockState ore = null;
|
||||
if (hasSurfaceOres) {
|
||||
if (biomeSurfaceBand.contains(i)) {
|
||||
ore = biomeOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && regionSurfaceBand.contains(i)) {
|
||||
ore = regionOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && dimensionSurfaceBand.contains(i)) {
|
||||
ore = dimensionOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
}
|
||||
if (ore != null) {
|
||||
place(h, xf, i, zf, ore);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i > he && i <= hf) {
|
||||
int fdepth = hf - i;
|
||||
if (fblocks == null) {
|
||||
fblocks = layers.generateSeaLayers(biome, realX, realZ, rng, hf - he);
|
||||
}
|
||||
|
||||
if (fblocks.hasIndex(fdepth)) {
|
||||
place(h, xf, i, zf, fblocks.get(fdepth));
|
||||
} else {
|
||||
place(h, xf, i, zf, fluid);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i <= he) {
|
||||
int depth = he - i;
|
||||
if (depth == 0 && mappedSurfaceBlock != null) {
|
||||
place(h, xf, i, zf, mappedSurfaceBlock);
|
||||
continue;
|
||||
}
|
||||
if (blocks == null) {
|
||||
blocks = layers.generateLayers(biome, chunk.explosion, realX, realZ, rng, he, he, chunk.slope);
|
||||
}
|
||||
|
||||
if (blocks.hasIndex(depth)) {
|
||||
place(h, xf, i, zf, blocks.get(depth));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasUndergroundOres) {
|
||||
if (biomeUndergroundBand.contains(i)) {
|
||||
ore = biomeOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && regionUndergroundBand.contains(i)) {
|
||||
ore = regionOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && dimensionUndergroundBand.contains(i)) {
|
||||
ore = dimensionOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
}
|
||||
|
||||
place(h, xf, i, zf, ore != null ? ore : rock);
|
||||
}
|
||||
}
|
||||
|
||||
if (chunk.upper.isPresent()) {
|
||||
fillUpperDimension(chunk, chunk.upper.get(), xf, zf, realX, realZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The upper dimension's ground, filled in from the top of the column down to where it ends. */
|
||||
private void fillUpperDimension(Chunk chunk, UpperDimension upper, int xf, int zf, int realX, int realZ) {
|
||||
Hunk<BlockState> h = chunk.blocks;
|
||||
int chunkHeight = h.getHeight();
|
||||
OptionalInt upperY = chunk.terrain.upperDimensionY(realX, realZ);
|
||||
if (upperY.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int upperSurfaceY = upperY.getAsInt();
|
||||
if (upperSurfaceY >= chunkHeight - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
FeatureSettings upperSettings = upper.settings();
|
||||
BlockState upperRock = palettes.upperRockAt(upper, realX, realZ);
|
||||
BlockState upperMappedSurface = upper.surfaceBlock(realX, realZ).orElse(null);
|
||||
int upperThickness = chunkHeight - 1 - upperSurfaceY;
|
||||
LayeredBiome upperBiome = upperBiome(upperSettings, realX, realZ);
|
||||
KList<BlockState> upperBlocks = layers.generateLayers(upperBiome, PaletteExplosion.of(upperSettings, realX, realZ),
|
||||
realX, realZ, rng, upperThickness, upperThickness, chunk.slope);
|
||||
|
||||
for (int y = chunkHeight - 1; y >= upperSurfaceY; y--) {
|
||||
if (y == chunkHeight - 1 && chunk.bedrockEnabled) {
|
||||
place(h, xf, y, zf, BEDROCK);
|
||||
continue;
|
||||
}
|
||||
if (y == upperSurfaceY && upperMappedSurface != null) {
|
||||
place(h, xf, y, zf, upperMappedSurface);
|
||||
continue;
|
||||
}
|
||||
int depthFromFace = y - upperSurfaceY;
|
||||
if (upperBlocks.hasIndex(depthFromFace)) {
|
||||
place(h, xf, y, zf, upperBlocks.get(depthFromFace));
|
||||
} else {
|
||||
place(h, xf, y, zf, upperRock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** What the biome of the upper dimension at the column declares about its layers. */
|
||||
private LayeredBiome upperBiome(FeatureSettings upperSettings, int worldX, int worldZ) {
|
||||
return new LayeredBiome(biomeLevel(upperSettings, art.arcane.iris.builtin.terrain.LayersSettings.class, worldX, worldZ), null, null,
|
||||
biomeLevel(upperSettings, art.arcane.iris.builtin.terrain.LockLayersSettings.class, worldX, worldZ),
|
||||
biomeLevel(upperSettings, art.arcane.iris.builtin.terrain.LockLayersMaxSettings.class, worldX, worldZ), null);
|
||||
}
|
||||
|
||||
private static <S extends IrisFeature> S biomeLevel(FeatureSettings settings, Class<S> type, int worldX, int worldZ) {
|
||||
return settings.at(type, worldX, worldZ).stream().filter(entry -> entry.level() == Target.BIOME).map(Entry::value).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/** A block the palette has none of leaves the column as it is. */
|
||||
private static void place(Hunk<BlockState> blocks, int x, int y, int z, BlockState block) {
|
||||
if (block != null) {
|
||||
blocks.set(x, y, z, block);
|
||||
}
|
||||
}
|
||||
|
||||
/** The ores of a column's region and biome. */
|
||||
private record ColumnOres(ResolvedOres region, ResolvedOres biome) {
|
||||
static final ColumnOres NONE = new ColumnOres(ResolvedOres.NONE, ResolvedOres.NONE);
|
||||
}
|
||||
|
||||
/** What one chunk's columns share: its views, its dimension's switches and ores. */
|
||||
private final class Chunk {
|
||||
final Hunk<BlockState> blocks;
|
||||
final TerrainSampler terrain;
|
||||
final FeatureSettings settings;
|
||||
final int originX;
|
||||
final int originZ;
|
||||
final int clampedFluidHeight;
|
||||
final boolean bedrockEnabled;
|
||||
final PaletteExplosion explosion;
|
||||
final ColumnSlope slope;
|
||||
final Optional<UpperDimension> upper;
|
||||
final ResolvedOres dimensionOres;
|
||||
private final boolean hideOres;
|
||||
|
||||
Chunk(ChunkStageContext context) {
|
||||
this.blocks = context.hunk(BlockState.class);
|
||||
this.terrain = context.terrain();
|
||||
this.settings = context.settings();
|
||||
this.originX = context.originX();
|
||||
this.originZ = context.originZ();
|
||||
this.clampedFluidHeight = Math.min(blocks.getHeight(), terrain.fluidHeight());
|
||||
int centreX = originX + CHUNK_CENTRE;
|
||||
int centreZ = originZ + CHUNK_CENTRE;
|
||||
this.bedrockEnabled = dimensionValue(settings.at(BedrockSettings.class, centreX, centreZ), BedrockSettings::bedrock, true);
|
||||
this.hideOres = dimensionValue(settings.at(HideOresSettings.class, centreX, centreZ), HideOresSettings::hide, false);
|
||||
this.explosion = PaletteExplosion.of(settings, centreX, centreZ);
|
||||
this.slope = (x, z) -> terrain.column((int) x, (int) z).slope();
|
||||
this.upper = terrain.upperDimension();
|
||||
// Dimension-level ore lookups are chunk-invariant; resolving them per column paid the settings lookup times 256 per chunk for a constant.
|
||||
this.dimensionOres = hideOres ? ResolvedOres.NONE : ores.of(levelValue(settings.at(OreSettings.class, centreX, centreZ), Target.DIMENSION));
|
||||
}
|
||||
|
||||
/** The ores of the column's region and biome; none where the levels below the dimension declare none, or the dimension hides ores. */
|
||||
ColumnOres oresAt(int worldX, int worldZ) {
|
||||
if (hideOres || !levelsBelowTheDimensionDeclareOres) {
|
||||
return ColumnOres.NONE;
|
||||
}
|
||||
List<Entry<OreSettings>> declared = settings.at(OreSettings.class, worldX, worldZ);
|
||||
return new ColumnOres(ores.of(levelValue(declared, Target.REGION)), ores.of(levelValue(declared, Target.BIOME)));
|
||||
}
|
||||
}
|
||||
|
||||
private static <S extends IrisFeature, V> V dimensionValue(List<Entry<S>> entries, Function<S, V> read, V fallback) {
|
||||
S declared = levelValue(entries, Target.DIMENSION);
|
||||
return declared == null ? fallback : read.apply(declared);
|
||||
}
|
||||
|
||||
private static <S extends IrisFeature> S levelValue(List<Entry<S>> entries, Target level) {
|
||||
for (Entry<S> entry : entries) {
|
||||
if (entry.level() == level) {
|
||||
return entry.value();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.UpperDimensionContext;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.mantle.MantleWriter;
|
||||
import art.arcane.iris.engine.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.builtin.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CaveProfiles;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.terrain.carving.ResolvedCarvingEntry;
|
||||
@@ -471,7 +471,7 @@ public class CaveCarving {
|
||||
|
||||
private void prefillProfileFieldSamples(int startX, int startZ, IrisComplex complex, BlendScratch blendScratch) {
|
||||
fillFieldHeights(complex.getHeightStream(), startX, startZ, blendScratch.fieldSurfaceHeights);
|
||||
fillFieldFluidPresence(TerrainPalettes.of(engine), startX, startZ, blendScratch.fieldHasFluid);
|
||||
fillFieldFluidPresence(TerrainPalettes.of(engine.getGeneration().world()), startX, startZ, blendScratch.fieldHasFluid);
|
||||
fillFieldObjects(complex.getRegionStream(), startX, startZ, blendScratch.fieldRegions);
|
||||
fillFieldObjects(complex.getTrueBiomeStream(), startX, startZ, blendScratch.fieldSurfaceBiomes);
|
||||
fillFieldObjects(complex.getCaveBiomeStream(), startX, startZ, blendScratch.fieldCaveBiomes);
|
||||
@@ -499,7 +499,8 @@ public class CaveCarving {
|
||||
for (int fieldX = 0; fieldX < FIELD_SIZE; fieldX++) {
|
||||
int worldX = startX + fieldX;
|
||||
for (int fieldZ = 0; fieldZ < FIELD_SIZE; fieldZ++) {
|
||||
target[(fieldX * FIELD_SIZE) + fieldZ] = B.isFluid(palettes.fluidAt(worldX, startZ + fieldZ));
|
||||
com.volmit.block.BlockState fluid = palettes.fluidAt(worldX, startZ + fieldZ);
|
||||
target[(fieldX * FIELD_SIZE) + fieldZ] = fluid != null && B.isFluid(B.getState(fluid.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,8 @@ public final class CarveModule implements IrisModule {
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
graph.define(IrisStages.Carve.CAVES).reach(CAVE_REACH_BLOCKS).run(CarveModule::planCaves);
|
||||
graph.define(IrisStages.Carve.APPLY).requires(IrisStages.Terrain.SHAPE).run(CarveModule::applyCaves);
|
||||
// Ordering only: iris:terrain ships in the built-ins jar, which a pack may not have.
|
||||
graph.define(IrisStages.Carve.APPLY).softAfter(IrisStages.Terrain.SHAPE.ref()).run(CarveModule::applyCaves);
|
||||
}
|
||||
|
||||
private static void planCaves(MantleStageContext context) {
|
||||
|
||||
@@ -22,8 +22,8 @@ import art.arcane.iris.engine.UpperDimensionContext;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.engine.decorator.DecoratedBiome;
|
||||
import art.arcane.iris.engine.decorator.DecorationScene;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.engine.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.builtin.terrain.BiomeLayers;
|
||||
import art.arcane.iris.builtin.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.engine.decorator.IrisCeilingDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSurfaceDecorator;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
@@ -75,8 +75,8 @@ public class CaveApplying {
|
||||
public CaveApplying(Engine engine, ModuleLog log) {
|
||||
this.engine = engine;
|
||||
rng = new RNG(engine.getSeedManager().getCarve());
|
||||
layers = BiomeLayers.of(engine, log);
|
||||
palettes = TerrainPalettes.of(engine);
|
||||
layers = BiomeLayers.of(engine.getGeneration().world());
|
||||
palettes = TerrainPalettes.of(engine.getGeneration().world());
|
||||
}
|
||||
|
||||
/** Applies the caves to the chunk at chunk coordinates {@code x}, {@code z}. */
|
||||
@@ -153,7 +153,7 @@ public class CaveApplying {
|
||||
if (explicitCarveIntent) {
|
||||
// Only a fluid cavern consumes the fluid sample, and on the maintenance path that
|
||||
// sample is a full procedural stream evaluation, so never take it per voxel.
|
||||
PlatformBlockState fluid = isFluidIntent(cavern) ? palettes.fluidAt(chunkBlockX + rx, chunkBlockZ + rz) : null;
|
||||
PlatformBlockState fluid = isFluidIntent(cavern) ? IrisLayers.platform(palettes.fluidAt(chunkBlockX + rx, chunkBlockZ + rz)) : null;
|
||||
output.setRaw(rx, yy, rz, resolveExplicitCarveState(cavern, fluid, LAVA, AIR));
|
||||
} else if (usesDefaultLava(caveLavaHeight, yy)) {
|
||||
output.setRaw(rx, yy, rz, LAVA);
|
||||
@@ -180,7 +180,7 @@ public class CaveApplying {
|
||||
: resolveCustomBiome(customBiomeCache, customBiome);
|
||||
|
||||
if (biome != null) {
|
||||
PlatformBlockState data = layers.wall(biome).get(rng, worldX, yy, worldZ);
|
||||
PlatformBlockState data = IrisLayers.platform(layers.wall(IrisLayers.wallOf(biome)).get(rng, worldX, yy, worldZ));
|
||||
int columnIndex = PowerOfTwoCoordinates.packLocal16(rx, rz);
|
||||
|
||||
if (data != null && B.isSolid(output.getRaw(rx, yy, rz)) && yy < surfaceHeights[columnIndex]) {
|
||||
@@ -515,8 +515,8 @@ public class CaveApplying {
|
||||
}
|
||||
|
||||
if (floorBiome != null) {
|
||||
KList<PlatformBlockState> floorLayers = layers.generateLayers(floorBiome,
|
||||
engine.getDimension(), worldX, worldZ, rng, 3, zoneFloor, engine.getData(), engine.getComplex());
|
||||
KList<PlatformBlockState> floorLayers = IrisLayers.platform(layers.generateLayers(IrisLayers.biome(floorBiome),
|
||||
IrisLayers.explosion(engine.getDimension()), worldX, worldZ, rng, 3, zoneFloor, IrisLayers.slope(engine)));
|
||||
for (int i = 0; i < zoneFloor - 1; i++) {
|
||||
if (!floorLayers.hasIndex(i)) {
|
||||
break;
|
||||
@@ -540,8 +540,8 @@ public class CaveApplying {
|
||||
|
||||
if (ceilingBiome != null) {
|
||||
int worldMaxY = engine.getWorld().maxHeight() - engine.getWorld().minHeight();
|
||||
KList<PlatformBlockState> ceilingLayers = layers.generateCeilingLayers(ceilingBiome,
|
||||
engine.getDimension(), worldX, worldZ, rng, 3, zoneCeiling, engine.getData(), engine.getComplex());
|
||||
KList<PlatformBlockState> ceilingLayers = IrisLayers.platform(layers.generateCeilingLayers(IrisLayers.biome(ceilingBiome),
|
||||
IrisLayers.explosion(engine.getDimension()), worldX, worldZ, rng, 3));
|
||||
for (int i = 0; i < ceilingLayers.size(); i++) {
|
||||
int ceilingY = zoneCeiling + i + 1;
|
||||
if (ceilingY >= worldMaxY) {
|
||||
@@ -602,7 +602,7 @@ public class CaveApplying {
|
||||
}
|
||||
|
||||
if (floorBiome != null) {
|
||||
KList<PlatformBlockState> floorBlocks = layers.generateLayers(floorBiome, engine.getDimension(), xx, zz, rng, 3, zone.floor, engine.getData(), engine.getComplex());
|
||||
KList<PlatformBlockState> floorBlocks = IrisLayers.platform(layers.generateLayers(IrisLayers.biome(floorBiome), IrisLayers.explosion(engine.getDimension()), xx, zz, rng, 3, zone.floor, IrisLayers.slope(engine)));
|
||||
for (int i = 0; i < zone.floor - 1; i++) {
|
||||
if (!floorBlocks.hasIndex(i)) {
|
||||
break;
|
||||
@@ -622,7 +622,7 @@ public class CaveApplying {
|
||||
}
|
||||
|
||||
if (ceilingBiome != null) {
|
||||
KList<PlatformBlockState> ceilingBlocks = layers.generateCeilingLayers(ceilingBiome, engine.getDimension(), xx, zz, rng, 3, zone.ceiling, engine.getData(), engine.getComplex());
|
||||
KList<PlatformBlockState> ceilingBlocks = IrisLayers.platform(layers.generateCeilingLayers(IrisLayers.biome(ceilingBiome), IrisLayers.explosion(engine.getDimension()), xx, zz, rng, 3));
|
||||
for (int i = 0; i < ceilingBlocks.size(); i++) {
|
||||
int cy = zone.ceiling + i + 1;
|
||||
if (cy >= maxY) {
|
||||
@@ -642,6 +642,9 @@ public class CaveApplying {
|
||||
}
|
||||
|
||||
DecorationScene scene = SCRATCH.get().decoration;
|
||||
if (scene == null) {
|
||||
return;
|
||||
}
|
||||
if (floorBiome != null) {
|
||||
DecoratedBiome floor = IrisDecoratedBiomes.of(floorBiome, BiomeKind.CAVE);
|
||||
if (scene.decorators().hasDecorators(floor, DecorationPart.NONE) && hasStableCaveFloorSupport(output, rx, zone.getFloor(), rz)) {
|
||||
|
||||
@@ -27,6 +27,8 @@ import art.arcane.iris.builtin.terrain.PaletteLayer;
|
||||
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.builtin.terrain.ExplodeBiomePaletteSizeSettings;
|
||||
import art.arcane.iris.builtin.terrain.ExplodeBiomePalettesSettings;
|
||||
import art.arcane.iris.engine.decorator.DecorationScene;
|
||||
import art.arcane.iris.engine.decorator.FloatingDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSeaSurfaceDecorator;
|
||||
@@ -34,14 +36,14 @@ import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySampler;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.engine.terrain.ResolvedLayer;
|
||||
import art.arcane.iris.builtin.terrain.BiomeLayers;
|
||||
import art.arcane.iris.builtin.terrain.LayerNoise;
|
||||
import art.arcane.iris.builtin.terrain.ResolvedLayer;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.matter.MatterBiomeInject;
|
||||
@@ -86,7 +88,7 @@ public class FloatingIslands {
|
||||
int generatorSeed = 7235;
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
ResolvedLayer layer = biomeLayers.resolve(layers.get(i));
|
||||
CNG heightGenerator = layer.heightNoise(random.nextParallelRNG((generatorSeed++) * generatorSeed * generatorSeed * generatorSeed));
|
||||
LayerNoise heightGenerator = layer.heightNoise(random.nextParallelRNG((generatorSeed++) * generatorSeed * generatorSeed * generatorSeed));
|
||||
if (heightGenerator == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -107,7 +109,7 @@ public class FloatingIslands {
|
||||
}
|
||||
|
||||
try {
|
||||
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.zoom(), j, (wz - j) / layer.zoom()));
|
||||
generated.add(IrisLayers.platform(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.zoom(), j, (wz - j) / layer.zoom())));
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to pick a block of a floating island's palette", e);
|
||||
}
|
||||
@@ -117,9 +119,11 @@ public class FloatingIslands {
|
||||
break;
|
||||
}
|
||||
|
||||
if (dimension != null && dimension.isExplodeBiomePalettes()) {
|
||||
if (dimension != null && dimension.getModuleSettings().find(ExplodeBiomePalettesSettings.class).map(ExplodeBiomePalettesSettings::explode).orElse(false)) {
|
||||
PlatformBlockState barrier = B.getState("minecraft:barrier");
|
||||
for (int j = 0; j < dimension.getExplodeBiomePaletteSize(); j++) {
|
||||
int gap = dimension.getModuleSettings().find(ExplodeBiomePaletteSizeSettings.class).map(ExplodeBiomePaletteSizeSettings::size)
|
||||
.orElse(ExplodeBiomePaletteSizeSettings.DEFAULT_SIZE);
|
||||
for (int j = 0; j < gap; j++) {
|
||||
generated.add(barrier);
|
||||
|
||||
if (generated.size() >= maxDepth) {
|
||||
@@ -188,9 +192,9 @@ public class FloatingIslands {
|
||||
IrisBiome target = entry == null ? parent : entry.getRealBiome(parent, data);
|
||||
int entrySeed = entry == null || entry.settings().biome() == null ? 0 : entry.settings().biome().hashCode();
|
||||
RNG layerRng = rng.nextParallelRNG((int) (colSeed ^ 0x7A4E ^ entrySeed));
|
||||
KList<PlatformBlockState> topBlocks = target == null ? null : biomeLayers.generateLayers(target, dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
|
||||
KList<PlatformBlockState> topBlocks = target == null ? null : IrisLayers.platform(biomeLayers.generateLayers(IrisLayers.biome(target), IrisLayers.explosion(dimension), wx, wz, layerRng, paletteDepth, paletteDepth, IrisLayers.slope(engine)));
|
||||
if (topBlocks == null || topBlocks.isEmpty()) {
|
||||
topBlocks = biomeLayers.generateLayers(parent, dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
|
||||
topBlocks = IrisLayers.platform(biomeLayers.generateLayers(IrisLayers.biome(parent), IrisLayers.explosion(dimension), wx, wz, layerRng, paletteDepth, paletteDepth, IrisLayers.slope(engine)));
|
||||
}
|
||||
KList<PlatformBlockState> bottomBlocks = generateBottomPaletteLayers(entry, dimension, wx, wz, layerRng, paletteDepth, data, complex);
|
||||
return new PaletteContext(topBlocks, bottomBlocks, B.getState("minecraft:stone"));
|
||||
@@ -212,7 +216,7 @@ public class FloatingIslands {
|
||||
this.engine = engine;
|
||||
this.log = log;
|
||||
rng = new RNG(engine.getSeedManager().getTerrain() ^ 0x7EB0A73F1DCE514DL);
|
||||
biomeLayers = BiomeLayers.of(engine, log);
|
||||
biomeLayers = BiomeLayers.of(engine.getGeneration().world());
|
||||
}
|
||||
|
||||
/** Fills the islands' solids into the chunk whose first block is {@code x}, {@code z}. */
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.CaveCeilingLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.ExplodeBiomePaletteSizeSettings;
|
||||
import art.arcane.iris.builtin.terrain.ExplodeBiomePalettesSettings;
|
||||
import art.arcane.iris.builtin.terrain.LayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.LockLayersMaxSettings;
|
||||
import art.arcane.iris.builtin.terrain.LockLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.SeaLayersSettings;
|
||||
import art.arcane.iris.builtin.terrain.WallSettings;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.builtin.terrain.ColumnSlope;
|
||||
import art.arcane.iris.builtin.terrain.LayeredBiome;
|
||||
import art.arcane.iris.builtin.terrain.PaletteExplosion;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
/** What Iris's carving and floating islands, which hold Iris's own types, hand the terrain's layers and palettes, and take back as the platform's blocks. */
|
||||
final class IrisLayers {
|
||||
private IrisLayers() {
|
||||
}
|
||||
|
||||
/** What the biome declares about its layers. */
|
||||
static LayeredBiome biome(IrisBiome biome) {
|
||||
return new LayeredBiome(
|
||||
biome.getModuleSettings().find(LayersSettings.class).orElse(null),
|
||||
biome.getModuleSettings().find(SeaLayersSettings.class).orElse(null),
|
||||
biome.getModuleSettings().find(CaveCeilingLayersSettings.class).orElse(null),
|
||||
biome.getModuleSettings().find(LockLayersSettings.class).orElse(null),
|
||||
biome.getModuleSettings().find(LockLayersMaxSettings.class).orElse(null),
|
||||
biome.getModuleSettings().find(WallSettings.class).orElse(null));
|
||||
}
|
||||
|
||||
/** The biome with only its wall, for a caller that asks for nothing else. */
|
||||
static LayeredBiome wallOf(IrisBiome biome) {
|
||||
return new LayeredBiome(null, null, null, null, null, biome.getModuleSettings().find(WallSettings.class).orElse(null));
|
||||
}
|
||||
|
||||
static PaletteExplosion explosion(IrisDimension dimension) {
|
||||
if (dimension == null) {
|
||||
return PaletteExplosion.NONE;
|
||||
}
|
||||
return new PaletteExplosion(
|
||||
dimension.getModuleSettings().find(ExplodeBiomePalettesSettings.class).map(ExplodeBiomePalettesSettings::explode).orElse(false),
|
||||
dimension.getModuleSettings().find(ExplodeBiomePaletteSizeSettings.class).map(ExplodeBiomePaletteSizeSettings::size)
|
||||
.orElse(ExplodeBiomePaletteSizeSettings.DEFAULT_SIZE));
|
||||
}
|
||||
|
||||
static ColumnSlope slope(Engine engine) {
|
||||
return (x, z) -> engine.getComplex().getSlopeStream().get(x, z);
|
||||
}
|
||||
|
||||
static PlatformBlockState platform(BlockState block) {
|
||||
return block == null ? null : B.getState(block.key());
|
||||
}
|
||||
|
||||
static KList<PlatformBlockState> platform(KList<BlockState> blocks) {
|
||||
KList<PlatformBlockState> converted = new KList<>(blocks.size());
|
||||
for (BlockState block : blocks) {
|
||||
converted.add(platform(block));
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import art.arcane.iris.builtin.blocks.WrittenBlocks;
|
||||
import art.arcane.iris.core.modules.IrisPlacement;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.builtin.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.noise.SimplexNoise;
|
||||
@@ -98,7 +98,7 @@ public final class VacuumModule implements IrisModule {
|
||||
this.placement = IrisPlacement.current();
|
||||
this.prepared = prepared;
|
||||
this.world = new PlacementWorld(context.access(), placement.states());
|
||||
this.palettes = engine.getComplex() == null ? null : TerrainPalettes.of(engine);
|
||||
this.palettes = engine.getComplex() == null ? null : TerrainPalettes.of(engine.getGeneration().world());
|
||||
VacuumSettings settings = prepared.config().getVacuumSettings();
|
||||
this.radius = IrisObjectVacuum.resolveRadius(vacuum, settings);
|
||||
this.step = vacuum.columnStepBlocks();
|
||||
@@ -161,7 +161,8 @@ public final class VacuumModule implements IrisModule {
|
||||
}
|
||||
|
||||
private void raise(int x, int z, int fromY, int toY) {
|
||||
PlatformBlockState fill = palettes != null ? palettes.rockAt(x, z) : null;
|
||||
com.volmit.block.BlockState rock = palettes != null ? palettes.rockAt(x, z) : null;
|
||||
PlatformBlockState fill = rock != null ? B.getState(rock.key()) : null;
|
||||
if (B.isAir(fill)) {
|
||||
fill = IrisObject.States.STONE;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.terrain.BedrockSettings;
|
||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
@@ -101,7 +102,8 @@ public final class ValidateModule implements IrisModule {
|
||||
|
||||
private static boolean isOnBedrock(PreparedPlacement prepared, int y) {
|
||||
Engine engine = prepared.terrain().getEngine();
|
||||
return engine != null && engine.getDimension().isBedrock() && y <= BEDROCK_ROW;
|
||||
return engine != null && y <= BEDROCK_ROW
|
||||
&& engine.getDimension().getModuleSettings().find(BedrockSettings.class).map(BedrockSettings::bedrock).orElse(true);
|
||||
}
|
||||
|
||||
private static boolean lacksSurfaceSupport(IrisPlacement placement, PreparedPlacement prepared) {
|
||||
|
||||
+11
-3
@@ -20,7 +20,8 @@ package art.arcane.iris.engine.object.world.biome;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecoratorLoad;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.builtin.terrain.LayerLoad;
|
||||
import art.arcane.iris.builtin.terrain.LayersSettings;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.render.RenderType;
|
||||
@@ -87,8 +88,11 @@ final class IrisBiomeColorRenderer {
|
||||
}
|
||||
case LAYER_LOAD -> {
|
||||
return biome.getCacheColorLayerLoad().aquire(() -> {
|
||||
BiomeLayers layers = BiomeLayers.of(engine, engine.getGeneration().world().log());
|
||||
return Color.getHSBColor(0.625f, (float) (BiomeLayers.layersOf(biome).size() / layers.busiestLayerCount(engine)), 1f);
|
||||
double busiest = 0D;
|
||||
for (IrisBiome reachable : engine.getDimension().getReachableBiomes(engine)) {
|
||||
busiest = Math.max(busiest, layerCountOf(reachable));
|
||||
}
|
||||
return Color.getHSBColor(0.625f, (float) (layerCountOf(biome) / busiest), 1f);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -96,6 +100,10 @@ final class IrisBiomeColorRenderer {
|
||||
return Color.black;
|
||||
}
|
||||
|
||||
private static int layerCountOf(IrisBiome biome) {
|
||||
return LayerLoad.layersOf(biome.getModuleSettings().find(LayersSettings.class).orElse(null)).size();
|
||||
}
|
||||
|
||||
private static DecorantSettings decorantSettingsOf(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(DecorantSettings.class).orElse(null);
|
||||
}
|
||||
|
||||
@@ -111,14 +111,8 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private int logicalHeight = 256;
|
||||
@Desc("If set to true, Iris will remove chunks to allow visualizing cross sections of chunks easily")
|
||||
private boolean debugChunkCrossSections = false;
|
||||
@Desc("Vertically split up the biome palettes with barrier blocks in between to visualize them. The gap size comes from explodeBiomePaletteSize.")
|
||||
private boolean explodeBiomePalettes = false;
|
||||
@Desc("Studio Mode for testing different parts of the world")
|
||||
private StudioMode studioMode = StudioMode.NORMAL;
|
||||
@MinNumber(1)
|
||||
@MaxNumber(16)
|
||||
@Desc("Customize the palette height explosion")
|
||||
private int explodeBiomePaletteSize = 3;
|
||||
@MinNumber(2)
|
||||
@MaxNumber(16)
|
||||
@Desc("Every X/Z % debugCrossSectionsMod == 0 cuts the chunk")
|
||||
@@ -128,8 +122,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@MinNumber(0)
|
||||
@Desc("The version of this dimension. Changing this will stop users from accidentally upgrading (and breaking their worlds).")
|
||||
private int version = 1;
|
||||
@Desc("Should bedrock be generated or not.")
|
||||
private boolean bedrock = true;
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The land chance. Up to 1.0 for total land or 0.0 for total sea")
|
||||
|
||||
Reference in new issue
Block a user