mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Merge branch 'wave3b/4'
# Conflicts: # builtin-modules.txt # src/main/java/art/arcane/iris/builtin/package-info.java # src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java # src/main/java/art/arcane/iris/engine/modifier/CarveModule.java # src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java # src/main/java/art/arcane/iris/engine/modifier/IrisCarveScratch.java # src/main/java/art/arcane/iris/engine/object/placement/VacuumModule.java # src/main/java/art/arcane/iris/engine/object/placement/ValidateModule.java
This commit is contained in:
commit
81e8b300ef
50 files changed
+2183
-1442
No files matched your search
@@ -27,7 +27,7 @@ import com.volmit.world.PackWorld;
|
||||
* from {@link PackWorld#seed()}.
|
||||
*/
|
||||
public enum IrisSeed {
|
||||
BIOME, CARVE, COMPONENT, DECORATOR, DEPOSIT, ENTITY, LOOT, MANTLE, POST, TERRAIN;
|
||||
BIOME, CARVE, COMPLEX, COMPONENT, DECORATOR, DEPOSIT, ENTITY, LOOT, MANTLE, POST, TERRAIN;
|
||||
|
||||
/** This seed of {@code world}, which must be a world Iris generates. */
|
||||
public long of(PackWorld world) {
|
||||
|
||||
@@ -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.decorant;
|
||||
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
/** Whether a dimension decorates at all, written as {@code "decorate": false}. A dimension without the key decorates. */
|
||||
@Desc("Generate decorations or not")
|
||||
@Feature(id = "iris:decorant/decorate", name = "Decorate", key = "decorate", root = "decorate", targets = Target.DIMENSION)
|
||||
public final class DecorateSettings implements IrisFeature {
|
||||
@Desc("Generate decorations or not")
|
||||
private boolean decorate = true;
|
||||
|
||||
public DecorateSettings() {
|
||||
}
|
||||
|
||||
public boolean decorate() {
|
||||
return decorate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.decorant;
|
||||
|
||||
/** How loaded with decorating a biome is, which studio's decorator load view colours it by. */
|
||||
public final class DecoratorLoad {
|
||||
private static final int COLUMNS_PER_CHUNK = 256;
|
||||
|
||||
private DecoratorLoad() {
|
||||
}
|
||||
|
||||
/** The sum of the decorators' chances times their stack heights, at least one block each; 0 for a biome without decorators. */
|
||||
public static double of(DecorantSettings settings) {
|
||||
if (settings == null) {
|
||||
return 0D;
|
||||
}
|
||||
|
||||
double load = 0D;
|
||||
for (Decorator decorator : settings.decorators()) {
|
||||
load += Math.max(decorator.stackMax(), 1) * decorator.chance();
|
||||
}
|
||||
return load;
|
||||
}
|
||||
|
||||
/** The sum of the decorators' chances over a chunk's columns, which is how strongly the view colours the biome. */
|
||||
public static double colour(DecorantSettings settings) {
|
||||
if (settings == null) {
|
||||
return 0D;
|
||||
}
|
||||
|
||||
double load = 0D;
|
||||
for (Decorator decorator : settings.decorators()) {
|
||||
load += decorator.chance() * Math.min(1, decorator.stackMax()) * COLUMNS_PER_CHUNK;
|
||||
}
|
||||
return load;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,8 @@
|
||||
* Besides those, it holds what the compiled-in built-ins and the built-ins jar must share, since each sees its own copy
|
||||
* of every other class: narrow facades only Iris's own built-ins use, interfaces Iris's worlds implement
|
||||
* ({@link art.arcane.iris.builtin.IrisSeed}, {@link art.arcane.iris.builtin.LiveWorld}), and per-world state several of them use
|
||||
* ({@link art.arcane.iris.builtin.terrain.LayerBlocks}). Keep them few: each is a promise.
|
||||
* ({@link art.arcane.iris.builtin.terrain.LayerBlocks}, {@link art.arcane.iris.builtin.terrain.BiomeLayers},
|
||||
* {@link art.arcane.iris.builtin.terrain.TerrainPalettes}). Keep them few: each is a promise.
|
||||
* <p>
|
||||
* The placement stages ({@code iris:prepare} to {@code iris:snow}) reach the object being placed through
|
||||
* {@link art.arcane.iris.builtin.placement.ObjectPlacement}, a facade Iris implements for each placement. Its types
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -19,40 +19,36 @@
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.core.modules.IrisChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecorateSettings;
|
||||
import art.arcane.iris.engine.decorator.BiomeDecorators;
|
||||
import art.arcane.iris.engine.decorator.DecoratedBiome;
|
||||
import art.arcane.iris.engine.decorator.DecorationScene;
|
||||
import art.arcane.iris.engine.decorator.IrisSeaFloorDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSeaSurfaceDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisShoreLineDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSurfaceDecorator;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineDecorator;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
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.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
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.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
/**
|
||||
* Module {@code iris:decorant}: the biomes' decorators ({@link DecorantSettings}), placed on the surface the mantle's
|
||||
* blocks left: the surface itself, the sea surface and floor, and the shore line. A dimension turns decorating off with
|
||||
* {@code decorate}. The decorators' noise is built ahead of generation, in {@link #warmUp}.
|
||||
* {@link DecorateSettings}. The decorators' noise is built ahead of generation, in {@link #warmUp}.
|
||||
*/
|
||||
public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
private static final String VERSION = "built-in";
|
||||
private static final int CHUNK_CENTRE = 7;
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
@@ -62,6 +58,7 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerSettings(DecorantSettings.class);
|
||||
registry.registerSettings(DecorateSettings.class);
|
||||
registry.registerLifecycle(this);
|
||||
}
|
||||
|
||||
@@ -77,87 +74,62 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
}
|
||||
|
||||
private static void decorate(ChunkStageContext context) {
|
||||
IrisChunk chunk = IrisChunk.current();
|
||||
decorating(context.world()).decorate(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.context());
|
||||
if (!decorates(context)) {
|
||||
return;
|
||||
}
|
||||
decorate(DecorationScene.of(context), context.settings(), context.originX(), context.originZ());
|
||||
}
|
||||
|
||||
/** The world's decorating, kept in its state store. */
|
||||
static Decorating decorating(PackWorld world) {
|
||||
return world.state(Decorating.class, Decorating::new);
|
||||
/** A dimension decorates unless it says {@code decorate: false}. */
|
||||
private static boolean decorates(ChunkStageContext context) {
|
||||
return context.settings().at(DecorateSettings.class, context.originX() + CHUNK_CENTRE, context.originZ() + CHUNK_CENTRE).stream()
|
||||
.allMatch(entry -> entry.value().decorate());
|
||||
}
|
||||
|
||||
/** What decorating keeps for one world: one decorator per kind of place. */
|
||||
static final class Decorating {
|
||||
private static final Predicate<PlatformBlockState> PREDICATE_SOLID = (s) -> s != null && !B.isAirOrFluid(s);
|
||||
/** Decorates the 16 x 16 columns of the chunk whose first block is {@code x}, {@code z}, a biome's decorators on the surface its blocks left. */
|
||||
static void decorate(DecorationScene scene, FeatureSettings settings, int x, int z) {
|
||||
Hunk<BlockState> output = scene.blocks();
|
||||
TerrainSampler terrain = scene.terrain();
|
||||
BiomeDecorators decorators = scene.decorators();
|
||||
IrisSurfaceDecorator surfaceDecorator = new IrisSurfaceDecorator(scene);
|
||||
IrisSeaSurfaceDecorator seaSurfaceDecorator = new IrisSeaSurfaceDecorator(scene);
|
||||
IrisSeaFloorDecorator seaFloorDecorator = new IrisSeaFloorDecorator(scene);
|
||||
IrisShoreLineDecorator shoreLineDecorator = new IrisShoreLineDecorator(scene);
|
||||
int fluidHeight = scene.fluidHeight();
|
||||
int worldHeight = scene.worldHeight();
|
||||
|
||||
private final Engine engine;
|
||||
private final BiomeDecorators decorators;
|
||||
private final IrisSurfaceDecorator surfaceDecorator;
|
||||
private final EngineDecorator seaSurfaceDecorator;
|
||||
private final EngineDecorator seaFloorDecorator;
|
||||
private final EngineDecorator shoreLineDecorator;
|
||||
for (int i = 0; i < output.getWidth(); i++) {
|
||||
int realX = Math.round(x + i);
|
||||
for (int j = 0; j < output.getDepth(); j++) {
|
||||
int realZ = Math.round(z + j);
|
||||
DecoratedBiome biome = BiomeDecorators.biomeOf(settings, realX, realZ, terrain.surfaceKind(realX, realZ));
|
||||
if (!decorators.hasDecorators(biome)) {
|
||||
continue;
|
||||
}
|
||||
int height = (int) Math.round(terrain.surfaceY(realX, realZ));
|
||||
|
||||
Decorating(PackWorld world) {
|
||||
this(IrisPackWorld.of(world).engine());
|
||||
}
|
||||
if (height >= 0 && height < fluidHeight && scene.isSolid(output.get(i, height, j))
|
||||
&& height + 1 < output.getHeight() && scene.isWater(output.get(i, height + 1, j))) {
|
||||
seaSurfaceDecorator.decorate(i, j,
|
||||
realX, Math.round(i + 1), Math.round(x + i - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
biome, fluidHeight, worldHeight);
|
||||
seaFloorDecorator.decorate(i, j,
|
||||
realX, realZ, biome, height + 1,
|
||||
fluidHeight + 1);
|
||||
}
|
||||
|
||||
Decorating(Engine engine) {
|
||||
this.engine = engine;
|
||||
decorators = BiomeDecorators.of(engine);
|
||||
surfaceDecorator = new IrisSurfaceDecorator(engine);
|
||||
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(engine);
|
||||
shoreLineDecorator = new IrisShoreLineDecorator(engine);
|
||||
seaFloorDecorator = new IrisSeaFloorDecorator(engine);
|
||||
}
|
||||
if (height == fluidHeight) {
|
||||
shoreLineDecorator.decorate(i, j,
|
||||
realX, Math.round(x + i + 1), Math.round(x + i - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
biome, height, worldHeight);
|
||||
}
|
||||
|
||||
/** Decorates the 16 x 16 columns of the chunk whose first block is {@code x}, {@code z}, a biome's decorators on the surface its blocks left. */
|
||||
@BlockCoordinates
|
||||
void decorate(int x, int z, Hunk<PlatformBlockState> output, ChunkContext context) {
|
||||
if (!engine.getDimension().isDecorate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
|
||||
for (int i = 0; i < output.getWidth(); i++) {
|
||||
int height;
|
||||
int realX = Math.round(x + i);
|
||||
int realZ;
|
||||
IrisBiome biome;
|
||||
for (int j = 0; j < output.getDepth(); j++) {
|
||||
realZ = Math.round(z + j);
|
||||
height = context.getRoundedHeight(i, j);
|
||||
biome = context.getBiome().get(i, j);
|
||||
|
||||
if (!decorators.hasDecorators(biome)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (height < engine.getDimension().getFluidHeight() && PREDICATE_SOLID.test(output.get(i, height, j))
|
||||
&& height + 1 < output.getHeight() && B.isWater(output.get(i, height + 1, j))) {
|
||||
seaSurfaceDecorator.decorate(i, j,
|
||||
realX, Math.round(i + 1), Math.round(x + i - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
output, biome, engine.getDimension().getFluidHeight(), engine.getHeight());
|
||||
seaFloorDecorator.decorate(i, j,
|
||||
realX, realZ, output, biome, height + 1,
|
||||
engine.getDimension().getFluidHeight() + 1);
|
||||
}
|
||||
|
||||
if (height == engine.getDimension().getFluidHeight()) {
|
||||
shoreLineDecorator.decorate(i, j,
|
||||
realX, Math.round(x + i + 1), Math.round(x + i - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
output, biome, height, engine.getHeight());
|
||||
}
|
||||
|
||||
if (height >= 0 && height < output.getHeight()) {
|
||||
surfaceDecorator.decorate(i, j, realX, realZ, output, biome, height, engine.getHeight() - height);
|
||||
}
|
||||
if (height >= 0 && height < output.getHeight()) {
|
||||
surfaceDecorator.decorate(i, j, realX, realZ, biome, height, worldHeight - height);
|
||||
}
|
||||
}
|
||||
|
||||
engine.getMetrics().getDecoration().put(p.getMilliseconds());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,321 @@
|
||||
/*
|
||||
* 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, chunk.upperExplosion(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;
|
||||
private PaletteExplosion upperExplosion;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
/** What the upper dimension declares about exploded palettes: a setting of the dimension, so the same for every column of the chunk. */
|
||||
PaletteExplosion upperExplosion(FeatureSettings upperSettings, int worldX, int worldZ) {
|
||||
if (upperExplosion == null) {
|
||||
upperExplosion = PaletteExplosion.of(upperSettings, worldX, worldZ);
|
||||
}
|
||||
return upperExplosion;
|
||||
}
|
||||
|
||||
/** 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;
|
||||
}
|
||||
}
|
||||
@@ -15,16 +15,17 @@
|
||||
* 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.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.builtin.decorant.Decorator;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -35,41 +36,30 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* What the decorant module keeps for one world: the decorators of its biomes made ready ({@link ResolvedDecorator}),
|
||||
* sorted into the places they decorate, and how loaded the busiest biome is. Built from the biomes' {@link DecorantSettings}
|
||||
* when first asked for, or ahead of generation by {@link #warm()}.
|
||||
* What the decorant module keeps for one world: the decorators of its biomes made ready ({@link ResolvedDecorator}), sorted into
|
||||
* the places they decorate. Built from the biomes' {@link DecorantSettings} when first asked for, or ahead of generation by
|
||||
* {@link #warm()}.
|
||||
*
|
||||
* <p>A decorator's noise seed is a function of the world's decorator seed, its biome's key and its place in the biome's
|
||||
* list, so it does not depend on which column or which warm-up reached it first.
|
||||
*/
|
||||
public final class BiomeDecorators {
|
||||
private static final ResolvedDecorator[] NO_DECORATORS = new ResolvedDecorator[0];
|
||||
private static final int COLUMNS_PER_CHUNK = 256;
|
||||
private static final String BIOME_PATH_PREFIX = "biome/";
|
||||
private static final long KEY_SEED_FACTOR = 0x9E3779B97F4A7C15L;
|
||||
private static final long INDEX_SEED_FACTOR = 0xC2B2AE3D27D4EB4FL;
|
||||
|
||||
private final Engine engine;
|
||||
private final PackWorld world;
|
||||
private final PackResources resources;
|
||||
private final ModuleLog log;
|
||||
private final long decoratorSeed;
|
||||
private final Map<DecorantSettings, Map<DecorationPart, ResolvedDecorator[]>> decorators = new ConcurrentHashMap<>();
|
||||
private volatile Double busiestBiomeLoad;
|
||||
|
||||
/** @param world a world of an Iris engine */
|
||||
BiomeDecorators(PackWorld world) {
|
||||
this(IrisPackWorld.of(world).engine(), world.log());
|
||||
}
|
||||
|
||||
BiomeDecorators(Engine engine) {
|
||||
this(engine, engine.getGeneration().world().log());
|
||||
}
|
||||
|
||||
BiomeDecorators(Engine engine, ModuleLog log) {
|
||||
this.engine = engine;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/** The world {@code engine} generates now. */
|
||||
public static BiomeDecorators of(Engine engine) {
|
||||
return engine.getGeneration().state(BiomeDecorators.class, BiomeDecorators::new);
|
||||
this.world = world;
|
||||
this.resources = world.resources();
|
||||
this.log = world.log();
|
||||
this.decoratorSeed = IrisSeed.DECORATOR.of(world);
|
||||
}
|
||||
|
||||
/** The world's decorators, kept in its state store. */
|
||||
@@ -77,36 +67,51 @@ public final class BiomeDecorators {
|
||||
return world.state(BiomeDecorators.class, BiomeDecorators::new);
|
||||
}
|
||||
|
||||
/** The key of the biome a settings entry was declared by, such as {@code desert/dunes} for {@code overworld:biome/desert/dunes}. */
|
||||
public static String biomeKey(ResourceId source) {
|
||||
String path = source.path();
|
||||
return path.startsWith(BIOME_PATH_PREFIX) ? path.substring(BIOME_PATH_PREFIX.length()) : path;
|
||||
}
|
||||
|
||||
/** The biome of the entry a column's settings gave, which is the column's surface biome; null when the biome declares nothing. */
|
||||
public static DecoratedBiome biomeOf(FeatureSettings settings, int worldX, int worldZ, com.volmit.world.BiomeKind kind) {
|
||||
List<Entry<DecorantSettings>> entries = settings.at(DecorantSettings.class, worldX, worldZ);
|
||||
if (entries.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Entry<DecorantSettings> entry = entries.getLast();
|
||||
return new DecoratedBiome(biomeKey(entry.source()), entry.value(), kind);
|
||||
}
|
||||
|
||||
/** The log of the module that decorates, which the decorators write to. */
|
||||
ModuleLog log() {
|
||||
return log;
|
||||
}
|
||||
|
||||
/** Whether the biome declares any decorator. */
|
||||
public boolean hasDecorators(IrisBiome biome) {
|
||||
DecorantSettings settings = settingsOf(biome);
|
||||
return settings != null && !settings.decorators().isEmpty();
|
||||
public boolean hasDecorators(DecoratedBiome biome) {
|
||||
return biome != null && biome.settings() != null && !biome.settings().decorators().isEmpty();
|
||||
}
|
||||
|
||||
/** The biome's decorators for {@code part}, in the order the biome lists them. */
|
||||
ResolvedDecorator[] decorators(IrisBiome biome, DecorationPart part) {
|
||||
DecorantSettings settings = settingsOf(biome);
|
||||
if (settings == null) {
|
||||
ResolvedDecorator[] decorators(DecoratedBiome biome, DecorationPart part) {
|
||||
if (biome == null || biome.settings() == null) {
|
||||
return NO_DECORATORS;
|
||||
}
|
||||
return decorators.computeIfAbsent(settings, declared -> resolve(biome.getLoadKey(), declared)).getOrDefault(part, NO_DECORATORS);
|
||||
return decorators.computeIfAbsent(biome.settings(), declared -> resolve(biome.key(), declared)).getOrDefault(part, NO_DECORATORS);
|
||||
}
|
||||
|
||||
/** Whether the biome has a decorator for {@code part}. */
|
||||
public boolean hasDecorators(IrisBiome biome, DecorationPart part) {
|
||||
public boolean hasDecorators(DecoratedBiome biome, DecorationPart part) {
|
||||
return decorators(biome, part).length > 0;
|
||||
}
|
||||
|
||||
/** Resolves every decorator of every biome the dimension reaches and builds its noise, so that generation finds them ready. */
|
||||
public void warm() {
|
||||
List<IrisBiome> biomes = engine.getAllBiomes();
|
||||
biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
|
||||
for (IrisBiome biome : biomes) {
|
||||
List<Entry<DecorantSettings>> declared = new ArrayList<>(world.settings().declared(DecorantSettings.class));
|
||||
declared.sort(Comparator.comparing(entry -> biomeKey(entry.source())));
|
||||
for (Entry<DecorantSettings> entry : declared) {
|
||||
DecoratedBiome biome = new DecoratedBiome(biomeKey(entry.source()), entry.value(), null);
|
||||
for (DecorationPart part : DecorationPart.values()) {
|
||||
for (ResolvedDecorator decorator : decorators(biome, part)) {
|
||||
decorator.warm();
|
||||
@@ -115,53 +120,6 @@ public final class BiomeDecorators {
|
||||
}
|
||||
}
|
||||
|
||||
/** The most decorating any reachable biome does, as the sum of its decorators' chances times their stack heights. */
|
||||
public double busiestBiomeLoad() {
|
||||
Double cached = busiestBiomeLoad;
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
double busiest = 0D;
|
||||
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
|
||||
busiest = Math.max(busiest, load(biome));
|
||||
}
|
||||
busiestBiomeLoad = busiest;
|
||||
return busiest;
|
||||
}
|
||||
|
||||
/** How loaded the biome is with decorators: the sum of their chances times their stack heights, at least one block each. */
|
||||
public double load(IrisBiome biome) {
|
||||
DecorantSettings settings = settingsOf(biome);
|
||||
if (settings == null) {
|
||||
return 0D;
|
||||
}
|
||||
|
||||
double load = 0D;
|
||||
for (Decorator decorator : settings.decorators()) {
|
||||
load += Math.max(decorator.stackMax(), 1) * decorator.chance();
|
||||
}
|
||||
return load;
|
||||
}
|
||||
|
||||
/** How strongly studio's decorator load view colours the biome: the sum of its decorators' chances over a chunk's columns. */
|
||||
public double colourLoad(IrisBiome biome) {
|
||||
DecorantSettings settings = settingsOf(biome);
|
||||
if (settings == null) {
|
||||
return 0D;
|
||||
}
|
||||
|
||||
double load = 0D;
|
||||
for (Decorator decorator : settings.decorators()) {
|
||||
load += decorator.chance() * Math.min(1, decorator.stackMax()) * COLUMNS_PER_CHUNK;
|
||||
}
|
||||
return load;
|
||||
}
|
||||
|
||||
private static DecorantSettings settingsOf(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(DecorantSettings.class).orElse(null);
|
||||
}
|
||||
|
||||
private Map<DecorationPart, ResolvedDecorator[]> resolve(String biomeKey, DecorantSettings settings) {
|
||||
Map<DecorationPart, List<ResolvedDecorator>> staging = new EnumMap<>(DecorationPart.class);
|
||||
List<Decorator> declared = settings.decorators();
|
||||
@@ -170,7 +128,7 @@ public final class BiomeDecorators {
|
||||
if (decorator == null) {
|
||||
continue;
|
||||
}
|
||||
ResolvedDecorator resolved = ResolvedDecorator.of(decorator, engine, decoratorSeed(biomeKey, index), log);
|
||||
ResolvedDecorator resolved = ResolvedDecorator.of(decorator, resources, seedOf(biomeKey, index), log, biomeKey);
|
||||
staging.computeIfAbsent(decorator.partOf(), part -> new ArrayList<>()).add(resolved);
|
||||
}
|
||||
|
||||
@@ -179,7 +137,7 @@ public final class BiomeDecorators {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
private long decoratorSeed(String biomeKey, int index) {
|
||||
return engine.getSeedManager().getDecorator() + (biomeKey.hashCode() * KEY_SEED_FACTOR) + (index * INDEX_SEED_FACTOR);
|
||||
private long seedOf(String biomeKey, int index) {
|
||||
return decoratorSeed + (biomeKey.hashCode() * KEY_SEED_FACTOR) + (index * INDEX_SEED_FACTOR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import com.volmit.world.BiomeKind;
|
||||
|
||||
/**
|
||||
* A biome as the decorators see it: the key the pack names it by, which seeds its decorators' noise, the decorators it declares
|
||||
* (none when it declares no {@link DecorantSettings}) and what it was generated as.
|
||||
*/
|
||||
public record DecoratedBiome(String key, DecorantSettings settings, BiomeKind kind) {
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.mantle.MantleLayer;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Everything the decorators of one chunk look at: its blocks, the blocks the mantle planned around it, the terrain, the pack's
|
||||
* block rules and the biomes' decorators. A decorator places into {@link #blocks()} only. What it asks of a block is asked
|
||||
* once for each distinct block instance, since a chunk holds few.
|
||||
*/
|
||||
public final class DecorationScene {
|
||||
private final Hunk<BlockState> blocks;
|
||||
private final BlockRegistry registry;
|
||||
private final TerrainSampler terrain;
|
||||
private final MantleLayer<BlockState> planned;
|
||||
private final BiomeDecorators decorators;
|
||||
private final long seed;
|
||||
private final ModuleLog log;
|
||||
private final Map<BlockTrait, Map<BlockState, Boolean>> traits = new EnumMap<>(BlockTrait.class);
|
||||
private final Map<BlockState, Map<BlockState, Boolean>> supports = new IdentityHashMap<>();
|
||||
|
||||
/** The chunk of {@code context}, decorated with the world's decorators. */
|
||||
public static DecorationScene of(ChunkStageContext context) {
|
||||
Mantle mantle = context.mantle();
|
||||
return new DecorationScene(context.hunk(BlockState.class), context.resources().blocks(), context.terrain(),
|
||||
mantle == null ? null : mantle.blocks(), BiomeDecorators.of(context.world()), IrisSeed.COMPONENT.of(context.world()),
|
||||
context.log());
|
||||
}
|
||||
|
||||
public DecorationScene(Hunk<BlockState> blocks, BlockRegistry registry, TerrainSampler terrain, MantleLayer<BlockState> planned,
|
||||
BiomeDecorators decorators, long seed, ModuleLog log) {
|
||||
this.blocks = blocks;
|
||||
this.registry = registry;
|
||||
this.terrain = terrain;
|
||||
this.planned = planned;
|
||||
this.decorators = decorators;
|
||||
this.seed = seed;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
public Hunk<BlockState> blocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public BlockRegistry registry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
public TerrainSampler terrain() {
|
||||
return terrain;
|
||||
}
|
||||
|
||||
public BiomeDecorators decorators() {
|
||||
return decorators;
|
||||
}
|
||||
|
||||
/** The seed the decorators of every place draw from, each shifted by its own part. */
|
||||
long seed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
ModuleLog log() {
|
||||
return log;
|
||||
}
|
||||
|
||||
/** The height of the chunk's volume. */
|
||||
public int worldHeight() {
|
||||
return blocks.getHeight();
|
||||
}
|
||||
|
||||
public int fluidHeight() {
|
||||
return terrain.fluidHeight();
|
||||
}
|
||||
|
||||
/** The slope of the terrain at the column. */
|
||||
double slopeAt(int worldX, int worldZ) {
|
||||
return terrain.column(worldX, worldZ).slope();
|
||||
}
|
||||
|
||||
/** The height of the terrain at the column, rounded. */
|
||||
long roundedHeightAt(int worldX, int worldZ) {
|
||||
return Math.round(terrain.surfaceY(worldX, worldZ));
|
||||
}
|
||||
|
||||
/** The block a placement planned at the position, or air; positions the mantle does not cover read as air. */
|
||||
BlockState plannedAt(int worldX, int y, int worldZ) {
|
||||
if (planned == null || y < 0 || y >= worldHeight()) {
|
||||
return null;
|
||||
}
|
||||
return planned.get(worldX, y, worldZ);
|
||||
}
|
||||
|
||||
boolean has(BlockTrait trait, BlockState block) {
|
||||
return traits.computeIfAbsent(trait, ignored -> new IdentityHashMap<>())
|
||||
.computeIfAbsent(block, known -> registry.hasTrait(known, trait));
|
||||
}
|
||||
|
||||
public boolean isAir(BlockState block) {
|
||||
return has(BlockTrait.AIR, block);
|
||||
}
|
||||
|
||||
public boolean isFluid(BlockState block) {
|
||||
return has(BlockTrait.FLUID, block);
|
||||
}
|
||||
|
||||
public boolean isSolid(BlockState block) {
|
||||
return has(BlockTrait.SOLID, block);
|
||||
}
|
||||
|
||||
public boolean isWater(BlockState block) {
|
||||
return has(BlockTrait.WATER, block);
|
||||
}
|
||||
|
||||
/** Whether {@code decoration} may stand on {@code surface}: its kind of block on that kind of block, and the surface carries a block on its top face. */
|
||||
boolean canGoOn(BlockState decoration, BlockState surface) {
|
||||
return supports.computeIfAbsent(decoration, ignored -> new IdentityHashMap<>())
|
||||
.computeIfAbsent(surface, known -> registry.canPlaceOn(decoration, known)
|
||||
&& registry.canAttach(decoration, known, com.volmit.block.BlockFace.UP));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,35 +15,41 @@
|
||||
* 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.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.platform.bukkit.BukkitBlockState;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.ModuleLog;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockSupport;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
import com.volmit.block.BlockFace;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
final class DecoratorCore {
|
||||
|
||||
private static final long SEED_OFFSET = 29356788L;
|
||||
private static final long PART_FACTOR = 10439677L;
|
||||
private static final String WEEPING_VINES = "minecraft:weeping_vines";
|
||||
private static final String WEEPING_VINES_PLANT = "minecraft:weeping_vines_plant";
|
||||
private static final String TWISTING_VINES = "minecraft:twisting_vines";
|
||||
private static final String TWISTING_VINES_PLANT = "minecraft:twisting_vines_plant";
|
||||
private static volatile PlatformBlockState weepingVines;
|
||||
private static volatile PlatformBlockState weepingVinesPlant;
|
||||
private static volatile PlatformBlockState twistingVines;
|
||||
private static volatile PlatformBlockState twistingVinesPlant;
|
||||
private static final String HALF = "half";
|
||||
private static final ResourceId WEEPING_VINES = ResourceId.parse("minecraft:weeping_vines");
|
||||
private static final ResourceId WEEPING_VINES_PLANT = ResourceId.parse("minecraft:weeping_vines_plant");
|
||||
private static final ResourceId TWISTING_VINES = ResourceId.parse("minecraft:twisting_vines");
|
||||
private static final ResourceId TWISTING_VINES_PLANT = ResourceId.parse("minecraft:twisting_vines_plant");
|
||||
private static final ResourceId POINTED_DRIPSTONE = ResourceId.parse("minecraft:pointed_dripstone");
|
||||
private static final String[] DRIPSTONE_THICKNESS = {"tip", "frustum", "base"};
|
||||
private static final BlockState[] DRIPSTONE_UP = dripstones("up");
|
||||
private static final BlockState[] DRIPSTONE_DOWN = dripstones("down");
|
||||
private static final BlockState AIR = new BlockState("minecraft:air");
|
||||
/** The faces a vine can grow on, in the order Iris looks at them, with the neighbour each faces. */
|
||||
private static final List<Face> FACES = List.of(new Face(BlockFace.NORTH, "north", 0, 0, -1), new Face(BlockFace.EAST, "east", 1, 0, 0),
|
||||
new Face(BlockFace.SOUTH, "south", 0, 0, 1), new Face(BlockFace.WEST, "west", -1, 0, 0), new Face(BlockFace.UP, "up", 0, 1, 0),
|
||||
new Face(BlockFace.DOWN, "down", 0, -1, 0));
|
||||
private static final Map<BlockFace, BlockFace> OPPOSITES = Map.of(BlockFace.NORTH, BlockFace.SOUTH, BlockFace.SOUTH, BlockFace.NORTH,
|
||||
BlockFace.EAST, BlockFace.WEST, BlockFace.WEST, BlockFace.EAST, BlockFace.UP, BlockFace.DOWN, BlockFace.DOWN, BlockFace.UP);
|
||||
private static final int CHUNK_LAST = 15;
|
||||
|
||||
static final ThreadLocal<PlaceOpts> SCRATCH_OPTS = ThreadLocal.withInitial(PlaceOpts::new);
|
||||
|
||||
@@ -59,6 +65,9 @@ final class DecoratorCore {
|
||||
}
|
||||
}
|
||||
|
||||
private record Face(BlockFace face, String property, int dx, int dy, int dz) {
|
||||
}
|
||||
|
||||
static long partSeed(long baseSeed, int partOrdinal) {
|
||||
return baseSeed + SEED_OFFSET - (partOrdinal * PART_FACTOR);
|
||||
}
|
||||
@@ -96,77 +105,75 @@ final class DecoratorCore {
|
||||
return half.equals("upper") || half.equals("lower") ? "lower" : "bottom";
|
||||
}
|
||||
|
||||
static void placeSurfaceSingle(ResolvedDecorator decorator,
|
||||
static void placeSurfaceSingle(ResolvedDecorator decorator, DecorationScene scene,
|
||||
int x, int z, int realX, int height, int realZ,
|
||||
Hunk<PlatformBlockState> data,
|
||||
boolean underwater, boolean caveSkipFluid, EngineMantle mantle, ModuleLog log) {
|
||||
boolean underwater, boolean caveSkipFluid) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState bdx = data.get(x, height, z);
|
||||
PlatformBlockState bd = decorator.pickBlock(realX, realZ);
|
||||
BlockState bdx = data.get(x, height, z);
|
||||
BlockState bd = decorator.pickBlock(realX, realZ);
|
||||
|
||||
if (!underwater && !canGoOn(bd, bdx)
|
||||
if (!underwater && !canGoOn(scene, bd, bdx)
|
||||
&& !decorator.isForcePlace() && decorator.forceBlock() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (decorator.forceBlock() != null) {
|
||||
if (caveSkipFluid && B.isFluid(bdx)) {
|
||||
if (caveSkipFluid && scene.isFluid(bdx)) {
|
||||
return;
|
||||
}
|
||||
data.set(x, height, z, fixFacesForHunk(
|
||||
decorator.forceBlock(), data, x, z, realX, height, realZ, mantle));
|
||||
data.set(x, height, z, fixFacesForHunk(scene, decorator.forceBlock(), x, z, realX, height, realZ));
|
||||
}
|
||||
|
||||
if (!decorator.isForcePlace() && decorator.rejectsSurface(bdx)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String half = bd == null ? null : IrisProceduralBlocks.propertyValue(bd, "half");
|
||||
String half = bd == null ? null : bd.properties().get(HALF);
|
||||
if (half != null) {
|
||||
int lowerY = height + 1;
|
||||
int upperY = height + 2;
|
||||
if (!canPlaceTwoBlockPlant(data, x, z, lowerY, upperY, caveSkipFluid)) {
|
||||
if (!canPlaceTwoBlockPlant(scene, x, z, lowerY, upperY, caveSkipFluid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
PlatformBlockState upper = bd.withProperty("half", topHalfValue(half));
|
||||
PlatformBlockState lower = fixFacesForHunk(
|
||||
bd.withProperty("half", bottomHalfValue(half)),
|
||||
data, x, z, realX, lowerY, realZ, mantle);
|
||||
BlockState upper = bd.withProperty(HALF, topHalfValue(half));
|
||||
BlockState lower = fixFacesForHunk(scene,
|
||||
bd.withProperty(HALF, bottomHalfValue(half)),
|
||||
x, z, realX, lowerY, realZ);
|
||||
data.set(x, lowerY, z, lower);
|
||||
data.set(x, upperY, z, upper);
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to place a two-block plant", e);
|
||||
scene.log().error("Failed to place a two-block plant", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int targetY = height + 1;
|
||||
if (targetY < data.getHeight() && B.isAir(data.get(x, targetY, z))) {
|
||||
data.set(x, targetY, z, fixFacesForHunk(bd, data, x, z, realX, targetY, realZ, mantle));
|
||||
if (bd != null && targetY < data.getHeight() && scene.isAir(data.get(x, targetY, z))) {
|
||||
data.set(x, targetY, z, fixFacesForHunk(scene, bd, x, z, realX, targetY, realZ));
|
||||
}
|
||||
}
|
||||
|
||||
static void placeSingleAt(ResolvedDecorator decorator, int x, int z,
|
||||
int realX, int height, int realZ, Hunk<PlatformBlockState> data,
|
||||
boolean applyFixFaces, EngineMantle mantle) {
|
||||
PlatformBlockState bd = decorator.pickBlock(realX, realZ);
|
||||
static void placeSingleAt(ResolvedDecorator decorator, DecorationScene scene, int x, int z,
|
||||
int realX, int height, int realZ, boolean applyFixFaces) {
|
||||
BlockState bd = decorator.pickBlock(realX, realZ);
|
||||
if (bd == null) {
|
||||
return;
|
||||
}
|
||||
if (applyFixFaces) {
|
||||
bd = fixFacesForHunk(bd, data, x, z, realX, height, realZ, mantle);
|
||||
bd = fixFacesForHunk(scene, bd, x, z, realX, height, realZ);
|
||||
}
|
||||
data.set(x, height, z, bd);
|
||||
scene.blocks().set(x, height, z, bd);
|
||||
}
|
||||
|
||||
static void placeStackUp(ResolvedDecorator decorator, int x, int z, int realX, int realZ,
|
||||
int height, int max, Hunk<PlatformBlockState> data,
|
||||
PlaceOpts opts) {
|
||||
static void placeStackUp(ResolvedDecorator decorator, DecorationScene scene, int x, int z, int realX, int realZ,
|
||||
int height, int max, PlaceOpts opts) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
@@ -184,14 +191,14 @@ final class DecoratorCore {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState existing = data.get(x, targetY, z);
|
||||
if (!canReplaceStackTarget(existing, opts.underwater)
|
||||
|| (opts.caveSkipFluid && B.isFluid(existing))) {
|
||||
BlockState existing = data.get(x, targetY, z);
|
||||
if (!canReplaceStackTarget(scene, existing, opts.underwater)
|
||||
|| (opts.caveSkipFluid && scene.isFluid(existing))) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState block = decorator.pickTopBlock(realX, realZ);
|
||||
if (block == null || (!opts.underwater && !canGoOn(block, data.get(x, height, z)))) {
|
||||
BlockState block = decorator.pickTopBlock(realX, realZ);
|
||||
if (block == null || (!opts.underwater && !canGoOn(scene, block, data.get(x, height, z)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -200,12 +207,11 @@ final class DecoratorCore {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState bdx = data.get(x, height, z);
|
||||
BlockState bdx = data.get(x, height, z);
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
PlatformBlockState bd = threshold >= decorator.topThreshold()
|
||||
BlockState bd = threshold >= decorator.topThreshold()
|
||||
? decorator.pickTopBlock(realX, realZ)
|
||||
: decorator.pickBlock(realX, realZ);
|
||||
|
||||
@@ -213,7 +219,7 @@ final class DecoratorCore {
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 0 && !opts.underwater && !canGoOn(bd, bdx)) {
|
||||
if (i == 0 && !opts.underwater && !canGoOn(scene, bd, bdx)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -225,14 +231,14 @@ final class DecoratorCore {
|
||||
break;
|
||||
}
|
||||
|
||||
PlatformBlockState existing = data.get(x, height + 1 + i, z);
|
||||
if (!canReplaceStackTarget(existing, opts.underwater)
|
||||
|| (opts.caveSkipFluid && B.isFluid(existing))) {
|
||||
BlockState existing = data.get(x, height + 1 + i, z);
|
||||
if (!canReplaceStackTarget(scene, existing, opts.underwater)
|
||||
|| (opts.caveSkipFluid && scene.isFluid(existing))) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (IrisProceduralBlocks.materialKey(bd).equals("minecraft:pointed_dripstone")) {
|
||||
bd = dripstoneBlock(stack, i, "up");
|
||||
if (bd.material().equals(POINTED_DRIPSTONE)) {
|
||||
bd = dripstoneBlock(stack, i, DRIPSTONE_UP);
|
||||
}
|
||||
|
||||
bd = stackedVineBlock(bd, stack, i);
|
||||
@@ -240,9 +246,9 @@ final class DecoratorCore {
|
||||
}
|
||||
}
|
||||
|
||||
static void placeStackDown(ResolvedDecorator decorator, int x, int z, int realX, int realZ,
|
||||
int height, int minHeight, Hunk<PlatformBlockState> data,
|
||||
int max, PlaceOpts opts, EngineMantle mantle) {
|
||||
static void placeStackDown(ResolvedDecorator decorator, DecorationScene scene, int x, int z, int realX, int realZ,
|
||||
int height, int minHeight, int max, PlaceOpts opts) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
@@ -250,15 +256,15 @@ final class DecoratorCore {
|
||||
int stack = computeStack(decorator, realX, realZ, max);
|
||||
|
||||
if (stack == 1) {
|
||||
if (opts.caveSkipFluid && B.isFluid(data.get(x, height, z))) {
|
||||
if (opts.caveSkipFluid && scene.isFluid(data.get(x, height, z))) {
|
||||
return;
|
||||
}
|
||||
PlatformBlockState block = decorator.pickTopBlock(realX, realZ);
|
||||
BlockState block = decorator.pickTopBlock(realX, realZ);
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
block = stackedVineBlock(block, stack, 0);
|
||||
data.set(x, height, z, fixFacesForHunk(block, data, x, z, realX, height, realZ, mantle));
|
||||
data.set(x, height, z, fixFacesForHunk(scene, block, x, z, realX, height, realZ));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,7 +275,7 @@ final class DecoratorCore {
|
||||
}
|
||||
|
||||
double threshold = ((double) i) / (double) (stack - 1);
|
||||
PlatformBlockState bd = threshold >= decorator.topThreshold()
|
||||
BlockState bd = threshold >= decorator.topThreshold()
|
||||
? decorator.pickTopBlock(realX, realZ)
|
||||
: decorator.pickBlock(realX, realZ);
|
||||
|
||||
@@ -277,41 +283,42 @@ final class DecoratorCore {
|
||||
break;
|
||||
}
|
||||
|
||||
if (IrisProceduralBlocks.materialKey(bd).equals("minecraft:pointed_dripstone")) {
|
||||
bd = dripstoneBlock(stack, i, "down");
|
||||
if (bd.material().equals(POINTED_DRIPSTONE)) {
|
||||
bd = dripstoneBlock(stack, i, DRIPSTONE_DOWN);
|
||||
}
|
||||
|
||||
bd = stackedVineBlock(bd, stack, i);
|
||||
if (opts.caveSkipFluid && B.isFluid(data.get(x, h, z))) {
|
||||
if (opts.caveSkipFluid && scene.isFluid(data.get(x, h, z))) {
|
||||
break;
|
||||
}
|
||||
data.set(x, h, z, fixFacesForHunk(bd, data, x, z, realX, h, realZ, mantle));
|
||||
data.set(x, h, z, fixFacesForHunk(scene, bd, x, z, realX, h, realZ));
|
||||
}
|
||||
}
|
||||
|
||||
static void placeFloatingSimple(ResolvedDecorator decorator,
|
||||
static void placeFloatingSimple(ResolvedDecorator decorator, DecorationScene scene,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, Hunk<PlatformBlockState> data, ModuleLog log) {
|
||||
PlatformBlockState bd = decorator.pickBlock(realX, realZ);
|
||||
int height, int max) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
BlockState bd = decorator.pickBlock(realX, realZ);
|
||||
if (bd == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String half = IrisProceduralBlocks.propertyValue(bd, "half");
|
||||
String half = bd.properties().get(HALF);
|
||||
if (half != null) {
|
||||
int lowerY = height + 1;
|
||||
int upperY = height + 2;
|
||||
if (max <= 2 || !canPlaceTwoBlockPlant(data, xf, zf, lowerY, upperY, false)) {
|
||||
if (max <= 2 || !canPlaceTwoBlockPlant(scene, xf, zf, lowerY, upperY, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
PlatformBlockState upper = bd.withProperty("half", topHalfValue(half));
|
||||
PlatformBlockState lower = bd.withProperty("half", bottomHalfValue(half));
|
||||
BlockState upper = bd.withProperty(HALF, topHalfValue(half));
|
||||
BlockState lower = bd.withProperty(HALF, bottomHalfValue(half));
|
||||
data.set(xf, lowerY, zf, lower);
|
||||
data.set(xf, upperY, zf, upper);
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to place a two-block plant", e);
|
||||
scene.log().error("Failed to place a two-block plant", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -321,9 +328,10 @@ final class DecoratorCore {
|
||||
}
|
||||
}
|
||||
|
||||
static int placeFloatingStacked(ResolvedDecorator decorator,
|
||||
static int placeFloatingStacked(ResolvedDecorator decorator, DecorationScene scene,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, Hunk<PlatformBlockState> data) {
|
||||
int height, int max) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
int stack = decorator.stackHeight(realX, realZ);
|
||||
if (decorator.isScaleStack()) {
|
||||
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.absoluteMaxStack());
|
||||
@@ -338,7 +346,7 @@ final class DecoratorCore {
|
||||
break;
|
||||
}
|
||||
double threshold = stack == 1 ? 0.0 : ((double) i) / (stack - 1);
|
||||
PlatformBlockState bd = threshold >= decorator.topThreshold()
|
||||
BlockState bd = threshold >= decorator.topThreshold()
|
||||
? decorator.pickTopBlock(realX, realZ)
|
||||
: decorator.pickBlock(realX, realZ);
|
||||
if (bd == null) {
|
||||
@@ -351,94 +359,85 @@ final class DecoratorCore {
|
||||
return placed;
|
||||
}
|
||||
|
||||
static PlatformBlockState fixFacesForHunk(PlatformBlockState b, Hunk<PlatformBlockState> hunk, int rX, int rZ,
|
||||
int x, int y, int z, EngineMantle mantle) {
|
||||
if (!B.isVineBlock(b)) {
|
||||
/**
|
||||
* A vine placed at {@code x}, {@code y}, {@code z} (the chunk's local column {@code rX}, {@code rZ}) faces the neighbours that
|
||||
* can hold it: the blocks the mantle planned there, else the chunk's own blocks. A vine with no such neighbour faces down,
|
||||
* or up when it cannot face down. Any other block is returned as it is.
|
||||
*/
|
||||
static BlockState fixFacesForHunk(DecorationScene scene, BlockState b, int rX, int rZ, int x, int y, int z) {
|
||||
if (b == null || !scene.has(BlockTrait.VINE, b)) {
|
||||
return b;
|
||||
}
|
||||
DecoratorPlatformHooks.FaceFixer fixer = DecoratorPlatformHooks.faceFixer();
|
||||
if (fixer != null) {
|
||||
return fixer.fixFaces(b, hunk, rX, rZ, x, y, z, mantle);
|
||||
Hunk<BlockState> hunk = scene.blocks();
|
||||
BlockState fixed = b;
|
||||
for (Face face : FACES) {
|
||||
if (b.properties().containsKey(face.property())) {
|
||||
fixed = fixed.withProperty(face.property(), "false");
|
||||
}
|
||||
}
|
||||
BlockData rawB = (BlockData) b.nativeHandle();
|
||||
BlockData cloned = rawB.clone();
|
||||
MultipleFacing data = (MultipleFacing) cloned;
|
||||
data.getFaces().forEach(f -> data.setFace(f, false));
|
||||
|
||||
boolean found = false;
|
||||
for (BlockFace f : BlockFace.values()) {
|
||||
if (!f.isCartesian()) {
|
||||
continue;
|
||||
}
|
||||
int yy = y + f.getModY();
|
||||
for (Face face : FACES) {
|
||||
int yy = y + face.dy();
|
||||
BlockFace opposite = OPPOSITES.get(face.face());
|
||||
|
||||
PlatformBlockState rs = null;
|
||||
if (mantle != null) {
|
||||
rs = mantle.getMantle().get(x + f.getModX(), yy, z + f.getModZ(), PlatformBlockState.class);
|
||||
}
|
||||
BlockData r = rs == null ? (BlockData) EngineMantle.AIR.nativeHandle() : (BlockData) rs.nativeHandle();
|
||||
if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) {
|
||||
if (data.getAllowedFaces().contains(f)) {
|
||||
BlockState planned = scene.plannedAt(x + face.dx(), yy, z + face.dz());
|
||||
BlockState support = planned == null ? AIR : planned;
|
||||
if (scene.registry().canAttach(b, support, opposite)) {
|
||||
if (b.properties().containsKey(face.property())) {
|
||||
found = true;
|
||||
data.setFace(f, true);
|
||||
fixed = fixed.withProperty(face.property(), "true");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
int xx = rX + f.getModX();
|
||||
int zz = rZ + f.getModZ();
|
||||
if (xx < 0 || xx > 15 || zz < 0 || zz > 15 || yy < 0 || yy >= hunk.getHeight()) {
|
||||
int xx = rX + face.dx();
|
||||
int zz = rZ + face.dz();
|
||||
if (xx < 0 || xx > CHUNK_LAST || zz < 0 || zz > CHUNK_LAST || yy < 0 || yy >= hunk.getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
r = (BlockData) hunk.get(xx, yy, zz).nativeHandle();
|
||||
if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) {
|
||||
if (data.getAllowedFaces().contains(f)) {
|
||||
if (scene.registry().canAttach(b, hunk.get(xx, yy, zz), opposite)) {
|
||||
if (b.properties().containsKey(face.property())) {
|
||||
found = true;
|
||||
data.setFace(f, true);
|
||||
fixed = fixed.withProperty(face.property(), "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
BlockFace fallback = data.getAllowedFaces().contains(BlockFace.DOWN) ? BlockFace.DOWN : BlockFace.UP;
|
||||
if (data.getAllowedFaces().contains(fallback)) {
|
||||
data.setFace(fallback, true);
|
||||
String fallback = b.properties().containsKey("down") ? "down" : "up";
|
||||
if (b.properties().containsKey(fallback)) {
|
||||
fixed = fixed.withProperty(fallback, "true");
|
||||
}
|
||||
}
|
||||
return BukkitBlockState.of(cloned);
|
||||
return fixed;
|
||||
}
|
||||
|
||||
static boolean canGoOn(PlatformBlockState decorator, PlatformBlockState surface) {
|
||||
if (!B.canPlaceOnto(decorator, surface)) {
|
||||
return false;
|
||||
}
|
||||
DecoratorPlatformHooks.SurfaceSturdiness sturdiness = DecoratorPlatformHooks.surfaceSturdiness();
|
||||
if (sturdiness != null) {
|
||||
return sturdiness.canGoOn(surface);
|
||||
}
|
||||
return ((BlockData) surface.nativeHandle()).isFaceSturdy(BlockFace.UP, BlockSupport.FULL);
|
||||
static boolean canGoOn(DecorationScene scene, BlockState decorator, BlockState surface) {
|
||||
return decorator != null && surface != null && scene.canGoOn(decorator, surface);
|
||||
}
|
||||
|
||||
static boolean isValidShorelineSupport(ResolvedDecorator decorator, PlatformBlockState decorant, PlatformBlockState surface) {
|
||||
static boolean isValidShorelineSupport(DecorationScene scene, ResolvedDecorator decorator, BlockState decorant, BlockState surface) {
|
||||
return surface != null
|
||||
&& B.isSolid(surface)
|
||||
&& (decorator.isForcePlace() || canGoOn(decorant, surface));
|
||||
&& scene.isSolid(surface)
|
||||
&& (decorator.isForcePlace() || canGoOn(scene, decorant, surface));
|
||||
}
|
||||
|
||||
static boolean canReplaceStackTarget(PlatformBlockState state, boolean allowFluid) {
|
||||
return B.isAir(state) || allowFluid && B.isFluid(state);
|
||||
static boolean canReplaceStackTarget(DecorationScene scene, BlockState state, boolean allowFluid) {
|
||||
return scene.isAir(state) || allowFluid && scene.isFluid(state);
|
||||
}
|
||||
|
||||
private static boolean canPlaceTwoBlockPlant(Hunk<PlatformBlockState> data, int x, int z,
|
||||
private static boolean canPlaceTwoBlockPlant(DecorationScene scene, int x, int z,
|
||||
int lowerY, int upperY, boolean caveSkipFluid) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (lowerY < 0 || upperY >= data.getHeight()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PlatformBlockState lower = data.get(x, lowerY, z);
|
||||
PlatformBlockState upper = data.get(x, upperY, z);
|
||||
return B.isAir(lower) && B.isAir(upper)
|
||||
&& (!caveSkipFluid || !B.isFluid(lower) && !B.isFluid(upper));
|
||||
BlockState lower = data.get(x, lowerY, z);
|
||||
BlockState upper = data.get(x, upperY, z);
|
||||
return scene.isAir(lower) && scene.isAir(upper)
|
||||
&& (!caveSkipFluid || !scene.isFluid(lower) && !scene.isFluid(upper));
|
||||
}
|
||||
|
||||
private static int computeStack(ResolvedDecorator decorator, double realX, double realZ, int max) {
|
||||
@@ -451,19 +450,15 @@ final class DecoratorCore {
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static volatile PlatformBlockState[] dripstoneUp;
|
||||
private static volatile PlatformBlockState[] dripstoneDown;
|
||||
|
||||
private static PlatformBlockState[] buildDripstoneArr(String direction) {
|
||||
String[] order = {"tip", "frustum", "base"};
|
||||
PlatformBlockState[] arr = new PlatformBlockState[3];
|
||||
for (int k = 0; k < 3; k++) {
|
||||
arr[k] = B.getState("minecraft:pointed_dripstone[thickness=" + order[k] + ",vertical_direction=" + direction + "]");
|
||||
private static BlockState[] dripstones(String direction) {
|
||||
BlockState[] arr = new BlockState[DRIPSTONE_THICKNESS.length];
|
||||
for (int k = 0; k < arr.length; k++) {
|
||||
arr[k] = BlockState.parse("minecraft:pointed_dripstone[thickness=" + DRIPSTONE_THICKNESS[k] + ",vertical_direction=" + direction + "]");
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
private static PlatformBlockState dripstoneBlock(int stack, int i, String direction) {
|
||||
private static BlockState dripstoneBlock(int stack, int i, BlockState[] byThickness) {
|
||||
int thIdx;
|
||||
if (i == stack - 1) {
|
||||
thIdx = 0;
|
||||
@@ -472,39 +467,24 @@ final class DecoratorCore {
|
||||
} else {
|
||||
thIdx = 2;
|
||||
}
|
||||
if (direction.equals("up")) {
|
||||
if (dripstoneUp == null) {
|
||||
dripstoneUp = buildDripstoneArr("up");
|
||||
}
|
||||
return dripstoneUp[thIdx];
|
||||
}
|
||||
if (dripstoneDown == null) {
|
||||
dripstoneDown = buildDripstoneArr("down");
|
||||
}
|
||||
return dripstoneDown[thIdx];
|
||||
return byThickness[thIdx];
|
||||
}
|
||||
|
||||
static String stackedVineKey(PlatformBlockState state, int stack, int index) {
|
||||
String material = IrisProceduralBlocks.materialKey(state);
|
||||
/** The key of the vine block that fills a stack of vines at {@code index}: the tip at the end, the plant before it; null for other blocks. */
|
||||
static ResourceId stackedVineMaterial(BlockState state, int stack, int index) {
|
||||
ResourceId material = state.material();
|
||||
boolean tip = index == stack - 1;
|
||||
return switch (material) {
|
||||
case WEEPING_VINES, WEEPING_VINES_PLANT -> tip ? WEEPING_VINES : WEEPING_VINES_PLANT;
|
||||
case TWISTING_VINES, TWISTING_VINES_PLANT -> tip ? TWISTING_VINES : TWISTING_VINES_PLANT;
|
||||
default -> null;
|
||||
};
|
||||
if (material.equals(WEEPING_VINES) || material.equals(WEEPING_VINES_PLANT)) {
|
||||
return tip ? WEEPING_VINES : WEEPING_VINES_PLANT;
|
||||
}
|
||||
if (material.equals(TWISTING_VINES) || material.equals(TWISTING_VINES_PLANT)) {
|
||||
return tip ? TWISTING_VINES : TWISTING_VINES_PLANT;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static PlatformBlockState stackedVineBlock(PlatformBlockState state, int stack, int index) {
|
||||
String key = stackedVineKey(state, stack, index);
|
||||
if (key == null) {
|
||||
return state;
|
||||
}
|
||||
return switch (key) {
|
||||
case WEEPING_VINES -> weepingVines == null ? weepingVines = B.getState(key) : weepingVines;
|
||||
case WEEPING_VINES_PLANT -> weepingVinesPlant == null ? weepingVinesPlant = B.getState(key) : weepingVinesPlant;
|
||||
case TWISTING_VINES -> twistingVines == null ? twistingVines = B.getState(key) : twistingVines;
|
||||
case TWISTING_VINES_PLANT -> twistingVinesPlant == null ? twistingVinesPlant = B.getState(key) : twistingVinesPlant;
|
||||
default -> state;
|
||||
};
|
||||
private static BlockState stackedVineBlock(BlockState state, int stack, int index) {
|
||||
ResourceId material = stackedVineMaterial(state, stack, index);
|
||||
return material == null ? state : new BlockState(material.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit 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.decorator;
|
||||
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
|
||||
public final class DecoratorPlatformHooks {
|
||||
private static volatile FaceFixer FACE_FIXER = null;
|
||||
private static volatile SurfaceSturdiness SURFACE_STURDINESS = null;
|
||||
|
||||
private DecoratorPlatformHooks() {
|
||||
}
|
||||
|
||||
public interface FaceFixer {
|
||||
PlatformBlockState fixFaces(PlatformBlockState state, Hunk<PlatformBlockState> hunk, int rX, int rZ, int x, int y, int z, EngineMantle mantle);
|
||||
}
|
||||
|
||||
public interface SurfaceSturdiness {
|
||||
boolean canGoOn(PlatformBlockState surface);
|
||||
}
|
||||
|
||||
public static synchronized Bindings bind(FaceFixer faceFixer, SurfaceSturdiness surfaceSturdiness) {
|
||||
Bindings previous = new Bindings(FACE_FIXER, SURFACE_STURDINESS);
|
||||
FACE_FIXER = faceFixer;
|
||||
SURFACE_STURDINESS = surfaceSturdiness;
|
||||
return previous;
|
||||
}
|
||||
|
||||
public static synchronized void restore(Bindings bindings) {
|
||||
FACE_FIXER = bindings.faceFixer();
|
||||
SURFACE_STURDINESS = bindings.surfaceSturdiness();
|
||||
}
|
||||
|
||||
static FaceFixer faceFixer() {
|
||||
return FACE_FIXER;
|
||||
}
|
||||
|
||||
static SurfaceSturdiness surfaceSturdiness() {
|
||||
return SURFACE_STURDINESS;
|
||||
}
|
||||
|
||||
public record Bindings(FaceFixer faceFixer, SurfaceSturdiness surfaceSturdiness) {
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,28 +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.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
|
||||
/*
|
||||
* Floating island decoration path. Bypasses all canGoOn, slope, whitelist, and blacklist
|
||||
* gating from IrisSurfaceDecorator — the island top IS the biome's designated surface by
|
||||
* gating from IrisSurfaceDecorator: the island top IS the biome's designated surface by
|
||||
* construction, so those material-compatibility checks are never meaningful here.
|
||||
*/
|
||||
public class FloatingDecorator {
|
||||
|
||||
public static int decorateColumn(Engine engine, IrisBiome target, DecorationPart part,
|
||||
public static int decorateColumn(DecorationScene scene, DecoratedBiome target, DecorationPart part,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, Hunk<PlatformBlockState> data, RNG rng,
|
||||
int height, int max, RNG rng,
|
||||
Runnable candidatesNullCallback) {
|
||||
BiomeDecorators decorators = BiomeDecorators.of(engine);
|
||||
BiomeDecorators decorators = scene.decorators();
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(target, part), rng, realX, realZ, decorators.log());
|
||||
|
||||
if (decorator == null) {
|
||||
@@ -45,10 +40,10 @@ public class FloatingDecorator {
|
||||
}
|
||||
|
||||
if (!decorator.isStacking()) {
|
||||
DecoratorCore.placeFloatingSimple(decorator, xf, zf, realX, realZ, height, max, data, decorators.log());
|
||||
DecoratorCore.placeFloatingSimple(decorator, scene, xf, zf, realX, realZ, height, max);
|
||||
return max > 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
return DecoratorCore.placeFloatingStacked(decorator, xf, zf, realX, realZ, height, max, data);
|
||||
return DecoratorCore.placeFloatingStacked(decorator, scene, xf, zf, realX, realZ, height, max);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,35 +15,20 @@
|
||||
* 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.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
|
||||
public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
public IrisCeilingDecorator(Engine engine) {
|
||||
super(engine, "Ceiling", DecorationPart.CEILING);
|
||||
public IrisCeilingDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.CEILING);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
|
||||
decorate(x, z, realX, realX1, realX_1, realZ, realZ1, realZ_1, data, biome, biome.getInferredType(), height, max);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, InferredType inferredType, int height, int max) {
|
||||
boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(inferredType);
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(biome.kind());
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
|
||||
|
||||
@@ -52,19 +37,16 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
if (!decorator.isStacking()) {
|
||||
if (caveSkipFluid) {
|
||||
PlatformBlockState state = data.get(x, height, z);
|
||||
if (B.isFluid(state)) {
|
||||
return;
|
||||
}
|
||||
if (caveSkipFluid && scene.isFluid(scene.blocks().get(x, height, z))) {
|
||||
return;
|
||||
}
|
||||
DecoratorCore.placeSingleAt(decorator, x, z, realX, height, realZ, data, true, getEngine().getMantle());
|
||||
DecoratorCore.placeSingleAt(decorator, scene, x, z, realX, height, realZ, true);
|
||||
return;
|
||||
}
|
||||
|
||||
DecoratorCore.PlaceOpts opts = DecoratorCore.SCRATCH_OPTS.get();
|
||||
opts.reset();
|
||||
opts.caveSkipFluid = caveSkipFluid;
|
||||
DecoratorCore.placeStackDown(decorator, x, z, realX, realZ, height, 0, data, max, opts, getEngine().getMantle());
|
||||
DecoratorCore.placeStackDown(decorator, scene, x, z, realX, realZ, height, 0, max, opts);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,33 +15,49 @@
|
||||
* 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.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineAssignedComponent;
|
||||
import art.arcane.iris.engine.framework.EngineDecorator;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.Getter;
|
||||
|
||||
public abstract class IrisEngineDecorator extends EngineAssignedComponent implements EngineDecorator {
|
||||
@Getter
|
||||
/** A decorator of one kind of place, placing into the blocks of a {@link DecorationScene}. */
|
||||
public abstract class IrisEngineDecorator {
|
||||
private static final long COLUMN_X_FACTOR = 29356788L;
|
||||
private static final long COLUMN_Z_FACTOR = 10439677L;
|
||||
private static final int X_PART_OFFSET = 6;
|
||||
private static final int Z_PART_OFFSET = 1;
|
||||
|
||||
private final DecorationPart part;
|
||||
protected final DecorationScene scene;
|
||||
protected final BiomeDecorators decorators;
|
||||
|
||||
public IrisEngineDecorator(Engine engine, String name, DecorationPart part) {
|
||||
super(engine, name + " Decorator");
|
||||
protected IrisEngineDecorator(DecorationScene scene, DecorationPart part) {
|
||||
this.scene = scene;
|
||||
this.part = part;
|
||||
this.decorators = BiomeDecorators.of(engine);
|
||||
this.decorators = scene.decorators();
|
||||
}
|
||||
|
||||
public DecorationPart getPart() {
|
||||
return part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorates one column. {@code x} and {@code z} are the column in the chunk, {@code realX} and {@code realZ} in the world,
|
||||
* with the world columns next to it on either side; {@code height} is the Y to decorate from and {@code max} how much room
|
||||
* there is.
|
||||
*/
|
||||
public abstract void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
DecoratedBiome biome, int height, int max);
|
||||
|
||||
/** {@link #decorate} for a decorator that looks at no neighbouring column. */
|
||||
public void decorate(int x, int z, int realX, int realZ, DecoratedBiome biome, int height, int max) {
|
||||
decorate(x, z, realX, realX, realX, realZ, realZ, realZ, biome, height, max);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
protected RNG getRNG(int x, int z) {
|
||||
long seed = DecoratorCore.partSeed(getSeed(), part);
|
||||
long modX = 29356788L ^ (part.ordinal() + 6);
|
||||
long modZ = 10439677L ^ (part.ordinal() + 1);
|
||||
long seed = DecoratorCore.partSeed(scene.seed(), part);
|
||||
long modX = COLUMN_X_FACTOR ^ (part.ordinal() + X_PART_OFFSET);
|
||||
long modZ = COLUMN_Z_FACTOR ^ (part.ordinal() + Z_PART_OFFSET);
|
||||
return new RNG(x * modX + z * modZ + seed);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,26 +15,20 @@
|
||||
* 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.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
public IrisSeaFloorDecorator(Engine engine) {
|
||||
super(engine, "Sea Floor", DecorationPart.SEA_FLOOR);
|
||||
public IrisSeaFloorDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.SEA_FLOOR);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
|
||||
|
||||
@@ -42,12 +36,13 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = scene.blocks();
|
||||
if (!decorator.isStacking()) {
|
||||
if (decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ))) {
|
||||
if (decorator.slopeBlocks(() -> scene.slopeAt(realX, realZ))) {
|
||||
return;
|
||||
}
|
||||
if (height >= 0 && height < getEngine().getHeight()) {
|
||||
data.set(x, height, z, decorator.blockAt(biome, realX, height, realZ));
|
||||
if (height >= 0 && height < scene.worldHeight()) {
|
||||
place(x, height, z, decorator.blockAt(realX, height, realZ));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -60,20 +55,27 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
if (stack == 1) {
|
||||
data.set(x, height, z, decorator.topBlockAt(biome, realX, height, realZ));
|
||||
place(x, height, z, decorator.topBlockAt(realX, height, realZ));
|
||||
return;
|
||||
}
|
||||
|
||||
int engineHeight = getEngine().getHeight();
|
||||
int engineHeight = scene.worldHeight();
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
if (h > max || h > engineHeight) {
|
||||
continue;
|
||||
}
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
data.set(x, h, z, threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(biome, realX, h, realZ)
|
||||
: decorator.blockAt(biome, realX, h, realZ));
|
||||
place(x, h, z, threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(realX, h, realZ)
|
||||
: decorator.blockAt(realX, h, realZ));
|
||||
}
|
||||
}
|
||||
|
||||
/** A block the decorator has none of leaves the water as it is. */
|
||||
private void place(int x, int y, int z, BlockState block) {
|
||||
if (block != null && y < scene.worldHeight()) {
|
||||
scene.blocks().set(x, y, z, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,26 +15,20 @@
|
||||
* 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.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
public IrisSeaSurfaceDecorator(Engine engine) {
|
||||
super(engine, "Sea Surface", DecorationPart.SEA_SURFACE);
|
||||
public IrisSeaSurfaceDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.SEA_SURFACE);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
|
||||
|
||||
@@ -42,11 +36,12 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = scene.blocks();
|
||||
if (!decorator.isStacking()) {
|
||||
int targetY = height + 1;
|
||||
if (height >= 0 && targetY < getEngine().getHeight()
|
||||
&& DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
PlatformBlockState block = decorator.blockAt(biome, realX, height, realZ);
|
||||
if (height >= 0 && targetY < scene.worldHeight()
|
||||
&& DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
BlockState block = decorator.blockAt(realX, height, realZ);
|
||||
if (block != null) {
|
||||
data.set(x, targetY, z, block);
|
||||
}
|
||||
@@ -61,29 +56,29 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
|
||||
if (stack == 1) {
|
||||
int targetY = height + 1;
|
||||
if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState block = decorator.topBlockAt(biome, realX, height, realZ);
|
||||
BlockState block = decorator.topBlockAt(realX, height, realZ);
|
||||
if (block != null) {
|
||||
data.set(x, targetY, z, block);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int engineHeight = getEngine().getHeight();
|
||||
int engineHeight = scene.worldHeight();
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
int targetY = h + 1;
|
||||
if (h >= max || targetY >= engineHeight
|
||||
|| !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
|| !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
break;
|
||||
}
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
PlatformBlockState block = threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(biome, realX, h, realZ)
|
||||
: decorator.blockAt(biome, realX, h, realZ);
|
||||
BlockState block = threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(realX, h, realZ)
|
||||
: decorator.blockAt(realX, h, realZ);
|
||||
if (block == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,37 +15,29 @@
|
||||
* 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.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.iris.util.project.stream.ProceduralStream;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
public IrisShoreLineDecorator(Engine engine) {
|
||||
super(engine, "Shore Line", DecorationPart.SHORE_LINE);
|
||||
public IrisShoreLineDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.SHORE_LINE);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
|
||||
if (height != getDimension().getFluidHeight()) {
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
if (height != scene.fluidHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
double complexFluidHeight = getComplex().getFluidHeight();
|
||||
ProceduralStream<Double> heightStream = getComplex().getHeightStream();
|
||||
if (Math.round(heightStream.get(realX1, realZ)) >= complexFluidHeight
|
||||
&& Math.round(heightStream.get(realX_1, realZ)) >= complexFluidHeight
|
||||
&& Math.round(heightStream.get(realX, realZ1)) >= complexFluidHeight
|
||||
&& Math.round(heightStream.get(realX, realZ_1)) >= complexFluidHeight) {
|
||||
double complexFluidHeight = scene.fluidHeight();
|
||||
if (scene.roundedHeightAt(realX1, realZ) >= complexFluidHeight
|
||||
&& scene.roundedHeightAt(realX_1, realZ) >= complexFluidHeight
|
||||
&& scene.roundedHeightAt(realX, realZ1) >= complexFluidHeight
|
||||
&& scene.roundedHeightAt(realX, realZ_1) >= complexFluidHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,23 +48,24 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
|
||||
if (decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ))) {
|
||||
if (decorator.slopeBlocks(() -> scene.slopeAt(realX, realZ))) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState support = data.get(x, height, z);
|
||||
if (support == null || !support.isSolid()) {
|
||||
var data = scene.blocks();
|
||||
BlockState support = data.get(x, height, z);
|
||||
if (support == null || !scene.isSolid(support)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decorator.isStacking()) {
|
||||
int targetY = height + 1;
|
||||
if (targetY >= data.getHeight()
|
||||
|| !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
|| !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
return;
|
||||
}
|
||||
PlatformBlockState block = decorator.blockAt(biome, realX, height, realZ);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
|
||||
BlockState block = decorator.blockAt(realX, height, realZ);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(scene, decorator, block, support)) {
|
||||
data.set(x, targetY, z, block);
|
||||
}
|
||||
return;
|
||||
@@ -87,12 +80,12 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
|
||||
if (stack == 1) {
|
||||
int targetY = height + 1;
|
||||
if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformBlockState block = decorator.topBlockAt(biome, realX, height, realZ);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
|
||||
BlockState block = decorator.topBlockAt(realX, height, realZ);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(scene, decorator, block, support)) {
|
||||
data.set(x, targetY, z, block);
|
||||
}
|
||||
return;
|
||||
@@ -102,17 +95,17 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
int h = height + i;
|
||||
int targetY = h + 1;
|
||||
if (targetY >= data.getHeight()
|
||||
|| !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
|| !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
|
||||
break;
|
||||
}
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
PlatformBlockState block = threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(biome, realX, h, realZ)
|
||||
: decorator.blockAt(biome, realX, h, realZ);
|
||||
BlockState block = threshold >= decorator.topThreshold()
|
||||
? decorator.topBlockAt(realX, h, realZ)
|
||||
: decorator.blockAt(realX, h, realZ);
|
||||
if (block == null) {
|
||||
break;
|
||||
}
|
||||
if (i == 0 && !DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
|
||||
if (i == 0 && !DecoratorCore.isValidShorelineSupport(scene, decorator, block, support)) {
|
||||
break;
|
||||
}
|
||||
data.set(x, targetY, z, block);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,48 +15,32 @@
|
||||
* 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.decorator;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.volmit.world.BiomeKind;
|
||||
|
||||
public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
public IrisSurfaceDecorator(Engine engine) {
|
||||
super(engine, "Surface", DecorationPart.NONE);
|
||||
}
|
||||
|
||||
protected IrisSurfaceDecorator(Engine engine, String name) {
|
||||
super(engine, name, DecorationPart.NONE);
|
||||
public IrisSurfaceDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.NONE);
|
||||
}
|
||||
|
||||
protected boolean isSlopeValid(ResolvedDecorator decorator, int realX, int realZ) {
|
||||
return !decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ));
|
||||
return !decorator.slopeBlocks(() -> scene.slopeAt(realX, realZ));
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
|
||||
decorate(x, z, realX, realX1, realX_1, realZ, realZ1, realZ_1, data, biome, biome.getInferredType(), height, max);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
Hunk<PlatformBlockState> data, IrisBiome biome, InferredType inferredType, int height, int max) {
|
||||
int fluidHeight = getDimension().getFluidHeight();
|
||||
if (inferredType == InferredType.SHORE && height < fluidHeight) {
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
BiomeKind kind = biome.kind();
|
||||
int fluidHeight = scene.fluidHeight();
|
||||
if (kind == BiomeKind.SHORE && height < fluidHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean underwater = isUnderwater(inferredType, height, fluidHeight);
|
||||
boolean caveSkipFluid = skipsFluid(inferredType);
|
||||
boolean underwater = isUnderwater(kind, height, fluidHeight);
|
||||
boolean caveSkipFluid = skipsFluid(kind);
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
|
||||
|
||||
@@ -70,19 +54,18 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
opts.underwater = underwater;
|
||||
opts.fluidHeight = fluidHeight;
|
||||
opts.caveSkipFluid = caveSkipFluid;
|
||||
DecoratorCore.placeStackUp(decorator, x, z, realX, realZ, height, max, data, opts);
|
||||
DecoratorCore.placeStackUp(decorator, scene, x, z, realX, realZ, height, max, opts);
|
||||
return;
|
||||
}
|
||||
|
||||
DecoratorCore.placeSurfaceSingle(decorator, x, z, realX, height, realZ,
|
||||
data, underwater, caveSkipFluid, getEngine().getMantle(), decorators.log());
|
||||
DecoratorCore.placeSurfaceSingle(decorator, scene, x, z, realX, height, realZ, underwater, caveSkipFluid);
|
||||
}
|
||||
|
||||
static boolean isUnderwater(InferredType inferredType, int height, int fluidHeight) {
|
||||
return height < fluidHeight && inferredType != InferredType.CAVE;
|
||||
static boolean isUnderwater(BiomeKind kind, int height, int fluidHeight) {
|
||||
return height < fluidHeight && kind != BiomeKind.CAVE;
|
||||
}
|
||||
|
||||
static boolean skipsFluid(InferredType inferredType) {
|
||||
return inferredType == InferredType.CAVE;
|
||||
static boolean skipsFluid(BiomeKind kind) {
|
||||
return kind == BiomeKind.CAVE;
|
||||
}
|
||||
}
|
||||
@@ -21,22 +21,20 @@ package art.arcane.iris.engine.decorator;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.builtin.decorant.Decorator;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
/**
|
||||
* One {@link Decorator} made ready for one world: its palettes resolved to the platform's blocks, and the noise that
|
||||
* One {@link Decorator} made ready for one world: its palettes resolved to blocks, and the noise that
|
||||
* decides where it places, which block of the palette it picks and how tall it stacks, built when first asked for. What
|
||||
* the decorator describes stays in the settings; everything that needs the platform, the pack or the world seed is here.
|
||||
*
|
||||
@@ -47,17 +45,18 @@ final class ResolvedDecorator {
|
||||
private final Decorator settings;
|
||||
private final long seed;
|
||||
private final NoiseFactory noise;
|
||||
private final List<PlatformBlockState> blocks;
|
||||
private final List<PlatformBlockState> topBlocks;
|
||||
private final PlatformBlockState[] blockArray;
|
||||
private final PlatformBlockState[] topBlockArray;
|
||||
private final PlatformBlockState forceBlock;
|
||||
private final PlatformBlockState[] whitelist;
|
||||
private final PlatformBlockState[] blacklist;
|
||||
private final List<BlockState> blocks;
|
||||
private final List<BlockState> topBlocks;
|
||||
private final BlockState[] blockArray;
|
||||
private final BlockState[] topBlockArray;
|
||||
private final BlockState forceBlock;
|
||||
private final BlockState[] whitelist;
|
||||
private final BlockState[] blacklist;
|
||||
private final AtomicCache<NoiseSampler> chanceNoise = new AtomicCache<>();
|
||||
private final AtomicCache<NoiseSampler> varianceNoise = new AtomicCache<>();
|
||||
private final AtomicCache<NoiseSampler> heightNoise = new AtomicCache<>();
|
||||
private final ModuleLog log;
|
||||
private final String biomeKey;
|
||||
|
||||
/**
|
||||
* @param blocks the palette as the platform's blocks, each repeated by its weight
|
||||
@@ -66,43 +65,38 @@ final class ResolvedDecorator {
|
||||
* @param whitelist the blocks it may only be placed onto; ignored unless the decorator has a whitelist
|
||||
* @param blacklist the blocks it is never placed onto; ignored unless the decorator has a blacklist
|
||||
* @param log the log of the module that decorates
|
||||
* @param biomeKey the key of the biome that declares the decorator, which names it in the log
|
||||
*/
|
||||
ResolvedDecorator(Decorator settings, long seed, NoiseFactory noise, List<PlatformBlockState> blocks, List<PlatformBlockState> topBlocks,
|
||||
PlatformBlockState forceBlock, List<PlatformBlockState> whitelist, List<PlatformBlockState> blacklist,
|
||||
ModuleLog log) {
|
||||
ResolvedDecorator(Decorator settings, long seed, NoiseFactory noise, List<BlockState> blocks, List<BlockState> topBlocks,
|
||||
BlockState forceBlock, List<BlockState> whitelist, List<BlockState> blacklist,
|
||||
ModuleLog log, String biomeKey) {
|
||||
this.settings = settings;
|
||||
this.seed = seed;
|
||||
this.noise = noise;
|
||||
this.blocks = List.copyOf(blocks);
|
||||
this.topBlocks = List.copyOf(topBlocks);
|
||||
this.blockArray = blocks.toArray(new PlatformBlockState[0]);
|
||||
this.topBlockArray = topBlocks.toArray(new PlatformBlockState[0]);
|
||||
this.blockArray = blocks.toArray(new BlockState[0]);
|
||||
this.topBlockArray = topBlocks.toArray(new BlockState[0]);
|
||||
this.forceBlock = forceBlock;
|
||||
this.whitelist = whitelist.toArray(new PlatformBlockState[0]);
|
||||
this.blacklist = blacklist.toArray(new PlatformBlockState[0]);
|
||||
this.whitelist = whitelist.toArray(new BlockState[0]);
|
||||
this.blacklist = blacklist.toArray(new BlockState[0]);
|
||||
this.log = log;
|
||||
this.biomeKey = biomeKey;
|
||||
}
|
||||
|
||||
/** {@code settings} ready for {@code engine}: its blocks resolved through the pack, its noise seeded from {@code seed}. */
|
||||
static ResolvedDecorator of(Decorator settings, Engine engine, long seed, ModuleLog log) {
|
||||
var resources = engine.getData().getPackResources();
|
||||
/** {@code settings} ready for a world with {@code resources}: its blocks resolved through the pack, its noise seeded from {@code seed}. */
|
||||
static ResolvedDecorator of(Decorator settings, PackResources resources, long seed, ModuleLog log, String biomeKey) {
|
||||
BlockRegistry registry = resources.blocks();
|
||||
PlatformBlockState forced = settings.forceBlock().map(spec -> platformState(registry, spec)).orElse(null);
|
||||
BlockState forced = settings.forceBlock().map(registry::resolve).orElse(null);
|
||||
return new ResolvedDecorator(settings, seed, resources.noise(), weighted(registry, settings.palette()),
|
||||
weighted(registry, settings.topPalette()), forced, each(registry, settings.whitelist()), each(registry, settings.blacklist()), log);
|
||||
weighted(registry, settings.topPalette()), forced, each(registry, settings.whitelist()), each(registry, settings.blacklist()), log,
|
||||
biomeKey);
|
||||
}
|
||||
|
||||
private static PlatformBlockState platformState(BlockRegistry registry, BlockSpec spec) {
|
||||
return B.getState(registry.resolve(spec).key());
|
||||
}
|
||||
|
||||
private static List<PlatformBlockState> weighted(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
List<PlatformBlockState> weighted = new ArrayList<>();
|
||||
private static List<BlockState> weighted(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
List<BlockState> weighted = new ArrayList<>();
|
||||
for (BlockSpec spec : palette) {
|
||||
PlatformBlockState state = platformState(registry, spec);
|
||||
if (state == null) {
|
||||
continue;
|
||||
}
|
||||
BlockState state = registry.resolve(spec);
|
||||
for (int n = 0; n < spec.weight(); n++) {
|
||||
weighted.add(state);
|
||||
}
|
||||
@@ -110,8 +104,8 @@ final class ResolvedDecorator {
|
||||
return weighted;
|
||||
}
|
||||
|
||||
private static List<PlatformBlockState> each(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
return palette.stream().map(spec -> platformState(registry, spec)).toList();
|
||||
private static List<BlockState> each(BlockRegistry registry, List<BlockSpec> palette) {
|
||||
return palette.stream().map(registry::resolve).toList();
|
||||
}
|
||||
|
||||
Decorator settings() {
|
||||
@@ -148,7 +142,7 @@ final class ResolvedDecorator {
|
||||
}
|
||||
|
||||
/** The block it forces onto the surface instead of the one found there, or null. */
|
||||
PlatformBlockState forceBlock() {
|
||||
BlockState forceBlock() {
|
||||
return forceBlock;
|
||||
}
|
||||
|
||||
@@ -161,15 +155,15 @@ final class ResolvedDecorator {
|
||||
}
|
||||
|
||||
/** Whether the white and black lists keep the decorator off {@code surface}. */
|
||||
boolean rejectsSurface(PlatformBlockState surface) {
|
||||
boolean rejectsSurface(BlockState surface) {
|
||||
if (settings.hasWhitelist() && !matches(whitelist, surface)) {
|
||||
return true;
|
||||
}
|
||||
return settings.hasBlacklist() && matches(blacklist, surface);
|
||||
}
|
||||
|
||||
private static boolean matches(PlatformBlockState[] palette, PlatformBlockState surface) {
|
||||
for (PlatformBlockState state : palette) {
|
||||
private static boolean matches(BlockState[] palette, BlockState surface) {
|
||||
for (BlockState state : palette) {
|
||||
if (state.equals(surface)) {
|
||||
return true;
|
||||
}
|
||||
@@ -197,9 +191,9 @@ final class ResolvedDecorator {
|
||||
}
|
||||
|
||||
/** The block of the palette at the position, for decorations that fill a column block by block; null when the palette has no block. */
|
||||
PlatformBlockState blockAt(IrisBiome biome, double x, double y, double z) {
|
||||
BlockState blockAt(double x, double y, double z) {
|
||||
if (blocks.isEmpty()) {
|
||||
log.warnOnce("decorator-empty:" + biome.getName(), "Empty Block Data for " + biome.getName());
|
||||
log.warnOnce("decorator-empty:" + biomeKey, "Empty Block Data for " + biomeKey);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -211,9 +205,9 @@ final class ResolvedDecorator {
|
||||
}
|
||||
|
||||
/** The top palette's block at the position, or the palette's when there is no top palette; null where the chance noise declines. */
|
||||
PlatformBlockState topBlockAt(IrisBiome biome, double x, double y, double z) {
|
||||
BlockState topBlockAt(double x, double y, double z) {
|
||||
if (topBlocks.isEmpty()) {
|
||||
return blockAt(biome, x, y, z);
|
||||
return blockAt(x, y, z);
|
||||
}
|
||||
|
||||
double zoom = settings.style().zoom();
|
||||
@@ -229,19 +223,19 @@ final class ResolvedDecorator {
|
||||
}
|
||||
|
||||
/** The palette's block for the column, or null when the palette has no block. */
|
||||
PlatformBlockState pickBlock(double x, double z) {
|
||||
BlockState pickBlock(double x, double z) {
|
||||
return pick(blockArray, x, z);
|
||||
}
|
||||
|
||||
/** The top palette's block for the column; the palette's when there is no top palette. */
|
||||
PlatformBlockState pickTopBlock(double x, double z) {
|
||||
BlockState pickTopBlock(double x, double z) {
|
||||
if (topBlockArray.length == 0) {
|
||||
return pickBlock(x, z);
|
||||
}
|
||||
return pick(topBlockArray, x, z);
|
||||
}
|
||||
|
||||
private PlatformBlockState pick(PlatformBlockState[] palette, double x, double z) {
|
||||
private BlockState pick(BlockState[] palette, double x, double z) {
|
||||
if (palette.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.volmlib.util.data.VectorMap;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
/**
|
||||
* The blocks of one deposit clump, around its centre. Blocks are kept in a {@link VectorMap} of positions relative to the centre,
|
||||
* which is how Iris always held a clump, so a clump's blocks come in the same order and a chunk's deposits draw the same random
|
||||
* numbers.
|
||||
*/
|
||||
final class DepositClump {
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final int depth;
|
||||
private final Vector3i center;
|
||||
private final VectorMap<BlockState> blocks = new VectorMap<>();
|
||||
|
||||
DepositClump(int width, int height, int depth) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.depth = depth;
|
||||
this.center = new Vector3i(width / 2, height / 2, depth / 2);
|
||||
}
|
||||
|
||||
/** How many blocks wide the clump's box is, along X. */
|
||||
int width() {
|
||||
return width;
|
||||
}
|
||||
|
||||
Vector3i center() {
|
||||
return center;
|
||||
}
|
||||
|
||||
/** The clump's blocks by their position relative to its centre. */
|
||||
VectorMap<BlockState> blocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/** Puts {@code block} at {@code x}, {@code y}, {@code z} counted from the corner of the clump's box. */
|
||||
void setFromCorner(int x, int y, int z, BlockState block) {
|
||||
if (x >= width || y >= height || z >= depth) {
|
||||
throw new IllegalArgumentException(x + " " + y + " " + z + " exceeds limit of " + width + " " + height + " " + depth);
|
||||
}
|
||||
blocks.put(new IrisBlockVector(x - center.getX(), y - center.getY(), z - center.getZ()), block);
|
||||
}
|
||||
|
||||
/** Puts {@code block} on the centre, which is where a one block clump has its block. */
|
||||
void setCentre(BlockState block) {
|
||||
blocks.put(new IrisBlockVector(center.getX(), center.getY(), center.getZ()), block);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import art.arcane.iris.builtin.deposit.DepositSettings;
|
||||
import art.arcane.iris.builtin.deposit.DepositVariantSettings;
|
||||
import art.arcane.iris.builtin.deposit.OreFrequencySettings;
|
||||
import art.arcane.iris.builtin.deposit.OreSizeSettings;
|
||||
import art.arcane.iris.core.modules.IrisChunk;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
@@ -45,7 +44,6 @@ import java.util.List;
|
||||
public final class DepositModule implements IrisModule {
|
||||
private static final String VERSION = "built-in";
|
||||
private static final int CHUNK_CENTRE = 7;
|
||||
private static final int CHUNK_SHIFT = 4;
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
@@ -69,13 +67,11 @@ public final class DepositModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static void place(ChunkStageContext context, List<Entry<DepositSettings>> inChunk) {
|
||||
IrisChunk chunk = IrisChunk.current();
|
||||
List<DepositGenerator> generators = generatorsAtCentre(context.settings(), context.originX(), context.originZ());
|
||||
if (generators.isEmpty() || chunk.bypassesMantleStages()) {
|
||||
if (generators.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
chunk.state(DepositPlacer.class, DepositPlacer::new).generate(generators, chunk.blocks(),
|
||||
chunk.originX() >> CHUNK_SHIFT, chunk.originZ() >> CHUNK_SHIFT, chunk.multicore(), chunk.context());
|
||||
DepositPlacer.of(context.world()).generate(context, generators);
|
||||
}
|
||||
|
||||
/** Every level's generators at the centre column of the chunk whose first block is {@code originX}, {@code originZ}, in level order. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -15,9 +15,9 @@
|
||||
* 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.IrisSeed;
|
||||
import art.arcane.iris.builtin.deposit.DepositGenerator;
|
||||
import art.arcane.iris.builtin.deposit.DepositHeightDistribution;
|
||||
import art.arcane.iris.builtin.deposit.DepositPlacementScope;
|
||||
@@ -25,213 +25,341 @@ import art.arcane.iris.builtin.deposit.DepositVariant;
|
||||
import art.arcane.iris.builtin.deposit.DepositVariantSettings;
|
||||
import art.arcane.iris.builtin.deposit.OreFrequencySettings;
|
||||
import art.arcane.iris.builtin.deposit.OreSizeSettings;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineAssignedComponent;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.util.project.context.ChunkContext;
|
||||
import art.arcane.volmlib.util.data.HeightMap;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.iris.engine.modifier.ResolvedDeposit.BiomeIdentity;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import art.arcane.iris.util.common.parallel.BurstExecutor;
|
||||
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.mantle.MantleLayer;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.resource.ResourceKey;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.BiomeSample;
|
||||
import com.volmit.world.PackBiome;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Places deposit clumps into one chunk for {@link DepositModule}: one per engine runtime, holding the deposit
|
||||
* stream's random and each generator made ready for this engine ({@link ResolvedDeposit}: resolved blocks and clump
|
||||
* shapes). Each generator gets its own random, derived from the chunk and its position in the list.
|
||||
* Places deposit clumps into one chunk for {@link DepositModule}: one per world, holding the deposit stream's random and each
|
||||
* generator made ready for this world ({@link ResolvedDeposit}: resolved blocks and clump shapes). Each generator gets its own
|
||||
* random, derived from the chunk and its position in the list, and the generators of a chunk run one after the other.
|
||||
*/
|
||||
public class DepositPlacer extends EngineAssignedComponent {
|
||||
private final RNG rng;
|
||||
final class DepositPlacer {
|
||||
private static final double UNCHANGED_ORE_MULTIPLIER = 1D;
|
||||
private static final int CHUNK_SHIFT = 4;
|
||||
private static final int CHUNK_WIDTH = 16;
|
||||
private static final long CHUNK_X_SEED_FACTOR = 341873128712L;
|
||||
private static final long CHUNK_Z_SEED_FACTOR = 132897987541L;
|
||||
private static final int DEFAULT_SURFACE_CLEARANCE = 7;
|
||||
private static final BlockState BEDROCK = new BlockState("minecraft:bedrock");
|
||||
|
||||
private final RNG rng;
|
||||
private final BlockRegistry registry;
|
||||
private final PackResources resources;
|
||||
private final ModuleLog log;
|
||||
private final boolean tunesOres;
|
||||
private final boolean remapsOres;
|
||||
private final Map<DepositGenerator, ResolvedDeposit> resolved = new ConcurrentHashMap<>();
|
||||
private final Map<DepositVariant, ResolvedDepositVariant> variants = new ConcurrentHashMap<>();
|
||||
private final Map<ResourceId, Optional<BiomeIdentity>> biomeIdentities = new ConcurrentHashMap<>();
|
||||
|
||||
public DepositPlacer(Engine engine) {
|
||||
super(engine, "Deposit");
|
||||
rng = new RNG(getEngine().getSeedManager().getDeposit());
|
||||
DepositPlacer(PackWorld world) {
|
||||
this.rng = new RNG(IrisSeed.DEPOSIT.of(world));
|
||||
this.resources = world.resources();
|
||||
this.registry = resources.blocks();
|
||||
this.log = world.log();
|
||||
this.tunesOres = declares(world, OreFrequencySettings.class) || declares(world, OreSizeSettings.class);
|
||||
this.remapsOres = declares(world, DepositVariantSettings.class);
|
||||
}
|
||||
|
||||
/** Runs {@code generators}, in order, on the chunk at chunk coordinates {@code x}, {@code z}. */
|
||||
public void generate(List<DepositGenerator> generators, Hunk<PlatformBlockState> terrain, int x, int z, boolean multicore,
|
||||
ChunkContext context) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
generateDeposits(generators, terrain, x, z, multicore, context);
|
||||
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
|
||||
/** The world's deposit placer, kept in its state store. */
|
||||
static DepositPlacer of(PackWorld world) {
|
||||
return world.state(DepositPlacer.class, DepositPlacer::new);
|
||||
}
|
||||
|
||||
private void generateDeposits(List<DepositGenerator> generators, Hunk<PlatformBlockState> terrain, int x, int z,
|
||||
boolean multicore, ChunkContext context) {
|
||||
BurstExecutor burst = burst().burst(multicore);
|
||||
/** Whether any level of the pack declares {@code settings}; a world that declares none never asks a biome for them. */
|
||||
private static boolean declares(PackWorld world, Class<? extends com.volmit.IrisFeature> settings) {
|
||||
return !world.settings().declared(settings).isEmpty();
|
||||
}
|
||||
|
||||
long seed = x * 341873128712L + z * 132897987541L;
|
||||
/** Runs {@code generators}, in order, on the chunk of {@code context}. */
|
||||
void generate(ChunkStageContext context, List<DepositGenerator> generators) {
|
||||
Placing placing = new Placing(context);
|
||||
int chunkX = context.originX() >> CHUNK_SHIFT;
|
||||
int chunkZ = context.originZ() >> CHUNK_SHIFT;
|
||||
long seed = chunkX * CHUNK_X_SEED_FACTOR + chunkZ * CHUNK_Z_SEED_FACTOR;
|
||||
long mask = 0;
|
||||
MantleChunk chunk = getEngine().getMantle().getMantle().getChunk(x, z).use();
|
||||
try {
|
||||
for (DepositGenerator k : generators) {
|
||||
long finalSeed = seed * ++mask;
|
||||
burst.queue(() -> generate(k, chunk, terrain, rng.nextParallelRNG(finalSeed), x, z, false, context));
|
||||
}
|
||||
} finally {
|
||||
// complete() must run before release() even when queueing throws — already
|
||||
// submitted burst tasks must never write into a released chunk.
|
||||
try {
|
||||
burst.complete();
|
||||
} finally {
|
||||
chunk.release();
|
||||
}
|
||||
for (DepositGenerator generator : generators) {
|
||||
long finalSeed = seed * ++mask;
|
||||
placing.generate(generator, rng.nextParallelRNG(finalSeed));
|
||||
}
|
||||
}
|
||||
|
||||
public void generate(DepositGenerator k, MantleChunk chunk, Hunk<PlatformBlockState> data, RNG rng, int cx, int cz, boolean safe, ChunkContext context) {
|
||||
generate(k, chunk, data, rng, cx, cz, safe, null, context);
|
||||
private ResolvedDeposit resolved(DepositGenerator generator) {
|
||||
return resolved.computeIfAbsent(generator, ignored -> new ResolvedDeposit(generator, rng.getSeed(), registry));
|
||||
}
|
||||
|
||||
public void generate(DepositGenerator k, MantleChunk chunk, Hunk<PlatformBlockState> data, RNG rng, int cx, int cz, boolean safe, HeightMap he, ChunkContext context) {
|
||||
ResolvedDeposit deposit = resolved(k);
|
||||
if (k.spawnChance() < rng.d())
|
||||
return;
|
||||
private Optional<BiomeIdentity> identityOf(ResourceId biome) {
|
||||
return biomeIdentities.computeIfAbsent(biome, id -> resources.find(new ResourceKey<>(id, PackBiome.class))
|
||||
.map(found -> new BiomeIdentity(id.path(), found.platformBiome().toString(), found.vanillaBiome().toString())));
|
||||
}
|
||||
|
||||
for (int l = 0; l < rng.i(k.minPerChunk(), k.maxPerChunk() + 1); l++) {
|
||||
if (k.perClumpSpawnChance() < rng.d())
|
||||
continue;
|
||||
/** Places deposits into one chunk, with the views of its invocation. */
|
||||
private final class Placing {
|
||||
private final Hunk<BlockState> blocks;
|
||||
private final TerrainSampler terrain;
|
||||
private final FeatureSettings settings;
|
||||
private final MantleLayer<Boolean> caverns;
|
||||
private final int originX;
|
||||
private final int originZ;
|
||||
private final int worldHeight;
|
||||
private final int minWorldY;
|
||||
private final int[] surfaceHeights = new int[CHUNK_WIDTH * CHUNK_WIDTH];
|
||||
private boolean surfaceKnown;
|
||||
private final Map<BlockState, Boolean> airStates = new IdentityHashMap<>();
|
||||
private final Map<BlockState, Boolean> replaceableStates = new IdentityHashMap<>();
|
||||
private final Map<BlockState, Map<BlockState, BlockState>> suitedOres = new IdentityHashMap<>();
|
||||
|
||||
IrisObject clump = deposit.clump(rng);
|
||||
Placing(ChunkStageContext context) {
|
||||
this.blocks = context.hunk(BlockState.class);
|
||||
this.terrain = context.terrain();
|
||||
this.settings = context.settings();
|
||||
this.caverns = context.mantle().caverns();
|
||||
this.originX = context.originX();
|
||||
this.originZ = context.originZ();
|
||||
this.worldHeight = blocks.getHeight();
|
||||
this.minWorldY = terrain.minWorldY();
|
||||
}
|
||||
|
||||
int dim = clump.getW();
|
||||
int min = dim / 2;
|
||||
int max = (int) (16D - dim / 2D);
|
||||
void generate(DepositGenerator k, RNG rng) {
|
||||
ResolvedDeposit deposit = resolved(k);
|
||||
if (k.spawnChance() < rng.d())
|
||||
return;
|
||||
|
||||
if (min > max || min < 0 || max > 15) {
|
||||
min = 6;
|
||||
max = 9;
|
||||
}
|
||||
for (int l = 0; l < rng.i(k.minPerChunk(), k.maxPerChunk() + 1); l++) {
|
||||
if (k.perClumpSpawnChance() < rng.d())
|
||||
continue;
|
||||
|
||||
int x = rng.i(min, max + 1);
|
||||
int z = rng.i(min, max + 1);
|
||||
int terrainSurface = getDepositTerrainSurface(cx, cz, x, z, he, context);
|
||||
int height = k.placementScope() == DepositPlacementScope.TERRAIN
|
||||
? depositSurfaceLimit(terrainSurface, k.surfaceClearance())
|
||||
: getEngine().getHeight() - 1;
|
||||
DepositClump clump = deposit.clump(rng);
|
||||
|
||||
if (height < 0) {
|
||||
continue;
|
||||
}
|
||||
int dim = clump.width();
|
||||
int min = dim / 2;
|
||||
int max = (int) (16D - dim / 2D);
|
||||
|
||||
int y = sampleHeight(
|
||||
k.heightDistribution(), rng, k.minHeight(), k.maxHeight(),
|
||||
Math.min(height, getEngine().getHeight() - 1));
|
||||
if (y == Integer.MIN_VALUE) {
|
||||
continue;
|
||||
}
|
||||
if (min > max || min < 0 || max > 15) {
|
||||
min = 6;
|
||||
max = 9;
|
||||
}
|
||||
|
||||
boolean clippedHeight = k.heightDistribution() == DepositHeightDistribution.CLIPPED_UNIFORM;
|
||||
if (clippedHeight && y > height - 2)
|
||||
continue;
|
||||
int x = rng.i(min, max + 1);
|
||||
int z = rng.i(min, max + 1);
|
||||
int terrainSurface = terrainSurface(x, z);
|
||||
int height = k.placementScope() == DepositPlacementScope.TERRAIN
|
||||
? depositSurfaceLimit(terrainSurface, k.surfaceClearance())
|
||||
: worldHeight - 1;
|
||||
|
||||
int biomeY = Math.max(0, Math.min(getEngine().getHeight() - 1, y));
|
||||
boolean oreDeposit = deposit.isOre();
|
||||
IrisBiome surfaceBiome = context.getBiome().get(x, z);
|
||||
IrisBiome depositBiome = oreDeposit || k.usesCaveBiomeFilter()
|
||||
? getEngine().getCaveBiome((cx << 4) + x, biomeY, (cz << 4) + z)
|
||||
: null;
|
||||
if (!deposit.matchesBiome(surfaceBiome, depositBiome)) {
|
||||
continue;
|
||||
}
|
||||
if (height < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oreDeposit) {
|
||||
if (depositBiome != null) {
|
||||
double frequencyMultiplier = oreFrequencyMultiplier(depositBiome);
|
||||
if (frequencyMultiplier < 1D
|
||||
&& !passesOreFrequency(frequencyMultiplier, rng.d())) {
|
||||
continue;
|
||||
}
|
||||
int y = sampleHeight(
|
||||
k.heightDistribution(), rng, k.minHeight(), k.maxHeight(),
|
||||
Math.min(height, worldHeight - 1));
|
||||
if (y == Integer.MIN_VALUE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double sizeMultiplier = oreSizeMultiplier(depositBiome);
|
||||
if (sizeMultiplier != 1D) {
|
||||
IrisObject scaledClump = deposit.clump(rng, sizeMultiplier);
|
||||
int scaledDimension = scaledClump.getW();
|
||||
x = clampDepositCenter(x, scaledDimension, 16);
|
||||
if (clippedHeight) {
|
||||
y = clampDepositCenter(y, scaledDimension, getEngine().getHeight());
|
||||
boolean clippedHeight = k.heightDistribution() == DepositHeightDistribution.CLIPPED_UNIFORM;
|
||||
if (clippedHeight && y > height - 2)
|
||||
continue;
|
||||
|
||||
int biomeY = Math.max(0, Math.min(worldHeight - 1, y));
|
||||
boolean oreDeposit = deposit.isOre();
|
||||
Supplier<BiomeSample> biomes = biomesAt(x, biomeY, z);
|
||||
if (!deposit.matchesBiome(() -> identityOf(biomes.get().surfaceBiome()).orElse(null),
|
||||
() -> biomes.get().caveBiome().flatMap(id -> identityOf(id)).orElse(null))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oreDeposit && tunesOres) {
|
||||
Optional<ResourceId> caveBiome = biomes.get().caveBiome();
|
||||
if (caveBiome.isPresent()) {
|
||||
double frequencyMultiplier = oreFrequencyMultiplier(caveBiome.get());
|
||||
if (frequencyMultiplier < 1D
|
||||
&& !passesOreFrequency(frequencyMultiplier, rng.d())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double sizeMultiplier = oreSizeMultiplier(caveBiome.get());
|
||||
if (sizeMultiplier != 1D) {
|
||||
DepositClump scaledClump = deposit.clump(rng, sizeMultiplier);
|
||||
int scaledDimension = scaledClump.width();
|
||||
x = clampDepositCenter(x, scaledDimension, 16);
|
||||
if (clippedHeight) {
|
||||
y = clampDepositCenter(y, scaledDimension, worldHeight);
|
||||
}
|
||||
z = clampDepositCenter(z, scaledDimension, 16);
|
||||
clump = scaledClump;
|
||||
}
|
||||
z = clampDepositCenter(z, scaledDimension, 16);
|
||||
clump = scaledClump;
|
||||
}
|
||||
}
|
||||
|
||||
placeClump(k, deposit, clump, rng, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
IrisDimension dimension = getDimension();
|
||||
|
||||
for (art.arcane.volmlib.util.math.IrisBlockVector j : clump.getBlocks().keys()) {
|
||||
private void placeClump(DepositGenerator k, ResolvedDeposit deposit, DepositClump clump, RNG rng, int x, int y, int z) {
|
||||
for (IrisBlockVector j : clump.blocks().keys()) {
|
||||
int nx = j.getBlockX() + x;
|
||||
int ny = j.getBlockY() + y;
|
||||
int nz = j.getBlockZ() + z;
|
||||
|
||||
if (nx > 15 || nx < 0 || ny >= getEngine().getHeight() || ny < 0 || nz < 0 || nz > 15) {
|
||||
if (nx > 15 || nx < 0 || ny >= worldHeight || ny < 0 || nz < 0 || nz > 15) {
|
||||
continue;
|
||||
}
|
||||
int columnSurface = getDepositTerrainSurface(cx, cz, nx, nz, he, context);
|
||||
int columnSurface = terrainSurface(nx, nz);
|
||||
if (!placementSurfaceAllows(
|
||||
k.placementScope(), ny, columnSurface, k.surfaceClearance())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PlatformBlockState current = data.get(nx, ny, nz);
|
||||
if (!canReplaceDepositTarget(current)) {
|
||||
BlockState current = blocks.get(nx, ny, nz);
|
||||
if (!canReplaceTarget(current)) {
|
||||
continue;
|
||||
}
|
||||
if (!deposit.canReplace(current)) {
|
||||
continue;
|
||||
}
|
||||
if (!k.replaceBedrock() && IrisProceduralBlocks.materialKey(current).equals("minecraft:bedrock")) {
|
||||
if (!k.replaceBedrock() && current.material().equals(BEDROCK.material())) {
|
||||
continue;
|
||||
}
|
||||
if (shouldDiscardExposed(
|
||||
k.discardChanceOnAirExposure(), rng.d(), isAdjacentToAir(data, nx, ny, nz))) {
|
||||
k.discardChanceOnAirExposure(), rng.d(), isAdjacentToAir(blocks, nx, ny, nz, this::isAir))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (chunk.get(nx, ny, nz, MatterCavern.class) == null) {
|
||||
PlatformBlockState ore = clump.getBlocks().get(j);
|
||||
PlatformBlockState remapped = resolveDepositVariant(
|
||||
cx, cz, nx, ny, nz, ore, dimension, context);
|
||||
PlatformBlockState finalBlock = remapped != null
|
||||
if (caverns.get(originX + nx, ny, originZ + nz) == null) {
|
||||
BlockState ore = clump.blocks().get(j);
|
||||
BlockState remapped = remapped(nx, ny, nz, ore);
|
||||
BlockState finalBlock = remapped != null
|
||||
? remapped
|
||||
: B.toDeepSlateOre(current, ore);
|
||||
data.set(nx, ny, nz, finalBlock);
|
||||
: oreSuiting(current, ore);
|
||||
blocks.set(nx, ny, nz, finalBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ResolvedDeposit resolved(DepositGenerator generator) {
|
||||
return resolved.computeIfAbsent(generator, ignored -> ResolvedDeposit.of(generator, getEngine()));
|
||||
}
|
||||
/** Asks the host for the biomes of the column only if a filter or an ore tuning reads them, and only once. */
|
||||
private Supplier<BiomeSample> biomesAt(int localX, int y, int localZ) {
|
||||
BiomeSample[] sample = new BiomeSample[1];
|
||||
return () -> {
|
||||
if (sample[0] == null) {
|
||||
sample[0] = terrain.biome(originX + localX, y, originZ + localZ);
|
||||
}
|
||||
return sample[0];
|
||||
};
|
||||
}
|
||||
|
||||
private int getDepositTerrainSurface(
|
||||
int cx, int cz, int localX, int localZ, HeightMap heightMap,
|
||||
ChunkContext context) {
|
||||
return heightMap != null
|
||||
? heightMap.getHeight((cx << 4) + localX, (cz << 4) + localZ)
|
||||
: context.getRoundedHeight(localX, localZ);
|
||||
/** {@code ore}, or the variant of it that suits the rock it replaces; the platform knows the variants, so each pair is asked once. */
|
||||
private BlockState oreSuiting(BlockState rock, BlockState ore) {
|
||||
return suitedOres.computeIfAbsent(rock, known -> new IdentityHashMap<>())
|
||||
.computeIfAbsent(ore, known -> registry.oreFor(rock, known));
|
||||
}
|
||||
|
||||
private boolean isAir(BlockState state) {
|
||||
return airStates.computeIfAbsent(state, known -> registry.hasTrait(known, BlockTrait.AIR));
|
||||
}
|
||||
|
||||
private boolean canReplaceTarget(BlockState state) {
|
||||
return replaceableStates.computeIfAbsent(state, known -> canReplaceDepositTarget(registry, known));
|
||||
}
|
||||
|
||||
/** The height of the terrain at a column of the chunk, as the stages before the deposits see it. */
|
||||
private int terrainSurface(int localX, int localZ) {
|
||||
if (!surfaceKnown) {
|
||||
for (int x = 0; x < CHUNK_WIDTH; x++) {
|
||||
for (int z = 0; z < CHUNK_WIDTH; z++) {
|
||||
surfaceHeights[x * CHUNK_WIDTH + z] = (int) Math.round(terrain.surfaceY(originX + x, originZ + z));
|
||||
}
|
||||
}
|
||||
surfaceKnown = true;
|
||||
}
|
||||
return surfaceHeights[localX * CHUNK_WIDTH + localZ];
|
||||
}
|
||||
|
||||
private BlockState remapped(int localX, int localY, int localZ, BlockState ore) {
|
||||
if (!remapsOres) {
|
||||
return null;
|
||||
}
|
||||
int worldX = originX + localX;
|
||||
int worldZ = originZ + localZ;
|
||||
int worldY = absoluteWorldY(minWorldY, localY);
|
||||
|
||||
Optional<ResourceId> caveBiome = terrain.biome(worldX, localY, worldZ).caveBiome();
|
||||
if (caveBiome.isPresent()) {
|
||||
BlockState match = matchDepositVariant(settings.declaredBy(caveBiome.get(), DepositVariantSettings.class), ore, worldY);
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
BlockState match = matchDepositVariant(levelSettings(Target.REGION, worldX, worldZ), ore, worldY);
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
|
||||
return matchDepositVariant(levelSettings(Target.DIMENSION, worldX, worldZ), ore, worldY);
|
||||
}
|
||||
|
||||
private Optional<DepositVariantSettings> levelSettings(Target level, int worldX, int worldZ) {
|
||||
return settings.at(DepositVariantSettings.class, worldX, worldZ).stream()
|
||||
.filter(entry -> entry.level() == level)
|
||||
.map(Entry::value)
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
private BlockState matchDepositVariant(Optional<DepositVariantSettings> owner, BlockState ore, int y) {
|
||||
for (DepositVariant declared : owner.map(DepositVariantSettings::variants).orElse(List.of())) {
|
||||
ResolvedDepositVariant variant = variants.computeIfAbsent(declared, rule -> new ResolvedDepositVariant(rule, registry, log));
|
||||
if (!variant.appliesAt(y)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockState swapped = variant.remapOrNull(ore);
|
||||
if (swapped != null) {
|
||||
return swapped;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private double oreFrequencyMultiplier(ResourceId caveBiome) {
|
||||
return settings.declaredBy(caveBiome, OreFrequencySettings.class).map(OreFrequencySettings::multiplier).orElse(UNCHANGED_ORE_MULTIPLIER);
|
||||
}
|
||||
|
||||
private double oreSizeMultiplier(ResourceId caveBiome) {
|
||||
return settings.declaredBy(caveBiome, OreSizeSettings.class).map(OreSizeSettings::multiplier).orElse(UNCHANGED_ORE_MULTIPLIER);
|
||||
}
|
||||
}
|
||||
|
||||
static int depositSurfaceLimit(int surfaceY) {
|
||||
return depositSurfaceLimit(surfaceY, 7);
|
||||
return depositSurfaceLimit(surfaceY, DEFAULT_SURFACE_CLEARANCE);
|
||||
}
|
||||
|
||||
static int depositSurfaceLimit(int surfaceY, int surfaceClearance) {
|
||||
@@ -252,8 +380,8 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
return minHeight + localY;
|
||||
}
|
||||
|
||||
static boolean canReplaceDepositTarget(PlatformBlockState state) {
|
||||
return state != null && !state.isAir() && !state.isFluid();
|
||||
static boolean canReplaceDepositTarget(BlockRegistry registry, BlockState state) {
|
||||
return state != null && !registry.hasTrait(state, BlockTrait.AIR) && !registry.hasTrait(state, BlockTrait.FLUID);
|
||||
}
|
||||
|
||||
static int sampleHeight(
|
||||
@@ -285,23 +413,22 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
return adjacentToAir && chance > 0D && sample < Math.min(1D, chance);
|
||||
}
|
||||
|
||||
static boolean isAdjacentToAir(Hunk<PlatformBlockState> data, int x, int y, int z) {
|
||||
return isAirAt(data, x - 1, y, z)
|
||||
|| isAirAt(data, x + 1, y, z)
|
||||
|| isAirAt(data, x, y - 1, z)
|
||||
|| isAirAt(data, x, y + 1, z)
|
||||
|| isAirAt(data, x, y, z - 1)
|
||||
|| isAirAt(data, x, y, z + 1);
|
||||
static boolean isAdjacentToAir(Hunk<BlockState> data, int x, int y, int z, Predicate<BlockState> isAir) {
|
||||
return isAirAt(data, x - 1, y, z, isAir)
|
||||
|| isAirAt(data, x + 1, y, z, isAir)
|
||||
|| isAirAt(data, x, y - 1, z, isAir)
|
||||
|| isAirAt(data, x, y + 1, z, isAir)
|
||||
|| isAirAt(data, x, y, z - 1, isAir)
|
||||
|| isAirAt(data, x, y, z + 1, isAir);
|
||||
}
|
||||
|
||||
private static boolean isAirAt(Hunk<PlatformBlockState> data, int x, int y, int z) {
|
||||
private static boolean isAirAt(Hunk<BlockState> data, int x, int y, int z, Predicate<BlockState> isAir) {
|
||||
if (x < 0 || x >= data.getWidth()
|
||||
|| y < 0 || y >= data.getHeight()
|
||||
|| z < 0 || z >= data.getDepth()) {
|
||||
return false;
|
||||
}
|
||||
PlatformBlockState state = data.getRaw(x, y, z);
|
||||
return state == null || state.isAir();
|
||||
return isAir.test(data.get(x, y, z));
|
||||
}
|
||||
|
||||
static boolean passesOreFrequency(double multiplier, double sample) {
|
||||
@@ -313,63 +440,4 @@ public class DepositPlacer extends EngineAssignedComponent {
|
||||
int maximum = (int) (limit - dimension / 2D);
|
||||
return Math.max(minimum, Math.min(center, maximum));
|
||||
}
|
||||
|
||||
private PlatformBlockState resolveDepositVariant(int cx, int cz, int nx, int localY, int nz, PlatformBlockState ore, IrisDimension dimension, ChunkContext context) {
|
||||
int worldX = (cx << 4) + nx;
|
||||
int worldZ = (cz << 4) + nz;
|
||||
int worldY = absoluteWorldY(getEngine().getMinHeight(), localY);
|
||||
|
||||
IrisBiome biome = getEngine().getCaveBiome(worldX, localY, worldZ);
|
||||
if (biome != null) {
|
||||
PlatformBlockState match = matchDepositVariant(biome, ore, worldY);
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
IrisRegion region = context.getRegion().get(nx, nz);
|
||||
if (region != null) {
|
||||
PlatformBlockState match = matchDepositVariant(region, ore, worldY);
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
if (dimension != null) {
|
||||
PlatformBlockState match = matchDepositVariant(dimension, ore, worldY);
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private PlatformBlockState matchDepositVariant(IrisRegistrant owner, PlatformBlockState ore, int y) {
|
||||
for (DepositVariant declared : variantsOf(owner)) {
|
||||
ResolvedDepositVariant variant = variants.computeIfAbsent(declared, ResolvedDepositVariant::new);
|
||||
if (!variant.appliesAt(y)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PlatformBlockState swapped = variant.remapOrNull(ore);
|
||||
if (swapped != null) {
|
||||
return swapped;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<DepositVariant> variantsOf(IrisRegistrant owner) {
|
||||
return owner.getModuleSettings().find(DepositVariantSettings.class).map(DepositVariantSettings::variants).orElse(List.of());
|
||||
}
|
||||
|
||||
private static double oreFrequencyMultiplier(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(OreFrequencySettings.class).map(OreFrequencySettings::multiplier).orElse(UNCHANGED_ORE_MULTIPLIER);
|
||||
}
|
||||
|
||||
private static double oreSizeMultiplier(IrisBiome biome) {
|
||||
return biome.getModuleSettings().find(OreSizeSettings.class).map(OreSizeSettings::multiplier).orElse(UNCHANGED_ORE_MULTIPLIER);
|
||||
}
|
||||
}
|
||||
@@ -27,21 +27,23 @@ 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;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineDecorator;
|
||||
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;
|
||||
@@ -51,6 +53,7 @@ import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import java.util.IdentityHashMap;
|
||||
|
||||
import static art.arcane.iris.engine.mantle.EngineMantle.AIR;
|
||||
@@ -66,8 +69,8 @@ public class FloatingIslands {
|
||||
};
|
||||
private final Engine engine;
|
||||
private final RNG rng;
|
||||
private final EngineDecorator seaSurfaceDecorator;
|
||||
private final BiomeLayers biomeLayers;
|
||||
private final IrisLayers glue;
|
||||
private final ModuleLog log;
|
||||
|
||||
private KList<PlatformBlockState> generateBottomPaletteLayers(ResolvedFloatingChild entry, IrisDimension dimension, double wx, double wz, RNG random, int paletteDepth, IrisData data, IrisComplex complex) {
|
||||
@@ -86,7 +89,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 +110,7 @@ public class FloatingIslands {
|
||||
}
|
||||
|
||||
try {
|
||||
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.zoom(), j, (wz - j) / layer.zoom()));
|
||||
generated.add(glue.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 +120,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 +193,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 : glue.platform(biomeLayers.generateLayers(glue.biome(target), IrisLayers.explosionOf(dimension), wx, wz, layerRng, paletteDepth, paletteDepth, glue.slope()));
|
||||
if (topBlocks == null || topBlocks.isEmpty()) {
|
||||
topBlocks = biomeLayers.generateLayers(parent, dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
|
||||
topBlocks = glue.platform(biomeLayers.generateLayers(glue.biome(parent), IrisLayers.explosionOf(dimension), wx, wz, layerRng, paletteDepth, paletteDepth, glue.slope()));
|
||||
}
|
||||
KList<PlatformBlockState> bottomBlocks = generateBottomPaletteLayers(entry, dimension, wx, wz, layerRng, paletteDepth, data, complex);
|
||||
return new PaletteContext(topBlocks, bottomBlocks, B.getState("minecraft:stone"));
|
||||
@@ -212,8 +217,8 @@ public class FloatingIslands {
|
||||
this.engine = engine;
|
||||
this.log = log;
|
||||
rng = new RNG(engine.getSeedManager().getTerrain() ^ 0x7EB0A73F1DCE514DL);
|
||||
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(engine);
|
||||
biomeLayers = BiomeLayers.of(engine, log);
|
||||
biomeLayers = BiomeLayers.of(engine.getGeneration().world());
|
||||
glue = new IrisLayers(engine);
|
||||
}
|
||||
|
||||
/** Fills the islands' solids into the chunk whose first block is {@code x}, {@code z}. */
|
||||
@@ -305,7 +310,7 @@ public class FloatingIslands {
|
||||
}
|
||||
|
||||
/** Decorates the tops of the islands in the chunk whose first block is {@code x}, {@code z}. */
|
||||
public void decorateColumns(int x, int z, Hunk<PlatformBlockState> output, boolean multicore, ChunkContext context) {
|
||||
public void decorateColumns(int x, int z, Hunk<PlatformBlockState> output, boolean multicore, ChunkContext context, DecorationScene scene) {
|
||||
int chunkHeight = output.getHeight();
|
||||
IrisData data = engine.getData();
|
||||
IrisComplex complex = engine.getComplex();
|
||||
@@ -338,7 +343,7 @@ public class FloatingIslands {
|
||||
if (above == null || above.isAir()) {
|
||||
try {
|
||||
RNG colRng = rng.nextParallelRNG((int) FloatingIslandSample.columnSeed(baseSeed, wx, wz));
|
||||
FloatingDecorator.decorateColumn(engine, target, DecorationPart.NONE, xf, zf, wx, wz, topY, max, output, colRng, NOOP_DECORATION_MISS);
|
||||
FloatingDecorator.decorateColumn(scene, IrisDecoratedBiomes.of(target, BiomeKind.LAND), DecorationPart.NONE, xf, zf, wx, wz, topY, max, colRng, NOOP_DECORATION_MISS);
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to decorate the top of a floating island", e);
|
||||
}
|
||||
@@ -370,7 +375,7 @@ public class FloatingIslands {
|
||||
}
|
||||
if (fluidTopY > 0 && fluidTopY + 1 < chunkHeight && B.isAir(output.get(xf, fluidTopY + 1, zf))) {
|
||||
try {
|
||||
seaSurfaceDecorator.decorate(xf, zf, wx, wx + 1, wx - 1, wz, wz + 1, wz - 1, output, target, fluidTopY, chunkHeight);
|
||||
new IrisSeaSurfaceDecorator(scene).decorate(xf, zf, wx, wx + 1, wx - 1, wz, wz + 1, wz - 1, IrisDecoratedBiomes.of(target, BiomeKind.LAND), fluidTopY, chunkHeight);
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to decorate the sea surface of a floating island", e);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import art.arcane.iris.builtin.floating.MergeFloatingChildrenSettings;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.core.modules.IrisChunk;
|
||||
import art.arcane.iris.engine.decorator.DecorationScene;
|
||||
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
@@ -65,7 +66,8 @@ public final class FloatingModule implements IrisModule {
|
||||
.run(FloatingModule::objects);
|
||||
// Ordering only: iris:post ships in the built-ins jar, which a pack may not have.
|
||||
graph.define(IrisStages.Floating.SOLIDS).softAfter(IrisStages.Post.SMOOTH.ref()).run(FloatingModule::solids);
|
||||
graph.define(IrisStages.Floating.DECORATE).requires(IrisStages.Decorant.DECORATE).run(FloatingModule::decorate);
|
||||
// Ordering only: iris:decorant ships in the built-ins jar, which a pack may not have.
|
||||
graph.define(IrisStages.Floating.DECORATE).softAfter(IrisStages.Decorant.DECORATE.ref()).run(FloatingModule::decorate);
|
||||
}
|
||||
|
||||
private static void objects(MantleStageContext context) {
|
||||
@@ -84,7 +86,8 @@ public final class FloatingModule implements IrisModule {
|
||||
|
||||
private static void decorate(ChunkStageContext context) {
|
||||
IrisChunk chunk = IrisChunk.current();
|
||||
islands(chunk, context.log()).decorateColumns(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context());
|
||||
islands(chunk, context.log()).decorateColumns(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context(),
|
||||
DecorationScene.of(context));
|
||||
}
|
||||
|
||||
private static FloatingObjectPlacing objectPlacing(Engine engine, ModuleLog log) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.decorant.DecorantSettings;
|
||||
import art.arcane.iris.engine.decorator.DecoratedBiome;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import com.volmit.world.BiomeKind;
|
||||
|
||||
/** The decorators' view of a biome Iris's carving and floating islands hold as an {@link IrisBiome}. */
|
||||
final class IrisDecoratedBiomes {
|
||||
private IrisDecoratedBiomes() {
|
||||
}
|
||||
|
||||
static DecoratedBiome of(IrisBiome biome, BiomeKind kind) {
|
||||
return new DecoratedBiome(biome.getLoadKey(), biome.getModuleSettings().find(DecorantSettings.class).orElse(null), kind);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 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. One per engine: what a biome declares about its layers is read once for each biome.
|
||||
*/
|
||||
final class IrisLayers {
|
||||
private final Engine engine;
|
||||
private final Map<IrisBiome, LayeredBiome> biomes = Collections.synchronizedMap(new IdentityHashMap<>());
|
||||
private final Map<BlockState, PlatformBlockState> platformStates = Collections.synchronizedMap(new IdentityHashMap<>());
|
||||
private final ColumnSlope slope;
|
||||
private volatile PaletteExplosion explosion;
|
||||
|
||||
IrisLayers(Engine engine) {
|
||||
this.engine = engine;
|
||||
this.slope = (x, z) -> engine.getComplex().getSlopeStream().get(x, z);
|
||||
}
|
||||
|
||||
/** What the biome declares about its layers. */
|
||||
LayeredBiome biome(IrisBiome biome) {
|
||||
return biomes.computeIfAbsent(biome, declared -> new LayeredBiome(
|
||||
declared.getModuleSettings().find(LayersSettings.class).orElse(null),
|
||||
declared.getModuleSettings().find(SeaLayersSettings.class).orElse(null),
|
||||
declared.getModuleSettings().find(CaveCeilingLayersSettings.class).orElse(null),
|
||||
declared.getModuleSettings().find(LockLayersSettings.class).orElse(null),
|
||||
declared.getModuleSettings().find(LockLayersMaxSettings.class).orElse(null),
|
||||
declared.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));
|
||||
}
|
||||
|
||||
/** What the engine's dimension declares about separating layers with barriers. */
|
||||
PaletteExplosion explosion() {
|
||||
PaletteExplosion known = explosion;
|
||||
if (known == null) {
|
||||
known = explosionOf(engine.getDimension());
|
||||
explosion = known;
|
||||
}
|
||||
return known;
|
||||
}
|
||||
|
||||
static PaletteExplosion explosionOf(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));
|
||||
}
|
||||
|
||||
ColumnSlope slope() {
|
||||
return slope;
|
||||
}
|
||||
|
||||
/** The platform's block for {@code block}, worked out once for each block instance, since a world's layers hold few. */
|
||||
PlatformBlockState platform(BlockState block) {
|
||||
return block == null ? null : platformStates.computeIfAbsent(block, known -> B.getState(known.key()));
|
||||
}
|
||||
|
||||
KList<PlatformBlockState> platform(KList<BlockState> blocks) {
|
||||
KList<PlatformBlockState> converted = new KList<>(blocks.size());
|
||||
for (BlockState block : blocks) {
|
||||
converted.add(platform(block));
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
}
|
||||
@@ -15,35 +15,31 @@
|
||||
* 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.deposit.DepositBiomeScope;
|
||||
import art.arcane.iris.builtin.deposit.DepositGenerator;
|
||||
import art.arcane.iris.builtin.deposit.DepositShape;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.collection.KSet;
|
||||
import art.arcane.volmlib.util.math.BlockPosition;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* One {@link DepositGenerator} made ready for one engine: its palette resolved to the platform's blocks, whether it is
|
||||
* an ore deposit, the blocks it may replace, and the clump shapes it places, built once per size. What the settings
|
||||
* describe stays in the settings; everything that needs the platform, the pack or the world seed is here.
|
||||
* One {@link DepositGenerator} made ready for one world: its palette resolved to blocks, whether it is an ore deposit, the blocks
|
||||
* it may replace, and the clump shapes it places, built once per size. What the settings describe stays in the settings;
|
||||
* everything that needs the pack or the world seed is here.
|
||||
*/
|
||||
final class ResolvedDeposit {
|
||||
private static final long FNV_OFFSET_BASIS = 0xcbf29ce484222325L;
|
||||
@@ -57,27 +53,18 @@ final class ResolvedDeposit {
|
||||
|
||||
private final DepositGenerator generator;
|
||||
private final long depositSeed;
|
||||
private final List<PlatformBlockState> palette;
|
||||
private final List<BlockState> palette;
|
||||
private final boolean ore;
|
||||
private final Set<String> replaceableMaterials;
|
||||
private final Map<ClumpSizes, List<IrisObject>> clumps = new ConcurrentHashMap<>();
|
||||
private final Set<ResourceId> replaceableMaterials;
|
||||
private final Map<ClumpSizes, List<DepositClump>> clumps = new ConcurrentHashMap<>();
|
||||
|
||||
/** @param palette the generator's palette as the platform's blocks, in order */
|
||||
ResolvedDeposit(DepositGenerator generator, long depositSeed, List<PlatformBlockState> palette) {
|
||||
/** @param registry the pack's blocks, which resolve the generator's palette and the blocks it may replace */
|
||||
ResolvedDeposit(DepositGenerator generator, long depositSeed, BlockRegistry registry) {
|
||||
this.generator = generator;
|
||||
this.depositSeed = depositSeed;
|
||||
this.palette = List.copyOf(palette);
|
||||
this.ore = palette.stream().anyMatch(PlatformBlockState::isOre);
|
||||
this.replaceableMaterials = replaceableMaterials(generator.replaceableBlocks());
|
||||
}
|
||||
|
||||
/** {@code generator} ready for {@code engine}: its blocks resolved through the pack, clumps seeded from the world's deposit seed. */
|
||||
static ResolvedDeposit of(DepositGenerator generator, Engine engine) {
|
||||
BlockRegistry blocks = engine.getData().getPackResources().blocks();
|
||||
List<PlatformBlockState> palette = generator.palette().stream()
|
||||
.map(spec -> B.getState(blocks.resolve(spec).key()))
|
||||
.toList();
|
||||
return new ResolvedDeposit(generator, engine.getSeedManager().getDeposit(), palette);
|
||||
this.palette = generator.palette().stream().map(registry::resolve).toList();
|
||||
this.ore = palette.stream().anyMatch(block -> registry.hasTrait(block, BlockTrait.ORE));
|
||||
this.replaceableMaterials = replaceableMaterials(registry, generator.replaceableBlocks());
|
||||
}
|
||||
|
||||
DepositGenerator generator() {
|
||||
@@ -90,13 +77,19 @@ final class ResolvedDeposit {
|
||||
}
|
||||
|
||||
/** Whether the deposit may replace {@code state}: any block when it names none, otherwise only the named ones. */
|
||||
boolean canReplace(PlatformBlockState state) {
|
||||
return generator.replaceableBlocks().isEmpty() || replaceableMaterials.contains(IrisProceduralBlocks.materialKey(state));
|
||||
boolean canReplace(BlockState state) {
|
||||
return generator.replaceableBlocks().isEmpty() || replaceableMaterials.contains(state.material());
|
||||
}
|
||||
|
||||
/** Whether the biome the generator's scope picks passes its include and exclude filters. */
|
||||
boolean matchesBiome(IrisBiome surfaceBiome, IrisBiome caveBiome) {
|
||||
IrisBiome selected = generator.biomeScope() == DepositBiomeScope.SURFACE ? surfaceBiome : caveBiome;
|
||||
/**
|
||||
* Whether the biome the generator's scope picks passes its include and exclude filters. The biomes are asked for only when
|
||||
* the generator has a filter, and a biome that is none (a dimension without cave biomes) matches no key.
|
||||
*/
|
||||
boolean matchesBiome(Supplier<BiomeIdentity> surfaceBiome, Supplier<BiomeIdentity> caveBiome) {
|
||||
if (generator.includedBiomes().isEmpty() && generator.excludedBiomes().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
BiomeIdentity selected = (generator.biomeScope() == DepositBiomeScope.SURFACE ? surfaceBiome : caveBiome).get();
|
||||
if (!generator.includedBiomes().isEmpty() && !matchesAnyBiome(selected, generator.includedBiomes())) {
|
||||
return false;
|
||||
}
|
||||
@@ -104,12 +97,12 @@ final class ResolvedDeposit {
|
||||
}
|
||||
|
||||
/** One clump to place, picked with {@code rng}. */
|
||||
IrisObject clump(RNG rng) {
|
||||
DepositClump clump(RNG rng) {
|
||||
return clump(rng, generator.minSize(), generator.maxSize(), 0L);
|
||||
}
|
||||
|
||||
/** One clump to place with every size scaled by {@code sizeMultiplier}, as a biome's ore size tuning asks. */
|
||||
IrisObject clump(RNG rng, double sizeMultiplier) {
|
||||
DepositClump clump(RNG rng, double sizeMultiplier) {
|
||||
if (sizeMultiplier == 1D) {
|
||||
return clump(rng);
|
||||
}
|
||||
@@ -119,13 +112,13 @@ final class ResolvedDeposit {
|
||||
return clump(rng, minSize, maxSize, sizeSeed);
|
||||
}
|
||||
|
||||
private IrisObject clump(RNG rng, int minSize, int maxSize, long sizeSeed) {
|
||||
private DepositClump clump(RNG rng, int minSize, int maxSize, long sizeSeed) {
|
||||
if (generator.shape() != DepositShape.IRIS) {
|
||||
return configuredClump(rng, minSize, maxSize);
|
||||
}
|
||||
List<IrisObject> variants = clumps.computeIfAbsent(new ClumpSizes(minSize, maxSize), sizes -> {
|
||||
List<DepositClump> variants = clumps.computeIfAbsent(new ClumpSizes(minSize, maxSize), sizes -> {
|
||||
RNG variantRng = new RNG(depositSeed + stableClumpSalt() + sizeSeed);
|
||||
List<IrisObject> built = new ArrayList<>();
|
||||
List<DepositClump> built = new ArrayList<>();
|
||||
for (int i = 0; i < generator.varience(); i++) {
|
||||
built.add(irisClump(variantRng.nextParallelRNG(VARIANT_SEED_STEP * i + VARIANT_SEED_OFFSET), sizes.minSize(), sizes.maxSize()));
|
||||
}
|
||||
@@ -155,7 +148,7 @@ final class ResolvedDeposit {
|
||||
hash = mix(hash, Double.doubleToLongBits(generator.perClumpSpawnChance()));
|
||||
hash = mix(hash, Double.doubleToLongBits(generator.discardChanceOnAirExposure()));
|
||||
hash = mix(hash, palette.size());
|
||||
for (PlatformBlockState block : palette) {
|
||||
for (BlockState block : palette) {
|
||||
hash = mixString(hash, block == null ? null : block.key());
|
||||
}
|
||||
hash = mix(hash, generator.varience());
|
||||
@@ -193,7 +186,7 @@ final class ResolvedDeposit {
|
||||
return mixed;
|
||||
}
|
||||
|
||||
private IrisObject configuredClump(RNG rng, int minSize, int maxSize) {
|
||||
private DepositClump configuredClump(RNG rng, int minSize, int maxSize) {
|
||||
int size = rng.i(minSize, maxSize + 1);
|
||||
return switch (generator.shape()) {
|
||||
case VANILLA_ELLIPSOID -> vanillaEllipsoid(rng, size);
|
||||
@@ -203,9 +196,9 @@ final class ResolvedDeposit {
|
||||
}
|
||||
|
||||
/** Minecraft's ordinary ore vein: a chain of overlapping ellipsoids whose reach grows with {@code size}. */
|
||||
IrisObject vanillaEllipsoid(RNG rng, int size) {
|
||||
DepositClump vanillaEllipsoid(RNG rng, int size) {
|
||||
if (size <= 0) {
|
||||
return new IrisObject(1, 1, 1);
|
||||
return new DepositClump(1, 1, 1);
|
||||
}
|
||||
|
||||
float angle = rng.nextFloat() * (float) Math.PI;
|
||||
@@ -286,11 +279,11 @@ final class ResolvedDeposit {
|
||||
}
|
||||
}
|
||||
|
||||
return objectFromCells(cells, rng);
|
||||
return clumpFromCells(cells, rng);
|
||||
}
|
||||
|
||||
/** Minecraft's scattered ore: up to {@code size} candidate offsets, the later ones further from the centre. */
|
||||
IrisObject vanillaScattered(RNG rng, int size) {
|
||||
DepositClump vanillaScattered(RNG rng, int size) {
|
||||
KSet<BlockPosition> cells = new KSet<>();
|
||||
int candidates = rng.nextInt(Math.max(0, size) + 1);
|
||||
for (int i = 0; i < candidates; i++) {
|
||||
@@ -300,12 +293,12 @@ final class ResolvedDeposit {
|
||||
Math.round((rng.nextFloat() - rng.nextFloat()) * magnitude),
|
||||
Math.round((rng.nextFloat() - rng.nextFloat()) * magnitude)));
|
||||
}
|
||||
return objectFromCells(cells, rng);
|
||||
return clumpFromCells(cells, rng);
|
||||
}
|
||||
|
||||
private IrisObject objectFromCells(KSet<BlockPosition> cells, RNG rng) {
|
||||
private DepositClump clumpFromCells(KSet<BlockPosition> cells, RNG rng) {
|
||||
if (cells.isEmpty()) {
|
||||
return new IrisObject(1, 1, 1);
|
||||
return new DepositClump(1, 1, 1);
|
||||
}
|
||||
|
||||
int minX = Integer.MAX_VALUE;
|
||||
@@ -326,25 +319,24 @@ final class ResolvedDeposit {
|
||||
int extentX = Math.max(Math.abs(minX), Math.abs(maxX));
|
||||
int extentY = Math.max(Math.abs(minY), Math.abs(maxY));
|
||||
int extentZ = Math.max(Math.abs(minZ), Math.abs(maxZ));
|
||||
IrisObject object = new IrisObject(extentX * 2 + 1, extentY * 2 + 1, extentZ * 2 + 1);
|
||||
DepositClump clump = new DepositClump(extentX * 2 + 1, extentY * 2 + 1, extentZ * 2 + 1);
|
||||
for (BlockPosition cell : cells) {
|
||||
object.setUnsigned(cell.getX() + extentX, cell.getY() + extentY, cell.getZ() + extentZ, nextBlock(rng));
|
||||
clump.setFromCorner(cell.getX() + extentX, cell.getY() + extentY, cell.getZ() + extentZ, nextBlock(rng));
|
||||
}
|
||||
return object;
|
||||
return clump;
|
||||
}
|
||||
|
||||
/** The traditional Iris clump: a cube just large enough for the block count, filled at random cells. */
|
||||
private IrisObject irisClump(RNG rng, int minSize, int maxSize) {
|
||||
private DepositClump irisClump(RNG rng, int minSize, int maxSize) {
|
||||
int remaining = rng.i(minSize, maxSize + 1);
|
||||
if (remaining == 1) {
|
||||
IrisObject single = new IrisObject(1, 1, 1);
|
||||
Vector3i center = single.getCenter();
|
||||
single.getBlocks().put(new IrisBlockVector(center.getX(), center.getY(), center.getZ()), nextBlock(rng));
|
||||
DepositClump single = new DepositClump(1, 1, 1);
|
||||
single.setCentre(nextBlock(rng));
|
||||
return single;
|
||||
}
|
||||
|
||||
int dimension = Math.min(MAX_CLUMP_DIMENSION, (int) Math.ceil(Math.cbrt(remaining)));
|
||||
IrisObject clump = new IrisObject(dimension, dimension, dimension);
|
||||
DepositClump clump = new DepositClump(dimension, dimension, dimension);
|
||||
if (remaining >= dimension * dimension * dimension) {
|
||||
fillCube(clump, dimension, rng);
|
||||
return clump;
|
||||
@@ -357,45 +349,47 @@ final class ResolvedDeposit {
|
||||
continue;
|
||||
}
|
||||
remaining--;
|
||||
clump.setUnsigned(cell.getX(), cell.getY(), cell.getZ(), nextBlock(rng));
|
||||
clump.setFromCorner(cell.getX(), cell.getY(), cell.getZ(), nextBlock(rng));
|
||||
}
|
||||
return clump;
|
||||
}
|
||||
|
||||
private void fillCube(IrisObject clump, int dimension, RNG rng) {
|
||||
private void fillCube(DepositClump clump, int dimension, RNG rng) {
|
||||
for (int z = 0; z < dimension; z++) {
|
||||
for (int y = 0; y < dimension; y++) {
|
||||
for (int x = 0; x < dimension; x++) {
|
||||
clump.setUnsigned(x, y, z, nextBlock(rng));
|
||||
clump.setFromCorner(x, y, z, nextBlock(rng));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PlatformBlockState nextBlock(RNG rng) {
|
||||
private BlockState nextBlock(RNG rng) {
|
||||
return palette.get(rng.i(0, palette.size()));
|
||||
}
|
||||
|
||||
private static Set<String> replaceableMaterials(List<String> keys) {
|
||||
Set<String> materials = new KSet<>();
|
||||
/** The materials of the blocks the pack names that this platform knows; a block it does not know replaces nothing. */
|
||||
private static Set<ResourceId> replaceableMaterials(BlockRegistry registry, List<String> keys) {
|
||||
Set<ResourceId> materials = new HashSet<>();
|
||||
for (String key : keys) {
|
||||
PlatformBlockState state = B.getStateOrNull(key, false);
|
||||
if (state != null) {
|
||||
materials.add(IrisProceduralBlocks.materialKey(state));
|
||||
try {
|
||||
materials.add(registry.resolve(key).material());
|
||||
} catch (IllegalArgumentException unknownBlock) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return materials;
|
||||
}
|
||||
|
||||
private static boolean matchesAnyBiome(IrisBiome biome, List<String> configuredBiomes) {
|
||||
private static boolean matchesAnyBiome(BiomeIdentity biome, List<String> configuredBiomes) {
|
||||
if (biome == null) {
|
||||
return false;
|
||||
}
|
||||
for (String configured : configuredBiomes) {
|
||||
String namespaced = configured.contains(":") ? configured : MINECRAFT_NAMESPACE + configured;
|
||||
if (configured.equals(biome.getLoadKey())
|
||||
|| namespaced.equals(biome.getDerivativeKey())
|
||||
|| namespaced.equals(biome.getVanillaDerivativeKey())) {
|
||||
if (configured.equals(biome.key())
|
||||
|| namespaced.equals(biome.platformBiome())
|
||||
|| namespaced.equals(biome.vanillaBiome())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -405,4 +399,8 @@ final class ResolvedDeposit {
|
||||
/** The sizes one set of clump variants is built for: the generator's own, or scaled by a biome's ore tuning. */
|
||||
record ClumpSizes(int minSize, int maxSize) {
|
||||
}
|
||||
|
||||
/** What a deposit's biome filter compares: the pack key of a biome, the platform biome it is written as and the one vanilla sees. */
|
||||
record BiomeIdentity(String key, String platformBiome, String vanillaBiome) {
|
||||
}
|
||||
}
|
||||
@@ -15,17 +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.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.deposit.DepositVariant;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* One {@link DepositVariant} made ready: its source and replacement block ids resolved to the platform's blocks, built once on
|
||||
@@ -33,10 +34,14 @@ import java.util.Map;
|
||||
*/
|
||||
final class ResolvedDepositVariant {
|
||||
private final DepositVariant settings;
|
||||
private final AtomicCache<Map<String, PlatformBlockState>> remapped = new AtomicCache<>();
|
||||
private final BlockRegistry registry;
|
||||
private final ModuleLog log;
|
||||
private final AtomicCache<Map<ResourceId, BlockState>> remapped = new AtomicCache<>();
|
||||
|
||||
ResolvedDepositVariant(DepositVariant settings) {
|
||||
ResolvedDepositVariant(DepositVariant settings, BlockRegistry registry, ModuleLog log) {
|
||||
this.settings = settings;
|
||||
this.registry = registry;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
boolean appliesAt(int worldY) {
|
||||
@@ -44,23 +49,35 @@ final class ResolvedDepositVariant {
|
||||
}
|
||||
|
||||
/** The block {@code ore} is rewritten to, or null when the rule does not remap its material. */
|
||||
PlatformBlockState remapOrNull(PlatformBlockState ore) {
|
||||
BlockState remapOrNull(BlockState ore) {
|
||||
if (ore == null || settings.remap().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return remapped.aquire(this::resolveRemap).get(IrisProceduralBlocks.materialKey(ore));
|
||||
return remapped.aquire(this::resolveRemap).get(ore.material());
|
||||
}
|
||||
|
||||
private Map<String, PlatformBlockState> resolveRemap() {
|
||||
Map<String, PlatformBlockState> resolved = new HashMap<>();
|
||||
private Map<ResourceId, BlockState> resolveRemap() {
|
||||
Map<ResourceId, BlockState> resolved = new HashMap<>();
|
||||
for (Map.Entry<String, String> entry : settings.remap().entrySet()) {
|
||||
PlatformBlockState source = B.getStateOrNull(entry.getKey(), false);
|
||||
PlatformBlockState target = B.getStateOrNull(entry.getValue(), true);
|
||||
if (source == null || target == null) {
|
||||
Optional<BlockState> source = known(entry.getKey(), false);
|
||||
Optional<BlockState> target = known(entry.getValue(), true);
|
||||
if (source.isEmpty() || target.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
resolved.put(IrisProceduralBlocks.materialKey(source), target);
|
||||
resolved.put(source.get().material(), target.get());
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
|
||||
/** The block the platform has under {@code key}; a replacement it lacks is reported once. */
|
||||
private Optional<BlockState> known(String key, boolean reportMissing) {
|
||||
try {
|
||||
return Optional.of(registry.resolve(key));
|
||||
} catch (IllegalArgumentException unknownBlock) {
|
||||
if (reportMissing) {
|
||||
log.warnOnce("deposit-variant-block:" + key, "Deposit variant replaces ores with " + key + ", which this server does not have");
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
-6
@@ -18,8 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.world.biome;
|
||||
|
||||
import art.arcane.iris.engine.decorator.BiomeDecorators;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecoratorLoad;
|
||||
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;
|
||||
@@ -77,18 +79,32 @@ final class IrisBiomeColorRenderer {
|
||||
}
|
||||
case DECORATOR_LOAD -> {
|
||||
return biome.getCacheColorDecoratorLoad().aquire(() -> {
|
||||
BiomeDecorators decorators = BiomeDecorators.of(engine);
|
||||
return Color.getHSBColor(0.41f, (float) (decorators.colourLoad(biome) / decorators.busiestBiomeLoad()), 1f);
|
||||
double busiest = 0D;
|
||||
for (IrisBiome reachable : engine.getDimension().getReachableBiomes(engine)) {
|
||||
busiest = Math.max(busiest, DecoratorLoad.of(decorantSettingsOf(reachable)));
|
||||
}
|
||||
return Color.getHSBColor(0.41f, (float) (DecoratorLoad.colour(decorantSettingsOf(biome)) / busiest), 1f);
|
||||
});
|
||||
}
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -109,14 +109,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")
|
||||
@@ -126,8 +120,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")
|
||||
@@ -146,8 +138,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private IrisGeneratorStyle caveBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||
@Desc("Instead of filling objects with air, fills them with cobweb so you can see them")
|
||||
private boolean debugSmartBore = false;
|
||||
@Desc("Generate decorations or not")
|
||||
private boolean decorate = true;
|
||||
@Desc("Refuse to place surface objects and trees over carved surface openings.")
|
||||
private boolean requireObjectSurfaceSupport = true;
|
||||
@MinNumber(0)
|
||||
|
||||
Reference in new issue
Block a user