Merge branch 'wave2/c'

# Conflicts:
#	README.md
#	src/main/java/art/arcane/iris/engine/mantle/components/ObjectModule.java
#	src/main/java/art/arcane/iris/engine/object/decoration/IrisDecorator.java
#	src/main/java/art/arcane/iris/engine/object/world/biome/IrisBiome.java
This commit is contained in:
piexel committed 2026-10-09 22:47:28 +02:00
commit 4203c07c29
25 files changed
+1102 -565

No files matched your search

@@ -21,12 +21,14 @@ 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.engine.decorator.BiomeDecorators;
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;
@@ -34,8 +36,10 @@ 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.stage.ChunkStageContext;
import com.volmit.stage.StageGraph;
import com.volmit.world.PackWorld;
@@ -43,11 +47,11 @@ import com.volmit.world.PackWorld;
import java.util.function.Predicate;
/**
* Module {@code iris:decorant}: the biomes' decorators, 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}.
* 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}.
*/
public final class DecorantModule implements IrisModule {
public final class DecorantModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = "built-in";
@Override
@@ -55,6 +59,17 @@ public final class DecorantModule implements IrisModule {
return ModuleInfo.of("iris:decorant", "Decorators", VERSION);
}
@Override
public void register(FeatureRegistry registry) {
registry.registerSettings(DecorantSettings.class);
registry.registerLifecycle(this);
}
@Override
public void warmUp(PackWorld world) {
BiomeDecorators.of(world).warm();
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Decorant.DECORATE).requires(IrisStages.Matter.INSERT).run(DecorantModule::decorate);
@@ -75,6 +90,7 @@ public final class DecorantModule implements IrisModule {
private static final Predicate<PlatformBlockState> PREDICATE_SOLID = (s) -> s != null && !B.isAirOrFluid(s);
private final Engine engine;
private final BiomeDecorators decorators;
private final IrisSurfaceDecorator surfaceDecorator;
private final EngineDecorator seaSurfaceDecorator;
private final EngineDecorator seaFloorDecorator;
@@ -86,6 +102,7 @@ public final class DecorantModule implements IrisModule {
Decorating(Engine engine) {
this.engine = engine;
decorators = BiomeDecorators.of(engine);
surfaceDecorator = new IrisSurfaceDecorator(engine);
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(engine);
shoreLineDecorator = new IrisShoreLineDecorator(engine);
@@ -111,7 +128,7 @@ public final class DecorantModule implements IrisModule {
height = context.getRoundedHeight(i, j);
biome = context.getBiome().get(i, j);
if (biome.getDecorators().isEmpty()) {
if (!decorators.hasDecorators(biome)) {
continue;
}
@@ -0,0 +1,73 @@
/*
* 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.engine.framework.Engine;
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator;
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.volmlib.util.math.RNG;
import java.util.Comparator;
/**
* Builds the noise of every ore generator the world's biomes, regions and dimension declare before generation needs it.
* A generator keeps the noise of the first random it is given, so each one is warmed with the random of its place in
* this order: the biomes by key, the regions by key, then the dimension. The order is part of what a world generates.
*/
final class OreWarmUp {
private static final long ROOT_SEED_SALT = 7777L;
private final Engine engine;
private final RNG root;
private int warmed;
OreWarmUp(Engine engine) {
this.engine = engine;
this.root = new RNG(engine.getSeedManager().getComponent() + ROOT_SEED_SALT);
}
void warm() {
KList<IrisBiome> biomes = engine.getAllBiomes();
biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
for (IrisBiome biome : biomes) {
warmAll(biome.getOres());
}
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
regions.sort(Comparator.comparing(IrisRegion::getLoadKey));
for (IrisRegion region : regions) {
warmAll(region.getOres());
}
warmAll(engine.getDimension().getOres());
}
private void warmAll(KList<IrisOreGenerator> ores) {
if (ores == null) {
return;
}
for (IrisOreGenerator ore : ores) {
if (ore != null) {
ore.warm(root.nextParallelRNG(warmed++), engine.getData());
}
}
}
}
@@ -21,6 +21,7 @@ package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.IrisStages;
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.framework.Engine;
@@ -38,17 +39,21 @@ 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.stage.ChunkStageContext;
import com.volmit.stage.StageGraph;
import com.volmit.world.PackWorld;
/**
* 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
* biome replacing blocks on the way and the upper dimension's ground filled in from the top.
* biome replacing blocks on the way and the upper dimension's ground filled in from the top. The ore generators' noise
* is built ahead of generation, in {@link #warmUp}.
*/
public final class TerrainModule implements IrisModule {
public final class TerrainModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = "built-in";
@Override
@@ -56,6 +61,16 @@ public final class TerrainModule implements IrisModule {
return ModuleInfo.of("iris:terrain", "Terrain", VERSION);
}
@Override
public void register(FeatureRegistry registry) {
registry.registerLifecycle(this);
}
@Override
public void warmUp(PackWorld world) {
new OreWarmUp(IrisPackWorld.of(world).engine()).warm();
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Terrain.SHAPE).run(TerrainModule::shape);
@@ -0,0 +1,173 @@
/*
* 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 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.world.PackWorld;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.List;
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()}.
*
* <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 long KEY_SEED_FACTOR = 0x9E3779B97F4A7C15L;
private static final long INDEX_SEED_FACTOR = 0xC2B2AE3D27D4EB4FL;
private final Engine engine;
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());
}
BiomeDecorators(Engine engine) {
this.engine = engine;
}
/** The world {@code engine} generates now. */
public static BiomeDecorators of(Engine engine) {
return engine.getGeneration().state(BiomeDecorators.class, BiomeDecorators::new);
}
/** The world's decorators, kept in its state store. */
public static BiomeDecorators of(PackWorld world) {
return world.state(BiomeDecorators.class, BiomeDecorators::new);
}
/** Whether the biome declares any decorator. */
public boolean hasDecorators(IrisBiome biome) {
DecorantSettings settings = settingsOf(biome);
return settings != null && !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) {
return NO_DECORATORS;
}
return decorators.computeIfAbsent(settings, declared -> resolve(biome.getLoadKey(), declared)).getOrDefault(part, NO_DECORATORS);
}
/** Whether the biome has a decorator for {@code part}. */
public boolean hasDecorators(IrisBiome 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) {
for (DecorationPart part : DecorationPart.values()) {
for (ResolvedDecorator decorator : decorators(biome, part)) {
decorator.warm();
}
}
}
}
/** 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();
for (int index = 0; index < declared.size(); index++) {
Decorator decorator = declared.get(index);
if (decorator == null) {
continue;
}
ResolvedDecorator resolved = ResolvedDecorator.of(decorator, engine, decoratorSeed(biomeKey, index));
staging.computeIfAbsent(decorator.partOf(), part -> new ArrayList<>()).add(resolved);
}
Map<DecorationPart, ResolvedDecorator[]> buckets = new EnumMap<>(DecorationPart.class);
staging.forEach((part, list) -> buckets.put(part, list.toArray(NO_DECORATORS)));
return buckets;
}
private long decoratorSeed(String biomeKey, int index) {
return engine.getSeedManager().getDecorator() + (biomeKey.hashCode() * KEY_SEED_FACTOR) + (index * INDEX_SEED_FACTOR);
}
}
@@ -18,11 +18,8 @@
package art.arcane.iris.engine.decorator;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.engine.mantle.EngineMantle;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.engine.object.decoration.IrisDecorator;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.platform.bukkit.BukkitBlockState;
import art.arcane.iris.spi.IrisLogging;
@@ -66,23 +63,18 @@ final class DecoratorCore {
return baseSeed + SEED_OFFSET - (partOrdinal * PART_FACTOR);
}
static long partSeed(long baseSeed, IrisDecorationPart part) {
static long partSeed(long baseSeed, DecorationPart part) {
return partSeed(baseSeed, part.ordinal());
}
static IrisDecorator pickDecorator(IrisBiome biome, IrisDecorationPart part, RNG gRNG,
RNG colRng, IrisData data, double realX, double realZ) {
IrisDecorator[] bucket = biome.getDecoratorBucket(part);
if (bucket.length == 0) {
return null;
}
IrisDecorator picked = null;
/** The decorator of {@code bucket} that decorates the column, drawing from {@code colRng} to choose between those whose chance noise passes. */
static ResolvedDecorator pickDecorator(ResolvedDecorator[] bucket, RNG colRng, double realX, double realZ) {
ResolvedDecorator picked = null;
int count = 0;
for (IrisDecorator d : bucket) {
for (ResolvedDecorator d : bucket) {
try {
if (d.passesChanceGate(gRNG, realX, realZ, data)) {
if (d.passesChanceGate(realX, realZ)) {
count++;
if (count == 1 || colRng.nextInt(count) == 0) {
picked = d;
@@ -104,37 +96,32 @@ final class DecoratorCore {
return half.equals("upper") || half.equals("lower") ? "lower" : "bottom";
}
static void placeSurfaceSingle(IrisDecorator decorator,
static void placeSurfaceSingle(ResolvedDecorator decorator,
int x, int z, int realX, int height, int realZ,
Hunk<PlatformBlockState> data, RNG rng, IrisData irisData,
Hunk<PlatformBlockState> data,
boolean underwater, boolean caveSkipFluid, EngineMantle mantle) {
if (height < 0 || height >= data.getHeight()) {
return;
}
PlatformBlockState bdx = data.get(x, height, z);
PlatformBlockState bd = decorator.pickBlockData(rng, irisData, realX, realZ);
PlatformBlockState bd = decorator.pickBlock(realX, realZ);
if (!underwater && !canGoOn(bd, bdx)
&& !decorator.isForcePlace() && decorator.getForceBlock() == null) {
&& !decorator.isForcePlace() && decorator.forceBlock() == null) {
return;
}
if (decorator.getForceBlock() != null) {
if (decorator.forceBlock() != null) {
if (caveSkipFluid && B.isFluid(bdx)) {
return;
}
data.set(x, height, z, fixFacesForHunk(
decorator.getForceBlock().getBlockData(irisData), data, x, z, realX, height, realZ, mantle));
decorator.forceBlock(), data, x, z, realX, height, realZ, mantle));
}
if (!decorator.isForcePlace()) {
if (decorator.getWhitelist() != null && !matchesPalette(decorator.getWhitelistArray(irisData), bdx)) {
return;
}
if (decorator.getBlacklist() != null && matchesPalette(decorator.getBlacklistArray(irisData), bdx)) {
return;
}
if (!decorator.isForcePlace() && decorator.rejectsSurface(bdx)) {
return;
}
String half = bd == null ? null : IrisProceduralBlocks.propertyValue(bd, "half");
@@ -164,20 +151,10 @@ final class DecoratorCore {
}
}
private static boolean matchesPalette(PlatformBlockState[] palette, PlatformBlockState surface) {
for (int i = 0; i < palette.length; i++) {
if (palette[i].equals(surface)) {
return true;
}
}
return false;
}
static void placeSingleAt(IrisDecorator decorator, int x, int z,
static void placeSingleAt(ResolvedDecorator decorator, int x, int z,
int realX, int height, int realZ, Hunk<PlatformBlockState> data,
RNG rng, IrisData irisData, boolean applyFixFaces, EngineMantle mantle) {
PlatformBlockState bd = decorator.pickBlockData(rng, irisData, realX, realZ);
boolean applyFixFaces, EngineMantle mantle) {
PlatformBlockState bd = decorator.pickBlock(realX, realZ);
if (bd == null) {
return;
}
@@ -187,9 +164,9 @@ final class DecoratorCore {
data.set(x, height, z, bd);
}
static void placeStackUp(IrisDecorator decorator, int x, int z, int realX, int realZ,
static void placeStackUp(ResolvedDecorator decorator, int x, int z, int realX, int realZ,
int height, int max, Hunk<PlatformBlockState> data,
RNG rng, IrisData irisData, PlaceOpts opts) {
PlaceOpts opts) {
if (height < 0 || height >= data.getHeight()) {
return;
}
@@ -199,7 +176,7 @@ final class DecoratorCore {
effectiveMax = opts.fluidHeight;
}
int stack = computeStack(decorator, rng, realX, realZ, irisData, effectiveMax);
int stack = computeStack(decorator, realX, realZ, effectiveMax);
if (stack == 1) {
int targetY = height + 1;
@@ -213,7 +190,7 @@ final class DecoratorCore {
return;
}
PlatformBlockState block = decorator.pickBlockDataTop(rng, irisData, realX, realZ);
PlatformBlockState block = decorator.pickTopBlock(realX, realZ);
if (block == null || (!opts.underwater && !canGoOn(block, data.get(x, height, z)))) {
return;
}
@@ -228,9 +205,9 @@ final class DecoratorCore {
for (int i = 0; i < stack; i++) {
int h = height + i;
double threshold = ((double) i) / (stack - 1);
PlatformBlockState bd = threshold >= decorator.getTopThreshold()
? decorator.pickBlockDataTop(rng, irisData, realX, realZ)
: decorator.pickBlockData(rng, irisData, realX, realZ);
PlatformBlockState bd = threshold >= decorator.topThreshold()
? decorator.pickTopBlock(realX, realZ)
: decorator.pickBlock(realX, realZ);
if (bd == null) {
break;
@@ -263,20 +240,20 @@ final class DecoratorCore {
}
}
static void placeStackDown(IrisDecorator decorator, int x, int z, int realX, int realZ,
static void placeStackDown(ResolvedDecorator decorator, int x, int z, int realX, int realZ,
int height, int minHeight, Hunk<PlatformBlockState> data,
RNG rng, IrisData irisData, int max, PlaceOpts opts, EngineMantle mantle) {
int max, PlaceOpts opts, EngineMantle mantle) {
if (height < 0 || height >= data.getHeight()) {
return;
}
int stack = computeStack(decorator, rng, realX, realZ, irisData, max);
int stack = computeStack(decorator, realX, realZ, max);
if (stack == 1) {
if (opts.caveSkipFluid && B.isFluid(data.get(x, height, z))) {
return;
}
PlatformBlockState block = decorator.pickBlockDataTop(rng, irisData, realX, realZ);
PlatformBlockState block = decorator.pickTopBlock(realX, realZ);
if (block == null) {
return;
}
@@ -292,9 +269,9 @@ final class DecoratorCore {
}
double threshold = ((double) i) / (double) (stack - 1);
PlatformBlockState bd = threshold >= decorator.getTopThreshold()
? decorator.pickBlockDataTop(rng, irisData, realX, realZ)
: decorator.pickBlockData(rng, irisData, realX, realZ);
PlatformBlockState bd = threshold >= decorator.topThreshold()
? decorator.pickTopBlock(realX, realZ)
: decorator.pickBlock(realX, realZ);
if (bd == null) {
break;
@@ -312,11 +289,10 @@ final class DecoratorCore {
}
}
static void placeFloatingSimple(IrisDecorator decorator,
static void placeFloatingSimple(ResolvedDecorator decorator,
int xf, int zf, int realX, int realZ,
int height, int max, Hunk<PlatformBlockState> data,
RNG rng, IrisData irisData) {
PlatformBlockState bd = decorator.pickBlockData(rng, irisData, realX, realZ);
int height, int max, Hunk<PlatformBlockState> data) {
PlatformBlockState bd = decorator.pickBlock(realX, realZ);
if (bd == null) {
return;
}
@@ -345,13 +321,12 @@ final class DecoratorCore {
}
}
static int placeFloatingStacked(IrisDecorator decorator,
static int placeFloatingStacked(ResolvedDecorator decorator,
int xf, int zf, int realX, int realZ,
int height, int max, Hunk<PlatformBlockState> data,
RNG rng, IrisData irisData) {
int stack = decorator.getHeight(rng, realX, realZ, irisData);
int height, int max, Hunk<PlatformBlockState> data) {
int stack = decorator.stackHeight(realX, realZ);
if (decorator.isScaleStack()) {
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.getAbsoluteMaxStack());
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.absoluteMaxStack());
} else {
stack = Math.min(max, stack);
}
@@ -363,9 +338,9 @@ final class DecoratorCore {
break;
}
double threshold = stack == 1 ? 0.0 : ((double) i) / (stack - 1);
PlatformBlockState bd = threshold >= decorator.getTopThreshold()
? decorator.pickBlockDataTop(rng, irisData, realX, realZ)
: decorator.pickBlockData(rng, irisData, realX, realZ);
PlatformBlockState bd = threshold >= decorator.topThreshold()
? decorator.pickTopBlock(realX, realZ)
: decorator.pickBlock(realX, realZ);
if (bd == null) {
break;
}
@@ -444,7 +419,7 @@ final class DecoratorCore {
return ((BlockData) surface.nativeHandle()).isFaceSturdy(BlockFace.UP, BlockSupport.FULL);
}
static boolean isValidShorelineSupport(IrisDecorator decorator, PlatformBlockState decorant, PlatformBlockState surface) {
static boolean isValidShorelineSupport(ResolvedDecorator decorator, PlatformBlockState decorant, PlatformBlockState surface) {
return surface != null
&& B.isSolid(surface)
&& (decorator.isForcePlace() || canGoOn(decorant, surface));
@@ -466,11 +441,10 @@ final class DecoratorCore {
&& (!caveSkipFluid || !B.isFluid(lower) && !B.isFluid(upper));
}
private static int computeStack(IrisDecorator decorator, RNG rng, double realX, double realZ,
IrisData irisData, int max) {
int stack = decorator.getHeight(rng, realX, realZ, irisData);
private static int computeStack(ResolvedDecorator decorator, double realX, double realZ, int max) {
int stack = decorator.stackHeight(realX, realZ);
if (decorator.isScaleStack()) {
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.getAbsoluteMaxStack());
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.absoluteMaxStack());
} else {
stack = Math.min(max, stack);
}
@@ -18,10 +18,9 @@
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.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.engine.object.decoration.IrisDecorator;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.iris.spi.PlatformBlockState;
@@ -33,12 +32,11 @@ import art.arcane.iris.spi.PlatformBlockState;
*/
public class FloatingDecorator {
public static int decorateColumn(Engine engine, IrisBiome target, IrisDecorationPart part,
public static int decorateColumn(Engine engine, IrisBiome target, DecorationPart part,
int xf, int zf, int realX, int realZ,
int height, int max, Hunk<PlatformBlockState> data, RNG rng,
Runnable candidatesNullCallback) {
RNG gRNG = new RNG(DecoratorCore.partSeed(engine.getSeedManager().getDecorator(), part));
IrisDecorator decorator = DecoratorCore.pickDecorator(target, part, gRNG, rng, engine.getData(), realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(BiomeDecorators.of(engine).decorators(target, part), rng, realX, realZ);
if (decorator == null) {
candidatesNullCallback.run();
@@ -46,10 +44,10 @@ public class FloatingDecorator {
}
if (!decorator.isStacking()) {
DecoratorCore.placeFloatingSimple(decorator, xf, zf, realX, realZ, height, max, data, rng, engine.getData());
DecoratorCore.placeFloatingSimple(decorator, xf, zf, realX, realZ, height, max, data);
return max > 1 ? 1 : 0;
}
return DecoratorCore.placeFloatingStacked(decorator, xf, zf, realX, realZ, height, max, data, rng, engine.getData());
return DecoratorCore.placeFloatingStacked(decorator, xf, zf, realX, realZ, height, max, data);
}
}
@@ -21,8 +21,7 @@ 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.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.engine.object.decoration.IrisDecorator;
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;
@@ -30,11 +29,8 @@ import art.arcane.volmlib.util.math.RNG;
import art.arcane.iris.spi.PlatformBlockState;
public class IrisCeilingDecorator extends IrisEngineDecorator {
private final RNG partRNG;
public IrisCeilingDecorator(Engine engine) {
super(engine, "Ceiling", IrisDecorationPart.CEILING);
this.partRNG = new RNG(DecoratorCore.partSeed(getSeed(), IrisDecorationPart.CEILING));
super(engine, "Ceiling", DecorationPart.CEILING);
}
@BlockCoordinates
@@ -49,7 +45,7 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
Hunk<PlatformBlockState> data, IrisBiome biome, InferredType inferredType, int height, int max) {
boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(inferredType);
RNG rng = getRNG(realX, realZ);
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ);
if (decorator == null) {
return;
@@ -62,13 +58,13 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
return;
}
}
DecoratorCore.placeSingleAt(decorator, x, z, realX, height, realZ, data, rng, getData(), true, getEngine().getMantle());
DecoratorCore.placeSingleAt(decorator, x, z, realX, height, realZ, data, true, getEngine().getMantle());
return;
}
DecoratorCore.PlaceOpts opts = DecoratorCore.SCRATCH_OPTS.get();
opts.reset();
opts.caveSkipFluid = caveSkipFluid;
DecoratorCore.placeStackDown(decorator, x, z, realX, realZ, height, 0, data, rng, getData(), max, opts, getEngine().getMantle());
DecoratorCore.placeStackDown(decorator, x, z, realX, realZ, height, 0, data, max, opts, getEngine().getMantle());
}
}
@@ -21,18 +21,20 @@ 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.engine.object.decoration.IrisDecorationPart;
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
private final IrisDecorationPart part;
private final DecorationPart part;
protected final BiomeDecorators decorators;
public IrisEngineDecorator(Engine engine, String name, IrisDecorationPart part) {
public IrisEngineDecorator(Engine engine, String name, DecorationPart part) {
super(engine, name + " Decorator");
this.part = part;
this.decorators = BiomeDecorators.of(engine);
}
@BlockCoordinates
@@ -20,19 +20,15 @@ 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.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.engine.object.decoration.IrisDecorator;
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;
public class IrisSeaFloorDecorator extends IrisEngineDecorator {
private final RNG partRNG;
public IrisSeaFloorDecorator(Engine engine) {
super(engine, "Sea Floor", IrisDecorationPart.SEA_FLOOR);
this.partRNG = new RNG(DecoratorCore.partSeed(getSeed(), IrisDecorationPart.SEA_FLOOR));
super(engine, "Sea Floor", DecorationPart.SEA_FLOOR);
}
@BlockCoordinates
@@ -40,24 +36,23 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
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) {
RNG rng = getRNG(realX, realZ);
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ);
if (decorator == null) {
return;
}
if (!decorator.isStacking()) {
if (!decorator.isForcePlace() && !decorator.getSlopeCondition().isDefault()
&& !decorator.getSlopeCondition().isValid(getComplex().getSlopeStream().get(realX, realZ))) {
if (decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ))) {
return;
}
if (height >= 0 && height < getEngine().getHeight()) {
data.set(x, height, z, decorator.getBlockData100(biome, rng, realX, height, realZ, getData()));
data.set(x, height, z, decorator.blockAt(biome, realX, height, realZ));
}
return;
}
int stack = decorator.getHeight(rng, realX, realZ, getData());
int stack = decorator.stackHeight(realX, realZ);
if (decorator.isScaleStack()) {
stack = (int) Math.ceil((double) (max - height) * ((double) stack / 100));
} else {
@@ -65,7 +60,7 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
}
if (stack == 1) {
data.set(x, height, z, decorator.getBlockDataForTop(biome, rng, realX, height, realZ, getData()));
data.set(x, height, z, decorator.topBlockAt(biome, realX, height, realZ));
return;
}
@@ -76,9 +71,9 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
continue;
}
double threshold = ((double) i) / (stack - 1);
data.set(x, h, z, threshold >= decorator.getTopThreshold()
? decorator.getBlockDataForTop(biome, rng, realX, h, realZ, getData())
: decorator.getBlockData100(biome, rng, realX, h, realZ, getData()));
data.set(x, h, z, threshold >= decorator.topThreshold()
? decorator.topBlockAt(biome, realX, h, realZ)
: decorator.blockAt(biome, realX, h, realZ));
}
}
}
@@ -20,19 +20,15 @@ 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.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.engine.object.decoration.IrisDecorator;
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;
public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
private final RNG partRNG;
public IrisSeaSurfaceDecorator(Engine engine) {
super(engine, "Sea Surface", IrisDecorationPart.SEA_SURFACE);
this.partRNG = new RNG(DecoratorCore.partSeed(getSeed(), IrisDecorationPart.SEA_SURFACE));
super(engine, "Sea Surface", DecorationPart.SEA_SURFACE);
}
@BlockCoordinates
@@ -40,7 +36,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
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) {
RNG rng = getRNG(realX, realZ);
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ);
if (decorator == null) {
return;
@@ -50,7 +46,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
int targetY = height + 1;
if (height >= 0 && targetY < getEngine().getHeight()
&& DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
PlatformBlockState block = decorator.getBlockData100(biome, rng, realX, height, realZ, getData());
PlatformBlockState block = decorator.blockAt(biome, realX, height, realZ);
if (block != null) {
data.set(x, targetY, z, block);
}
@@ -58,7 +54,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
return;
}
int stack = decorator.getHeight(rng, realX, realZ, getData());
int stack = decorator.stackHeight(realX, realZ);
if (decorator.isScaleStack()) {
stack = (int) Math.ceil((double) (max - height) * ((double) stack / 100));
}
@@ -69,7 +65,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
return;
}
PlatformBlockState block = decorator.getBlockDataForTop(biome, rng, realX, height, realZ, getData());
PlatformBlockState block = decorator.topBlockAt(biome, realX, height, realZ);
if (block != null) {
data.set(x, targetY, z, block);
}
@@ -85,9 +81,9 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
break;
}
double threshold = ((double) i) / (stack - 1);
PlatformBlockState block = threshold >= decorator.getTopThreshold()
? decorator.getBlockDataForTop(biome, rng, realX, h, realZ, getData())
: decorator.getBlockData100(biome, rng, realX, h, realZ, getData());
PlatformBlockState block = threshold >= decorator.topThreshold()
? decorator.topBlockAt(biome, realX, h, realZ)
: decorator.blockAt(biome, realX, h, realZ);
if (block == null) {
break;
}
@@ -20,8 +20,7 @@ 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.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.engine.object.decoration.IrisDecorator;
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;
@@ -29,11 +28,8 @@ import art.arcane.volmlib.util.math.RNG;
import art.arcane.iris.spi.PlatformBlockState;
public class IrisShoreLineDecorator extends IrisEngineDecorator {
private final RNG partRNG;
public IrisShoreLineDecorator(Engine engine) {
super(engine, "Shore Line", IrisDecorationPart.SHORE_LINE);
this.partRNG = new RNG(DecoratorCore.partSeed(getSeed(), IrisDecorationPart.SHORE_LINE));
super(engine, "Shore Line", DecorationPart.SHORE_LINE);
}
@BlockCoordinates
@@ -54,14 +50,13 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
}
RNG rng = getRNG(realX, realZ);
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ);
if (decorator == null) {
return;
}
if (!decorator.isForcePlace() && !decorator.getSlopeCondition().isDefault()
&& !decorator.getSlopeCondition().isValid(getComplex().getSlopeStream().get(realX, realZ))) {
if (decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ))) {
return;
}
@@ -76,14 +71,14 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|| !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
return;
}
PlatformBlockState block = decorator.getBlockData100(biome, rng, realX, height, realZ, getData());
PlatformBlockState block = decorator.blockAt(biome, realX, height, realZ);
if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
data.set(x, targetY, z, block);
}
return;
}
int stack = decorator.getHeight(rng, realX, realZ, getData());
int stack = decorator.stackHeight(realX, realZ);
if (decorator.isScaleStack()) {
stack = (int) Math.ceil((double) (max - height) * ((double) stack / 100));
} else {
@@ -96,7 +91,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
return;
}
PlatformBlockState block = decorator.getBlockDataForTop(biome, rng, realX, height, realZ, getData());
PlatformBlockState block = decorator.topBlockAt(biome, realX, height, realZ);
if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
data.set(x, targetY, z, block);
}
@@ -111,9 +106,9 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
break;
}
double threshold = ((double) i) / (stack - 1);
PlatformBlockState block = threshold >= decorator.getTopThreshold()
? decorator.getBlockDataForTop(biome, rng, realX, h, realZ, getData())
: decorator.getBlockData100(biome, rng, realX, h, realZ, getData());
PlatformBlockState block = threshold >= decorator.topThreshold()
? decorator.topBlockAt(biome, realX, h, realZ)
: decorator.blockAt(biome, realX, h, realZ);
if (block == null) {
break;
}
@@ -21,31 +21,23 @@ 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.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.engine.object.decoration.IrisDecorator;
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;
public class IrisSurfaceDecorator extends IrisEngineDecorator {
private final RNG partRNG;
public IrisSurfaceDecorator(Engine engine) {
super(engine, "Surface", IrisDecorationPart.NONE);
this.partRNG = new RNG(DecoratorCore.partSeed(getSeed(), IrisDecorationPart.NONE));
super(engine, "Surface", DecorationPart.NONE);
}
protected IrisSurfaceDecorator(Engine engine, String name) {
super(engine, name, IrisDecorationPart.NONE);
this.partRNG = new RNG(DecoratorCore.partSeed(getSeed(), IrisDecorationPart.NONE));
super(engine, name, DecorationPart.NONE);
}
protected boolean isSlopeValid(IrisDecorator decorator, int realX, int realZ) {
if (decorator.isForcePlace() || decorator.getSlopeCondition().isDefault()) {
return true;
}
return decorator.getSlopeCondition().isValid(getComplex().getSlopeStream().get(realX, realZ));
protected boolean isSlopeValid(ResolvedDecorator decorator, int realX, int realZ) {
return !decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ));
}
@BlockCoordinates
@@ -66,7 +58,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
boolean underwater = isUnderwater(inferredType, height, fluidHeight);
boolean caveSkipFluid = skipsFluid(inferredType);
RNG rng = getRNG(realX, realZ);
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ);
if (decorator == null || !isSlopeValid(decorator, realX, realZ)) {
return;
@@ -78,12 +70,12 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
opts.underwater = underwater;
opts.fluidHeight = fluidHeight;
opts.caveSkipFluid = caveSkipFluid;
DecoratorCore.placeStackUp(decorator, x, z, realX, realZ, height, max, data, rng, getData(), opts);
DecoratorCore.placeStackUp(decorator, x, z, realX, realZ, height, max, data, opts);
return;
}
DecoratorCore.placeSurfaceSingle(decorator, x, z, realX, height, realZ,
data, rng, getData(), underwater, caveSkipFluid, getEngine().getMantle());
data, underwater, caveSkipFluid, getEngine().getMantle());
}
static boolean isUnderwater(InferredType inferredType, int height, int fluidHeight) {
@@ -0,0 +1,274 @@
/*
* 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.DecorationPart;
import art.arcane.iris.builtin.decorant.Decorator;
import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.spi.IrisLogging;
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.noise.NoiseFactory;
import com.volmit.noise.NoiseSampler;
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
* 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.
*
* <p>The noise seeds are the decorator's own seed plus the same offsets Iris's decorator always used, so a decorator
* noise is a pure function of its seed.
*/
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 AtomicCache<NoiseSampler> chanceNoise = new AtomicCache<>();
private final AtomicCache<NoiseSampler> varianceNoise = new AtomicCache<>();
private final AtomicCache<NoiseSampler> heightNoise = new AtomicCache<>();
/**
* @param blocks the palette as the platform's blocks, each repeated by its weight
* @param topBlocks the top palette the same way
* @param forceBlock the block it forces onto the surface, or null
* @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
*/
ResolvedDecorator(Decorator settings, long seed, NoiseFactory noise, List<PlatformBlockState> blocks, List<PlatformBlockState> topBlocks,
PlatformBlockState forceBlock, List<PlatformBlockState> whitelist, List<PlatformBlockState> blacklist) {
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.forceBlock = forceBlock;
this.whitelist = whitelist.toArray(new PlatformBlockState[0]);
this.blacklist = blacklist.toArray(new PlatformBlockState[0]);
}
/** {@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) {
var resources = engine.getData().getPackResources();
BlockRegistry registry = resources.blocks();
PlatformBlockState forced = settings.forceBlock().map(spec -> platformState(registry, spec)).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()));
}
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<>();
for (BlockSpec spec : palette) {
PlatformBlockState state = platformState(registry, spec);
if (state == null) {
continue;
}
for (int n = 0; n < spec.weight(); n++) {
weighted.add(state);
}
}
return weighted;
}
private static List<PlatformBlockState> each(BlockRegistry registry, List<BlockSpec> palette) {
return palette.stream().map(spec -> platformState(registry, spec)).toList();
}
Decorator settings() {
return settings;
}
/** The seed the decorator's noise is built from. */
long seed() {
return seed;
}
DecorationPart part() {
return settings.partOf();
}
boolean isStacking() {
return settings.isStacking();
}
boolean isForcePlace() {
return settings.forcePlace();
}
boolean isScaleStack() {
return settings.scaleStack();
}
int absoluteMaxStack() {
return settings.absoluteMaxStack();
}
double topThreshold() {
return settings.topThreshold();
}
/** The block it forces onto the surface instead of the one found there, or null. */
PlatformBlockState forceBlock() {
return forceBlock;
}
/** Whether the terrain's slope keeps the decorator off; the slope is only worked out when the decorator limits it. */
boolean slopeBlocks(DoubleSupplier slope) {
if (settings.forcePlace() || settings.slopeCondition().isDefault()) {
return false;
}
return !settings.slopeCondition().isValid(slope.getAsDouble());
}
/** Whether the white and black lists keep the decorator off {@code surface}. */
boolean rejectsSurface(PlatformBlockState 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) {
if (state.equals(surface)) {
return true;
}
}
return false;
}
/** How many blocks the decorator stacks at the column: the minimum, or a height between the limits drawn from its height noise. */
int stackHeight(double x, double z) {
if (settings.stackMin() == settings.stackMax()) {
return settings.stackMin();
}
double zoom = settings.heightVariance().zoom();
return fit(settings.stackMin(), settings.stackMax(), heightNoise().sample(x / zoom, z / zoom));
}
/** Whether the chance noise lets the decorator place at the column. */
boolean passesChanceGate(double x, double z) {
if (blocks.isEmpty()) {
return false;
}
double zoom = settings.style().zoom();
return chanceNoise().sample(x / zoom, z / zoom) <= settings.chance();
}
/** 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) {
if (blocks.isEmpty()) {
IrisLogging.warnOnce("decorator-empty:" + biome.getName(), "Empty Block Data for " + biome.getName());
return null;
}
if (blocks.size() == 1) {
return blocks.get(0);
}
return blocks.get(fit(0, blocks.size() - 1, varianceNoise().sample(z, y, x))); // X and Z are switched
}
/** 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) {
if (topBlocks.isEmpty()) {
return blockAt(biome, x, y, z);
}
double zoom = settings.style().zoom();
if (!(chanceNoise().sample(x / zoom, z / zoom) <= settings.chance())) {
return null;
}
if (blocks.size() == 1) {
return topBlocks.get(0);
}
return topBlocks.get(fit(0, topBlocks.size() - 1, varianceNoise().sample(z, y, x)));
}
/** The palette's block for the column, or null when the palette has no block. */
PlatformBlockState 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) {
if (topBlockArray.length == 0) {
return pickBlock(x, z);
}
return pick(topBlockArray, x, z);
}
private PlatformBlockState pick(PlatformBlockState[] palette, double x, double z) {
if (palette.length == 0) {
return null;
}
if (palette.length == 1) {
return palette[0];
}
return palette[Math.abs(fit(0, palette.length - 1, varianceNoise().sample(z, x)))];
}
/** Builds the noise now instead of when first asked for. */
void warm() {
heightNoise();
chanceNoise();
varianceNoise();
}
private NoiseSampler heightNoise() {
return heightNoise.aquireOrThrow(() -> noise.sampler(settings.heightVariance(),
seed + blocks.size() + settings.stackMax() + settings.stackMin()));
}
private NoiseSampler chanceNoise() {
return chanceNoise.aquireOrThrow(() -> noise.sampler(settings.style(), seed + blocks.size()));
}
private NoiseSampler varianceNoise() {
return varianceNoise.aquireOrThrow(() -> noise.sampler(settings.variance(), seed + blocks.size()));
}
/** The whole number between {@code min} and {@code max} that {@code fraction}, from 0 to 1, is the way along. */
private static int fit(int min, int max, double fraction) {
return (int) Math.round(min + (fraction * (max - min)));
}
}
@@ -29,24 +29,28 @@ import art.arcane.iris.builtin.objects.tree.TreeDecorator;
import art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf;
import art.arcane.iris.core.modules.IrisMantleChunk;
import art.arcane.iris.core.modules.IrisPackSettings;
import art.arcane.iris.core.modules.IrisPackWorld;
import art.arcane.iris.engine.framework.Engine;
import com.volmit.FeatureRegistry;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLifecycle;
import com.volmit.config.PackSettings;
import com.volmit.service.ObjectsAt;
import com.volmit.service.SaplingGrowth;
import com.volmit.stage.MantleStageContext;
import com.volmit.stage.StageGraph;
import com.volmit.world.PackWorld;
/**
* Module {@code iris:objects}: the objects the dimension's regions and biomes place, written into the mantle
* once the caves they may anchor in are planned. A port of what was Iris's object mantle component, its work
* done by {@link ObjectPlacing}, one per engine runtime. Its reach is the pack's largest object placement. It tells
* done by {@link ObjectPlacing}, one per engine runtime, with the noise of its placements and the variants of its procedural
* objects built ahead of generation ({@link #warmUp}). Its reach is the pack's largest object placement. It tells
* Iris which objects a chunk would get and which biomes and regions place an object ({@link ObjectLocating}), for the
* object search and studio tools, and grows the trees of saplings ({@link TreeGrowing}).
*/
public final class ObjectModule implements IrisModule {
public final class ObjectModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = "built-in";
@Override
@@ -71,6 +75,12 @@ public final class ObjectModule implements IrisModule {
registry.registerHeldType(Formation.class);
registry.registerHeldType(Fungus.class);
registry.registerHeldType(Ruin.class);
registry.registerLifecycle(this);
}
@Override
public void warmUp(PackWorld world) {
new ObjectWarmUp(IrisPackWorld.of(world).engine()).warm();
}
private static void place(MantleStageContext context) {
@@ -0,0 +1,91 @@
/*
* 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.mantle.components;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
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.volmlib.util.math.RNG;
import java.util.Comparator;
/**
* Builds what object placing would build on first use, for every object placement and procedural object the world's
* biomes and regions declare: the placement's surface warp and density noise, and a procedural object's variants. None
* of it depends on the random it is warmed with; the warp is seeded from the world, the density noise is cached per seed
* and the variants are baked whatever picks one.
*/
final class ObjectWarmUp {
private static final long ROOT_SEED_SALT = 7777L;
private static final int PROBE_COORDINATE = 0;
private final Engine engine;
private final RNG root;
private int warmed;
ObjectWarmUp(Engine engine) {
this.engine = engine;
this.root = new RNG(engine.getSeedManager().getComponent() + ROOT_SEED_SALT);
}
void warm() {
KList<IrisBiome> biomes = engine.getAllBiomes();
biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
for (IrisBiome biome : biomes) {
warmPlacements(biome.getObjects());
warmProcedural(biome.getProceduralObjects());
}
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
regions.sort(Comparator.comparing(IrisRegion::getLoadKey));
for (IrisRegion region : regions) {
warmPlacements(region.getObjects());
warmProcedural(region.getProceduralObjects());
}
}
private void warmPlacements(KList<IrisObjectPlacement> placements) {
if (placements == null) {
return;
}
for (IrisObjectPlacement placement : placements) {
if (placement == null) {
continue;
}
RNG rng = root.nextParallelRNG(warmed++);
placement.getSurfaceWarp(rng, engine.getData(), engine);
placement.getDensity(rng, PROBE_COORDINATE, PROBE_COORDINATE, engine.getData());
}
}
private void warmProcedural(IrisProceduralObjects procedural) {
if (procedural == null) {
return;
}
for (IrisProceduralPlacement placement : procedural.getAllPlacements()) {
if (placement != null) {
placement.getVariantObject(engine.getData(), root.nextParallelRNG(warmed++));
}
}
}
}
@@ -19,13 +19,13 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.engine.UpperDimensionContext;
import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.engine.decorator.BiomeDecorators;
import art.arcane.iris.engine.decorator.IrisCeilingDecorator;
import art.arcane.iris.engine.decorator.IrisSurfaceDecorator;
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.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.engine.object.decoration.IrisDecorator;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.iris.util.common.data.B;
@@ -65,12 +65,14 @@ public class CaveApplying {
private final RNG rng;
private final PlatformBlockState AIR = B.getState("CAVE_AIR");
private final PlatformBlockState LAVA = B.getState("LAVA");
private final BiomeDecorators decorators;
private final IrisSurfaceDecorator surfaceDecorator;
private final IrisCeilingDecorator ceilingDecorator;
public CaveApplying(Engine engine) {
this.engine = engine;
rng = new RNG(engine.getSeedManager().getCarve());
decorators = BiomeDecorators.of(engine);
surfaceDecorator = new IrisSurfaceDecorator(engine);
ceilingDecorator = new IrisCeilingDecorator(engine);
}
@@ -640,17 +642,11 @@ public class CaveApplying {
}
}
IrisDecorator[] surfaceDecorators = floorBiome == null
? new IrisDecorator[0]
: floorBiome.getDecoratorBucket(IrisDecorationPart.NONE);
if (surfaceDecorators.length > 0 && hasStableCaveFloorSupport(output, rx, zone.getFloor(), rz)) {
if (floorBiome != null && decorators.hasDecorators(floorBiome, DecorationPart.NONE) && hasStableCaveFloorSupport(output, rx, zone.getFloor(), rz)) {
surfaceDecorator.decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, floorBiome, InferredType.CAVE, zone.getFloor() - 1, zone.airThickness());
}
IrisDecorator[] ceilingDecorators = ceilingBiome == null
? new IrisDecorator[0]
: ceilingBiome.getDecoratorBucket(IrisDecorationPart.CEILING);
if (ceilingDecorators.length > 0 && zone.getCeiling() + 1 < maxY && B.isSolid(output.getRaw(rx, zone.getCeiling() + 1, rz))) {
if (ceilingBiome != null && decorators.hasDecorators(ceilingBiome, DecorationPart.CEILING) && zone.getCeiling() + 1 < maxY && B.isSolid(output.getRaw(rx, zone.getCeiling() + 1, rz))) {
ceilingDecorator.decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, ceilingBiome, InferredType.CAVE, zone.getCeiling(), zone.airThickness());
}
}
@@ -33,7 +33,7 @@ import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySamp
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.terrain.IrisBiomePaletteLayer;
import art.arcane.iris.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.util.common.data.B;
@@ -331,7 +331,7 @@ public class FloatingIslands {
if (above == null || above.isAir()) {
try {
RNG colRng = rng.nextParallelRNG((int) FloatingIslandSample.columnSeed(baseSeed, wx, wz));
FloatingDecorator.decorateColumn(engine, target, IrisDecorationPart.NONE, xf, zf, wx, wz, topY, max, output, colRng, NOOP_DECORATION_MISS);
FloatingDecorator.decorateColumn(engine, target, DecorationPart.NONE, xf, zf, wx, wz, topY, max, output, colRng, NOOP_DECORATION_MISS);
} catch (Throwable e) {
IrisLogging.reportError(e);
}
@@ -1,39 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.object.decoration;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("Represents a location where decorations should go")
public enum IrisDecorationPart {
@Desc("The default, decorate anywhere")
NONE,
@Desc("Targets shore lines (typically for sugar cane)")
SHORE_LINE,
@Desc("Target sea surfaces (typically for lilypads)")
SEA_SURFACE,
@Desc("Targets the sea floor (entire placement must be bellow sea level)")
SEA_FLOOR,
@Desc("Decorates on cave & carving ceilings or underside of overhangs")
CEILING,
}
@@ -1,356 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.object.decoration;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.iris.engine.object.material.IrisBlockData;
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
import art.arcane.iris.engine.object.noise.NoiseStyle;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.engine.object.annotations.ArrayType;
import art.arcane.iris.engine.object.annotations.DependsOn;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.MaxNumber;
import art.arcane.iris.engine.object.annotations.MinNumber;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.iris.util.project.noise.CNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import art.arcane.iris.spi.PlatformBlockState;
import lombok.experimental.Accessors;
@Snippet("decorator")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A biome decorator is used for placing flowers, grass, cacti and so on")
@Data
public class IrisDecorator {
private final transient AtomicCache<CNG> layerGenerator = new AtomicCache<>();
private final transient AtomicCache<CNG> varianceGenerator = new AtomicCache<>();
private final transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();
private final transient AtomicCache<KList<PlatformBlockState>> blockData = new AtomicCache<>();
private final transient AtomicCache<KList<PlatformBlockState>> blockDataTops = new AtomicCache<>();
private final transient AtomicCache<PlatformBlockState[]> blockDataArray = new AtomicCache<>();
private final transient AtomicCache<PlatformBlockState[]> blockDataTopsArray = new AtomicCache<>();
private final transient AtomicCache<PlatformBlockState[]> whitelistArray = new AtomicCache<>();
private final transient AtomicCache<PlatformBlockState[]> blacklistArray = new AtomicCache<>();
@Desc("The varience dispersion is used when multiple blocks are put in the palette. Scatter scrambles them, Wispy shows streak-looking varience")
private IrisGeneratorStyle variance = NoiseStyle.STATIC.style();
@Desc("Forcefully place this decorant anywhere it is supposed to go even if it should not go on a specific surface block. For example, you could force tallgrass to place on top of stone by using this.")
private boolean forcePlace = false;
@Desc("Forced the surface block of this decorant to be the specified block. Assumes forcePlace.")
private IrisBlockData forceBlock;
@ArrayType(min = 1, type = IrisBlockData.class)
@Desc("When set, the decorator can only place onto any of these blocks.")
private KList<IrisBlockData> whitelist;
@ArrayType(min = 1, type = IrisBlockData.class)
@Desc("When set, the decorator will never place onto any of these blocks.")
private KList<IrisBlockData> blacklist;
@Desc("The slope at which this decorator can be placed. Range from 0 to 10 by default. Calculated from a 3-block radius from the center of the decorator placement.")
private SlopeClip slopeCondition = new SlopeClip();
@DependsOn({"scaleStack", "stackMin", "stackMax"})
@Desc("If stackMax is set to true, use this to limit its max height for large caverns")
private int absoluteMaxStack = 30;
@Desc("Dispersion is used to pick places to spawn. Scatter randomly places them (vanilla) or Wispy for a streak like patch system.")
private IrisGeneratorStyle style = NoiseStyle.STATIC.style();
@DependsOn({"stackMin", "stackMax"})
@Desc("If this decorator has a height more than 1 this changes how it picks the height between your maxes. Scatter = random, Wispy = wavy heights")
private IrisGeneratorStyle heightVariance = NoiseStyle.STATIC.style();
@Desc("Tells iris where this decoration is a part of. I.e. SHORE_LINE or SEA_SURFACE")
private IrisDecorationPart partOf = IrisDecorationPart.NONE;
@DependsOn({"stackMin", "stackMax"})
@MinNumber(1)
@MaxNumber(2032)
@Desc("The minimum repeat stack height (setting to 3 would stack 3 of <block> on top of each other")
private int stackMin = 1;
@DependsOn({"stackMin", "stackMax"})
@MinNumber(1)
@MaxNumber(2032)
@Desc("The maximum repeat stack height")
private int stackMax = 1;
@DependsOn({"stackMin", "stackMax"})
@Desc("""
Changes stackMin and stackMin from being absolute block heights and instead uses them as a percentage to scale the stack based on the cave height
Within a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height""")
private boolean scaleStack = false;
@Required
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance for this decorator to decorate at a given X,Y coordinate. This is hit 256 times per chunk (per surface block)")
private double chance = 0.1;
@Required
@ArrayType(min = 1, type = IrisBlockData.class)
@Desc("The palette of blocks to pick from when this decorator needs to place.")
private KList<IrisBlockData> palette = new KList<IrisBlockData>().qadd(new IrisBlockData("grass"));
@ArrayType(min = 1, type = IrisBlockData.class)
@Desc("The palette of blocks used at the very top of a 'stackMax' of higher than 1. For example, bamboo tops.")
private KList<IrisBlockData> topPalette = new KList<>();
@DependsOn("topPalette")
@MinNumber(0.01)
@MaxNumber(1.0)
@Desc("When the stack passes the top threshold, the top palette will start being used instead of the normal palette.")
private double topThreshold = 1.0;
public int getHeight(RNG rng, double x, double z, IrisData data) {
if (stackMin == stackMax) {
return stackMin;
}
return getHeightGenerator(rng, data)
.fit(stackMin, stackMax,
x / heightVariance.getZoom(),
z / heightVariance.getZoom());
}
public CNG getHeightGenerator(RNG rng, IrisData data) {
CNG cached = heightGenerator.getIfPresent();
if (cached != null) {
return cached;
}
return heightGenerator.aquire(() ->
heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin), data));
}
public CNG getGenerator(RNG rng, IrisData data) {
CNG cached = layerGenerator.getIfPresent();
if (cached != null) {
return cached;
}
return layerGenerator.aquire(() -> style.create(rng.nextParallelRNG(getBlockData(data).size()), data));
}
public CNG getVarianceGenerator(RNG rng, IrisData data) {
CNG cached = varianceGenerator.getIfPresent();
if (cached != null) {
return cached;
}
return varianceGenerator.aquire(() ->
variance.create(
rng.nextParallelRNG(getBlockData(data).size()), data)
.scale(1D / variance.getZoom()));
}
public KList<IrisBlockData> add(String b) {
palette.add(new IrisBlockData(b));
return palette;
}
public boolean passesChanceGate(RNG rng, double x, double z, IrisData data) {
if (getBlockData(data).isEmpty()) {
return false;
}
double xx = x / style.getZoom();
double zz = z / style.getZoom();
return getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance;
}
public PlatformBlockState getBlockData(IrisBiome b, RNG rng, double x, double z, IrisData data) {
if (!passesChanceGate(rng, x, z, data)) {
return null;
}
if (getBlockData(data).size() == 1) {
return getBlockData(data).get(0);
}
return getVarianceGenerator(rng, data).fit(getBlockData(data), z, x);
}
public PlatformBlockState getBlockData100(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) {
if (getBlockData(data).isEmpty()) {
IrisLogging.warnOnce("decorator-empty:" + b.getName(), "Empty Block Data for " + b.getName());
return null;
}
if (getBlockData(data).size() == 1) {
return getBlockData(data).get(0);
}
return getVarianceGenerator(rng, data).fit(getBlockData(data), z, y, x); //X and Z must be switched
}
public PlatformBlockState getBlockDataForTop(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) {
if (getBlockDataTops(data).isEmpty()) {
return getBlockData100(b, rng, x, y, z, data);
}
double xx = x / style.getZoom();
double zz = z / style.getZoom();
if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
if (getBlockData(data).size() == 1) {
return getBlockDataTops(data).get(0);
}
return getVarianceGenerator(rng, data).fit(getBlockDataTops(data), z, y, x); //X and Z must be switched
}
return null;
}
public KList<PlatformBlockState> getBlockData(IrisData data) {
KList<PlatformBlockState> cached = blockData.getIfPresent();
if (cached != null) {
return cached;
}
return blockData.aquire(() ->
{
KList<PlatformBlockState> blockData = new KList<>();
for (IrisBlockData i : palette) {
PlatformBlockState bx = i.getBlockData(data);
if (bx != null) {
for (int n = 0; n < i.getWeight(); n++) {
blockData.add(bx);
}
}
}
return blockData;
});
}
public KList<PlatformBlockState> getBlockDataTops(IrisData data) {
KList<PlatformBlockState> cached = blockDataTops.getIfPresent();
if (cached != null) {
return cached;
}
return blockDataTops.aquire(() ->
{
KList<PlatformBlockState> blockDataTops = new KList<>();
for (IrisBlockData i : topPalette) {
PlatformBlockState bx = i.getBlockData(data);
if (bx != null) {
for (int n = 0; n < i.getWeight(); n++) {
blockDataTops.add(bx);
}
}
}
return blockDataTops;
});
}
public PlatformBlockState[] getBlockDataArray(IrisData data) {
PlatformBlockState[] cached = blockDataArray.getIfPresent();
if (cached != null) {
return cached;
}
return blockDataArray.aquire(() -> {
KList<PlatformBlockState> list = getBlockData(data);
return list.toArray(new PlatformBlockState[0]);
});
}
public PlatformBlockState[] getBlockDataTopsArray(IrisData data) {
PlatformBlockState[] cached = blockDataTopsArray.getIfPresent();
if (cached != null) {
return cached;
}
return blockDataTopsArray.aquire(() -> {
KList<PlatformBlockState> list = getBlockDataTops(data);
return list.toArray(new PlatformBlockState[0]);
});
}
/**
* The resolved whitelist palette. Empty when no whitelist is configured; callers must still gate on
* {@link #getWhitelist()} being non null, because an explicitly empty whitelist blocks all placement.
*/
public PlatformBlockState[] getWhitelistArray(IrisData data) {
PlatformBlockState[] cached = whitelistArray.getIfPresent();
if (cached != null) {
return cached;
}
return whitelistArray.aquire(() -> resolvePalette(whitelist, data));
}
public PlatformBlockState[] getBlacklistArray(IrisData data) {
PlatformBlockState[] cached = blacklistArray.getIfPresent();
if (cached != null) {
return cached;
}
return blacklistArray.aquire(() -> resolvePalette(blacklist, data));
}
private static PlatformBlockState[] resolvePalette(KList<IrisBlockData> list, IrisData data) {
if (list == null) {
return new PlatformBlockState[0];
}
PlatformBlockState[] resolved = new PlatformBlockState[list.size()];
for (int i = 0; i < resolved.length; i++) {
resolved[i] = list.get(i).getBlockData(data);
}
return resolved;
}
public PlatformBlockState pickBlockData(RNG rng, IrisData data, double x, double z) {
PlatformBlockState[] arr = getBlockDataArray(data);
if (arr.length == 0) {
return null;
}
if (arr.length == 1) {
return arr[0];
}
return arr[Math.abs((int) getVarianceGenerator(rng, data).fit(0, arr.length - 1, z, x))];
}
public PlatformBlockState pickBlockDataTop(RNG rng, IrisData data, double x, double z) {
PlatformBlockState[] arr = getBlockDataTopsArray(data);
if (arr.length == 0) {
return pickBlockData(rng, data, x, z);
}
if (arr.length == 1) {
return arr[0];
}
return arr[Math.abs((int) getVarianceGenerator(rng, data).fit(0, arr.length - 1, z, x))];
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isStacking() {
return getStackMax() > 1;
}
}
@@ -20,8 +20,6 @@ package art.arcane.iris.engine.object.world.biome;
import art.arcane.iris.builtin.floating.FloatingChildBiome;
import art.arcane.iris.builtin.carve.CaveProfile;
import art.arcane.iris.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.engine.object.decoration.IrisDecorator;
import art.arcane.iris.engine.object.entity.IrisEffect;
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
import art.arcane.iris.engine.object.loot.IrisBlockDrops;
@@ -118,12 +116,10 @@ public class IrisBiome extends IrisRegistrant implements IRare {
private final transient AtomicCache<KList<IrisOreGenerator>> undergroundOreCache = new AtomicCache<>();
private final transient AtomicCache<IrisOreGeneratorBounds> surfaceOreBoundsCache = new AtomicCache<>();
private final transient AtomicCache<IrisOreGeneratorBounds> undergroundOreBoundsCache = new AtomicCache<>();
private final transient AtomicCache<EnumMap<IrisDecorationPart, IrisDecorator[]>> decoratorBuckets = new AtomicCache<>();
private final transient AtomicCache<Biome> derivativeResolved = new AtomicCache<>();
private final transient AtomicCache<Biome> vanillaDerivativeResolved = new AtomicCache<>();
private final transient AtomicCache<KList<Biome>> biomeScatterResolved = new AtomicCache<>();
private final transient AtomicCache<KList<Biome>> biomeSkyScatterResolved = new AtomicCache<>();
private static final IrisDecorator[] EMPTY_BUCKET = new IrisDecorator[0];
@MinNumber(2)
@Required
@Desc("This is the human readable name for this biome. This can and should be different than the file name. This is not used for loading biomes in other objects.")
@@ -205,9 +201,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
@ArrayType(type = IrisBiomePaletteLayer.class)
@Desc("Layers of materials filling the water column of sea biomes, indexed downward from the water surface. Anything below the last layer is filled with the dimension fluid palette, not stone.")
private KList<IrisBiomePaletteLayer> seaLayers = new KList<>();
@ArrayType(min = 1, type = IrisDecorator.class)
@Desc("Decorators are used for things like tall grass, bisected flowers, and even kelp or cactus (random heights)")
private KList<IrisDecorator> decorators = new KList<>();
@ArrayType(min = 1, type = IrisObjectPlacement.class)
@Desc("Objects define what schematics (iob files) iris will place in this biome")
private KList<IrisObjectPlacement> objects = new KList<>();
@@ -635,23 +628,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return "biomes";
}
public IrisDecorator[] getDecoratorBucket(IrisDecorationPart part) {
return decoratorBuckets.aquire(this::buildDecoratorBuckets).getOrDefault(part, EMPTY_BUCKET);
}
private EnumMap<IrisDecorationPart, IrisDecorator[]> buildDecoratorBuckets() {
EnumMap<IrisDecorationPart, KList<IrisDecorator>> staging = new EnumMap<>(IrisDecorationPart.class);
for (IrisDecorator d : decorators) {
staging.computeIfAbsent(d.getPartOf(), k -> new KList<>()).add(d);
}
EnumMap<IrisDecorationPart, IrisDecorator[]> result = new EnumMap<>(IrisDecorationPart.class);
for (IrisDecorationPart part : IrisDecorationPart.values()) {
KList<IrisDecorator> list = staging.get(part);
result.put(part, list == null ? EMPTY_BUCKET : list.toArray(EMPTY_BUCKET));
}
return result;
}
public String getTypeName() {
return "Biome";
}
@@ -18,7 +18,7 @@
package art.arcane.iris.engine.object.world.biome;
import art.arcane.iris.engine.object.decoration.IrisDecorator;
import art.arcane.iris.engine.decorator.BiomeDecorators;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.render.RenderType;
@@ -76,13 +76,8 @@ final class IrisBiomeColorRenderer {
}
case DECORATOR_LOAD -> {
return biome.getCacheColorDecoratorLoad().aquire(() -> {
double density = 0;
for (IrisDecorator i : biome.getDecorators()) {
density += i.getChance() * Math.min(1, i.getStackMax()) * 256;
}
return Color.getHSBColor(0.41f, (float) (density / engine.getMaxBiomeDecoratorDensity()), 1f);
BiomeDecorators decorators = BiomeDecorators.of(engine);
return Color.getHSBColor(0.41f, (float) (decorators.colourLoad(biome) / decorators.busiestBiomeLoad()), 1f);
});
}
case LAYER_LOAD -> {