Merge branch 'wave2/e2'

# Conflicts:
#	src/main/java/art/arcane/iris/engine/framework/IrisStructureLocator.java
#	src/main/java/art/arcane/iris/engine/mantle/components/ObjectModule.java
#	src/main/java/art/arcane/iris/engine/object/placement/BlocksModule.java
#	src/main/java/art/arcane/iris/engine/object/placement/IrisObjectPlacement.java
#	src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimension.java
This commit is contained in:
piexel committed 2026-10-09 22:33:42 +02:00
commit cd7584b2ab
126 files changed
+4291 -2047

No files matched your search

@@ -19,6 +19,7 @@
package art.arcane.iris.engine.framework;
import art.arcane.iris.engine.framework.structure.NativeStartPlanner;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.engine.framework.structure.StructureResources;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.structure.StructureGraphCatalog;
@@ -35,7 +36,6 @@ import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
import art.arcane.iris.engine.object.structure.IrisStructureTerrain;
import art.arcane.iris.engine.object.structure.IrisStructureTerrainMode;
import art.arcane.iris.engine.object.structure.vanilla.NativeStructureSuppression;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.engine.object.structure.StructureDistribution;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
@@ -18,8 +18,8 @@
package art.arcane.iris.engine.framework.structure;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.core.pack.PackValidationIo;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.volmlib.util.json.JSONArray;
import art.arcane.volmlib.util.json.JSONObject;
import com.volmit.validation.Problem;
@@ -18,12 +18,12 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.builtin.carve.CaveProfile;
import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.UpperDimensionContext;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.mantle.MantleWriter;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfile;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
import art.arcane.iris.engine.object.world.region.IrisRegion;
@@ -67,7 +67,7 @@ public class CaveCarving {
private final Engine engine;
private final Object profileCarverLock = new Object();
private volatile Map<IrisCaveProfile, IrisCaveCarver3D> profileCarvers = new IdentityHashMap<>();
private volatile Map<CaveProfile, IrisCaveCarver3D> profileCarvers = new IdentityHashMap<>();
static {
int kernelIndex = 0;
@@ -132,7 +132,7 @@ public class CaveCarving {
private static int maxSurfaceBreakDepth(List<WeightedProfile> weightedProfiles) {
int maxDepth = 0;
for (WeightedProfile weightedProfile : weightedProfiles) {
maxDepth = Math.max(maxDepth, Math.max(0, weightedProfile.profile.getSurfaceBreakDepth()));
maxDepth = Math.max(maxDepth, Math.max(0, weightedProfile.profile.surfaceBreakDepth()));
}
return maxDepth;
}
@@ -202,11 +202,11 @@ public class CaveCarving {
private List<WeightedProfile> resolveWeightedProfiles(int chunkX, int chunkZ, IrisComplex complex, IrisDimensionCarvingResolver.State resolverState) {
BlendScratch blendScratch = BLEND_SCRATCH.get();
IrisCaveProfile[] profileField = blendScratch.profileField;
Map<IrisCaveProfile, double[]> columnProfileWeights = blendScratch.columnProfileWeights;
IdentityHashMap<IrisCaveProfile, Boolean> activeProfiles = blendScratch.activeProfiles;
List<IrisCaveProfile> profileOrder = blendScratch.profileOrder;
IrisCaveProfile[] kernelProfiles = blendScratch.kernelProfiles;
CaveProfile[] profileField = blendScratch.profileField;
Map<CaveProfile, double[]> columnProfileWeights = blendScratch.columnProfileWeights;
IdentityHashMap<CaveProfile, Boolean> activeProfiles = blendScratch.activeProfiles;
List<CaveProfile> profileOrder = blendScratch.profileOrder;
CaveProfile[] kernelProfiles = blendScratch.kernelProfiles;
double[] kernelProfileWeights = blendScratch.kernelProfileWeights;
activeProfiles.clear();
profileOrder.clear();
@@ -222,7 +222,7 @@ public class CaveCarving {
for (int kernelIndex = 0; kernelIndex < KERNEL_SIZE; kernelIndex++) {
int sampleX = centerX + KERNEL_DX[kernelIndex];
int sampleZ = centerZ + KERNEL_DZ[kernelIndex];
IrisCaveProfile profile = profileField[(sampleX * FIELD_SIZE) + sampleZ];
CaveProfile profile = profileField[(sampleX * FIELD_SIZE) + sampleZ];
if (!isProfileEnabled(profile)) {
continue;
}
@@ -245,7 +245,7 @@ public class CaveCarving {
int columnIndex = PowerOfTwoCoordinates.packLocal16(localX, localZ);
for (int profileIndex = 0; profileIndex < profileCount; profileIndex++) {
IrisCaveProfile profile = kernelProfiles[profileIndex];
CaveProfile profile = kernelProfiles[profileIndex];
double kernelWeight = kernelProfileWeights[profileIndex];
kernelProfiles[profileIndex] = null;
kernelProfileWeights[profileIndex] = 0D;
@@ -271,7 +271,7 @@ public class CaveCarving {
}
List<WeightedProfile> columnWeightedProfiles = new ArrayList<>();
for (IrisCaveProfile profile : profileOrder) {
for (CaveProfile profile : profileOrder) {
double[] weights = columnProfileWeights.get(profile);
if (weights == null) {
continue;
@@ -319,8 +319,8 @@ public class CaveCarving {
IrisDimensionCarvingEntry[] columnPlan = dimensionColumnPlans.computeIfAbsent(entry, key -> new IrisDimensionCarvingEntry[CHUNK_AREA]);
buildDimensionColumnPlan(columnPlan, chunkX, chunkZ, entry, resolverState);
Map<IrisCaveProfile, double[]> rootProfileColumnWeights = new IdentityHashMap<>();
List<IrisCaveProfile> rootProfileOrder = new ArrayList<>();
Map<CaveProfile, double[]> rootProfileColumnWeights = new IdentityHashMap<>();
List<CaveProfile> rootProfileOrder = new ArrayList<>();
IrisRange worldYRange = entry.getWorldYRange();
for (int columnIndex = 0; columnIndex < CHUNK_AREA; columnIndex++) {
IrisDimensionCarvingEntry resolvedEntry = columnPlan[columnIndex];
@@ -329,7 +329,7 @@ public class CaveCarving {
continue;
}
IrisCaveProfile profile = resolvedBiome.getCaveProfile();
CaveProfile profile = resolvedBiome.getCaveProfile();
if (!isProfileEnabled(profile)) {
continue;
}
@@ -343,7 +343,7 @@ public class CaveCarving {
columnWeights[columnIndex] = 1D;
}
for (IrisCaveProfile profile : rootProfileOrder) {
for (CaveProfile profile : rootProfileOrder) {
weightedProfiles.add(new WeightedProfile(profile, rootProfileColumnWeights.get(profile), -1D, worldYRange, weightedProfiles.size()));
}
}
@@ -364,7 +364,7 @@ public class CaveCarving {
}
}
private void fillProfileField(IrisCaveProfile[] profileField, int chunkX, int chunkZ, IrisComplex complex, IrisDimensionCarvingResolver.State resolverState, BlendScratch blendScratch) {
private void fillProfileField(CaveProfile[] profileField, int chunkX, int chunkZ, IrisComplex complex, IrisDimensionCarvingResolver.State resolverState, BlendScratch blendScratch) {
int startX = PowerOfTwoCoordinates.chunkToBlock(chunkX) - BLEND_RADIUS;
int startZ = PowerOfTwoCoordinates.chunkToBlock(chunkZ) - BLEND_RADIUS;
prefillProfileFieldSamples(startX, startZ, complex, blendScratch);
@@ -387,7 +387,7 @@ public class CaveCarving {
}
}
private int findProfileIndex(IrisCaveProfile[] profiles, int size, IrisCaveProfile profile) {
private int findProfileIndex(CaveProfile[] profiles, int size, CaveProfile profile) {
for (int index = 0; index < size; index++) {
if (profiles[index] == profile) {
return index;
@@ -397,7 +397,7 @@ public class CaveCarving {
return -1;
}
private IrisCaveProfile resolveColumnProfile(
private CaveProfile resolveColumnProfile(
int worldX,
int worldZ,
double surfaceHeight,
@@ -406,21 +406,21 @@ public class CaveCarving {
IrisBiome caveBiome,
IrisDimensionCarvingResolver.State resolverState
) {
IrisCaveProfile resolved = null;
IrisCaveProfile dimensionProfile = engine.getDimension().getCaveProfile();
CaveProfile resolved = null;
CaveProfile dimensionProfile = engine.getDimension().getCaveProfile();
if (isProfileEnabled(dimensionProfile)) {
resolved = dimensionProfile;
}
if (region != null) {
IrisCaveProfile regionProfile = region.getCaveProfile();
CaveProfile regionProfile = region.getCaveProfile();
if (isProfileEnabled(regionProfile)) {
resolved = regionProfile;
}
}
if (surfaceBiome != null) {
IrisCaveProfile surfaceProfile = surfaceBiome.getCaveProfile();
CaveProfile surfaceProfile = surfaceBiome.getCaveProfile();
if (isProfileEnabled(surfaceProfile)) {
resolved = surfaceProfile;
}
@@ -455,7 +455,7 @@ public class CaveCarving {
}
}
IrisCaveProfile caveProfile = effectiveCaveBiome.getCaveProfile();
CaveProfile caveProfile = effectiveCaveBiome.getCaveProfile();
if (isProfileEnabled(caveProfile)) {
resolved = caveProfile;
}
@@ -499,7 +499,7 @@ public class CaveCarving {
}
}
private IrisCaveCarver3D getCarver(IrisCaveProfile profile) {
private IrisCaveCarver3D getCarver(CaveProfile profile) {
IrisCaveCarver3D carver = profileCarvers.get(profile);
if (carver != null) {
return carver;
@@ -512,15 +512,15 @@ public class CaveCarving {
return published;
}
Map<IrisCaveProfile, IrisCaveCarver3D> updated = new IdentityHashMap<>(profileCarvers);
Map<CaveProfile, IrisCaveCarver3D> updated = new IdentityHashMap<>(profileCarvers);
updated.put(profile, createdCarver);
profileCarvers = updated;
return createdCarver;
}
}
private boolean isProfileEnabled(IrisCaveProfile profile) {
return profile != null && profile.isEnabled();
private boolean isProfileEnabled(CaveProfile profile) {
return profile != null && profile.enabled();
}
private int[] prepareChunkSurfaceHeights(int chunkX, int chunkZ, ChunkContext context, int[] scratch) {
@@ -656,13 +656,13 @@ public class CaveCarving {
}
private static final class WeightedProfile {
private final IrisCaveProfile profile;
private final CaveProfile profile;
private final double[] columnWeights;
private final double averageWeight;
private final IrisRange worldYRange;
private final int sequence;
private WeightedProfile(IrisCaveProfile profile, double[] columnWeights, double averageWeight, IrisRange worldYRange, int sequence) {
private WeightedProfile(CaveProfile profile, double[] columnWeights, double averageWeight, IrisRange worldYRange, int sequence) {
this.profile = profile;
this.columnWeights = columnWeights;
this.averageWeight = averageWeight;
@@ -676,13 +676,13 @@ public class CaveCarving {
}
private static final class BlendScratch {
private final IrisCaveProfile[] profileField = new IrisCaveProfile[FIELD_SIZE * FIELD_SIZE];
private final IrisCaveProfile[] kernelProfiles = new IrisCaveProfile[KERNEL_SIZE];
private final CaveProfile[] profileField = new CaveProfile[FIELD_SIZE * FIELD_SIZE];
private final CaveProfile[] kernelProfiles = new CaveProfile[KERNEL_SIZE];
private final double[] kernelProfileWeights = new double[KERNEL_SIZE];
private final IdentityHashMap<IrisCaveProfile, double[]> columnProfileWeights = new IdentityHashMap<>();
private final IdentityHashMap<CaveProfile, double[]> columnProfileWeights = new IdentityHashMap<>();
private final IdentityHashMap<IrisDimensionCarvingEntry, IrisDimensionCarvingEntry[]> dimensionColumnPlans = new IdentityHashMap<>();
private final IdentityHashMap<IrisCaveProfile, Boolean> activeProfiles = new IdentityHashMap<>();
private final List<IrisCaveProfile> profileOrder = new ArrayList<>();
private final IdentityHashMap<CaveProfile, Boolean> activeProfiles = new IdentityHashMap<>();
private final List<CaveProfile> profileOrder = new ArrayList<>();
private final double[] fieldSurfaceHeights = new double[FIELD_SIZE * FIELD_SIZE];
private final boolean[] fieldHasFluid = new boolean[FIELD_SIZE * FIELD_SIZE];
private final IrisRegion[] fieldRegions = new IrisRegion[FIELD_SIZE * FIELD_SIZE];
@@ -18,7 +18,7 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.engine.object.terrain.carving.IrisCaveFieldModule;
import art.arcane.iris.engine.object.terrain.carving.ResolvedCaveProfile;
import art.arcane.iris.engine.object.value.IrisRange;
import art.arcane.iris.util.project.noise.CNG;
@@ -32,14 +32,14 @@ final class CaveFieldModuleState {
final double minContribution;
final double maxContribution;
CaveFieldModuleState(IrisCaveFieldModule module, CNG density) {
IrisRange range = module.getVerticalRange();
CaveFieldModuleState(ResolvedCaveProfile.Module module, CNG density) {
IrisRange range = module.verticalRange();
this.density = density;
this.minY = (int) Math.floor(range.getMin());
this.maxY = (int) Math.ceil(range.getMax());
this.weight = module.getWeight();
this.threshold = module.getThreshold();
this.invert = module.isInvert();
this.weight = module.weight();
this.threshold = module.threshold();
this.invert = module.invert();
double rawMin = invert ? threshold - 1D : -1D - threshold;
double rawMax = invert ? threshold + 1D : 1D - threshold;
this.minContribution = rawMin * weight;
@@ -18,6 +18,10 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.engine.object.terrain.floating.FloatingChildren;
import art.arcane.iris.builtin.floating.FloatingChildBiome;
import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.IrisComplex;
@@ -28,12 +32,10 @@ import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
import art.arcane.iris.engine.object.placement.FloatingObjectFootprint;
import art.arcane.iris.engine.object.placement.IObjectPlacer;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
@@ -47,6 +49,7 @@ import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -91,10 +94,10 @@ public class FloatingObjectPlacing {
// The IdentityHashMaps are lookup indices only. Iteration MUST follow the encounter
// order of the deterministic 0..255 column scan: identity-hash order changes per JVM
// run, and the shared chunkRng makes placement output depend on iteration order.
IdentityHashMap<IrisFloatingChildBiomes, KList<Integer>> entryColumns = new IdentityHashMap<>();
IdentityHashMap<IrisFloatingChildBiomes, KList<Integer>> bottomEntryColumns = new IdentityHashMap<>();
KList<IrisFloatingChildBiomes> entryOrder = new KList<>();
KList<IrisFloatingChildBiomes> bottomEntryOrder = new KList<>();
IdentityHashMap<ResolvedFloatingChild, KList<Integer>> entryColumns = new IdentityHashMap<>();
IdentityHashMap<ResolvedFloatingChild, KList<Integer>> bottomEntryColumns = new IdentityHashMap<>();
KList<ResolvedFloatingChild> entryOrder = new KList<>();
KList<ResolvedFloatingChild> bottomEntryOrder = new KList<>();
for (int i = 0; i < 256; i++) {
FloatingIslandSample s = samples[i];
if (s == null || s.entry == null) {
@@ -104,7 +107,7 @@ public class FloatingObjectPlacing {
entryOrder.add(e);
return new KList<>();
}).add(i);
IrisFloatingChildBiomes bottomEntry = s.bottomEntry();
ResolvedFloatingChild bottomEntry = s.bottomEntry();
if (bottomEntry != null) {
bottomEntryColumns.computeIfAbsent(bottomEntry, e -> {
bottomEntryOrder.add(e);
@@ -113,7 +116,7 @@ public class FloatingObjectPlacing {
}
}
for (IrisFloatingChildBiomes entry : entryOrder) {
for (ResolvedFloatingChild entry : entryOrder) {
KList<Integer> columns = entryColumns.get(entry);
if (columns.isEmpty()) {
continue;
@@ -123,7 +126,7 @@ public class FloatingObjectPlacing {
IrisBiome parent = sampleResolver.parent(minX + (firstKey & 15), minZ + (firstKey >> 4));
IrisBiome target = entry.getRealBiome(parent, data);
KList<IrisObjectPlacement> floating = entry.getFloatingObjects();
KList<IrisObjectPlacement> floating = new KList<>(entry.settings().floatingObjects());
if (floating != null && !floating.isEmpty()) {
for (IrisObjectPlacement placement : floating) {
tryPlaceFloatingChunk(writer, complex, chunkRng, data, placement, columns, minX, minZ, entry);
@@ -131,7 +134,7 @@ public class FloatingObjectPlacing {
}
KList<IrisObjectPlacement> surface = target != null ? entry.resolveTopObjects(target) : null;
KList<IrisObjectPlacement> extras = entry.getExtraObjects();
KList<IrisObjectPlacement> extras = new KList<>(entry.settings().extraObjects());
boolean hasSurface = surface != null && !surface.isEmpty();
boolean hasExtras = extras != null && !extras.isEmpty();
KList<Integer> interior = null;
@@ -150,7 +153,7 @@ public class FloatingObjectPlacing {
}
}
for (IrisFloatingChildBiomes entry : bottomEntryOrder) {
for (ResolvedFloatingChild entry : bottomEntryOrder) {
KList<Integer> columns = bottomEntryColumns.get(entry);
if (columns.isEmpty()) {
continue;
@@ -170,7 +173,7 @@ public class FloatingObjectPlacing {
}
@ChunkCoordinates
private void tryPlaceFloatingChunk(MantleWriter writer, IrisComplex complex, RNG rng, IrisData data, IrisObjectPlacement placement, KList<Integer> columns, int minX, int minZ, IrisFloatingChildBiomes entry) {
private void tryPlaceFloatingChunk(MantleWriter writer, IrisComplex complex, RNG rng, IrisData data, IrisObjectPlacement placement, KList<Integer> columns, int minX, int minZ, ResolvedFloatingChild entry) {
if (placement == null || columns == null || columns.isEmpty()) {
return;
}
@@ -216,7 +219,7 @@ public class FloatingObjectPlacing {
}
@ChunkCoordinates
private void tryPlaceAnchoredChunk(MantleWriter writer, IrisComplex complex, RNG rng, IrisData data, IrisObjectPlacement placement, FloatingIslandSample[] samples, IslandObjectPlacer.SampleProvider sampleProvider, KList<Integer> columns, KList<Integer> interior, int minX, int minZ, IrisFloatingChildBiomes entry) {
private void tryPlaceAnchoredChunk(MantleWriter writer, IrisComplex complex, RNG rng, IrisData data, IrisObjectPlacement placement, FloatingIslandSample[] samples, IslandObjectPlacer.SampleProvider sampleProvider, KList<Integer> columns, KList<Integer> interior, int minX, int minZ, ResolvedFloatingChild entry) {
if (placement == null || columns.isEmpty()) {
return;
}
@@ -301,7 +304,7 @@ public class FloatingObjectPlacing {
}
@ChunkCoordinates
private void tryPlaceInvertedChunk(MantleWriter writer, IrisComplex complex, RNG rng, IrisData data, IrisObjectPlacement placement, FloatingIslandSample[] samples, IslandObjectPlacer.SampleProvider sampleProvider, KList<Integer> columns, KList<Integer> interior, int minX, int minZ, IrisFloatingChildBiomes entry) {
private void tryPlaceInvertedChunk(MantleWriter writer, IrisComplex complex, RNG rng, IrisData data, IrisObjectPlacement placement, FloatingIslandSample[] samples, IslandObjectPlacer.SampleProvider sampleProvider, KList<Integer> columns, KList<Integer> interior, int minX, int minZ, ResolvedFloatingChild entry) {
if (placement == null || columns.isEmpty()) {
return;
}
@@ -405,7 +408,7 @@ public class FloatingObjectPlacing {
static boolean isFootprintFlatBottom(FloatingObjectFootprint fp, IrisObjectRotation rotation,
int pickedX, int pickedZ, int pickBottomY,
IslandObjectPlacer.SampleProvider samples,
IrisFloatingChildBiomes entry, int tolerance) {
ResolvedFloatingChild entry, int tolerance) {
IrisBlockVector anchor = invertedFootprintAnchor(fp, rotation);
long[] cells = fp.footprintXZ();
if (cells.length == 0) {
@@ -475,7 +478,7 @@ public class FloatingObjectPlacing {
static boolean isFootprintFlat(FloatingObjectFootprint fp, int pickedX, int pickedZ, int pickTopY,
IslandObjectPlacer.SampleProvider samples,
IrisFloatingChildBiomes entry, int tolerance) {
ResolvedFloatingChild entry, int tolerance) {
int tallestKx = fp.getTallestKx();
int tallestKz = fp.getTallestKz();
long[] cells = fp.footprintXZ();
@@ -499,7 +502,7 @@ public class FloatingObjectPlacing {
private static KList<Integer> interiorColumns(IslandObjectPlacer.SampleProvider samples,
KList<Integer> columns, int minX, int minZ,
IrisFloatingChildBiomes entry,
ResolvedFloatingChild entry,
IslandObjectPlacer.AnchorFace face) {
KList<Integer> interior = new KList<>();
for (int key : columns) {
@@ -554,15 +557,15 @@ public class FloatingObjectPlacing {
try {
IrisData data = engine.getData();
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
KList<IrisFloatingChildBiomes> entries = biome.getFloatingChildBiomes();
if (entries == null || entries.isEmpty()) {
List<FloatingChildBiome> settings = biome.getFloatingChildBiomes();
if (settings == null || settings.isEmpty()) {
continue;
}
for (IrisFloatingChildBiomes entry : entries) {
maxObjectExtent = Math.max(maxObjectExtent, computePlacementRadius(entry.getFloatingObjects(), data, sizeCache, warnedLargeObjects));
maxObjectExtent = Math.max(maxObjectExtent, computePlacementRadius(entry.getExtraObjects(), data, sizeCache, warnedLargeObjects));
maxObjectExtent = Math.max(maxObjectExtent, computePlacementRadius(entry.getTopObjectOverrides(), data, sizeCache, warnedLargeObjects));
maxObjectExtent = Math.max(maxObjectExtent, computePlacementRadius(entry.getBottomObjectOverrides(), data, sizeCache, warnedLargeObjects));
for (ResolvedFloatingChild entry : FloatingChildren.of(engine).of(settings)) {
maxObjectExtent = Math.max(maxObjectExtent, computePlacementRadius(new KList<>(entry.settings().floatingObjects()), data, sizeCache, warnedLargeObjects));
maxObjectExtent = Math.max(maxObjectExtent, computePlacementRadius(new KList<>(entry.settings().extraObjects()), data, sizeCache, warnedLargeObjects));
maxObjectExtent = Math.max(maxObjectExtent, computePlacementRadius(new KList<>(entry.settings().topObjectOverrides()), data, sizeCache, warnedLargeObjects));
maxObjectExtent = Math.max(maxObjectExtent, computePlacementRadius(new KList<>(entry.settings().bottomObjectOverrides()), data, sizeCache, warnedLargeObjects));
try {
IrisBiome target = entry.getRealBiome(biome, data);
if (target != null) {
@@ -18,11 +18,11 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.builtin.carve.CaveProfile;
import art.arcane.iris.engine.object.terrain.carving.ResolvedCaveProfile;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.mantle.MantleWriter;
import art.arcane.iris.engine.object.terrain.carving.IrisCaveFieldModule;
import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfile;
import art.arcane.iris.engine.object.value.IrisRange;
import art.arcane.iris.engine.object.noise.IrisStyledRange;
import art.arcane.iris.util.project.noise.CNG;
@@ -53,7 +53,8 @@ public class IrisCaveCarver3D {
private final Engine engine;
private final IrisData data;
private final IrisCaveProfile profile;
private final CaveProfile profile;
private final ResolvedCaveProfile resolved;
private final CNG baseDensity;
private final CNG detailDensity;
private final CNG warpDensity;
@@ -81,10 +82,11 @@ public class IrisCaveCarver3D {
private final int aquiferCeilingY;
private final ThreadLocal<CaveCarveScratch> scratchCache = ThreadLocal.withInitial(CaveCarveScratch::new);
public IrisCaveCarver3D(Engine engine, IrisCaveProfile profile) {
public IrisCaveCarver3D(Engine engine, CaveProfile profile) {
this.engine = engine;
this.data = engine.getData();
this.profile = profile;
this.resolved = ResolvedCaveProfile.of(profile);
this.carveAir = new MatterCavern(true, "", LIQUID_AIR);
this.carveFluid = new MatterCavern(true, "", LIQUID_FLUID);
this.carveLava = new MatterCavern(true, "", LIQUID_LAVA);
@@ -92,26 +94,26 @@ public class IrisCaveCarver3D {
List<CaveFieldModuleState> moduleStates = new ArrayList<>();
RNG baseRng = new RNG(engine.getSeedManager().getCarve());
this.baseDensity = profile.getBaseDensityStyle().create(baseRng.nextParallelRNG(934_447), data);
this.detailDensity = profile.getDetailDensityStyle().create(baseRng.nextParallelRNG(612_991), data);
this.warpDensity = profile.getWarpStyle().create(baseRng.nextParallelRNG(770_713), data);
this.surfaceBreakDensity = profile.getSurfaceBreakStyle().create(baseRng.nextParallelRNG(341_219), data);
this.baseDensity = resolved.baseDensityStyle().create(baseRng.nextParallelRNG(934_447), data);
this.detailDensity = resolved.detailDensityStyle().create(baseRng.nextParallelRNG(612_991), data);
this.warpDensity = resolved.warpStyle().create(baseRng.nextParallelRNG(770_713), data);
this.surfaceBreakDensity = resolved.surfaceBreakStyle().create(baseRng.nextParallelRNG(341_219), data);
this.thresholdRng = baseRng.nextParallelRNG(489_112);
this.baseWeight = profile.getBaseWeight();
this.detailWeight = profile.getDetailWeight();
this.warpStrength = profile.getWarpStrength();
this.baseWeight = profile.baseWeight();
this.detailWeight = profile.detailWeight();
this.warpStrength = profile.warpStrength();
this.hasWarp = this.warpStrength > 0D;
this.warpResolution = 2;
this.allowFluid = profile.isAllowFluid();
this.fluidRequiresFloor = profile.isFluidRequiresFloor();
this.fluidMinDepthBelowSurface = Math.max(0, profile.getFluidMinDepthBelowSurface());
this.allowFluid = profile.allowFluid();
this.fluidRequiresFloor = profile.fluidRequiresFloor();
this.fluidMinDepthBelowSurface = Math.max(0, profile.fluidMinDepthBelowSurface());
this.fluidHeight = engine.getDimension().getFluidHeight();
this.aquiferCeilingY = engine.getHeight() - 1;
double weight = Math.abs(baseWeight) + Math.abs(detailWeight);
int index = 0;
for (IrisCaveFieldModule module : profile.getModules()) {
CNG moduleDensity = module.getStyle().create(baseRng.nextParallelRNG(1_000_003L + (index * 65_537L)), data);
for (ResolvedCaveProfile.Module module : resolved.modules()) {
CNG moduleDensity = module.style().create(baseRng.nextParallelRNG(1_000_003L + (index * 65_537L)), data);
CaveFieldModuleState state = new CaveFieldModuleState(module, moduleDensity);
moduleStates.add(state);
weight += Math.abs(state.weight);
@@ -217,7 +219,7 @@ public class IrisCaveCarver3D {
double resolvedMinWeight = Math.max(0D, Math.min(1D, minWeight));
double resolvedThresholdPenalty = Math.max(0D, thresholdPenalty);
int worldHeight = writer.getMantle().getWorldHeight();
IrisRange effectiveVerticalRange = overrideVerticalRange != null ? overrideVerticalRange : profile.getVerticalRange();
IrisRange effectiveVerticalRange = overrideVerticalRange != null ? overrideVerticalRange : resolved.verticalRange();
int minY = Math.max(0, (int) Math.floor(effectiveVerticalRange.getMin()));
int maxY = Math.min(worldHeight - 1, (int) Math.ceil(effectiveVerticalRange.getMax()));
if (worldYRange != null) {
@@ -227,16 +229,16 @@ public class IrisCaveCarver3D {
minY = Math.max(minY, rangeMinY);
maxY = Math.min(maxY, rangeMaxY);
}
int sampleStep = Math.max(1, profile.getSampleStep());
int sampleStep = Math.max(1, profile.sampleStep());
boolean exactSampling = sampleStep <= 2;
boolean adaptiveSampling = exactSampling && profile.isAdaptiveSampling();
int adaptiveSampleStep = Math.max(2, profile.getAdaptiveSampleStep());
double adaptiveThresholdMargin = Math.max(0D, profile.getAdaptiveThresholdMargin());
int surfaceClearance = Math.max(0, profile.getSurfaceClearance());
int surfaceBreakDepth = Math.max(0, profile.getSurfaceBreakDepth());
double surfaceBreakNoiseThreshold = profile.getSurfaceBreakNoiseThreshold();
double surfaceBreakThresholdBoost = Math.max(0, profile.getSurfaceBreakThresholdBoost());
boolean allowSurfaceBreak = profile.isAllowSurfaceBreak();
boolean adaptiveSampling = exactSampling && profile.adaptiveSampling();
int adaptiveSampleStep = Math.max(2, profile.adaptiveSampleStep());
double adaptiveThresholdMargin = Math.max(0D, profile.adaptiveThresholdMargin());
int surfaceClearance = Math.max(0, profile.surfaceClearance());
int surfaceBreakDepth = Math.max(0, profile.surfaceBreakDepth());
double surfaceBreakNoiseThreshold = profile.surfaceBreakNoiseThreshold();
double surfaceBreakThresholdBoost = Math.max(0, profile.surfaceBreakThresholdBoost());
boolean allowSurfaceBreak = profile.allowSurfaceBreak();
if (maxY < minY) {
return 0;
}
@@ -263,10 +265,10 @@ public class IrisCaveCarver3D {
// IrisStyledRange.get() resolves its CNG per call, which costs a cache-key allocation,
// a capturing lambda and a shared LRU touch. The CNG is constant for (thresholdRng, data),
// so resolve it once here and replicate the min==max / isFlat short circuits verbatim.
IrisStyledRange densityThreshold = profile.getDensityThreshold();
IrisStyledRange densityThreshold = resolved.densityThreshold();
double thresholdMin = densityThreshold.getMin();
double thresholdMax = densityThreshold.getMax();
double thresholdBias = profile.getThresholdBias();
double thresholdBias = profile.thresholdBias();
CNG thresholdDensity = null;
double constantThreshold = 0D;
if (thresholdMin == thresholdMax) {
@@ -2180,7 +2182,7 @@ public class IrisCaveCarver3D {
}
MatterCavern[] matterByY = scratch.matterByY;
boolean allowLava = profile.isAllowLava();
boolean allowLava = profile.allowLava();
int lavaHeight = engine.getDimension().getCaveLavaHeight();
for (int y = minY; y <= maxY; y++) {
@@ -2354,8 +2356,8 @@ public class IrisCaveCarver3D {
}
double[] verticalEdgeFade = scratch.verticalEdgeFade;
int fadeRange = Math.max(0, profile.getVerticalEdgeFade());
double fadeStrength = Math.max(0D, profile.getVerticalEdgeFadeStrength());
int fadeRange = Math.max(0, profile.verticalEdgeFade());
double fadeStrength = Math.max(0D, profile.verticalEdgeFadeStrength());
if (size <= 0 || fadeRange <= 0 || maxY <= minY || fadeStrength <= 0D) {
Arrays.fill(verticalEdgeFade, 0, size, 0D);
return verticalEdgeFade;
@@ -18,12 +18,12 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.mantle.MantleWriter;
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
import art.arcane.iris.engine.object.placement.IObjectPlacer;
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
import art.arcane.iris.engine.object.prefab.TileData;
import art.arcane.iris.spi.PlatformBlockState;
import org.jetbrains.annotations.Nullable;
@@ -34,7 +34,7 @@ public final class IslandObjectPlacer implements IObjectPlacer {
private final MantleWriter wrapped;
private final SampleProvider samples;
private final IrisFloatingChildBiomes entry;
private final ResolvedFloatingChild entry;
private final int anchorY;
private final AnchorFace face;
@@ -47,12 +47,12 @@ public final class IslandObjectPlacer implements IObjectPlacer {
}
public static IslandObjectPlacer top(MantleWriter wrapped, SampleProvider samples,
IrisFloatingChildBiomes entry, int anchorY) {
ResolvedFloatingChild entry, int anchorY) {
return new IslandObjectPlacer(wrapped, new AnchorSettings(samples, entry, anchorY, AnchorFace.TOP));
}
public static IslandObjectPlacer bottom(MantleWriter wrapped, SampleProvider samples,
IrisFloatingChildBiomes entry, int anchorY) {
ResolvedFloatingChild entry, int anchorY) {
return new IslandObjectPlacer(wrapped, new AnchorSettings(samples, entry, anchorY, AnchorFace.BOTTOM));
}
@@ -157,7 +157,7 @@ public final class IslandObjectPlacer implements IObjectPlacer {
return wrapped == null ? null : wrapped.getEngine();
}
static boolean matchesAnchor(FloatingIslandSample sample, IrisFloatingChildBiomes entry, AnchorFace face) {
static boolean matchesAnchor(FloatingIslandSample sample, ResolvedFloatingChild entry, AnchorFace face) {
if (sample == null) {
return false;
}
@@ -212,7 +212,7 @@ public final class IslandObjectPlacer implements IObjectPlacer {
private record AnchorSettings(
SampleProvider samples,
IrisFloatingChildBiomes entry,
ResolvedFloatingChild entry,
int anchorY,
AnchorFace face
) {
@@ -19,6 +19,14 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.objects.coral.Coral;
import art.arcane.iris.builtin.objects.crystal.Crystal;
import art.arcane.iris.builtin.objects.formation.Formation;
import art.arcane.iris.builtin.objects.fungi.Fungus;
import art.arcane.iris.builtin.objects.ruin.Ruin;
import art.arcane.iris.builtin.objects.tree.TreeCanopy;
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.engine.framework.Engine;
@@ -55,6 +63,14 @@ public final class ObjectModule implements IrisModule {
public void register(FeatureRegistry registry) {
registry.registerService(ObjectsAt.class, new ObjectLocating());
registry.registerService(SaplingGrowth.class, new TreeGrowing());
registry.registerHeldType(TreeCanopy.class);
registry.registerHeldType(TreeDecorator.class);
registry.registerHeldType(TreeSecondaryLeaf.class);
registry.registerHeldType(Coral.class);
registry.registerHeldType(Crystal.class);
registry.registerHeldType(Formation.class);
registry.registerHeldType(Fungus.class);
registry.registerHeldType(Ruin.class);
}
private static void place(MantleStageContext context) {
@@ -19,6 +19,11 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.carve.CaveAnchorMode;
import art.arcane.iris.builtin.carve.CaveProfile;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.placement.IrisObjectVacuum;
import art.arcane.iris.core.IrisSettings;
@@ -29,13 +34,9 @@ import art.arcane.iris.engine.UpperDimensionContext;
import art.arcane.iris.engine.mantle.MantleWriter;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.TreeBlockMaterial;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
import art.arcane.iris.engine.object.placement.DecayControlPlacer;
import art.arcane.iris.engine.object.placement.IObjectPlacer;
import art.arcane.iris.engine.object.prefab.IrisAxisRotationClamp;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.terrain.carving.IrisCaveAnchorMode;
import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfile;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
@@ -44,7 +45,6 @@ import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.collection.KMap;
@@ -234,8 +234,8 @@ public class ObjectPlacing {
int rejected = 0;
int nullObjects = 0;
int errors = 0;
IrisCaveProfile biomeCaveProfile = resolveCaveProfile(caveBiome.getCaveProfile(), region.getCaveProfile());
IrisCaveProfile regionCaveProfile = resolveCaveProfile(region.getCaveProfile(), caveBiome.getCaveProfile());
CaveProfile biomeCaveProfile = resolveCaveProfile(caveBiome.getCaveProfile(), region.getCaveProfile());
CaveProfile regionCaveProfile = resolveCaveProfile(region.getCaveProfile(), caveBiome.getCaveProfile());
CaveAnchorCache caveAnchorCache = new CaveAnchorCache();
for (IrisObjectPlacement i : surfaceBiome.getSurfaceObjects()) {
@@ -383,12 +383,12 @@ public class ObjectPlacing {
@ChunkCoordinates
private void placeProceduralObjects(MantleWriter writer, RNG rng, int x, int z, IrisBiome surfaceBiome, IrisBiome caveBiome, IrisRegion region) {
IrisCaveProfile surfaceCaveProfile = resolveCaveProfile(surfaceBiome.getCaveProfile(), region.getCaveProfile());
IrisCaveProfile regionCaveProfile = resolveCaveProfile(region.getCaveProfile(), caveBiome == null ? null : caveBiome.getCaveProfile());
CaveProfile surfaceCaveProfile = resolveCaveProfile(surfaceBiome.getCaveProfile(), region.getCaveProfile());
CaveProfile regionCaveProfile = resolveCaveProfile(region.getCaveProfile(), caveBiome == null ? null : caveBiome.getCaveProfile());
placeProceduralFrom(writer, rng, x, z, surfaceBiome.getProceduralObjects(), surfaceBiome.getName(), surfaceCaveProfile, surfaceBiome.getLoadKey());
placeProceduralFrom(writer, rng, x, z, region.getProceduralObjects(), region.getName(), regionCaveProfile, null);
if (caveBiome != null && caveBiome != surfaceBiome) {
IrisCaveProfile caveProfile = resolveCaveProfile(caveBiome.getCaveProfile(), region.getCaveProfile());
CaveProfile caveProfile = resolveCaveProfile(caveBiome.getCaveProfile(), region.getCaveProfile());
placeProceduralFrom(writer, rng, x, z, caveBiome.getProceduralObjects(), caveBiome.getName(), caveProfile, caveBiome.getLoadKey());
}
}
@@ -401,7 +401,7 @@ public class ObjectPlacing {
int z,
IrisProceduralObjects proceduralObjects,
String scope,
IrisCaveProfile caveProfile,
CaveProfile caveProfile,
String expectedCaveBiomeKey
) {
if (proceduralObjects == null || proceduralObjects.isEmpty()) {
@@ -427,9 +427,9 @@ public class ObjectPlacing {
IrisObjectPlacement placement = p.asPlacement();
boolean carving = placement.getCarvingSupport() == CarvingMode.CARVING_ONLY;
IrisCaveAnchorMode anchorMode = resolveAnchorMode(placement, caveProfile);
CaveAnchorMode anchorMode = resolveAnchorMode(placement, caveProfile);
if (placement.getMode() == ObjectPlaceMode.CEILING_HANG) {
anchorMode = IrisCaveAnchorMode.CEILING;
anchorMode = CaveAnchorMode.CEILING;
}
int anchorScanStep = resolveAnchorScanStep(caveProfile);
int minDepthBelowSurface = resolveObjectMinDepthBelowSurface(caveProfile);
@@ -558,7 +558,7 @@ public class ObjectPlacing {
RNG rng,
int minX,
int minZ,
IrisCaveAnchorMode anchorMode,
CaveAnchorMode anchorMode,
int anchorScanStep,
int minDepthBelowSurface,
int searchAttempts,
@@ -774,7 +774,7 @@ public class ObjectPlacing {
int chunkX,
int chunkZ,
IrisObjectPlacement objectPlacement,
IrisCaveProfile caveProfile,
CaveProfile caveProfile,
IrisComplex complex,
boolean traceRegen,
int metricChunkX,
@@ -791,9 +791,9 @@ public class ObjectPlacing {
int minX = chunkX << 4;
int minZ = chunkZ << 4;
int density = objectPlacement.getDensity(rng, minX, minZ, engine.getData());
IrisCaveAnchorMode anchorMode = resolveAnchorMode(objectPlacement, caveProfile);
CaveAnchorMode anchorMode = resolveAnchorMode(objectPlacement, caveProfile);
if (objectPlacement.getMode() == ObjectPlaceMode.CEILING_HANG) {
anchorMode = IrisCaveAnchorMode.CEILING;
anchorMode = CaveAnchorMode.CEILING;
}
int anchorScanStep = resolveAnchorScanStep(caveProfile);
int objectMinDepthBelowSurface = resolveObjectMinDepthBelowSurface(caveProfile);
@@ -1092,9 +1092,9 @@ public class ObjectPlacing {
private IrisObjectRotation buildUpsideDownRotation() {
IrisObjectRotation rt = new IrisObjectRotation();
rt.setEnabled(true);
rt.setXAxis(new IrisAxisRotationClamp(true, true, 180D, 180D, 90D));
rt.setYAxis(new IrisAxisRotationClamp(true, false, 0D, 0D, 90D));
rt.setZAxis(new IrisAxisRotationClamp());
rt.setXAxis(AxisRotationClamp.of(true, true, 180D, 180D, 90D));
rt.setYAxis(AxisRotationClamp.of(true, false, 0D, 0D, 90D));
rt.setZAxis(new AxisRotationClamp());
return rt;
}
@@ -1107,7 +1107,7 @@ public class ObjectPlacing {
IrisObject object,
int densityIndex,
int density,
IrisCaveAnchorMode anchorMode,
CaveAnchorMode anchorMode,
int anchorSearchAttempts,
int anchorScanStep,
int objectMinDepthBelowSurface,
@@ -1208,13 +1208,13 @@ public class ObjectPlacing {
return effectivePlacement;
}
private IrisObjectPlacement resolveCavePlacement(IrisObjectPlacement objectPlacement, IrisObject object, IrisCaveProfile caveProfile) {
private IrisObjectPlacement resolveCavePlacement(IrisObjectPlacement objectPlacement, IrisObject object, CaveProfile caveProfile) {
IrisObjectPlacement resolvedPlacement = resolveEffectivePlacement(objectPlacement, object);
if (resolvedPlacement.getMode() != ObjectPlaceMode.CENTER_HEIGHT || caveProfile == null) {
return resolvedPlacement;
}
ObjectPlaceMode profileMode = caveProfile.getDefaultObjectPlaceMode();
ObjectPlaceMode profileMode = caveProfile.defaultObjectPlaceMode().orElse(null);
if (profileMode == null) {
return resolvedPlacement;
}
@@ -1237,7 +1237,7 @@ public class ObjectPlacing {
return maxAnchorY + 1;
}
private int findCaveAnchorY(MantleWriter writer, RNG rng, int x, int z, IrisCaveAnchorMode anchorMode, int anchorScanStep, int objectMinDepthBelowSurface, CaveAnchorCache anchorCache) {
private int findCaveAnchorY(MantleWriter writer, RNG rng, int x, int z, CaveAnchorMode anchorMode, int anchorScanStep, int objectMinDepthBelowSurface, CaveAnchorCache anchorCache) {
KList<Integer> anchors = anchorCache.get(writer, anchorMode, anchorScanStep, objectMinDepthBelowSurface, x, z);
if (anchors.isEmpty()) {
return -1;
@@ -1250,7 +1250,7 @@ public class ObjectPlacing {
return anchors.get(rng.i(anchors.size()));
}
private KList<Integer> scanCaveAnchorColumn(MantleWriter writer, IrisCaveAnchorMode anchorMode, int anchorScanStep, int objectMinDepthBelowSurface, int x, int z, CaveAnchorCache anchorCache) {
private KList<Integer> scanCaveAnchorColumn(MantleWriter writer, CaveAnchorMode anchorMode, int anchorScanStep, int objectMinDepthBelowSurface, int x, int z, CaveAnchorCache anchorCache) {
int height = engine.getHeight();
int step = Math.max(1, anchorScanStep);
int surfaceY = anchorCache.getSurfaceHeight(x, z);
@@ -1264,7 +1264,7 @@ public class ObjectPlacing {
return scanCaveAnchorRange(anchorMode, step, carvedHeight, BEDROCK_CLEARANCE, maxAnchorExclusive, carvedColumn);
}
private KList<Integer> scanCaveAnchorRange(IrisCaveAnchorMode anchorMode, int step, int height, int minAnchorY, int maxAnchorY, byte[] carvedColumn) {
private KList<Integer> scanCaveAnchorRange(CaveAnchorMode anchorMode, int step, int height, int minAnchorY, int maxAnchorY, byte[] carvedColumn) {
KList<Integer> anchors = new KList<>();
int startY = alignAnchorScanStart(minAnchorY, step);
for (int y = startY; y < maxAnchorY; y += step) {
@@ -1308,7 +1308,7 @@ public class ObjectPlacing {
return false;
}
private boolean matchesCaveAnchor(IrisCaveAnchorMode anchorMode, boolean solidBelow, boolean solidAbove) {
private boolean matchesCaveAnchor(CaveAnchorMode anchorMode, boolean solidBelow, boolean solidAbove) {
return switch (anchorMode) {
case PROFILE_DEFAULT, FLOOR -> solidBelow;
case CEILING -> solidAbove;
@@ -1317,13 +1317,13 @@ public class ObjectPlacing {
};
}
private IrisCaveProfile resolveCaveProfile(IrisCaveProfile preferred, IrisCaveProfile secondary) {
IrisCaveProfile dimensionProfile = engine.getDimension().getCaveProfile();
if (preferred != null && preferred.isEnabled()) {
private CaveProfile resolveCaveProfile(CaveProfile preferred, CaveProfile secondary) {
CaveProfile dimensionProfile = engine.getDimension().getCaveProfile();
if (preferred != null && preferred.enabled()) {
return preferred;
}
if (secondary != null && secondary.isEnabled()) {
if (secondary != null && secondary.enabled()) {
return secondary;
}
@@ -1331,49 +1331,49 @@ public class ObjectPlacing {
return dimensionProfile;
}
return new IrisCaveProfile();
return new CaveProfile();
}
private IrisCaveAnchorMode resolveAnchorMode(IrisObjectPlacement objectPlacement, IrisCaveProfile caveProfile) {
IrisCaveAnchorMode placementMode = objectPlacement.getCaveAnchorMode();
if (placementMode != null && !placementMode.equals(IrisCaveAnchorMode.PROFILE_DEFAULT)) {
private CaveAnchorMode resolveAnchorMode(IrisObjectPlacement objectPlacement, CaveProfile caveProfile) {
CaveAnchorMode placementMode = objectPlacement.getCaveAnchorMode();
if (placementMode != null && !placementMode.equals(CaveAnchorMode.PROFILE_DEFAULT)) {
return placementMode;
}
if (caveProfile == null) {
return IrisCaveAnchorMode.FLOOR;
return CaveAnchorMode.FLOOR;
}
IrisCaveAnchorMode profileMode = caveProfile.getDefaultObjectAnchor();
if (profileMode == null || profileMode.equals(IrisCaveAnchorMode.PROFILE_DEFAULT)) {
return IrisCaveAnchorMode.FLOOR;
CaveAnchorMode profileMode = caveProfile.defaultObjectAnchor();
if (profileMode == null || profileMode.equals(CaveAnchorMode.PROFILE_DEFAULT)) {
return CaveAnchorMode.FLOOR;
}
return profileMode;
}
private int resolveAnchorScanStep(IrisCaveProfile caveProfile) {
private int resolveAnchorScanStep(CaveProfile caveProfile) {
if (caveProfile == null) {
return 1;
}
return Math.max(1, caveProfile.getAnchorScanStep());
return Math.max(1, caveProfile.anchorScanStep());
}
private int resolveObjectMinDepthBelowSurface(IrisCaveProfile caveProfile) {
private int resolveObjectMinDepthBelowSurface(CaveProfile caveProfile) {
if (caveProfile == null) {
return 6;
}
return Math.max(0, caveProfile.getObjectMinDepthBelowSurface());
return Math.max(0, caveProfile.objectMinDepthBelowSurface());
}
private int resolveAnchorSearchAttempts(IrisCaveProfile caveProfile) {
private int resolveAnchorSearchAttempts(CaveProfile caveProfile) {
if (caveProfile == null) {
return 6;
}
return Math.max(1, caveProfile.getAnchorSearchAttempts());
return Math.max(1, caveProfile.anchorSearchAttempts());
}
private boolean isRegenTraceThread() {
@@ -1542,8 +1542,8 @@ public class ObjectPlacing {
int height = scaledDimension(size.getBlockY(), scale);
int depth = scaledDimension(size.getBlockZ(), scale);
IrisObjectRotation rotation = placement.getRotation();
boolean rotateX = rotation != null && rotation.isEnabled() && rotation.getXAxis() != null && rotation.getXAxis().isEnabled();
boolean rotateZ = rotation != null && rotation.isEnabled() && rotation.getZAxis() != null && rotation.getZAxis().isEnabled();
boolean rotateX = rotation != null && rotation.isEnabled() && rotation.getXAxis() != null && rotation.getXAxis().enabled();
boolean rotateZ = rotation != null && rotation.isEnabled() && rotation.getZAxis() != null && rotation.getZAxis().enabled();
int footprint = rotateX || rotateZ ? Math.max(width, Math.max(height, depth)) : Math.max(width, depth);
int translation = calculateTranslationReach(placement.getTranslate(), rotation, rotateX || rotateZ);
int warp = placement.getWarp() != null && !placement.getWarp().isFlat()
@@ -1574,7 +1574,7 @@ public class ObjectPlacing {
if (rotateVertically) {
return (int) Math.ceil(Math.sqrt((x * x) + (y * y) + (z * z)));
}
boolean rotateY = rotation != null && rotation.isEnabled() && rotation.getYAxis() != null && rotation.getYAxis().isEnabled();
boolean rotateY = rotation != null && rotation.isEnabled() && rotation.getYAxis() != null && rotation.getYAxis().enabled();
return rotateY ? (int) Math.ceil(Math.hypot(x, z)) : (int) Math.max(Math.abs(x), Math.abs(z));
}
@@ -1602,7 +1602,7 @@ public class ObjectPlacing {
this.surfaceHeights.defaultReturnValue(Integer.MIN_VALUE);
}
private KList<Integer> get(MantleWriter writer, IrisCaveAnchorMode anchorMode, int anchorScanStep, int objectMinDepthBelowSurface, int x, int z) {
private KList<Integer> get(MantleWriter writer, CaveAnchorMode anchorMode, int anchorScanStep, int objectMinDepthBelowSurface, int x, int z) {
if (anchorScanStep > 65535 || objectMinDepthBelowSurface > 65535) {
return scanCaveAnchorColumn(writer, anchorMode, anchorScanStep, objectMinDepthBelowSurface, x, z, this);
}
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.engine.framework.structure.StructureResources;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.core.IrisSettings;
@@ -34,7 +35,6 @@ import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.iris.engine.object.structure.IrisStructure;
import art.arcane.iris.engine.object.structure.IrisStructureCarveShape;
@@ -18,6 +18,9 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.carve.CaveFieldModule;
import art.arcane.iris.builtin.carve.CaveProfile;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.core.modules.IrisChunk;
import art.arcane.iris.core.modules.IrisMantleChunk;
@@ -46,6 +49,12 @@ public final class CarveModule implements IrisModule {
return ModuleInfo.of("iris:carve", "Caves", VERSION);
}
@Override
public void register(FeatureRegistry registry) {
registry.registerHeldType(CaveProfile.class);
registry.registerHeldType(CaveFieldModule.class);
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Carve.CAVES).reach(CAVE_REACH_BLOCKS).run(CarveModule::planCaves);
@@ -19,6 +19,9 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild;
import art.arcane.iris.builtin.floating.FloatingBottomPaletteMode;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.IrisComplex;
@@ -26,15 +29,12 @@ 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.FloatingBottomPaletteMode;
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.object.terrain.IrisBiomePaletteLayer;
import art.arcane.iris.engine.object.decoration.IrisDecorationPart;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.terrain.floating.IrisFloatingChildBiomes;
import art.arcane.iris.engine.object.placement.IrisSlopeClip;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.context.ChunkContext;
@@ -65,11 +65,11 @@ public class FloatingIslands {
private final RNG rng;
private final EngineDecorator seaSurfaceDecorator;
private static KList<PlatformBlockState> generateBottomPaletteLayers(IrisFloatingChildBiomes entry, IrisDimension dimension, double wx, double wz, RNG random, int paletteDepth, IrisData data, IrisComplex complex) {
if (entry == null || entry.getBottomPaletteMode() != FloatingBottomPaletteMode.CUSTOM || entry.getBottomPalette() == null || entry.getBottomPalette().isEmpty()) {
private static KList<PlatformBlockState> generateBottomPaletteLayers(ResolvedFloatingChild entry, IrisDimension dimension, double wx, double wz, RNG random, int paletteDepth, IrisData data, IrisComplex complex) {
if (entry == null || entry.settings().bottomPaletteMode() != FloatingBottomPaletteMode.CUSTOM || entry.settings().bottomPalette() == null || entry.settings().bottomPalette().isEmpty()) {
return null;
}
return generatePaletteLayers(dimension, entry.getBottomPalette(), wx, wz, random.nextParallelRNG(0xB0770B), paletteDepth, data, complex);
return generatePaletteLayers(dimension, new KList<>(entry.settings().bottomPalette()), wx, wz, random.nextParallelRNG(0xB0770B), paletteDepth, data, complex);
}
private static KList<PlatformBlockState> generatePaletteLayers(IrisDimension dimension, KList<IrisBiomePaletteLayer> layers, double wx, double wz, RNG random, int maxDepth, IrisData data, IrisComplex complex) {
@@ -86,7 +86,7 @@ public class FloatingIslands {
continue;
}
double layerDepth = heightGenerator.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / layer.getZoom(), wz / layer.getZoom());
IrisSlopeClip slopeClip = layer.getSlopeCondition();
SlopeClip slopeClip = layer.getSlopeCondition();
if (slopeClip != null && !slopeClip.isDefault() && complex != null && !slopeClip.isValid(complex.getSlopeStream().get(wx, wz))) {
layerDepth = 0;
@@ -127,8 +127,8 @@ public class FloatingIslands {
return generated;
}
private static boolean usesBottomPalette(IrisFloatingChildBiomes entry) {
FloatingBottomPaletteMode mode = entry == null || entry.getBottomPaletteMode() == null ? FloatingBottomPaletteMode.DEPTH : entry.getBottomPaletteMode();
private static boolean usesBottomPalette(ResolvedFloatingChild entry) {
FloatingBottomPaletteMode mode = entry == null || entry.settings().bottomPaletteMode() == null ? FloatingBottomPaletteMode.DEPTH : entry.settings().bottomPaletteMode();
return mode != FloatingBottomPaletteMode.DEPTH;
}
@@ -138,7 +138,7 @@ public class FloatingIslands {
bottomDepths[i] = -1;
}
IdentityHashMap<IrisFloatingChildBiomes, Integer> depthByEntry = new IdentityHashMap<>();
IdentityHashMap<ResolvedFloatingChild, Integer> depthByEntry = new IdentityHashMap<>();
int max = Math.min(sample.topIdx, sample.solidMask.length - 1);
for (int k = 0; k <= max; k++) {
if (!sample.solidMask[k]) {
@@ -148,7 +148,7 @@ public class FloatingIslands {
if (y < 0 || y >= chunkHeight) {
continue;
}
IrisFloatingChildBiomes entry = sample.entryAt(k);
ResolvedFloatingChild entry = sample.entryAt(k);
int depth = depthByEntry.getOrDefault(entry, 0);
bottomDepths[k] = depth;
depthByEntry.put(entry, depth + 1);
@@ -157,8 +157,8 @@ public class FloatingIslands {
return bottomDepths;
}
private static PlatformBlockState selectPaletteBlock(IrisFloatingChildBiomes entry, KList<PlatformBlockState> topBlocks, KList<PlatformBlockState> bottomBlocks, int topDepth, int bottomDepth, PlatformBlockState fallbackSolid) {
FloatingBottomPaletteMode mode = entry == null || entry.getBottomPaletteMode() == null ? FloatingBottomPaletteMode.DEPTH : entry.getBottomPaletteMode();
private static PlatformBlockState selectPaletteBlock(ResolvedFloatingChild entry, KList<PlatformBlockState> topBlocks, KList<PlatformBlockState> bottomBlocks, int topDepth, int bottomDepth, PlatformBlockState fallbackSolid) {
FloatingBottomPaletteMode mode = entry == null || entry.settings().bottomPaletteMode() == null ? FloatingBottomPaletteMode.DEPTH : entry.settings().bottomPaletteMode();
if (mode == FloatingBottomPaletteMode.MIRROR_TOP) {
return paletteBlock(topBlocks, Math.min(topDepth, bottomDepth), fallbackSolid);
}
@@ -179,9 +179,9 @@ public class FloatingIslands {
return block == null ? fallbackSolid : block;
}
private PaletteContext createPaletteContext(IrisBiome parent, IrisFloatingChildBiomes entry, IrisDimension dimension, int wx, int wz, long colSeed, int paletteDepth, IrisData data, IrisComplex complex) {
private PaletteContext createPaletteContext(IrisBiome parent, ResolvedFloatingChild entry, IrisDimension dimension, int wx, int wz, long colSeed, int paletteDepth, IrisData data, IrisComplex complex) {
IrisBiome target = entry == null ? parent : entry.getRealBiome(parent, data);
int entrySeed = entry == null || entry.getBiome() == null ? 0 : entry.getBiome().hashCode();
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 : target.generateLayers(dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
if (topBlocks == null || topBlocks.isEmpty()) {
@@ -235,8 +235,8 @@ public class FloatingIslands {
long colSeed = FloatingIslandSample.columnSeed(baseSeed, wx, wz);
int paletteDepth = Math.max(4, sample.solidCount + 4);
IdentityHashMap<IrisFloatingChildBiomes, PaletteContext> paletteContexts = new IdentityHashMap<>();
IdentityHashMap<IrisFloatingChildBiomes, Integer> topDepthByEntry = new IdentityHashMap<>();
IdentityHashMap<ResolvedFloatingChild, PaletteContext> paletteContexts = new IdentityHashMap<>();
IdentityHashMap<ResolvedFloatingChild, Integer> topDepthByEntry = new IdentityHashMap<>();
int[] bottomDepths = bottomDepths(sample, chunkHeight);
for (int k = sample.topIdx; k >= 0; k--) {
if (!sample.solidMask[k]) {
@@ -246,7 +246,7 @@ public class FloatingIslands {
if (y < 0 || y >= chunkHeight) {
continue;
}
IrisFloatingChildBiomes entry = sample.entryAt(k);
ResolvedFloatingChild entry = sample.entryAt(k);
PaletteContext paletteContext = paletteContexts.get(entry);
if (paletteContext == null) {
paletteContext = createPaletteContext(parent, entry, dimension, wx, wz, colSeed, paletteDepth, data, complex);
@@ -261,10 +261,10 @@ public class FloatingIslands {
topDepthByEntry.put(entry, depth + 1);
}
IrisFloatingChildBiomes entry = sample.entry;
Integer localFluidHeight = entry.getLocalFluidHeight();
if (localFluidHeight != null && localFluidHeight > 0) {
PlatformBlockState fluid = B.getStateOrNull(entry.getFluidBlock());
ResolvedFloatingChild entry = sample.entry;
int localFluidHeight = entry.settings().localFluidHeight().orElse(0);
if (localFluidHeight > 0) {
PlatformBlockState fluid = B.getStateOrNull(entry.settings().fluidBlock());
if (fluid == null) {
fluid = B.getState("minecraft:water");
}
@@ -317,10 +317,10 @@ public class FloatingIslands {
if (sample == null) {
continue;
}
IrisFloatingChildBiomes entry = sample.entry;
ResolvedFloatingChild entry = sample.entry;
IrisBiome target = entry.getRealBiome(parent, data);
if (!entry.isInheritDecorators() || target == null) {
if (!entry.settings().inheritDecorators() || target == null) {
continue;
}
@@ -338,8 +338,8 @@ public class FloatingIslands {
}
}
Integer localFluidHeight = entry.getLocalFluidHeight();
if (localFluidHeight != null && localFluidHeight > 0) {
int localFluidHeight = entry.settings().localFluidHeight().orElse(0);
if (localFluidHeight > 0) {
int fluidCap = Math.min(sample.thickness - 1, localFluidHeight);
int fluidTopY = -1;
for (int k = 1; k <= fluidCap; k++) {
@@ -375,7 +375,7 @@ public class FloatingIslands {
private void writeIslandSkyBiomes(IrisBiome parent, int wx, int wz, FloatingIslandSample sample, int chunkHeight, IrisData data) {
try {
IdentityHashMap<IrisFloatingChildBiomes, MatterBiomeInject> matterByEntry = new IdentityHashMap<>();
IdentityHashMap<ResolvedFloatingChild, MatterBiomeInject> matterByEntry = new IdentityHashMap<>();
for (int k = 0; k <= sample.topIdx; k++) {
if (!sample.solidMask[k]) {
continue;
@@ -384,7 +384,7 @@ public class FloatingIslands {
if (y < 0 || y >= chunkHeight) {
continue;
}
IrisFloatingChildBiomes entry = sample.entryAt(k);
ResolvedFloatingChild entry = sample.entryAt(k);
MatterBiomeInject matter = matterByEntry.get(entry);
if (matter == null) {
IrisBiome target = entry == null ? parent : entry.getRealBiome(parent, data);
@@ -18,6 +18,8 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.floating.FloatingChildBiome;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.core.modules.IrisChunk;
import art.arcane.iris.core.modules.IrisMantleChunk;
@@ -46,6 +48,11 @@ public final class FloatingModule implements IrisModule {
return ModuleInfo.of("iris:floating", "Floating islands", VERSION);
}
@Override
public void register(FeatureRegistry registry) {
registry.registerHeldType(FloatingChildBiome.class);
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Floating.OBJECTS).softAfter(IrisStages.Objects.PLACE.ref()).reach(FloatingModule::objectReach)
@@ -18,12 +18,12 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.mantle.EngineMantle;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.engine.object.placement.IrisSlopeClip;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.hunk.Hunk;
@@ -210,7 +210,7 @@ public class SurfaceSmoothing {
|| (hd == h + 1 && isSolidNonSlab(x, hd, z - 1, originX, originZ, currentData)))
//@done
{
IrisSlopeClip sc = biome.getSlab().getSlopeCondition();
SlopeClip sc = biome.getSlab().getSlopeCondition();
PlatformBlockState d = sc.isValid(engine.getComplex().getSlopeStream().get(x, z)) ? biome.getSlab().get(rng, x, h, z, engine.getData()) : null;
if (d != null) {
@@ -18,10 +18,10 @@
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.placement.IrisSlopeClip;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.data.cache.AtomicCache;
@@ -71,7 +71,7 @@ public class IrisDecorator {
@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 IrisSlopeClip slopeCondition = new IrisSlopeClip();
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;
@@ -18,7 +18,7 @@
package art.arcane.iris.engine.object.mod;
import art.arcane.iris.engine.object.placement.IrisObjectReplace;
import art.arcane.iris.builtin.blocks.ObjectReplace;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.region.IrisRegion;
@@ -100,9 +100,9 @@ public class IrisMod extends IrisRegistrant {
@Desc("Replace regions with other regions")
private KList<IrisModRegionReplacer> regionReplacers = new KList<>();
@ArrayType(min = 1, type = IrisObjectReplace.class)
@ArrayType(min = 1, type = ObjectReplace.class)
@Desc("Replace blocks with other blocks")
private KList<IrisObjectReplace> blockReplacers = new KList<>();
private KList<ObjectReplace> blockReplacers = new KList<>();
@ArrayType(min = 1, type = IrisModNoiseStyleReplacer.class)
@Desc("Replace noise styles with other styles")
@@ -18,11 +18,12 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.anchor.AnchorHeight;
import art.arcane.iris.core.modules.IrisPlacement;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.stage.PlacementStageContext;
@@ -1,39 +0,0 @@
/*
* 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.object.placement;
/** How a placement mode finds the height of an object placed without a requested height. */
enum AnchorSampling {
/** The surface at the object's center, or the floor of the cave it is placed in. */
CENTER,
/** The highest surface under any column of the object. */
HIGHEST,
/** The highest surface under the object's four corners. */
HIGHEST_CORNER,
/** The lowest surface under any column of the object. */
LOWEST,
/** The lowest surface under the object's four corners. */
LOWEST_CORNER,
/** The surface at the object's center, ignoring caves; each block then follows its own column. */
SURFACE,
/** The translation alone, in open air. */
TRANSLATION,
/** The requested height, even when negative. */
REQUESTED
}
@@ -19,6 +19,10 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.engine.spawn.SpawnResources;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.blocks.ObjectReplace;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.blocks.ObjectMarkers;
import art.arcane.iris.builtin.blocks.WrittenBlocks;
@@ -30,7 +34,6 @@ import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectShaping;
import art.arcane.iris.engine.object.prefab.TileData;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.volmlib.util.collection.KList;
@@ -66,6 +69,11 @@ public final class BlocksModule implements IrisModule {
return ModuleInfo.of("iris:blocks", "Object blocks", PlacementModules.VERSION);
}
@Override
public void register(FeatureRegistry registry) {
registry.registerHeldType(ObjectReplace.class);
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Blocks.WRITE)
@@ -1,50 +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.placement;
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.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("object-limit")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Limits object placement by minimum and maximum world height")
@Data
public class IrisObjectLimit {
@MinNumber(-2048)
@MaxNumber(2048)
@Desc("The minimum height for placement (bottom of object)")
private int minimumHeight = -2048;
@MinNumber(-2048)
@MaxNumber(2048)
@Desc("The maximum height for placement (top of object)")
private int maximumHeight = 2048;
public boolean canPlace(int h, int l) {
return h <= maximumHeight && l >= minimumHeight;
}
}
@@ -19,6 +19,14 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.engine.loot.LootResources;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.carve.CaveAnchorMode;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.blocks.ObjectReplace;
import art.arcane.iris.builtin.stilt.StiltSettings;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.iris.builtin.vacuum.VacuumSettings;
import art.arcane.iris.builtin.validate.ObjectLimit;
import art.arcane.iris.core.modules.ModuleSettings;
import art.arcane.iris.engine.object.loot.IObjectLoot;
import art.arcane.iris.engine.object.loot.IrisLootTable;
@@ -34,8 +42,6 @@ import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectScale;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
import art.arcane.iris.engine.object.terrain.carving.IrisCaveAnchorMode;
import art.arcane.iris.platform.bukkit.BukkitBlockResolution;
import art.arcane.iris.core.loader.IrisData;
@@ -97,7 +103,7 @@ public class IrisObjectPlacement {
@Desc("Rotate this objects placement")
private IrisObjectRotation rotation = new IrisObjectRotation();
@Desc("Limit the max height or min height of placement.")
private IrisObjectLimit clamp = new IrisObjectLimit();
private ObjectLimit clamp = new ObjectLimit();
@MinNumber(0)
@MaxNumber(1)
@Desc("The maximum layer level of a snow filter overtop of this placement. Set to 0 to disable. Max of 1.")
@@ -105,7 +111,7 @@ public class IrisObjectPlacement {
@Desc("Whether or not this object can be targeted by a dolphin.")
private boolean isDolphinTarget = false;
@Desc("The slope at which this object can be placed. Range from 0 to 10 by default. Calculated from a 3-block radius from the center of the object placement.")
private IrisSlopeClip slopeCondition = new IrisSlopeClip();
private SlopeClip slopeCondition = new SlopeClip();
@Desc("Set to true to add the rotation of the direction of the slope of the terrain (wherever the slope is going down) to the y-axis rotation of the object." +
"Rounded to 90 degrees. Adds the *min* rotation of the y axis as well (to still allow you to rotate objects nicely). Discards *max* and *interval* on *yaxis*")
private boolean rotateTowardsSlope = false;
@@ -119,9 +125,9 @@ public class IrisObjectPlacement {
@Desc("If the chance check passes, and you specify this, it picks a number in the range based on noise, and 'density' is ignored.")
private IrisStyledRange densityStyle = null;
@Desc("When stilting is enabled, this object will define various properties related to it.")
private IrisStiltSettings stiltSettings;
private StiltSettings stiltSettings;
@Desc("When a VACUUM place mode is used, this defines the deformation radius and falloff.")
private IrisVacuumSettings vacuumSettings;
private VacuumSettings vacuumSettings;
@MaxNumber(64)
@MinNumber(0)
@Desc("When bore is enabled, expand max-y of the cuboid it removes")
@@ -148,7 +154,7 @@ public class IrisObjectPlacement {
@Desc("Set to false to let this placement sit over carved surface openings such as cave entrances.")
private boolean requireSurfaceSupport = true;
@Desc("When carving placement is enabled, select which carved-space anchor this placement targets.")
private IrisCaveAnchorMode caveAnchorMode = IrisCaveAnchorMode.PROFILE_DEFAULT;
private CaveAnchorMode caveAnchorMode = CaveAnchorMode.PROFILE_DEFAULT;
@Desc("If this is defined, this object wont place on the terrain heightmap, but instead on this virtual heightmap")
private IrisNoiseGenerator heightmap;
@Desc("If set to true, Iris will try to fill the insides of 'rooms' and 'pockets' where air should fit based off of raytrace checks. This prevents a village house placing in an area where a tree already exists, and instead replaces the parts of the tree where the interior of the structure is. \n\nThis operation does not affect warmed-up generation speed however it does slow down loading objects.")
@@ -169,9 +175,9 @@ public class IrisObjectPlacement {
private IrisGeneratorStyle warp = new IrisGeneratorStyle(NoiseStyle.FLAT);
@Desc("The placement mode")
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
@ArrayType(min = 1, type = IrisObjectReplace.class)
@ArrayType(min = 1, type = ObjectReplace.class)
@Desc("Find and replace blocks")
private KList<IrisObjectReplace> edit = new KList<>();
private KList<ObjectReplace> edit = new KList<>();
@Desc("Translate this object's placement")
private IrisObjectTranslate translate = new IrisObjectTranslate();
@Desc("Scale Objects")
@@ -1,84 +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.placement;
import art.arcane.iris.engine.object.material.IrisBlockData;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
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.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.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("object-block-replacer")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Find and replace object materials")
@Data
public class IrisObjectReplace {
private final transient AtomicCache<CNG> replaceGen = new AtomicCache<>();
private final transient AtomicCache<KList<PlatformBlockState>> findData = new AtomicCache<>();
private final transient AtomicCache<KList<PlatformBlockState>> replaceData = new AtomicCache<>();
@ArrayType(min = 1, type = IrisBlockData.class)
@Required
@Desc("Find this block")
private KList<IrisBlockData> find = new KList<>();
@Required
@Desc("Replace it with this block palette")
private IrisMaterialPalette replace = new IrisMaterialPalette();
@Desc("Exactly match the block data or not")
private boolean exact = false;
@MinNumber(0)
@MaxNumber(1)
@Desc("Modifies the chance the block is replaced")
private float chance = 1;
public KList<PlatformBlockState> getFind(IrisData rdata) {
return findData.aquire(() ->
{
KList<PlatformBlockState> b = new KList<>();
for (IrisBlockData i : find) {
PlatformBlockState bx = i.getBlockData(rdata);
if (bx != null) {
b.add(bx);
}
}
return b;
});
}
public PlatformBlockState getReplace(RNG seed, double x, double y, double z, IrisData rdata) {
return getReplace().get(seed, x, y, z, rdata);
}
}
@@ -18,6 +18,9 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.vacuum.VacuumSettings;
public final class IrisObjectVacuum {
private static final double DEFAULT_WAVE_AMPLITUDE = 3.0;
private static final double DEFAULT_WAVE_SCALE = 5.0;
@@ -28,21 +31,17 @@ public final class IrisObjectVacuum {
}
public static boolean isVacuumMode(ObjectPlaceMode mode) {
return mode == ObjectPlaceMode.VACUUM
|| mode == ObjectPlaceMode.VACUUM_HIGH
|| mode == ObjectPlaceMode.VACUUM_FAST
|| mode == ObjectPlaceMode.VACUUM_ORGANIC
|| mode == ObjectPlaceMode.VACUUM_WAVY;
return mode != null && mode.isVacuum();
}
public static int resolveRadius(ObjectPlaceMode mode, IrisVacuumSettings settings) {
public static int resolveRadius(ObjectPlaceMode mode, VacuumSettings settings) {
int radius = switch (mode) {
case VACUUM_HIGH -> 20;
case VACUUM_FAST -> 8;
default -> 12;
};
if (settings != null && settings.getRadius() > 0) {
radius = settings.getRadius();
if (settings != null && settings.radius() > 0) {
radius = settings.radius();
}
return Math.max(0, Math.min(MAX_RADIUS_BLOCKS, radius));
}
@@ -51,22 +50,22 @@ public final class IrisObjectVacuum {
return mode == ObjectPlaceMode.VACUUM_FAST ? 2 : 1;
}
public static double resolveFalloff(IrisVacuumSettings settings) {
return settings != null ? Math.max(0.25, settings.getFalloff()) : 2.0;
public static double resolveFalloff(VacuumSettings settings) {
return settings != null ? Math.max(0.25, settings.falloff()) : 2.0;
}
public static double resolveWaveAmplitude(IrisVacuumSettings settings) {
public static double resolveWaveAmplitude(VacuumSettings settings) {
if (settings == null) {
return DEFAULT_WAVE_AMPLITUDE;
}
return Math.max(0, settings.getWaveAmplitude());
return Math.max(0, settings.waveAmplitude());
}
public static double resolveWaveScale(IrisVacuumSettings settings) {
public static double resolveWaveScale(VacuumSettings settings) {
if (settings == null) {
return DEFAULT_WAVE_SCALE;
}
double scale = settings.getWaveScale();
double scale = settings.waveScale();
return scale > 0 ? scale : DEFAULT_WAVE_SCALE;
}
@@ -1,59 +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.placement;
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.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("slope-clip")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Limits placement to a minimum and maximum terrain slope")
@Data
public class IrisSlopeClip {
@MinNumber(0)
@MaxNumber(1024)
@Desc("The minimum slope for placement")
private double minimumSlope = 0;
@MinNumber(0)
@MaxNumber(1024)
@Desc("The maximum slope for placement")
private double maximumSlope = 10;
public boolean isDefault() {
return minimumSlope <= 0 && maximumSlope >= 10;
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isValid(double slope) {
if (isDefault()) {
return true;
}
return !(minimumSlope > slope) && !(maximumSlope < slope);
}
}
@@ -1,47 +0,0 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
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.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("stilt-settings")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Defines stilting behaviour.")
@Data
public class IrisStiltSettings {
@MinNumber(0)
@MaxNumber(64)
@Desc("Defines the maximum amount of blocks the object stilts verticially before overstilting and randomRange.")
private int yMax;
@MinNumber(0)
@MaxNumber(64)
@Desc("Defines the upper boundary for additional blocks after overstilting and/or maxStiltRange.")
private int yRand;
@MaxNumber(64)
@MinNumber(0)
@Desc("If the place mode is set to stilt, you can over-stilt it even further into the ground. Especially useful when using fast stilt due to inaccuracies.")
private int overStilt;
@Desc("If defined, stilting will be done using this block palette rather than the last layer of the object.")
private IrisMaterialPalette palette;
@MinNumber(1)
@MaxNumber(256)
@Desc("For ORGANIC_STILT / CEILING_HANG: the maximum number of blocks to scan toward the cave floor (or ceiling) looking for solid ground before giving up.")
private int organicMaxScan = 48;
@MinNumber(0)
@MaxNumber(32)
@Desc("For ORGANIC_STILT / CEILING_HANG: the maximum number of blocks each column's stilt is randomly shortened by, giving the underside a ragged organic edge instead of a flat disc.")
private int organicJitter = 3;
@MinNumber(0)
@MaxNumber(1)
@Desc("For ORGANIC_STILT / CEILING_HANG: in the deepest fraction of each stilt column, blocks are randomly skipped to break the tip up. Higher = more broken and scratchy. 0 disables.")
private double organicScratch = 0.55;
}
@@ -1,39 +0,0 @@
package art.arcane.iris.engine.object.placement;
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.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("vacuum-settings")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Defines how a VACUUM place mode bends terrain to meet an object's base.")
@Data
public class IrisVacuumSettings {
@MinNumber(0)
@MaxNumber(128)
@Desc("The horizontal radius (in blocks) the terrain deformation extends beyond the object footprint before it blends back to the natural surface. 0 = derive automatically from the place mode (VACUUM, VACUUM_HIGH larger, VACUUM_FAST smaller).")
private int radius = 0;
@MinNumber(0.25)
@MaxNumber(8)
@Desc("The falloff exponent controlling how the deformation eases out across the radius. 1 = linear (cone), 2 = parabolic (default, gentle bowl), higher = flatter near the object with a sharper drop at the edge.")
private double falloff = 2.0;
@MinNumber(0)
@MaxNumber(64)
@Desc("For VACUUM_ORGANIC: the maximum number of blocks the effective radius is randomly perturbed per column, giving the meeting edge an irregular organic outline instead of a clean circle.")
private int organicJitter = 4;
@MinNumber(0)
@MaxNumber(64)
@Desc("For VACUUM_WAVY: the vertical amplitude (in blocks) of the rolling simplex wave applied across the terrain bend. The wave fades to zero under the object (so it stays flush) and at the outer radius (so it blends back to the surface), peaking across the mid-slope. 0 disables the wave.")
private int waveAmplitude = 3;
@MinNumber(0.1)
@MaxNumber(64)
@Desc("For VACUUM_WAVY: the frequency of the simplex wave. Higher values make tighter, choppier ripples; lower values make broad, gentle swells. The wavelength in blocks is roughly 100 / waveScale.")
private double waveScale = 5.0;
}
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.blocks.ObjectReplace;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.material.BlockDataMergeSupport;
import art.arcane.iris.engine.object.prefab.IrisObjectShaping;
@@ -37,25 +38,27 @@ final class ObjectEdits {
/** {@code tile} may be null; the result's tile is the last replacement's tile, if it has one. */
static Edited apply(IrisObjectPlacement config, PlatformBlockState data, TileData tile, RNG rng,
double x, double y, double z, IrisData rdata) {
ResolvedReplaces replaces = ResolvedReplaces.of(rdata);
PlatformBlockState edited = data;
TileData editedTile = tile;
for (IrisObjectReplace replace : config.getEdit()) {
if (!rng.chance(replace.getChance())) {
for (ObjectReplace settings : config.getEdit()) {
ResolvedReplace replace = replaces.of(settings);
if (!rng.chance(replace.chance())) {
continue;
}
for (PlatformBlockState find : replace.getFind(rdata)) {
for (PlatformBlockState find : replace.find()) {
if (!finds(replace, find, edited)) {
continue;
}
edited = replaced(edited, replace.getReplace(rng, x, y, z, rdata));
editedTile = replace.getReplace().getTile(rng, x, y, z, rdata).orElse(editedTile);
edited = replaced(edited, replace.replacement(rng, x, y, z));
editedTile = replace.tile(rng).orElse(editedTile);
}
}
return new Edited(edited, editedTile);
}
private static boolean finds(IrisObjectReplace replace, PlatformBlockState find, PlatformBlockState data) {
return replace.isExact()
private static boolean finds(ResolvedReplace replace, PlatformBlockState find, PlatformBlockState data) {
return replace.exact()
? find.matches(data)
: IrisObjectShaping.materialKey(find).equals(IrisObjectShaping.materialKey(data));
}
@@ -1,130 +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.placement;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("Object Place modes are useful for positioning objects just right. The default value is CENTER_HEIGHT.")
public enum ObjectPlaceMode {
@Desc("The default place mode. This mode picks a center point (where the center of the object will be) and takes the height. That height is used for the whole object.")
CENTER_HEIGHT(AnchorSampling.CENTER, StiltShape.NONE),
@Desc("Samples a lot of points where the object will cover (horizontally) and picks the highest height, that height is then used to place the object. This mode is useful for preventing any part of your object from being buried though it will float off of cliffs.")
MAX_HEIGHT(AnchorSampling.HIGHEST, StiltShape.NONE),
@Desc("Samples only 4 points where the object will cover (horizontally) and picks the highest height, that height is then used to place the object. This mode is useful for preventing any part of your object from being buried though it will float off of cliffs.\"")
FAST_MAX_HEIGHT(AnchorSampling.HIGHEST_CORNER, StiltShape.NONE),
@Desc("Samples a lot of points where the object will cover (horizontally) and picks the lowest height, that height is then used to place the object. This mode is useful for preventing any part of your object from overhanging a cliff though it gets buried a lot")
MIN_HEIGHT(AnchorSampling.LOWEST, StiltShape.NONE),
@Desc("Samples only 4 points where the object will cover (horizontally) and picks the lowest height, that height is then used to place the object. This mode is useful for preventing any part of your object from overhanging a cliff though it gets buried a lot")
FAST_MIN_HEIGHT(AnchorSampling.LOWEST_CORNER, StiltShape.NONE),
@Desc("Stilting is MAX_HEIGHT but it repeats the bottom most block of your object until it hits the surface. This is expensive because it has to first sample every height value for each x,z position of your object. Avoid using this unless its structures for performance reasons.")
STILT(AnchorSampling.HIGHEST, StiltShape.STRAIGHT),
@Desc("Just like stilting but very inaccurate. Useful for stilting a lot of objects without too much care on accuracy (you can use the over-stilt value to force stilts under ground further)")
FAST_STILT(AnchorSampling.HIGHEST_CORNER, StiltShape.STRAIGHT),
@Desc("Stilting is MIN_HEIGHT but it repeats the bottom most block of your object until it hits the surface. This is expensive because it has to first sample every height value for each x,z position of your object. Avoid using this unless its structures for performance reasons.")
MIN_STILT(AnchorSampling.LOWEST, StiltShape.STRAIGHT),
@Desc("Just like MIN_STILT but very inaccurate. Useful for stilting a lot of objects without too much care on accuracy (you can use the over-stilt value to force stilts under ground further)")
FAST_MIN_STILT(AnchorSampling.LOWEST_CORNER, StiltShape.STRAIGHT),
@Desc("Stilting is CENTER_HEIGHT but it repeats the bottom most block of your object until it hits the surface. This is expensive because it has to first sample every height value for each x,z position of your object. Avoid using this unless its structures for performance reasons.")
CENTER_STILT(AnchorSampling.CENTER, StiltShape.STRAIGHT),
@Desc("Erode stilting tapers columns downward like an ice cream cone. Blocks near the center extend deepest while edge blocks drop off first. Blocks are randomly skipped in the lower portion for a rough organic eroded texture.")
ERODE_STILT(AnchorSampling.HIGHEST, StiltShape.ERODE),
@Desc("Organic stilting scans straight down from the bottom of the object to the first solid block (the cave floor, or terrain) and fills the gap with the object's own bottom block. Each column stops at a slightly different, noise-varied depth and the lower portion is randomly broken up, so the underside reads as rough organic roots rather than a flat disc. Designed for objects placed inside caves so they connect to the floor instead of floating. Tune with stilt-settings (organicMaxScan, organicJitter, organicScratch).")
ORGANIC_STILT(AnchorSampling.CENTER, StiltShape.ORGANIC),
@Desc("Hangs the object upside-down from a cave ceiling. The object is flipped vertically (its tip points down like a stalactite) and its top is anchored to the ceiling, while an organic, noise-varied stilt grows up into the ceiling so it never floats below the roof. Use inside caves; tune with stilt-settings (organicMaxScan, organicJitter, organicScratch).")
CEILING_HANG(AnchorSampling.CENTER, StiltShape.CEILING),
@Desc("Anchors the object at the terrain surface (plus translate.y) like CENTER_HEIGHT, then bends the surrounding terrain to be flush with the object's base. Columns inside the object footprint are raised (or lowered) to meet the base, and the deformation falls off parabolically out to a radius so the terrain smoothly blends back to its natural height. Use this to seat a floating/translated object on the ground without a flat stilt disc, e.g. a cube translated up 10 on a mountain pulls the terrain up to meet it. Tune with vacuum-settings (radius, falloff).")
VACUUM(AnchorSampling.CENTER, StiltShape.NONE),
@Desc("VACUUM with a larger radius and finer per-column sampling for the smoothest terrain blend. More expensive.")
VACUUM_HIGH(AnchorSampling.CENTER, StiltShape.NONE),
@Desc("VACUUM with a smaller radius and coarser sampling for performance. Use when seating many objects.")
VACUUM_FAST(AnchorSampling.CENTER, StiltShape.NONE),
@Desc("VACUUM whose falloff radius is perturbed by noise per column, so the terrain meets the object with an irregular organic edge rather than a clean parabolic bowl.")
VACUUM_ORGANIC(AnchorSampling.CENTER, StiltShape.NONE),
@Desc("VACUUM whose terrain bend is bent by smooth coherent simplex noise so the surface meets the object with a gently rolling, wavy slope instead of the ragged white-noise edge of VACUUM_ORGANIC or a clean parabolic bowl. The object itself still seats flush; the waves fade to zero under the object and at the outer rim, peaking across the mid-slope. Tune with vacuum-settings (waveAmplitude, waveScale).")
VACUUM_WAVY(AnchorSampling.CENTER, StiltShape.NONE),
@Desc("Samples the height of the terrain at every x,z position of your object and pushes it down to the surface. It's pretty much like a melt function over the terrain.")
PAINT(AnchorSampling.SURFACE, StiltShape.NONE),
@Desc("Places the object in pure air at an absolute Y driven entirely by translate.y (plus optional translate.yRandom). Terrain height, underwater, and carving anchor checks are skipped. Use this for floating islands, sky structures, clouds, or blimps where the object must not be translated to the ground.")
FLOATING(AnchorSampling.TRANSLATION, StiltShape.NONE),
@Desc("Raw stamp at the caller-supplied (x, y, z). No terrain sampling, no stilting, no Y recomputation, no underwater or carving anchor guards. Used internally to route native Minecraft structure pieces (villages etc.) through the Iris object placer.")
STRUCTURE_PIECE(AnchorSampling.REQUESTED, StiltShape.NONE);
private final AnchorSampling anchor;
private final StiltShape stilt;
ObjectPlaceMode(AnchorSampling anchor, StiltShape stilt) {
this.anchor = anchor;
this.stilt = stilt;
}
/** How a placement without a requested height finds one. */
AnchorSampling anchor() {
return anchor;
}
/** The stilt this mode grows under or above the object. */
StiltShape stilt() {
return stilt;
}
boolean isVacuum() {
return IrisObjectVacuum.isVacuumMode(this);
}
}
@@ -1,6 +1,6 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.engine.object.prefab.IrisAxisRotationClamp;
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.math.IrisBlockVector;
@@ -55,20 +55,20 @@ import art.arcane.iris.util.common.math.IrisBlockVector;
ySin = Math.sin(yAngle);
}
private static int modeOf(IrisAxisRotationClamp clamp) {
private static int modeOf(AxisRotationClamp clamp) {
if (!clamp.isLocked()) {
return MODE_ANGLE;
}
if (Math.abs(clamp.getMax()) % 360D == 180D) {
if (Math.abs(clamp.max()) % 360D == 180D) {
return MODE_FLIP;
}
if (clamp.getMax() % 360D == 90D || clamp.getMax() % 360D == -270D) {
if (clamp.max() % 360D == 90D || clamp.max() % 360D == -270D) {
return MODE_QUARTER;
}
if (clamp.getMax() == -90D || clamp.getMax() % 360D == 270D) {
if (clamp.max() == -90D || clamp.max() % 360D == 270D) {
return MODE_THREE_QUARTER;
}
@@ -18,11 +18,14 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.prepare.SlopeClip;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.core.modules.IrisPlacement;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.placer.HeightmapObjectPlacer;
import art.arcane.iris.engine.object.prefab.IrisAxisRotationClamp;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
@@ -52,6 +55,12 @@ public final class PrepareModule implements IrisModule {
return ModuleInfo.of("iris:prepare", "Placement preparation", PlacementModules.VERSION);
}
@Override
public void register(FeatureRegistry registry) {
registry.registerHeldType(SlopeClip.class);
registry.registerHeldType(AxisRotationClamp.class);
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Prepare.SLOPE).produce(PrepareModule::slope);
@@ -89,15 +98,15 @@ public final class PrepareModule implements IrisModule {
double downhill = lowest == north ? NORTH : lowest == east ? EAST : lowest == south ? SOUTH : WEST;
IrisObjectRotation requested = config.getRotation();
double turn = requested.getYAxis().getMin() + downhill;
double turn = requested.getYAxis().min() + downhill;
IrisObjectRotation rotation = new IrisObjectRotation();
rotation.setXAxis(requested.getXAxis());
rotation.setZAxis(requested.getZAxis());
if (turn == 0) {
rotation.setYAxis(new IrisAxisRotationClamp(false, false, 0, 0, QUARTER_TURN));
rotation.setYAxis(AxisRotationClamp.of(false, false, 0, 0, QUARTER_TURN));
rotation.setEnabled(requested.canRotateX() || requested.canRotateZ());
} else {
rotation.setYAxis(new IrisAxisRotationClamp(true, false, turn, turn, QUARTER_TURN));
rotation.setYAxis(AxisRotationClamp.of(true, false, turn, turn, QUARTER_TURN));
rotation.setEnabled(true);
}
IrisObjectPlacement turned = config.toPlacement(config.getPlace().toArray(new String[0]));
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.math.IrisBlockVector;
import art.arcane.iris.util.project.noise.CNG;
@@ -0,0 +1,94 @@
/*
* 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.object.placement;
import art.arcane.iris.builtin.blocks.ObjectReplace;
import art.arcane.iris.core.modules.BlockEntities;
import art.arcane.iris.engine.object.prefab.TileData;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.block.BlockRegistry;
import com.volmit.block.BlockSpec;
import com.volmit.block.PaletteSpec;
import com.volmit.object.BlockEntityData;
import java.util.List;
import java.util.Optional;
/**
* One {@link ObjectReplace} made ready for a pack: the blocks it finds resolved to the platform's, its palette
* picked through the pack's block registry with the seed of the {@link RNG} the placement hands in, and the tile
* data of the palette's entries resolved once. The old settings class cached the same things on itself.
*/
final class ResolvedReplace {
private final List<PlatformBlockState> find;
private final boolean exact;
private final float chance;
private final PaletteSpec replace;
private final BlockRegistry blocks;
private final List<Optional<BlockEntityData>> entryTiles;
private final int weightedSize;
ResolvedReplace(List<PlatformBlockState> find, boolean exact, float chance, PaletteSpec replace, BlockRegistry blocks) {
this.find = List.copyOf(find);
this.exact = exact;
this.chance = chance;
this.replace = replace;
this.blocks = blocks;
this.entryTiles = replace.palette().stream().map(blocks::blockEntity).toList();
this.weightedSize = replace.palette().stream().mapToInt(spec -> Math.max(0, spec.weight())).sum();
}
static ResolvedReplace of(ObjectReplace settings, BlockRegistry blocks) {
List<PlatformBlockState> find = settings.find().stream()
.map(spec -> B.getState(blocks.resolve(spec).key()))
.toList();
return new ResolvedReplace(find, settings.exact(), settings.chance(), settings.replace(), blocks);
}
float chance() {
return chance;
}
boolean exact() {
return exact;
}
List<PlatformBlockState> find() {
return find;
}
PlatformBlockState replacement(RNG rng, double x, double y, double z) {
return B.getState(blocks.palette(replace, rng.getSeed()).at(x, y, z).key());
}
/** The tile data of the entry picked for {@code rng}: the first entry when the palette's weights add up to one, else a uniform pick. */
Optional<TileData> tile(RNG rng) {
if (weightedSize == 0) {
return Optional.empty();
}
Optional<BlockEntityData> entity = entryTiles.get(weightedSize == 1 ? 0 : pickedEntry(rng));
return entity.map(BlockEntities::tileOf);
}
private int pickedEntry(RNG rng) {
return entryTiles.size() == 1 ? 0 : rng.nextInt(entryTiles.size());
}
}
@@ -0,0 +1,54 @@
/*
* 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.object.placement;
import art.arcane.iris.builtin.blocks.ObjectReplace;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import com.volmit.block.BlockRegistry;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** The {@link ResolvedReplace}s of one engine runtime, one per decoded {@link ObjectReplace}, built when a placement first uses it. */
final class ResolvedReplaces {
private final BlockRegistry blocks;
private final Map<ObjectReplace, ResolvedReplace> resolved = new ConcurrentHashMap<>();
ResolvedReplaces(Engine engine) {
this(engine.getData().getPackResources().blocks());
}
ResolvedReplaces(BlockRegistry blocks) {
this.blocks = blocks;
}
/** The replacements of the engine {@code data} serves, or of {@code data} alone when no engine runs it. */
static ResolvedReplaces of(IrisData data) {
Engine engine = data.getEngine();
if (engine == null) {
return new ResolvedReplaces(data.getPackResources().blocks());
}
return engine.getGeneration().state(ResolvedReplaces.class, ResolvedReplaces::new);
}
ResolvedReplace of(ObjectReplace settings) {
return resolved.computeIfAbsent(settings, replace -> ResolvedReplace.of(replace, blocks));
}
}
@@ -18,6 +18,9 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.StiltShape;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.stilt.StiltSettings;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.stilt.StiltLayers;
import art.arcane.iris.core.modules.IrisPlacement;
@@ -64,6 +67,11 @@ public final class StiltModule implements IrisModule {
return ModuleInfo.of("iris:stilt", "Stilts", PlacementModules.VERSION);
}
@Override
public void register(FeatureRegistry registry) {
registry.registerHeldType(StiltSettings.class);
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Stilt.LAYERS)
@@ -107,7 +115,8 @@ public final class StiltModule implements IrisModule {
private final IrisPlacement placement;
private final PreparedPlacement prepared;
private final IrisObjectPlacement config;
private final IrisStiltSettings settings;
private final StiltSettings settings;
private final PlatformBlockState palette;
private final StiltShape shape;
private final PlacementWorld world;
private final RNG rng;
@@ -124,10 +133,19 @@ public final class StiltModule implements IrisModule {
this.world = new PlacementWorld(context.access(), placement.states());
this.rng = new RNG(context.random().nextLong());
this.anchorY = context.output(IrisStages.Anchor.FINAL).y();
this.palette = settings == null ? null : paletteBlock(settings);
this.layerY = shape == StiltShape.CEILING ? layers.topY() : layers.bottomY();
this.erode = shape == StiltShape.ERODE ? ErodeShape.of(layers.bottom()) : null;
}
/** The block the settings' palette picks for this placement, the same for every column; null without a palette. */
private PlatformBlockState paletteBlock(StiltSettings stilt) {
return stilt.palette()
.map(spec -> placement.data().getPackResources().blocks().palette(spec, rng.getSeed()))
.map(picker -> B.getState(picker.at(placement.x(), anchorY, placement.z()).key()))
.orElse(null);
}
private void grow(ObjectBlock block) {
BlockPosition offset = block.position();
PlatformBlockState state = stiltState(block, offset);
@@ -152,8 +170,8 @@ public final class StiltModule implements IrisModule {
/** The block the stilt repeats: the palette's when the settings have one, soil turned to dirt, edited and turned with the object. */
private PlatformBlockState stiltState(ObjectBlock block, BlockPosition offset) {
PlatformBlockState state = placement.states().toPlatform(block.state());
if (settings != null && settings.getPalette() != null) {
state = settings.getPalette().get(rng, placement.x(), anchorY, placement.z(), placement.data());
if (palette != null) {
state = palette;
} else if (SOIL_MATERIALS.contains(IrisObjectShaping.materialKey(state))) {
state = B.getState(SOIL_REPLACEMENT);
}
@@ -174,9 +192,9 @@ public final class StiltModule implements IrisModule {
}
int lowerBound = highest - 1;
if (settings != null) {
lowerBound -= settings.getOverStilt() - rng.i(0, settings.getYRand());
if (settings.getYMax() != 0) {
lowerBound -= Math.min(settings.getYMax() - (top - highest), 0);
lowerBound -= settings.overStilt() - rng.i(0, settings.yRand());
if (settings.yMax() != 0) {
lowerBound -= Math.min(settings.yMax() - (top - highest), 0);
}
}
if (erode != null) {
@@ -198,9 +216,9 @@ public final class StiltModule implements IrisModule {
/** Grows from the layer toward the first solid block in {@code direction}, -1 down or 1 up. */
private void growOrganic(PlatformBlockState state, int x, int z, int direction) {
int maxScan = settings != null ? Math.max(1, settings.getOrganicMaxScan()) : DEFAULT_ORGANIC_MAX_SCAN;
int jitterMax = settings != null ? Math.max(0, settings.getOrganicJitter()) : DEFAULT_ORGANIC_JITTER;
double scratch = settings != null ? Math.max(0, Math.min(1, settings.getOrganicScratch())) : DEFAULT_ORGANIC_SCRATCH;
int maxScan = settings != null ? Math.max(1, settings.organicMaxScan()) : DEFAULT_ORGANIC_MAX_SCAN;
int jitterMax = settings != null ? Math.max(0, settings.organicJitter()) : DEFAULT_ORGANIC_JITTER;
double scratch = settings != null ? Math.max(0, Math.min(1, settings.organicScratch())) : DEFAULT_ORGANIC_SCRATCH;
long columnHash = ((long) x * HASH_X) ^ ((long) z * HASH_Y);
int jitter = jitterMax > 0 ? (int) (Math.abs(columnHash) % (jitterMax + 1)) : 0;
int start = layerY + anchorY;
@@ -1,32 +0,0 @@
/*
* 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.object.placement;
/** What a placement mode grows between the object and the ground or ceiling. */
enum StiltShape {
NONE,
/** Repeats the bottom layer straight down to the surface. */
STRAIGHT,
/** Like {@link #STRAIGHT}, tapering toward the edges and broken up at depth. */
ERODE,
/** Repeats the bottom layer down to the first solid block, each column a little different. */
ORGANIC,
/** Hangs the flipped object from a ceiling and grows its top layer up into it. */
CEILING
}
@@ -18,6 +18,9 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.vacuum.VacuumSettings;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.blocks.WrittenBlocks;
import art.arcane.iris.core.modules.IrisPlacement;
@@ -49,6 +52,11 @@ public final class VacuumModule implements IrisModule {
return ModuleInfo.of("iris:vacuum", "Vacuum", PlacementModules.VERSION);
}
@Override
public void register(FeatureRegistry registry) {
registry.registerHeldType(VacuumSettings.class);
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Vacuum.TERRAIN)
@@ -91,11 +99,11 @@ public final class VacuumModule implements IrisModule {
this.prepared = prepared;
this.world = new PlacementWorld(context.access(), placement.states());
this.complex = engine.getComplex();
IrisVacuumSettings settings = prepared.config().getVacuumSettings();
VacuumSettings settings = prepared.config().getVacuumSettings();
this.radius = IrisObjectVacuum.resolveRadius(mode, settings);
this.step = IrisObjectVacuum.resolveStep(mode);
this.falloff = IrisObjectVacuum.resolveFalloff(settings);
this.jitter = settings != null ? Math.max(0, settings.getOrganicJitter()) : DEFAULT_ORGANIC_JITTER;
this.jitter = settings != null ? Math.max(0, settings.organicJitter()) : DEFAULT_ORGANIC_JITTER;
this.waveAmplitude = IrisObjectVacuum.resolveWaveAmplitude(settings);
this.waveScale = IrisObjectVacuum.resolveWaveScale(settings);
this.waves = mode == ObjectPlaceMode.VACUUM_WAVY && waveAmplitude > 0 ? new SimplexNoise(WAVE_SEED) : null;
@@ -18,13 +18,16 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.validate.ObjectLimit;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.core.modules.IrisPlacement;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.NativeStructureVolume;
import art.arcane.iris.engine.framework.PlacedObject;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.util.collection.KList;
import com.volmit.IrisModule;
@@ -53,6 +56,11 @@ public final class ValidateModule implements IrisModule {
return ModuleInfo.of("iris:validate", "Placement checks", PlacementModules.VERSION);
}
@Override
public void register(FeatureRegistry registry) {
registry.registerHeldType(ObjectLimit.class);
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Validate.SURFACE)
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.core.modules.IrisPlacement;
/**
@@ -1,96 +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.prefab;
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.volmlib.util.math.M;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("axis-rotation")
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Desc("Represents a rotation axis with intervals and maxes. The x and z axis values are defaulted to disabled. The Y axis defaults to on, rotating by 90 degree increments.")
@Data
public class IrisAxisRotationClamp {
@Desc("Should this axis be rotated at all?")
private boolean enabled = false;
private transient boolean forceLock = false;
@Required
@DependsOn({"max"})
@MinNumber(-360)
@MaxNumber(360)
@Desc("The minimum angle (from) or set this and max to zero for any angle degrees. Set both to the same non-zero value to force it to that angle only")
private double min = 0;
@Required
@DependsOn({"min"})
@MinNumber(-360)
@MaxNumber(360)
@Desc("The maximum angle (to) or set this and min to zero for any angle degrees. Set both to the same non-zero value to force it to that angle only")
private double max = 0;
@Required
@DependsOn({"min", "max"})
@MinNumber(0)
@MaxNumber(360)
@Desc("Iris spins the axis but not freely. For example an interval of 90 would mean 4 possible angles (right angles) degrees. \nSetting this to 0 means totally free rotation.\n\nNote that a lot of structures can have issues with non 90 degree intervals because the minecraft block resolution is so low.")
private double interval = 0;
public void minMax(double fd) {
min = fd;
max = fd;
forceLock = true;
}
public boolean isUnlimited() {
return min == max && min == 0;
}
public boolean isLocked() {
return min == max && !isUnlimited();
}
public double getRadians(int rng) {
if (forceLock) {
return Math.toRadians(Math.ceil(Math.abs((max % 360D))));
}
if (isUnlimited()) {
double resolvedInterval = interval < 1 ? 1 : interval;
return Math.toRadians((resolvedInterval * (Math.ceil(Math.abs((rng % 360D) / resolvedInterval)))) % 360D);
}
if (min == max && min != 0) {
return Math.toRadians(max);
}
return Math.toRadians(M.clip((interval * (Math.ceil(Math.abs((rng % 360D) / interval)))) % 360D, Math.min(min, max), Math.max(min, max)));
}
}
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.object.prefab;
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
import art.arcane.iris.engine.object.value.IrisDirection;
import art.arcane.iris.engine.object.value.IrisPosition;
import art.arcane.iris.engine.object.annotations.Desc;
@@ -79,64 +80,41 @@ public class IrisObjectRotation {
private boolean enabled = true;
@Desc("The x axis rotation")
private IrisAxisRotationClamp xAxis = new IrisAxisRotationClamp();
private AxisRotationClamp xAxis = new AxisRotationClamp();
@Desc("The y axis rotation")
private IrisAxisRotationClamp yAxis = new IrisAxisRotationClamp(true, false, 0, 0, 90);
private AxisRotationClamp yAxis = AxisRotationClamp.of(true, false, 0, 0, 90);
@Desc("The z axis rotation")
private IrisAxisRotationClamp zAxis = new IrisAxisRotationClamp();
private AxisRotationClamp zAxis = new AxisRotationClamp();
public static IrisObjectRotation xFlip180() {
IrisObjectRotation rt = new IrisObjectRotation();
IrisAxisRotationClamp rtx = new IrisAxisRotationClamp();
IrisAxisRotationClamp rty = new IrisAxisRotationClamp();
IrisAxisRotationClamp rtz = new IrisAxisRotationClamp();
rt.setEnabled(true);
rt.setXAxis(rtx);
rt.setYAxis(rty);
rt.setZAxis(rtz);
rtx.setEnabled(true);
rtx.minMax(180);
rty.setEnabled(false);
rtz.setEnabled(false);
rt.setXAxis(AxisRotationClamp.locked(true, 180, 0));
rt.setYAxis(new AxisRotationClamp());
rt.setZAxis(new AxisRotationClamp());
return rt;
}
public static IrisObjectRotation xFlip180RandomY() {
IrisObjectRotation rt = xFlip180();
rt.setYAxis(new IrisAxisRotationClamp(true, false, 0, 0, 90));
rt.setYAxis(AxisRotationClamp.of(true, false, 0, 0, 90));
return rt;
}
public static IrisObjectRotation xFlip180WithY(double y) {
IrisObjectRotation rt = xFlip180();
IrisAxisRotationClamp rty = new IrisAxisRotationClamp();
rty.setEnabled(true);
rty.setInterval(90);
rty.minMax(y);
rt.setYAxis(rty);
rt.setYAxis(AxisRotationClamp.locked(true, y, 90));
return rt;
}
public static IrisObjectRotation of(double x, double y, double z) {
IrisObjectRotation rt = new IrisObjectRotation();
IrisAxisRotationClamp rtx = new IrisAxisRotationClamp();
IrisAxisRotationClamp rty = new IrisAxisRotationClamp();
IrisAxisRotationClamp rtz = new IrisAxisRotationClamp();
rt.setEnabled(x != 0 || y != 0 || z != 0);
rt.setXAxis(rtx);
rt.setYAxis(rty);
rt.setZAxis(rtz);
rtx.setEnabled(x != 0);
rty.setEnabled(y != 0);
rtz.setEnabled(z != 0);
rtx.setInterval(90);
rty.setInterval(90);
rtz.setInterval(90);
rtx.minMax(x);
rty.minMax(y);
rtz.minMax(z);
rt.setXAxis(AxisRotationClamp.locked(x != 0, x, 90));
rt.setYAxis(AxisRotationClamp.locked(y != 0, y, 90));
rt.setZAxis(AxisRotationClamp.locked(z != 0, z, 90));
return rt;
}
@@ -182,12 +160,12 @@ public class IrisObjectRotation {
return s;
}
public double getRotation(int spin, IrisAxisRotationClamp clamp) {
public double getRotation(int spin, AxisRotationClamp clamp) {
if (!enabled) {
return 0;
}
if (!clamp.isEnabled()) {
if (!clamp.enabled()) {
return 0;
}
@@ -457,14 +435,14 @@ public class IrisObjectRotation {
if (canRotateX()) {
if (getXAxis().isLocked()) {
if (Math.abs(getXAxis().getMax()) % 360D == 180D) {
if (Math.abs(getXAxis().max()) % 360D == 180D) {
v.setZ(-v.getZ());
v.setY(-v.getY());
} else if (getXAxis().getMax() % 360D == 90D || getXAxis().getMax() % 360D == -270D) {
} else if (getXAxis().max() % 360D == 90D || getXAxis().max() % 360D == -270D) {
double z = v.getZ();
v.setZ(v.getY());
v.setY(-z);
} else if (getXAxis().getMax() == -90D || getXAxis().getMax() % 360D == 270D) {
} else if (getXAxis().max() == -90D || getXAxis().max() % 360D == 270D) {
double z = v.getZ();
v.setZ(-v.getY());
v.setY(z);
@@ -478,14 +456,14 @@ public class IrisObjectRotation {
if (canRotateZ()) {
if (getZAxis().isLocked()) {
if (Math.abs(getZAxis().getMax()) % 360D == 180D) {
if (Math.abs(getZAxis().max()) % 360D == 180D) {
v.setY(-v.getY());
v.setX(-v.getX());
} else if (getZAxis().getMax() % 360D == 90D || getZAxis().getMax() % 360D == -270D) {
} else if (getZAxis().max() % 360D == 90D || getZAxis().max() % 360D == -270D) {
double y = v.getY();
v.setY(v.getX());
v.setX(-y);
} else if (getZAxis().getMax() == -90D || getZAxis().getMax() % 360D == 270D) {
} else if (getZAxis().max() == -90D || getZAxis().max() % 360D == 270D) {
double y = v.getY();
v.setY(-v.getX());
v.setX(y);
@@ -499,14 +477,14 @@ public class IrisObjectRotation {
if (canRotateY()) {
if (getYAxis().isLocked()) {
if (Math.abs(getYAxis().getMax()) % 360D == 180D) {
if (Math.abs(getYAxis().max()) % 360D == 180D) {
v.setX(-v.getX());
v.setZ(-v.getZ());
} else if (getYAxis().getMax() % 360D == 90D || getYAxis().getMax() % 360D == -270D) {
} else if (getYAxis().max() % 360D == 90D || getYAxis().max() % 360D == -270D) {
double x = v.getX();
v.setX(v.getZ());
v.setZ(-x);
} else if (getYAxis().getMax() == -90D || getYAxis().getMax() % 360D == 270D) {
} else if (getYAxis().max() == -90D || getYAxis().max() % 360D == 270D) {
double x = v.getX();
v.setX(-v.getZ());
v.setZ(x);
@@ -522,15 +500,15 @@ public class IrisObjectRotation {
}
public boolean canRotateX() {
return enabled && xAxis.isEnabled();
return enabled && xAxis.enabled();
}
public boolean canRotateY() {
return enabled && yAxis.isEnabled();
return enabled && yAxis.enabled();
}
public boolean canRotateZ() {
return enabled && zAxis.isEnabled();
return enabled && zAxis.enabled();
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
@@ -18,7 +18,6 @@
package art.arcane.iris.engine.object.procedural;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.spi.PlatformBlockState;
@@ -26,8 +25,10 @@ import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.common.math.IrisBlockVector;
import art.arcane.iris.util.common.math.Vector3i;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.block.PaletteSpec;
import java.util.Map;
import java.util.Optional;
/**
* Shared low-level helpers for building procedural objects in memory: resolving a
@@ -52,13 +53,26 @@ public final class IrisProceduralBlocks {
};
}
public static boolean paletteSet(IrisMaterialPalette palette) {
return palette != null && palette.getPalette() != null && !palette.getPalette().isEmpty();
public static boolean paletteSet(PaletteSpec palette) {
return palette != null && !palette.palette().isEmpty();
}
public static PlatformBlockState resolve(String block, IrisMaterialPalette palette, IrisData data, int x, int y, int z, RNG paletteRng) {
public static boolean paletteSet(Optional<PaletteSpec> palette) {
return palette.filter(IrisProceduralBlocks::paletteSet).isPresent();
}
public static PlatformBlockState resolve(String block, Optional<PaletteSpec> palette, IrisData data, int x, int y, int z, RNG paletteRng) {
return resolve(block, palette.orElse(null), data, x, y, z, paletteRng);
}
public static PlatformBlockState resolve(Optional<String> block, Optional<PaletteSpec> palette, IrisData data, int x, int y, int z, RNG paletteRng) {
return resolve(block.orElse(null), palette.orElse(null), data, x, y, z, paletteRng);
}
/** The block of {@code palette} at the position, picked with the seed of {@code paletteRng} as the palette's old class did; else {@code block}. */
public static PlatformBlockState resolve(String block, PaletteSpec palette, IrisData data, int x, int y, int z, RNG paletteRng) {
if (paletteSet(palette)) {
return palette.get(paletteRng, x, y, z, data);
return pick(palette, data, paletteRng.getSeed(), x, y, z);
}
if (block != null && !block.isEmpty()) {
return B.getStateOrNull(block, false);
@@ -66,6 +80,11 @@ public final class IrisProceduralBlocks {
return null;
}
/** The block {@code palette} gives at the position when its noise is seeded with {@code seed}. */
public static PlatformBlockState pick(PaletteSpec palette, IrisData data, long seed, int x, int y, int z) {
return B.getState(data.getPackResources().blocks().palette(palette, seed).at(x, y, z).key());
}
public static boolean hasProperty(PlatformBlockState state, String property) {
String key = state.key();
int start = propertyStart(key, property);
@@ -18,18 +18,31 @@
package art.arcane.iris.engine.object.procedural;
import art.arcane.iris.engine.object.procedural.coral.IrisCoral;
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
import art.arcane.iris.engine.object.procedural.ruin.IrisRuin;
import art.arcane.iris.builtin.objects.ruin.Ruin;
import art.arcane.iris.engine.object.procedural.ruin.ResolvedRuin;
import art.arcane.iris.builtin.objects.fungi.Fungus;
import art.arcane.iris.engine.object.procedural.fungi.ResolvedFungus;
import art.arcane.iris.builtin.objects.formation.Formation;
import art.arcane.iris.engine.object.procedural.formation.ResolvedFormation;
import art.arcane.iris.builtin.objects.crystal.Crystal;
import art.arcane.iris.engine.object.procedural.crystal.ResolvedCrystal;
import art.arcane.iris.builtin.objects.coral.Coral;
import art.arcane.iris.engine.object.procedural.coral.ResolvedCoral;
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
import art.arcane.iris.engine.object.annotations.ArrayType;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.volmlib.util.collection.KList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import lombok.AllArgsConstructor;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@@ -40,53 +53,59 @@ import lombok.experimental.Accessors;
@Desc("Procedurally generated objects placed in a biome or region. Unlike the objects block (which loads iob files), these are generated from scratch at world-gen time.")
@Data
public class IrisProceduralObjects {
@Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE)
@EqualsAndHashCode.Exclude
private final transient Map<Object, ResolvedProceduralPlacement> placeables = new ConcurrentHashMap<>();
@ArrayType(min = 1, type = IrisProceduralTree.class)
@Desc("Procedurally generated trees.")
private KList<IrisProceduralTree> trees = new KList<>();
@ArrayType(min = 1, type = IrisRuin.class)
@ArrayType(min = 1, type = Ruin.class)
@Desc("Procedurally generated ruins (crumbling pillars, walls, arches, rubble).")
private KList<IrisRuin> ruins = new KList<>();
private KList<Ruin> ruins = new KList<>();
@ArrayType(min = 1, type = IrisFormation.class)
@ArrayType(min = 1, type = Formation.class)
@Desc("Procedurally generated natural rock formations (spires, hoodoos, arches, sea stacks, boulders, basalt columns).")
private KList<IrisFormation> formations = new KList<>();
private KList<Formation> formations = new KList<>();
@ArrayType(min = 1, type = IrisCoral.class)
@ArrayType(min = 1, type = Coral.class)
@Desc("Procedurally generated underwater coral structures.")
private KList<IrisCoral> coral = new KList<>();
private KList<Coral> coral = new KList<>();
@ArrayType(min = 1, type = IrisFungus.class)
@ArrayType(min = 1, type = Fungus.class)
@Desc("Procedurally generated mushrooms and shelf fungi.")
private KList<IrisFungus> fungi = new KList<>();
private KList<Fungus> fungi = new KList<>();
@ArrayType(min = 1, type = IrisCrystal.class)
@ArrayType(min = 1, type = Crystal.class)
@Desc("Procedurally generated crystal clusters (usually placed in caves).")
private KList<IrisCrystal> crystals = new KList<>();
private KList<Crystal> crystals = new KList<>();
public KList<IrisProceduralPlacement> getAllPlacements() {
KList<IrisProceduralPlacement> all = new KList<>();
if (trees != null) {
all.addAll(trees);
}
if (ruins != null) {
all.addAll(ruins);
}
if (formations != null) {
all.addAll(formations);
}
if (coral != null) {
all.addAll(coral);
}
if (fungi != null) {
all.addAll(fungi);
}
if (crystals != null) {
all.addAll(crystals);
}
addPlaceable(all, ruins, ResolvedRuin::new);
addPlaceable(all, formations, ResolvedFormation::new);
addPlaceable(all, coral, ResolvedCoral::new);
addPlaceable(all, fungi, ResolvedFungus::new);
addPlaceable(all, crystals, ResolvedCrystal::new);
return all;
}
/** The settings in {@code settings}, each made placeable once, in order. */
@SuppressWarnings("unchecked")
private <S> void addPlaceable(KList<IrisProceduralPlacement> all, KList<S> settings, Function<S, ResolvedProceduralPlacement> resolve) {
if (settings == null) {
return;
}
for (S entry : settings) {
all.add(placeables.computeIfAbsent(entry, key -> resolve.apply((S) key)));
}
}
public boolean isEmpty() {
return getAllPlacements().isEmpty();
}
@@ -0,0 +1,158 @@
/*
* 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.object.procedural;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.prepare.ObjectRotation;
import art.arcane.iris.builtin.prepare.ObjectTranslate;
import art.arcane.iris.builtin.stilt.StiltSettings;
import art.arcane.iris.builtin.vacuum.VacuumSettings;
import art.arcane.iris.builtin.validate.ObjectLimit;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
/**
* A procedural object's settings made placeable: bakes a deterministic pool of variants from them, once, and turns
* the placement options into the object placement the engine scatters. The settings classes held the same cache
* and methods before they became module settings.
*/
public abstract class ResolvedProceduralPlacement implements IrisProceduralPlacement {
private static final long VARIANT_SEED_STRIDE = 7919L;
/** The options every procedural placement shares with an object placement. */
public record Shape(String name, double chance, int density, long seed, int variants, ObjectPlaceMode mode,
ObjectRotation rotation, ObjectLimit clamp, CarvingMode carvingSupport, boolean underwater,
ObjectTranslate translate, StiltSettings stiltSettings, VacuumSettings vacuumSettings) {
}
private final Shape shape;
private final AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
protected ResolvedProceduralPlacement(Shape shape) {
this.shape = shape;
}
/** The object variant {@code index} is baked as, from its own seeded stream. */
protected abstract IrisObject generate(int index, RNG rng, IrisData data);
/** The number of variants to bake; the settings' count, at least one. */
protected int variantCount() {
return Math.max(1, shape.variants());
}
@Override
public String getName() {
return shape.name();
}
@Override
public double getChance() {
return shape.chance();
}
@Override
public int getDensity() {
return shape.density();
}
@Override
public boolean isPlausible() {
return false;
}
@Override
public KList<IrisObject> getVariantObjects(IrisData data) {
return variantCache.aquire(() -> bake(data));
}
/** Bakes every variant; the default draws variant {@code i} from {@code seed + i * stride}. */
protected KList<IrisObject> bake(IrisData data) {
KList<IrisObject> baked = new KList<>();
int count = variantCount();
for (int i = 0; i < count; i++) {
IrisObject object = generate(i, variantRng(i), data);
if (object == null || object.getBlocks().isEmpty()) {
continue;
}
object.setLoadKey("procedural/" + shape.name() + "#" + i);
object.setLoader(data);
baked.add(object);
}
return baked;
}
protected final RNG variantRng(int index) {
return new RNG(shape.seed() + (index * VARIANT_SEED_STRIDE));
}
protected final long seed() {
return shape.seed();
}
@Override
public IrisObject getVariantObject(IrisData data, RNG rng) {
KList<IrisObject> baked = getVariantObjects(data);
if (baked == null || baked.isEmpty()) {
return null;
}
return baked.get(rng.i(baked.size()));
}
@Override
public IrisObjectPlacement asPlacement() {
IrisObjectPlacement placement = new IrisObjectPlacement();
placement.setMode(shape.mode());
placement.setRotation(irisRotation(shape.rotation()));
placement.setClamp(shape.clamp());
placement.setCarvingSupport(shape.carvingSupport());
placement.setUnderwater(shape.underwater());
placement.setTranslate(irisTranslate(shape.translate()));
placement.setStiltSettings(shape.stiltSettings());
placement.setVacuumSettings(shape.vacuumSettings());
placement.setChance(shape.chance());
placement.setDensity(shape.density());
customize(placement);
return placement;
}
/** Sets what this kind of placement adds to the common options. */
protected void customize(IrisObjectPlacement placement) {
}
private static IrisObjectRotation irisRotation(ObjectRotation rotation) {
return new IrisObjectRotation()
.setEnabled(rotation.enabled())
.setXAxis(rotation.xAxis())
.setYAxis(rotation.yAxis())
.setZAxis(rotation.zAxis());
}
private static IrisObjectTranslate irisTranslate(ObjectTranslate translate) {
return new IrisObjectTranslate(translate.x(), translate.y(), translate.yRandom(), translate.z());
}
}
@@ -18,8 +18,8 @@
package art.arcane.iris.engine.object.procedural.coral;
import art.arcane.iris.builtin.objects.coral.Coral;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.procedural.coral.IrisCoral;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
@@ -36,14 +36,14 @@ public final class CoralGenerator {
private CoralGenerator() {
}
public static IrisObject generate(IrisCoral coral, int variantIndex, RNG rng, IrisData data) {
int lo = Math.min(coral.getHeightMin(), coral.getHeightMax());
int hi = Math.max(coral.getHeightMin(), coral.getHeightMax());
public static IrisObject generate(Coral coral, int variantIndex, RNG rng, IrisData data) {
int lo = Math.min(coral.heightMin(), coral.heightMax());
int hi = Math.max(coral.heightMin(), coral.heightMax());
int height = Math.max(2, rng.i(lo, hi + 1));
long shapeSeed = rng.getSeed() + variantIndex * 31L;
CoralCanvas canvas = new CoralCanvas();
switch (coral.getForm()) {
switch (coral.form()) {
case BRANCHING -> buildBranching(canvas, coral, height, shapeSeed, rng);
case FAN -> buildFan(canvas, coral, height, shapeSeed);
case BRAIN -> buildBrain(canvas, coral, height, shapeSeed);
@@ -55,39 +55,39 @@ public final class CoralGenerator {
return IrisProceduralBlocks.assemble(resolved);
}
private static void buildBranching(CoralCanvas canvas, IrisCoral coral, int height, long seed, RNG rng) {
private static void buildBranching(CoralCanvas canvas, Coral coral, int height, long seed, RNG rng) {
int stalkTop = Math.max(1, (int) Math.round(height * 0.5));
for (int y = 0; y < stalkTop; y++) {
placeWavy(canvas, coral, 0, y, 0, y, seed, CoralCanvas.Role.STRUCTURE);
}
int count = Math.max(1, coral.getBranchCount());
int count = Math.max(1, coral.branchCount());
for (int b = 0; b < count; b++) {
double az = branchAzimuth(coral, b, count, rng);
int startY = stalkTop - 1 + (int) Math.round((b % 2) * 1.0);
double[] tip = rasterizeArm(canvas, coral, 0, startY, 0, az,
coral.getBranchElevation(), coral.getBranchLength(), seed + b * 131L);
coral.branchElevation(), coral.branchLength(), seed + b * 131L);
placeTipCluster(canvas, coral, (int) Math.round(tip[0]), (int) Math.round(tip[1]), (int) Math.round(tip[2]),
coral.getTipClusterRadius(), seed + b * 977L);
coral.tipClusterRadius(), seed + b * 977L);
if (coral.isSubBranches()) {
int subCount = Math.max(1, coral.getSubBranchCount());
if (coral.subBranches()) {
int subCount = Math.max(1, coral.subBranchCount());
for (int s = 0; s < subCount; s++) {
double subAz = az + (s - (subCount - 1) / 2.0) * 35.0;
double subLen = coral.getBranchLength() * coral.getSubBranchScale();
double subLen = coral.branchLength() * coral.subBranchScale();
double[] subTip = rasterizeArm(canvas, coral,
(int) Math.round(tip[0]), (int) Math.round(tip[1]), (int) Math.round(tip[2]),
subAz, coral.getBranchElevation() + 10.0, subLen, seed + b * 131L + s * 17L + 5000L);
subAz, coral.branchElevation() + 10.0, subLen, seed + b * 131L + s * 17L + 5000L);
placeTipCluster(canvas, coral, (int) Math.round(subTip[0]), (int) Math.round(subTip[1]), (int) Math.round(subTip[2]),
Math.max(0, coral.getTipClusterRadius() - 1), seed + b * 977L + s * 53L);
Math.max(0, coral.tipClusterRadius() - 1), seed + b * 977L + s * 53L);
}
}
}
}
private static void buildFan(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
int half = Math.max(1, coral.getFanWidth());
private static void buildFan(CoralCanvas canvas, Coral coral, int height, long seed) {
int half = Math.max(1, coral.fanWidth());
for (int y = 0; y < height; y++) {
double t = y / (double) Math.max(1, height - 1);
double profile = Math.sin(Math.PI * t);
@@ -101,10 +101,10 @@ public final class CoralGenerator {
}
}
private static void buildBrain(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
int r = Math.max(1, coral.getBrainRadius());
private static void buildBrain(CoralCanvas canvas, Coral coral, int height, long seed) {
int r = Math.max(1, coral.brainRadius());
int ry = Math.max(1, Math.min(r, (int) Math.round(height * 0.6)));
double rough = coral.getBrainRoughness();
double rough = coral.brainRoughness();
for (int dx = -r; dx <= r; dx++) {
for (int dz = -r; dz <= r; dz++) {
for (int dy = 0; dy <= ry * 2; dy++) {
@@ -121,8 +121,8 @@ public final class CoralGenerator {
}
}
private static void buildPillar(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
int r = Math.max(1, coral.getPillarRadius());
private static void buildPillar(CoralCanvas canvas, Coral coral, int height, long seed) {
int r = Math.max(1, coral.pillarRadius());
for (int y = 0; y < height; y++) {
for (int dx = -r; dx <= r; dx++) {
for (int dz = -r; dz <= r; dz++) {
@@ -132,12 +132,12 @@ public final class CoralGenerator {
}
}
}
placeTipCluster(canvas, coral, 0, height - 1, 0, coral.getTipClusterRadius(), seed);
placeTipCluster(canvas, coral, 0, height - 1, 0, coral.tipClusterRadius(), seed);
}
private static void buildTendril(CoralCanvas canvas, IrisCoral coral, int height, long seed, RNG rng) {
int count = Math.max(1, coral.getTendrilCount());
double radius = Math.max(0.0, coral.getSpread());
private static void buildTendril(CoralCanvas canvas, Coral coral, int height, long seed, RNG rng) {
int count = Math.max(1, coral.tendrilCount());
double radius = Math.max(0.0, coral.spread());
for (int c = 0; c < count; c++) {
double az = Math.toRadians(c * (360.0 / count));
double bx = Math.cos(az) * radius * 0.5;
@@ -153,7 +153,7 @@ public final class CoralGenerator {
}
}
private static double[] rasterizeArm(CoralCanvas canvas, IrisCoral coral, int ox, int oy, int oz,
private static double[] rasterizeArm(CoralCanvas canvas, Coral coral, int ox, int oy, int oz,
double azimuthDeg, double elevationDeg, double length, long seed) {
double azRad = Math.toRadians(azimuthDeg);
double elRad = Math.toRadians(elevationDeg);
@@ -175,23 +175,23 @@ public final class CoralGenerator {
return tip;
}
private static void placeWavy(CoralCanvas canvas, IrisCoral coral, int x, int y, int z, double phase, long seed, CoralCanvas.Role role) {
private static void placeWavy(CoralCanvas canvas, Coral coral, int x, int y, int z, double phase, long seed, CoralCanvas.Role role) {
double sway = swayOffset(coral, phase, seed);
int sx = (int) Math.round(sway);
int sz = (int) Math.round(swayOffset(coral, phase + 53.0, seed + 7L));
canvas.set(x + sx, y, z + sz, role);
}
private static double swayOffset(IrisCoral coral, double phase, long seed) {
double amount = Math.max(0.0, Math.min(1.0, coral.getSway()));
private static double swayOffset(Coral coral, double phase, long seed) {
double amount = Math.max(0.0, Math.min(1.0, coral.sway()));
if (amount <= 0.0) {
return 0.0;
}
double n = TreeFunctions.valueNoise1D(phase * 0.35, seed) - 0.5;
return n * 2.0 * amount * (1.0 + coral.getSpread() * 0.25);
return n * 2.0 * amount * (1.0 + coral.spread() * 0.25);
}
private static void placeTipCluster(CoralCanvas canvas, IrisCoral coral, int cx, int cy, int cz, int radius, long seed) {
private static void placeTipCluster(CoralCanvas canvas, Coral coral, int cx, int cy, int cz, int radius, long seed) {
if (radius <= 0) {
placeTip(canvas, coral, cx, cy, cz, seed);
return;
@@ -208,31 +208,31 @@ public final class CoralGenerator {
placeTip(canvas, coral, cx, cy + radius + 1, cz, seed);
}
private static void placeTip(CoralCanvas canvas, IrisCoral coral, int x, int y, int z, long seed) {
private static void placeTip(CoralCanvas canvas, Coral coral, int x, int y, int z, long seed) {
if (!hasTip(coral)) {
return;
}
if (TreeFunctions.valueNoise1D(x * 31.0 + y * 17.0 + z * 13.0, seed) <= coral.getTipChance()) {
if (TreeFunctions.valueNoise1D(x * 31.0 + y * 17.0 + z * 13.0, seed) <= coral.tipChance()) {
canvas.set(x, y, z, CoralCanvas.Role.TIP);
}
}
private static boolean hasTip(IrisCoral coral) {
return IrisProceduralBlocks.paletteSet(coral.getTipPalette())
|| (coral.getTipBlock() != null && !coral.getTipBlock().isEmpty());
private static boolean hasTip(Coral coral) {
return IrisProceduralBlocks.paletteSet(coral.tipPalette())
|| (coral.tipBlock() != null && !coral.tipBlock().isEmpty());
}
private static double branchAzimuth(IrisCoral coral, int index, int count, RNG rng) {
return switch (coral.getBranchAzimuth()) {
private static double branchAzimuth(Coral coral, int index, int count, RNG rng) {
return switch (coral.branchAzimuth()) {
case GOLDEN_ANGLE -> index * GOLDEN_ANGLE;
case EVEN -> index * (360.0 / count);
case RANDOM -> rng.d(0.0, 360.0);
};
}
private static Map<Vector3i, PlatformBlockState> resolve(CoralCanvas canvas, IrisCoral coral, IrisData data) {
private static Map<Vector3i, PlatformBlockState> resolve(CoralCanvas canvas, Coral coral, IrisData data) {
Map<Vector3i, PlatformBlockState> out = new HashMap<>();
RNG paletteRng = new RNG(coral.getSeed());
RNG paletteRng = new RNG(coral.seed());
for (Map.Entry<Long, CoralCanvas.Role> entry : canvas.getCells().entrySet()) {
int[] xyz = CoralCanvas.decode(entry.getKey());
int x = xyz[0];
@@ -240,17 +240,17 @@ public final class CoralGenerator {
int z = xyz[2];
PlatformBlockState state;
if (entry.getValue() == CoralCanvas.Role.TIP) {
state = IrisProceduralBlocks.resolve(coral.getTipBlock(), coral.getTipPalette(), data, x, y, z, paletteRng);
state = IrisProceduralBlocks.resolve(coral.tipBlock(), coral.tipPalette(), data, x, y, z, paletteRng);
if (state == null) {
state = IrisProceduralBlocks.resolve(coral.getBlock(), coral.getBlockPalette(), data, x, y, z, paletteRng);
state = IrisProceduralBlocks.resolve(coral.block(), coral.blockPalette(), data, x, y, z, paletteRng);
}
} else {
state = IrisProceduralBlocks.resolve(coral.getBlock(), coral.getBlockPalette(), data, x, y, z, paletteRng);
state = IrisProceduralBlocks.resolve(coral.block(), coral.blockPalette(), data, x, y, z, paletteRng);
}
if (state == null) {
continue;
}
if (coral.isWaterlogged() && IrisProceduralBlocks.hasProperty(state, "waterlogged")) {
if (coral.waterlogged() && IrisProceduralBlocks.hasProperty(state, "waterlogged")) {
try {
state = state.withProperty("waterlogged", "true");
} catch (IllegalArgumentException ignored) {
@@ -1,249 +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.procedural.coral;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.placement.IrisObjectLimit;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.placement.IrisStiltSettings;
import art.arcane.iris.engine.object.placement.IrisVacuumSettings;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.data.cache.AtomicCache;
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.RegistryListBlockType;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.iris.engine.object.procedural.coral.CoralGenerator;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("coral")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A single procedurally generated coral reef structure. Iris bakes a pool of deterministic variants from these settings and scatters them across the seafloor at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Mirrors the procedural tree system but tuned for underwater reefs: structural blocks are waterlogged so the coral stays alive, and placement defaults to anchoring on the terrain beneath the water surface.")
@Data
public class IrisCoral implements IrisProceduralPlacement {
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
@Desc("A human readable name used in logs and as the variant load key.")
private String name = "coral";
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance per chunk for this coral to attempt placement. Use density for multiple per chunk.")
private double chance = 0.4;
@MinNumber(1)
@Desc("If the chance check passes, attempt this many placements in the chunk.")
private int density = 1;
@MinNumber(1)
@MaxNumber(64)
@Desc("How many distinct variants to pre-bake for this coral. Higher means more variety at a small memory cost.")
private int variants = 6;
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
private long seed = 1337;
@Desc("The placement mode used to anchor the coral to the seafloor.")
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
@Desc("Rotate this coral's placement.")
private IrisObjectRotation rotation = new IrisObjectRotation();
@Desc("Limit the max or min height of placement.")
private IrisObjectLimit clamp = new IrisObjectLimit();
@Desc("Whether this coral may place on the terrain surface, under carvings, or both.")
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
@Desc("If true (default for coral), the coral anchors on the terrain height beneath the water, so it grows up from the seafloor rather than floating at the water surface.")
private boolean underwater = true;
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the seafloor.")
private IrisObjectTranslate translate = new IrisObjectTranslate();
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
private IrisStiltSettings stiltSettings;
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
private IrisVacuumSettings vacuumSettings;
@Desc("If true (default), every resolved coral block that is waterloggable is forced waterlogged so the coral does not die in water (coral fans, sea pickles and kelp also waterlog). Set false to place dead/dry coral.")
private boolean waterlogged = true;
@Desc("The overall silhouette this coral grows into (branching, fan, brain, pillar, tendril). Each form runs a different generation routine.")
private IrisCoralForm form = IrisCoralForm.BRANCHING;
@Required
@Desc("The structural coral block (the living wood of the reef), e.g. minecraft:tube_coral_block. Ignored when blockPalette is set.")
@RegistryListBlockType
private String block = "minecraft:tube_coral_block";
@Desc("A noise-driven palette for the structural coral block. When set this overrides the single block, letting the reef mix tube/brain/bubble/fire/horn coral_block tones across its body.")
private IrisMaterialPalette blockPalette = null;
@Desc("Optional tip block placed at branch tips and at the very top of the structure, e.g. coral fans or minecraft:sea_pickle. Ignored when tipPalette is set. Null disables tips.")
@RegistryListBlockType
private String tipBlock = null;
@Desc("A noise-driven palette for the tip block. When set this overrides the single tipBlock, letting tips mix fan / pickle decorations.")
private IrisMaterialPalette tipPalette = null;
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance per eligible tip position to place a tip block (coral fan / sea pickle).")
private double tipChance = 0.6;
@MinNumber(1)
@Desc("Minimum overall height of the coral in blocks.")
private int heightMin = 4;
@MinNumber(1)
@Desc("Maximum overall height of the coral in blocks.")
private int heightMax = 8;
@MinNumber(0)
@Desc("Horizontal spread of the structure in blocks. For BRANCHING this is how far arms reach out, for BRAIN/PILLAR/FAN it widens the base footprint.")
private double spread = 3;
@MinNumber(0)
@MaxNumber(1)
@Desc("Lateral noise wobble (0-1) applied to branches and tendrils so they are not ruler-straight. 0 is perfectly straight, 1 is heavily wandering.")
private double sway = 0.5;
@MinNumber(1)
@MaxNumber(12)
@Desc("BRANCHING only: how many arms sprout from the central stalk.")
private int branchCount = 4;
@MinNumber(1)
@Desc("BRANCHING only: the length of each arm in blocks before reaching its tip.")
private double branchLength = 3;
@MinNumber(0)
@MaxNumber(90)
@Desc("BRANCHING only: the upward elevation in degrees of each arm from horizontal. 90 is straight up, 0 is flat out.")
private double branchElevation = 55;
@Desc("BRANCHING only: how the arms are distributed around the stalk by azimuth.")
private IrisCoralBranchAzimuth branchAzimuth = IrisCoralBranchAzimuth.GOLDEN_ANGLE;
@Desc("BRANCHING only: if true, each arm splits once into a small fan of sub-arms for a bushier reef.")
private boolean subBranches = true;
@MinNumber(1)
@MaxNumber(5)
@Desc("BRANCHING only: how many sub-arms each arm splits into when subBranches is true.")
private int subBranchCount = 2;
@MinNumber(0)
@MaxNumber(1)
@Desc("BRANCHING only: the length of each sub-arm as a fraction of its parent arm.")
private double subBranchScale = 0.5;
@MinNumber(0)
@MaxNumber(4)
@Desc("BRANCHING and PILLAR only: the radius of the small coral tip cluster grown at each tip.")
private int tipClusterRadius = 1;
@MinNumber(1)
@MaxNumber(8)
@Desc("BRAIN only: the horizontal radius of the brain-coral blob in blocks.")
private int brainRadius = 3;
@MinNumber(0)
@MaxNumber(1)
@Desc("BRAIN only: how strongly 3D value noise perturbs the ellipsoid surface, for a wrinkled organic blob. 0 is a smooth dome.")
private double brainRoughness = 0.35;
@MinNumber(1)
@MaxNumber(12)
@Desc("PILLAR only: the radius of the stout vertical column in blocks.")
private int pillarRadius = 1;
@MinNumber(1)
@MaxNumber(8)
@Desc("FAN only: the half-width of the upright fan plane in blocks (the disc widens toward its mid-height).")
private int fanWidth = 3;
@MinNumber(1)
@MaxNumber(12)
@Desc("TENDRIL only: how many thin wavy stalks rise from the base.")
private int tendrilCount = 4;
public KList<IrisObject> getVariantObjects(IrisData data) {
return variantCache.aquire(() -> {
KList<IrisObject> baked = new KList<>();
int count = Math.max(1, variants);
for (int i = 0; i < count; i++) {
IrisObject object = CoralGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
if (object == null || object.getBlocks().isEmpty()) {
continue;
}
object.setLoadKey("procedural/" + name + "#" + i);
object.setLoader(data);
baked.add(object);
}
return baked;
});
}
public IrisObject getVariantObject(IrisData data, RNG rng) {
KList<IrisObject> baked = getVariantObjects(data);
if (baked == null || baked.isEmpty()) {
return null;
}
return baked.get(rng.i(baked.size()));
}
public IrisObjectPlacement asPlacement() {
IrisObjectPlacement placement = new IrisObjectPlacement();
placement.setMode(mode);
placement.setRotation(rotation);
placement.setClamp(clamp);
placement.setCarvingSupport(carvingSupport);
placement.setUnderwater(underwater);
placement.setTranslate(translate);
placement.setStiltSettings(stiltSettings);
placement.setVacuumSettings(vacuumSettings);
placement.setChance(chance);
placement.setDensity(density);
return placement;
}
public boolean isPlausible() {
return false;
}
}
@@ -1,33 +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.procedural.coral;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("How the arms of a BRANCHING coral are distributed around the central stalk by compass azimuth.")
public enum IrisCoralBranchAzimuth {
@Desc("Distribute arms by the golden angle (about 137.5 degrees per arm) for a natural phyllotactic spiral where no two arms overlap.")
GOLDEN_ANGLE,
@Desc("Distribute arms in evenly spaced spokes, dividing 360 degrees equally between them like a radial whorl.")
EVEN,
@Desc("Place each arm at a fully random azimuth using the deterministic per-variant RNG, for an irregular wild reef.")
RANDOM
}
@@ -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.procedural.coral;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("The overall silhouette a procedural coral grows into. Each form drives a completely different generation routine in the coral generator, from tree-like branching arms to rounded brain blobs and thin wavy tendrils.")
public enum IrisCoralForm {
@Desc("A tree-like coral built from a stout central stalk that sprouts several upward-leaning arms (distributed by golden angle or randomly), each optionally splitting once into sub-arms, with small coral tip clusters (fans / sea pickles) at the ends. The most structurally complex form and the closest analogue to a procedural tree.")
BRANCHING,
@Desc("A thin, single-block-thick vertical fan plane that rises and widens with height like a sheet of fire or horn coral. Reads as a flat decorative blade rather than a volume.")
FAN,
@Desc("A rounded, noise-perturbed ellipsoid blob of brain coral that bulges out of the seafloor like a boulder, with an irregular wrinkled surface driven by 3D value noise.")
BRAIN,
@Desc("A stout, thick vertical column of coral block topped with a dense tip cluster. Wider and blunter than a tendril, reading as a solid coral pillar or stack.")
PILLAR,
@Desc("Several very thin (one block wide) wavy stalks that rise upward and wander laterally using value noise, like a clump of swaying coral whips or kelp-thin growths.")
TENDRIL
}
@@ -0,0 +1,42 @@
/*
* 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.object.procedural.coral;
import art.arcane.iris.builtin.objects.coral.Coral;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
import art.arcane.volmlib.util.math.RNG;
/** A coral reef made placeable: its variants are baked by {@link CoralGenerator}. */
public final class ResolvedCoral extends ResolvedProceduralPlacement {
private final Coral settings;
public ResolvedCoral(Coral settings) {
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
this.settings = settings;
}
@Override
protected IrisObject generate(int index, RNG rng, IrisData data) {
return CoralGenerator.generate(settings, index, rng, data);
}
}
@@ -18,21 +18,21 @@
package art.arcane.iris.engine.object.procedural.crystal;
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
import art.arcane.iris.builtin.objects.crystal.Crystal;
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
public final class CrystalBaseBuilder {
private CrystalBaseBuilder() {
}
public static void build(CrystalCanvas canvas, IrisCrystal crystal, long seed) {
double radius = crystal.getBaseRadius();
public static void build(CrystalCanvas canvas, Crystal crystal, long seed) {
double radius = crystal.baseRadius();
if (radius <= 0.0) {
canvas.set(0, 0, 0, CrystalRole.BASE);
return;
}
double noiseStrength = crystal.getBaseNoise();
double noiseStrength = crystal.baseNoise();
int reach = (int) Math.ceil(radius + 1.0);
for (int x = -reach; x <= reach; x++) {
for (int y = -reach; y <= reach; y++) {
@@ -18,8 +18,9 @@
package art.arcane.iris.engine.object.procedural.crystal;
import art.arcane.iris.builtin.objects.crystal.Crystal;
import com.volmit.block.PaletteSpec;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.spi.PlatformBlockState;
@@ -33,7 +34,7 @@ public final class CrystalGenerator {
private CrystalGenerator() {
}
public static IrisObject generate(IrisCrystal crystal, int variantIndex, RNG rng, IrisData data) {
public static IrisObject generate(Crystal crystal, int variantIndex, RNG rng, IrisData data) {
CrystalCanvas canvas = new CrystalCanvas();
long structureSeed = rng.getSeed();
@@ -41,8 +42,8 @@ public final class CrystalGenerator {
CrystalShardBuilder.build(canvas, crystal, rng);
Map<Vector3i, PlatformBlockState> resolved = new HashMap<>();
RNG paletteRng = new RNG(crystal.getSeed());
RNG tipRng = new RNG(crystal.getSeed() + (variantIndex * 31337L) + 4099L);
RNG paletteRng = new RNG(crystal.seed());
RNG tipRng = new RNG(crystal.seed() + (variantIndex * 31337L) + 4099L);
for (Map.Entry<Vector3i, CrystalRole> entry : canvas.getCells().entrySet()) {
Vector3i position = entry.getKey();
@@ -59,7 +60,7 @@ public final class CrystalGenerator {
return IrisProceduralBlocks.assemble(resolved);
}
private static PlatformBlockState resolveRole(IrisCrystal crystal, CrystalRole role, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
private static PlatformBlockState resolveRole(Crystal crystal, CrystalRole role, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
return switch (role) {
case BASE -> resolveBase(crystal, data, x, y, z, paletteRng);
case SHARD -> resolveShard(crystal, data, x, y, z, paletteRng);
@@ -67,11 +68,11 @@ public final class CrystalGenerator {
};
}
private static PlatformBlockState resolveBase(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
boolean hasBase = IrisProceduralBlocks.paletteSet(crystal.getBasePalette())
|| (crystal.getBaseBlock() != null && !crystal.getBaseBlock().isEmpty());
private static PlatformBlockState resolveBase(Crystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
boolean hasBase = IrisProceduralBlocks.paletteSet(crystal.basePalette())
|| (crystal.baseBlock() != null && !crystal.baseBlock().isEmpty());
if (hasBase) {
PlatformBlockState base = IrisProceduralBlocks.resolve(crystal.getBaseBlock(), crystal.getBasePalette(), data, x, y, z, paletteRng);
PlatformBlockState base = IrisProceduralBlocks.resolve(crystal.baseBlock(), crystal.basePalette(), data, x, y, z, paletteRng);
if (base != null) {
return base;
}
@@ -79,17 +80,17 @@ public final class CrystalGenerator {
return resolveShard(crystal, data, x, y, z, paletteRng);
}
private static PlatformBlockState resolveShard(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
return IrisProceduralBlocks.resolve(crystal.getBlock(), crystal.getBlockPalette(), data, x, y, z, paletteRng);
private static PlatformBlockState resolveShard(Crystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
return IrisProceduralBlocks.resolve(crystal.block(), crystal.blockPalette(), data, x, y, z, paletteRng);
}
private static PlatformBlockState resolveTip(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
boolean hasTip = IrisProceduralBlocks.paletteSet(crystal.getTipPalette())
|| (crystal.getTipBlock() != null && !crystal.getTipBlock().isEmpty());
private static PlatformBlockState resolveTip(Crystal crystal, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
boolean hasTip = IrisProceduralBlocks.paletteSet(crystal.tipPalette())
|| (crystal.tipBlock() != null && !crystal.tipBlock().isEmpty());
if (hasTip) {
if (tipRng.chance(crystal.getTipChance())) {
PlatformBlockState tip = IrisProceduralBlocks.resolve(crystal.getTipBlock(), crystal.getTipPalette(), data, x, y, z, paletteRng);
if (tipRng.chance(crystal.tipChance())) {
PlatformBlockState tip = IrisProceduralBlocks.resolve(crystal.tipBlock(), crystal.tipPalette(), data, x, y, z, paletteRng);
if (tip != null) {
return tip;
}
@@ -97,9 +98,9 @@ public final class CrystalGenerator {
return resolveShard(crystal, data, x, y, z, paletteRng);
}
if (crystal.isGlow() && crystal.getGlowBlock() != null && !crystal.getGlowBlock().isEmpty()) {
if (tipRng.chance(crystal.getTipChance())) {
PlatformBlockState glow = IrisProceduralBlocks.resolve(crystal.getGlowBlock(), null, data, x, y, z, paletteRng);
if (crystal.glow() && crystal.glowBlock() != null && !crystal.glowBlock().isEmpty()) {
if (tipRng.chance(crystal.tipChance())) {
PlatformBlockState glow = IrisProceduralBlocks.resolve(crystal.glowBlock(), (PaletteSpec) null, data, x, y, z, paletteRng);
if (glow != null) {
return glow;
}
@@ -18,13 +18,14 @@
package art.arcane.iris.engine.object.procedural.crystal;
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystalSurface;
import art.arcane.iris.builtin.objects.crystal.CrystalSurface;
public final class CrystalGeometry {
private CrystalGeometry() {
}
public static double[] surfaceNormal(IrisCrystalSurface surface) {
public static double[] surfaceNormal(CrystalSurface surface) {
return switch (surface) {
case FLOOR -> new double[]{0.0, 1.0, 0.0};
case CEILING -> new double[]{0.0, -1.0, 0.0};
@@ -18,8 +18,8 @@
package art.arcane.iris.engine.object.procedural.crystal;
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystalDistribution;
import art.arcane.iris.builtin.objects.crystal.CrystalDistribution;
import art.arcane.iris.builtin.objects.crystal.Crystal;
import art.arcane.volmlib.util.math.RNG;
public final class CrystalShardBuilder {
@@ -28,24 +28,24 @@ public final class CrystalShardBuilder {
private CrystalShardBuilder() {
}
public static void build(CrystalCanvas canvas, IrisCrystal crystal, RNG rng) {
double[] normal = CrystalGeometry.surfaceNormal(crystal.getGrowthSurface());
public static void build(CrystalCanvas canvas, Crystal crystal, RNG rng) {
double[] normal = CrystalGeometry.surfaceNormal(crystal.growthSurface());
double[] u = CrystalGeometry.orthonormalBasisU(normal);
double[] v = CrystalGeometry.orthonormalBasisV(normal, u);
int countLo = Math.min(crystal.getShardCountMin(), crystal.getShardCountMax());
int countHi = Math.max(crystal.getShardCountMin(), crystal.getShardCountMax());
int countLo = Math.min(crystal.shardCountMin(), crystal.shardCountMax());
int countHi = Math.max(crystal.shardCountMin(), crystal.shardCountMax());
int shardCount = Math.max(1, rng.i(countLo, countHi + 1));
int lengthLo = Math.min(crystal.getShardLengthMin(), crystal.getShardLengthMax());
int lengthHi = Math.max(crystal.getShardLengthMin(), crystal.getShardLengthMax());
int lengthLo = Math.min(crystal.shardLengthMin(), crystal.shardLengthMax());
int lengthHi = Math.max(crystal.shardLengthMin(), crystal.shardLengthMax());
double spreadRadians = Math.toRadians(Math.max(0.0, Math.min(90.0, crystal.getSpreadAngle())));
double jitterAmount = Math.max(0.0, Math.min(1.0, crystal.getJitter()));
double emitRadius = Math.max(0.0, crystal.getBaseRadius() * 0.6);
double spreadRadians = Math.toRadians(Math.max(0.0, Math.min(90.0, crystal.spreadAngle())));
double jitterAmount = Math.max(0.0, Math.min(1.0, crystal.jitter()));
double emitRadius = Math.max(0.0, crystal.baseRadius() * 0.6);
for (int i = 0; i < shardCount; i++) {
double azimuth = azimuth(crystal.getDistribution(), i, rng);
double azimuth = azimuth(crystal.distribution(), i, rng);
azimuth += rng.d(-Math.PI, Math.PI) * jitterAmount * 0.5;
double cone = spreadRadians * fanFraction(shardCount, i, rng);
@@ -63,9 +63,9 @@ public final class CrystalShardBuilder {
}
}
private static void rasterizeShard(CrystalCanvas canvas, IrisCrystal crystal, double ox, double oy, double oz, double[] direction, int length) {
double baseRadius = Math.max(0.5, crystal.getShardBaseRadius());
double taper = Math.max(0.0, Math.min(1.0, crystal.getShardTaper()));
private static void rasterizeShard(CrystalCanvas canvas, Crystal crystal, double ox, double oy, double oz, double[] direction, int length) {
double baseRadius = Math.max(0.5, crystal.shardBaseRadius());
double taper = Math.max(0.0, Math.min(1.0, crystal.shardTaper()));
int samples = Math.max(1, length * 3);
@@ -108,8 +108,8 @@ public final class CrystalShardBuilder {
canvas.set(tipX, tipY, tipZ, CrystalRole.TIP);
}
private static double azimuth(IrisCrystalDistribution distribution, int index, RNG rng) {
if (distribution == IrisCrystalDistribution.GOLDEN_ANGLE) {
private static double azimuth(CrystalDistribution distribution, int index, RNG rng) {
if (distribution == CrystalDistribution.GOLDEN_ANGLE) {
return Math.toRadians(index * GOLDEN_ANGLE);
}
return rng.d(0.0, Math.PI * 2.0);
@@ -1,230 +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.procedural.crystal;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.placement.IrisObjectLimit;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.placement.IrisStiltSettings;
import art.arcane.iris.engine.object.placement.IrisVacuumSettings;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.data.cache.AtomicCache;
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.RegistryListBlockType;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.iris.engine.object.procedural.crystal.CrystalGenerator;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("crystal")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A single procedurally generated crystal cluster: a budding base blob with faceted, tapered shards radiating from it (geode / amethyst-style). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Built for caves.")
@Data
public class IrisCrystal implements IrisProceduralPlacement {
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
@Desc("A human readable name used in logs and as the variant load key.")
private String name = "crystal";
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance per chunk for this crystal cluster to attempt placement. Use density for multiple per chunk.")
private double chance = 0.2;
@MinNumber(1)
@Desc("If the chance check passes, attempt this many placements in the chunk.")
private int density = 1;
@MinNumber(1)
@MaxNumber(64)
@Desc("How many distinct variants to pre-bake for this crystal cluster. Higher means more variety at a small memory cost.")
private int variants = 6;
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
private long seed = 1337;
@Desc("The placement mode used to anchor the crystal cluster to the terrain.")
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
@Desc("Rotate this crystal cluster's placement.")
private IrisObjectRotation rotation = new IrisObjectRotation();
@Desc("Limit the max or min height of placement.")
private IrisObjectLimit clamp = new IrisObjectLimit();
@Desc("Whether this crystal cluster may place on the terrain surface, under carvings, or both. Crystals are meant for caves, so this defaults to CARVING_ONLY.")
private CarvingMode carvingSupport = CarvingMode.CARVING_ONLY;
@Desc("If true, the crystal cluster anchors on the terrain height ignoring the water surface.")
private boolean underwater = false;
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
private IrisObjectTranslate translate = new IrisObjectTranslate();
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
private IrisStiltSettings stiltSettings;
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
private IrisVacuumSettings vacuumSettings;
@Desc("The surface this crystal grows from (FLOOR shards up, CEILING shards down, WALL shards outward). This orients the baked geometry only.")
private IrisCrystalSurface growthSurface = IrisCrystalSurface.FLOOR;
@Required
@Desc("The primary crystal shard block, e.g. minecraft:amethyst_block. Ignored when blockPalette is set.")
@RegistryListBlockType
private String block = "minecraft:amethyst_block";
@Desc("A noise-driven palette for the crystal shards (a prismatic mix, e.g. amethyst_block, calcite, tinted_glass). When set this overrides the single block, letting the shards mix blocks by noise. Palette wins.")
private IrisMaterialPalette blockPalette = null;
@Desc("Optional block placed at the very tip of each shard for a different colored or sparkling point (e.g. minecraft:amethyst_cluster or glowstone). Ignored when tipPalette is set. If unset and glow is true, a light-emitting block is sprinkled among the tips instead.")
@RegistryListBlockType
private String tipBlock = null;
@Desc("A noise-driven palette for the shard tips. When set this overrides the single tipBlock. Palette wins.")
private IrisMaterialPalette tipPalette = null;
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance per shard that its very tip is replaced by the tip block (or glow block).")
private double tipChance = 0.6;
@Desc("If true and no tipBlock/tipPalette is set, sprinkle a light-emitting block (the glowBlock) among the shard tips for a sparkling geode.")
private boolean glow = false;
@Desc("The light-emitting block sprinkled among the tips when glow is true and no tip block is configured.")
@RegistryListBlockType
private String glowBlock = "minecraft:glowstone";
@Desc("Optional block for the budding base blob the shards grow from, e.g. minecraft:budding_amethyst or calcite. Ignored when basePalette is set. If unset, the base is built from the primary shard block.")
@RegistryListBlockType
private String baseBlock = "minecraft:budding_amethyst";
@Desc("A noise-driven palette for the budding base blob. When set this overrides the single baseBlock. Palette wins.")
private IrisMaterialPalette basePalette = null;
@MinNumber(0)
@Desc("Radius in blocks of the budding base blob the shards radiate from. 0 places no base blob (shards spring from a single point).")
private double baseRadius = 1.6;
@MinNumber(0)
@MaxNumber(1)
@Desc("How strongly value noise perturbs the surface of the base blob, for a lumpy organic budding base rather than a clean sphere.")
private double baseNoise = 0.35;
@MinNumber(1)
@Desc("Minimum number of shards radiating from the base.")
private int shardCountMin = 5;
@MinNumber(1)
@Desc("Maximum number of shards radiating from the base.")
private int shardCountMax = 11;
@MinNumber(1)
@Desc("Minimum length in blocks of a shard, measured from the base out to its pointed tip.")
private int shardLengthMin = 3;
@MinNumber(1)
@Desc("Maximum length in blocks of a shard, measured from the base out to its pointed tip.")
private int shardLengthMax = 8;
@MinNumber(0.5)
@Desc("Starting radius in blocks of a shard at its thick base end. The shard tapers from this down to a single block at the tip.")
private double shardBaseRadius = 1.4;
@MinNumber(0)
@MaxNumber(1)
@Desc("How aggressively each shard narrows from base to tip. 0 keeps a near-constant column; 1 tapers fully to a sharp point at the very tip. Each shard always ends in a single pointed block.")
private double shardTaper = 0.85;
@MinNumber(0)
@MaxNumber(90)
@Desc("The half-angle in degrees of the cone the shards fan within around the surface normal. 0 makes all shards parallel to the normal; larger values splay them outward into a starburst.")
private double spreadAngle = 45;
@Desc("How the shard azimuths are distributed around the normal (RANDOM for a chaotic clump, GOLDEN_ANGLE for an evenly spaced rosette).")
private IrisCrystalDistribution distribution = IrisCrystalDistribution.GOLDEN_ANGLE;
@MinNumber(0)
@MaxNumber(1)
@Desc("Per-shard angular randomness (0-1) added on top of the chosen distribution so the cluster never looks mechanically regular. 0 is perfectly distributed; 1 is heavily jittered.")
private double jitter = 0.25;
public KList<IrisObject> getVariantObjects(IrisData data) {
return variantCache.aquire(() -> {
KList<IrisObject> baked = new KList<>();
int count = Math.max(1, variants);
for (int i = 0; i < count; i++) {
IrisObject object = CrystalGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
if (object == null || object.getBlocks().isEmpty()) {
continue;
}
object.setLoadKey("procedural/" + name + "#" + i);
object.setLoader(data);
baked.add(object);
}
return baked;
});
}
public IrisObject getVariantObject(IrisData data, RNG rng) {
KList<IrisObject> baked = getVariantObjects(data);
if (baked == null || baked.isEmpty()) {
return null;
}
return baked.get(rng.i(baked.size()));
}
public IrisObjectPlacement asPlacement() {
IrisObjectPlacement placement = new IrisObjectPlacement();
placement.setMode(mode);
placement.setRotation(rotation);
placement.setClamp(clamp);
placement.setCarvingSupport(carvingSupport);
placement.setUnderwater(underwater);
placement.setTranslate(translate);
placement.setStiltSettings(stiltSettings);
placement.setVacuumSettings(vacuumSettings);
placement.setChance(chance);
placement.setDensity(density);
return placement;
}
public boolean isPlausible() {
return false;
}
}
@@ -1,30 +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.procedural.crystal;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("How the shards of a crystal cluster are angularly distributed around the surface normal.")
public enum IrisCrystalDistribution {
@Desc("Each shard gets a uniformly random azimuth around the normal. Produces a chaotic, naturally clumped cluster.")
RANDOM,
@Desc("Each shard's azimuth advances by the golden angle (~137.5 degrees) from the previous one. Produces an evenly spaced sunflower-like fan with no two shards overlapping, ideal for a geode rosette.")
GOLDEN_ANGLE
}
@@ -1,33 +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.procedural.crystal;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("The surface a crystal cluster grows from. This only orients the baked geometry (which way the shards point); placement of the object into a cave is handled by the placement system, not here.")
public enum IrisCrystalSurface {
@Desc("Grows from a cave floor. The budding base sits at the bottom and the shards point upward, fanning within the spread cone around the up axis. Built with positive py so the cluster grows up from the base layer.")
FLOOR,
@Desc("Grows from a cave ceiling. The budding base sits at the top and the shards point downward like stalactites, fanning within the spread cone around the down axis. Built with negative py so the cluster grows down from the ceiling.")
CEILING,
@Desc("Grows from a cave wall. The budding base hugs the wall and the shards point outward and slightly upward, fanning within the spread cone around a tilted normal so the cluster reads as a wall sconce of shards.")
WALL
}
@@ -0,0 +1,42 @@
/*
* 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.object.procedural.crystal;
import art.arcane.iris.builtin.objects.crystal.Crystal;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
import art.arcane.volmlib.util.math.RNG;
/** A crystal cluster made placeable: its variants are baked by {@link CrystalGenerator}. */
public final class ResolvedCrystal extends ResolvedProceduralPlacement {
private final Crystal settings;
public ResolvedCrystal(Crystal settings) {
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
this.settings = settings;
}
@Override
protected IrisObject generate(int index, RNG rng, IrisData data) {
return CrystalGenerator.generate(settings, index, rng, data);
}
}
@@ -18,8 +18,10 @@
package art.arcane.iris.engine.object.procedural.formation;
import com.volmit.block.PaletteSpec;
import java.util.Optional;
import art.arcane.iris.builtin.objects.formation.Formation;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.spi.PlatformBlockState;
@@ -30,37 +32,37 @@ public final class FormationBlockResolver {
private FormationBlockResolver() {
}
public static PlatformBlockState resolve(IrisFormation f, IrisData data, FormationCanvas.Role role, Vector3i raw) {
public static PlatformBlockState resolve(Formation f, IrisData data, FormationCanvas.Role role, Vector3i raw) {
int x = raw.getBlockX();
int y = raw.getBlockY();
int z = raw.getBlockZ();
RNG paletteRng = new RNG(f.getSeed());
RNG paletteRng = new RNG(f.seed());
if (role == FormationCanvas.Role.CAP && capDefined(f)) {
PlatformBlockState cap = IrisProceduralBlocks.resolve(f.getCapBlock(), f.getCapPalette(), data, x, y, z, paletteRng);
PlatformBlockState cap = IrisProceduralBlocks.resolve(f.capBlock(), f.capPalette(), data, x, y, z, paletteRng);
if (cap != null) {
return cap;
}
}
if (strataDefined(f)) {
IrisMaterialPalette strata = f.getStrataPalette();
int thickness = Math.max(1, f.getStrataThickness());
PaletteSpec strata = f.strataPalette().orElseThrow();
int thickness = Math.max(1, f.strataThickness());
int band = Math.floorDiv(y, thickness);
PlatformBlockState strataState = strata.get(new RNG(f.getSeed() + (band * 31L)), x, band, z, data);
PlatformBlockState strataState = IrisProceduralBlocks.pick(strata, data, f.seed() + (band * 31L), x, band, z);
if (strataState != null) {
return strataState;
}
}
return IrisProceduralBlocks.resolve(f.getBlock(), f.getBlockPalette(), data, x, y, z, paletteRng);
return IrisProceduralBlocks.resolve(f.block(), f.blockPalette(), data, x, y, z, paletteRng);
}
private static boolean capDefined(IrisFormation f) {
return IrisProceduralBlocks.paletteSet(f.getCapPalette()) || (f.getCapBlock() != null && !f.getCapBlock().isEmpty());
private static boolean capDefined(Formation f) {
return IrisProceduralBlocks.paletteSet(f.capPalette()) || f.capBlock().filter(block -> !block.isEmpty()).isPresent();
}
private static boolean strataDefined(IrisFormation f) {
return IrisProceduralBlocks.paletteSet(f.getStrataPalette());
private static boolean strataDefined(Formation f) {
return IrisProceduralBlocks.paletteSet(f.strataPalette());
}
}
@@ -18,8 +18,8 @@
package art.arcane.iris.engine.object.procedural.formation;
import art.arcane.iris.builtin.objects.formation.Formation;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.spi.PlatformBlockState;
@@ -33,18 +33,18 @@ public final class FormationGenerator {
private FormationGenerator() {
}
public static IrisObject generate(IrisFormation f, int variantIndex, RNG rng, IrisData data) {
int lo = Math.min(f.getHeightMin(), f.getHeightMax());
int hi = Math.max(f.getHeightMin(), f.getHeightMax());
public static IrisObject generate(Formation f, int variantIndex, RNG rng, IrisData data) {
int lo = Math.min(f.heightMin(), f.heightMax());
int hi = Math.max(f.heightMin(), f.heightMax());
int height = Math.max(3, rng.i(lo, hi + 1));
int wLo = Math.min(f.getBaseWidthMin(), f.getBaseWidthMax());
int wHi = Math.max(f.getBaseWidthMin(), f.getBaseWidthMax());
int wLo = Math.min(f.baseWidthMin(), f.baseWidthMax());
int wHi = Math.max(f.baseWidthMin(), f.baseWidthMax());
double baseRadius = Math.max(1, rng.i(wLo, wHi + 1));
FormationCanvas canvas = new FormationCanvas();
switch (f.getForm()) {
switch (f.form()) {
case SPIRE -> FormationShapeBuilder.spire(canvas, f, height, baseRadius, rng);
case HOODOO -> FormationShapeBuilder.hoodoo(canvas, f, height, baseRadius, rng);
case ARCH -> FormationShapeBuilder.arch(canvas, f, height, baseRadius, rng);
@@ -18,15 +18,16 @@
package art.arcane.iris.engine.object.procedural.formation;
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
import art.arcane.iris.builtin.objects.formation.Formation;
public final class FormationProfiles {
private FormationProfiles() {
}
public static double radiusAt(IrisFormation f, double baseRadius, double topRadius, double t) {
public static double radiusAt(Formation f, double baseRadius, double topRadius, double t) {
double clamped = Math.max(0.0, Math.min(1.0, t));
return switch (f.getProfile()) {
return switch (f.profile()) {
case CONSTANT -> baseRadius;
case LINEAR -> baseRadius + (topRadius - baseRadius) * clamped;
case TAPER -> baseRadius + (topRadius - baseRadius) * smoothstep(clamped);
@@ -35,9 +36,9 @@ public final class FormationProfiles {
};
}
private static double parabolic(IrisFormation f, double baseRadius, double topRadius, double t) {
double waist = Math.max(0.0, Math.min(1.0, f.getProfileWaist()));
double floor = Math.max(0.0, Math.min(1.0, f.getProfileWaistFloor()));
private static double parabolic(Formation f, double baseRadius, double topRadius, double t) {
double waist = Math.max(0.0, Math.min(1.0, f.profileWaist()));
double floor = Math.max(0.0, Math.min(1.0, f.profileWaistFloor()));
double denom = Math.pow(Math.max(waist, 1.0 - waist), 2);
if (denom == 0) {
denom = 1;
@@ -18,7 +18,7 @@
package art.arcane.iris.engine.object.procedural.formation;
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
import art.arcane.iris.builtin.objects.formation.Formation;
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
import art.arcane.iris.util.common.math.Vector3i;
import art.arcane.volmlib.util.math.RNG;
@@ -30,11 +30,11 @@ public final class FormationShapeBuilder {
private FormationShapeBuilder() {
}
public static void spire(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
double topRadius = f.getTopWidth();
public static void spire(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
double topRadius = f.topWidth();
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, true);
double lean = Math.toRadians(f.getLean());
double azimuth = Math.toRadians(f.getLeanAzimuth());
double lean = Math.toRadians(f.lean());
double azimuth = Math.toRadians(f.leanAzimuth());
int previousX = 0;
int previousZ = 0;
for (int y = 0; y < height; y++) {
@@ -53,25 +53,25 @@ public final class FormationShapeBuilder {
}
}
public static void seaStack(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
public static void seaStack(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
double topRadius = Math.max(1.0, baseRadius * 0.55);
if (f.getTopWidth() > 0) {
topRadius = f.getTopWidth();
if (f.topWidth() > 0) {
topRadius = f.topWidth();
}
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, true);
}
public static void hoodoo(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
double topRadius = f.getTopWidth() > 0 ? f.getTopWidth() : Math.max(1.0, baseRadius * 0.7);
public static void hoodoo(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
double topRadius = f.topWidth() > 0 ? f.topWidth() : Math.max(1.0, baseRadius * 0.7);
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, false);
int capRadius = f.getHoodooCapRadius();
int capRadius = f.hoodooCapRadius();
if (capRadius <= 0) {
return;
}
int capHeight = Math.max(1, f.getHoodooCapHeight());
double lean = Math.toRadians(f.getLean());
double azimuth = Math.toRadians(f.getLeanAzimuth());
int capHeight = Math.max(1, f.hoodooCapHeight());
double lean = Math.toRadians(f.lean());
double azimuth = Math.toRadians(f.leanAzimuth());
double shear = Math.tan(lean) * height;
double topOffX = Math.cos(azimuth) * shear;
double topOffZ = Math.sin(azimuth) * shear;
@@ -85,12 +85,12 @@ public final class FormationShapeBuilder {
}
}
public static void boulder(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
public static void boulder(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
double rx = baseRadius;
double ry = Math.max(2.0, height * 0.5);
double rz = baseRadius * (0.8 + rng.d(0.0, 0.3));
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
long noiseSeed = f.getSeed() + 4201L;
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
long noiseSeed = f.seed() + 4201L;
int maxR = (int) Math.ceil(Math.max(rx, Math.max(ry, rz))) + 2;
for (int x = -maxR; x <= maxR; x++) {
@@ -109,10 +109,10 @@ public final class FormationShapeBuilder {
}
}
public static void arch(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
double span = Math.max(2.0, f.getArchSpan());
double tubeRadius = Math.max(0.75, f.getArchThickness() * 0.5);
double asymmetry = Math.max(0.0, Math.min(1.0, f.getArchAsymmetry()));
public static void arch(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
double span = Math.max(2.0, f.archSpan());
double tubeRadius = Math.max(0.75, f.archThickness() * 0.5);
double asymmetry = Math.max(0.0, Math.min(1.0, f.archAsymmetry()));
double leftFootX = -span * 0.5 - tubeRadius - rng.d(0.0, span * 0.16) * asymmetry;
double rightFootX = span * 0.5 + tubeRadius + rng.d(0.0, span * 0.16) * asymmetry;
double leftFootZ = rng.d(-tubeRadius * 0.45, tubeRadius * 0.45) * asymmetry;
@@ -164,10 +164,10 @@ public final class FormationShapeBuilder {
}
}
public static void basaltColumns(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
int count = Math.max(2, f.getBasaltColumns());
int colRadius = Math.max(1, f.getBasaltColumnRadius());
double variance = Math.max(0.0, Math.min(1.0, f.getBasaltHeightVariance()));
public static void basaltColumns(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
int count = Math.max(2, f.basaltColumns());
int colRadius = Math.max(1, f.basaltColumnRadius());
double variance = Math.max(0.0, Math.min(1.0, f.basaltHeightVariance()));
int spread = (int) Math.ceil(baseRadius);
for (int c = 0; c < count; c++) {
@@ -194,14 +194,14 @@ public final class FormationShapeBuilder {
}
}
public static void iceberg(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
public static void iceberg(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
long noiseSeed = rng.nextLong();
double bodyHeight = Math.max(2.0, height * 0.42);
double radiusX = baseRadius * rng.d(1.15, 1.5);
double radiusZ = baseRadius * rng.d(1.0, 1.35);
ellipsoid(canvas, radiusX, bodyHeight, radiusZ, bodyHeight * 0.36, noiseSeed, f.getRoughness());
ellipsoid(canvas, radiusX, bodyHeight, radiusZ, bodyHeight * 0.36, noiseSeed, f.roughness());
int peaks = Math.max(1, f.getIcebergPeaks());
int peaks = Math.max(1, f.icebergPeaks());
double phase = rng.d(0.0, Math.PI * 2.0);
for (int i = 0; i < peaks; i++) {
double angle = phase + (Math.PI * 2.0 * i / peaks) + rng.d(-0.35, 0.35);
@@ -215,9 +215,9 @@ public final class FormationShapeBuilder {
}
}
public static void fissure(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
int count = Math.max(2, f.getFractureCount());
double separation = Math.max(1.0, f.getFractureSeparation());
public static void fissure(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
int count = Math.max(2, f.fractureCount());
double separation = Math.max(1.0, f.fractureSeparation());
double shardRadius = Math.max(1.0, baseRadius / Math.max(1.6, count * 0.72));
double phase = rng.d(0.0, Math.PI * 2.0);
@@ -233,11 +233,11 @@ public final class FormationShapeBuilder {
}
}
public static void spiral(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
public static void spiral(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
int steps = Math.max(12, height * 4);
double turns = Math.max(0.25, f.getSpiralTurns());
double startRadius = Math.max(1.0, f.getSpiralRadius());
double startThickness = Math.max(1.0, f.getSpiralThickness());
double turns = Math.max(0.25, f.spiralTurns());
double startRadius = Math.max(1.0, f.spiralRadius());
double startThickness = Math.max(1.0, f.spiralThickness());
double phase = rng.d(0.0, Math.PI * 2.0);
long noiseSeed = rng.nextLong();
@@ -257,11 +257,11 @@ public final class FormationShapeBuilder {
(int) Math.round(Math.sin(phase) * startRadius), footRadius, false, rng);
}
public static void overhang(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
public static void overhang(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
int steps = Math.max(12, height * 4);
double reach = Math.max(1.0, f.getOverhangReach());
double drop = Math.max(0.0, f.getOverhangDrop());
double phase = Math.toRadians(f.getLeanAzimuth()) + rng.d(-0.18, 0.18);
double reach = Math.max(1.0, f.overhangReach());
double drop = Math.max(0.0, f.overhangDrop());
double phase = Math.toRadians(f.leanAzimuth()) + rng.d(-0.18, 0.18);
double trunkHeight = Math.max(3.0, height * 0.62);
long noiseSeed = rng.nextLong();
@@ -285,12 +285,12 @@ public final class FormationShapeBuilder {
}
}
private static void column(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, double topRadius, int extraBaseX, int extraBaseZ, RNG rng, boolean capTop) {
double lean = Math.toRadians(f.getLean());
double azimuth = Math.toRadians(f.getLeanAzimuth());
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
long noiseSeed = f.getSeed() + 9001L;
private static void column(FormationCanvas canvas, Formation f, int height, double baseRadius, double topRadius, int extraBaseX, int extraBaseZ, RNG rng, boolean capTop) {
double lean = Math.toRadians(f.lean());
double azimuth = Math.toRadians(f.leanAzimuth());
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
double jitter = Math.max(0.0, Math.min(1.0, f.jitter()));
long noiseSeed = f.seed() + 9001L;
for (int y = 0; y < height; y++) {
double t = height <= 1 ? 1.0 : (y / (double) (height - 1));
@@ -311,7 +311,7 @@ public final class FormationShapeBuilder {
}
}
private static void ringDisc(FormationCanvas canvas, IrisFormation f, int cx, int y, int cz, double radius, double roughness, double jitter, long noiseSeed, boolean cap, RNG rng) {
private static void ringDisc(FormationCanvas canvas, Formation f, int cx, int y, int cz, double radius, double roughness, double jitter, long noiseSeed, boolean cap, RNG rng) {
int r = (int) Math.ceil(radius) + 1;
for (int x = -r; x <= r; x++) {
for (int z = -r; z <= r; z++) {
@@ -332,7 +332,7 @@ public final class FormationShapeBuilder {
}
}
private static void disc(FormationCanvas canvas, IrisFormation f, int cx, int y, int cz, double radius, boolean cap, RNG rng) {
private static void disc(FormationCanvas canvas, Formation f, int cx, int y, int cz, double radius, boolean cap, RNG rng) {
int r = (int) Math.ceil(radius) + 1;
for (int x = -r; x <= r; x++) {
for (int z = -r; z <= r; z++) {
@@ -347,11 +347,11 @@ public final class FormationShapeBuilder {
}
}
private static void taperedPeak(FormationCanvas canvas, IrisFormation f, int height, double radius,
private static void taperedPeak(FormationCanvas canvas, Formation f, int height, double radius,
int offsetX, int offsetZ, double leanAngle, double leanDistance, RNG rng) {
long noiseSeed = rng.nextLong();
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
double jitter = Math.max(0.0, Math.min(1.0, f.jitter()));
for (int y = 0; y < height; y++) {
double t = height <= 1 ? 1.0 : y / (double) (height - 1);
int x = offsetX + (int) Math.round(Math.cos(leanAngle) * leanDistance * t * t);
@@ -383,11 +383,11 @@ public final class FormationShapeBuilder {
}
}
private static void ball(FormationCanvas canvas, IrisFormation f, int centerX, int centerY, int centerZ,
private static void ball(FormationCanvas canvas, Formation f, int centerX, int centerY, int centerZ,
double radius, boolean cap, long noiseSeed, RNG rng) {
int extent = (int) Math.ceil(radius);
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
double jitter = Math.max(0.0, Math.min(1.0, f.jitter()));
for (int x = -extent; x <= extent; x++) {
for (int y = -extent; y <= extent; y++) {
for (int z = -extent; z <= extent; z++) {
@@ -1,304 +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.procedural.formation;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.placement.IrisObjectLimit;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.placement.IrisStiltSettings;
import art.arcane.iris.engine.object.placement.IrisVacuumSettings;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.data.cache.AtomicCache;
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.RegistryListBlockType;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.iris.engine.object.procedural.formation.FormationGenerator;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("formation")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A single procedurally generated natural formation, including rock landmarks and magical glacial silhouettes. Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file.")
@Data
public class IrisFormation implements IrisProceduralPlacement {
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
@Desc("A human readable name used in logs and as the variant load key.")
private String name = "formation";
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance per chunk for this formation to attempt placement. Use density for multiple per chunk.")
private double chance = 0.02;
@MinNumber(1)
@Desc("If the chance check passes, attempt this many placements in the chunk.")
private int density = 1;
@MinNumber(1)
@MaxNumber(64)
@Desc("How many distinct variants to pre-bake for this formation. Higher means more variety at a small memory cost.")
private int variants = 6;
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
private long seed = 1337;
@Desc("The placement mode used to anchor the formation to the terrain.")
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
@Desc("Rotate this formation's placement.")
private IrisObjectRotation rotation = new IrisObjectRotation();
@Desc("Limit the max or min height of placement.")
private IrisObjectLimit clamp = new IrisObjectLimit();
@Desc("Whether this formation may place on the terrain surface, under carvings, or both.")
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
@MinNumber(0)
@MaxNumber(16)
@Desc("Horizontal buffer, in blocks, beyond each lowest solid foundation block that must also be solid, un-carved ground.")
private int surfaceSupportBuffer = 3;
@Desc("If true, the formation anchors on the terrain height ignoring the water surface.")
private boolean underwater = false;
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
private IrisObjectTranslate translate = new IrisObjectTranslate();
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
private IrisStiltSettings stiltSettings;
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
private IrisVacuumSettings vacuumSettings;
@Desc("The overall silhouette of the formation. Drives which sculpting routine the generator uses.")
private IrisFormationForm form = IrisFormationForm.SPIRE;
@Required
@Desc("The main rock block, e.g. minecraft:stone. Ignored when blockPalette is set.")
@RegistryListBlockType
private String block = "minecraft:stone";
@Desc("A noise-driven palette for the main rock body. When set this overrides the single block, letting the body mix blocks by noise.")
private IrisMaterialPalette blockPalette = null;
@Desc("Optional caprock block placed on the top crown of the formation (and the wide overhanging cap for HOODOO). Ignored when capPalette is set. When null and capPalette is unset, the formation uses its main rock everywhere.")
@RegistryListBlockType
private String capBlock = null;
@Desc("A noise-driven palette for the caprock. When set this overrides the single capBlock.")
private IrisMaterialPalette capPalette = null;
@Desc("Optional palette of strata (horizontal colored bands) blended into the rock body by y level. When set, every strataThickness blocks of height switches to the next strata block, producing the signature banded look. Falls back to the main block where unset.")
private IrisMaterialPalette strataPalette = null;
@MinNumber(1)
@MaxNumber(32)
@Desc("The thickness in blocks of each horizontal strata band when strataPalette is set.")
private int strataThickness = 3;
@MinNumber(1)
@Desc("Minimum total height of the formation in blocks.")
private int heightMin = 14;
@MinNumber(1)
@Desc("Maximum total height of the formation in blocks.")
private int heightMax = 26;
@MinNumber(1)
@Desc("Minimum base radius (half-width) of the formation in blocks.")
private int baseWidthMin = 3;
@MinNumber(1)
@Desc("Maximum base radius (half-width) of the formation in blocks.")
private int baseWidthMax = 6;
@MinNumber(0)
@Desc("The target radius (half-width) at the very top of the formation in blocks, before the profile is applied. 0 means taper to a point.")
private int topWidth = 0;
@Desc("The function used to shape the formation radius over its height.")
private IrisFormationProfile profile = IrisFormationProfile.TAPER;
@MinNumber(0)
@MaxNumber(1)
@Desc("The normalized height (0 base, 1 top) of the pinched waist for the PARABOLIC profile (used by HOODOO).")
private double profileWaist = 0.55;
@MinNumber(0)
@MaxNumber(1)
@Desc("The minimum radius fraction at the waist for the PARABOLIC profile. Lower values pinch the waist tighter.")
private double profileWaistFloor = 0.35;
@MinNumber(0)
@Desc("How far the formation leans, in degrees from vertical. 0 is perfectly upright. The whole body is sheared by this amount over its height.")
private double lean = 0;
@Desc("Compass direction in degrees the formation leans toward when lean is non-zero.")
private double leanAzimuth = 0;
@MinNumber(0)
@MaxNumber(1)
@Desc("Surface roughness from 0 (a clean smooth solid) to 1 (heavily eroded and pitted). Driven by 3D value noise that perturbs the radius so the formation never reads as a clean cylinder.")
private double roughness = 0.3;
@MinNumber(0)
@MaxNumber(1)
@Desc("Per-block surface jitter from 0 (none) to 1 (maximum). Randomly carves and adds isolated edge blocks to break up the silhouette.")
private double jitter = 0.15;
@MinNumber(0)
@Desc("Extra wide cap radius in blocks added on top for the HOODOO form, producing the overhanging mushroom caprock. 0 disables the overhang.")
private int hoodooCapRadius = 3;
@MinNumber(1)
@MaxNumber(6)
@Desc("The height in blocks of the HOODOO overhanging caprock slab.")
private int hoodooCapHeight = 3;
@MinNumber(0)
@Desc("How wide the ARCH opening is in blocks (the gap between the two legs). The arch span is rasterized over this width.")
private int archSpan = 10;
@MinNumber(1)
@Desc("The thickness in blocks of the ARCH legs and spanning curve.")
private int archThickness = 3;
@MinNumber(0)
@MaxNumber(1)
@Desc("How strongly an ARCH varies its leg steepness, crown position, depth bow and tube width between deterministic variants. 0 is symmetric and 1 is highly organic.")
private double archAsymmetry = 0.35;
@MinNumber(2)
@MaxNumber(12)
@Desc("How many separate columns make up a BASALT_COLUMN cluster. Each column gets a randomized height around the formation height range.")
private int basaltColumns = 5;
@MinNumber(1)
@Desc("The radius (half-width) in blocks of each individual column in a BASALT_COLUMN cluster.")
private int basaltColumnRadius = 1;
@MinNumber(0)
@MaxNumber(1)
@Desc("How much the heights of individual BASALT_COLUMN columns vary from each other, from 0 (all equal) to 1 (highly varied).")
private double basaltHeightVariance = 0.45;
@MinNumber(1)
@MaxNumber(12)
@Desc("How many tapered summits crown an ICEBERG formation.")
private int icebergPeaks = 3;
@MinNumber(2)
@MaxNumber(8)
@Desc("How many separated shards form a FISSURE.")
private int fractureCount = 3;
@MinNumber(1)
@MaxNumber(16)
@Desc("Open-air separation in blocks between the shards of a FISSURE.")
private int fractureSeparation = 2;
@MinNumber(0.25)
@MaxNumber(6)
@Desc("How many complete turns a SPIRAL makes from base to tip.")
private double spiralTurns = 1.5;
@MinNumber(1)
@MaxNumber(32)
@Desc("The starting distance in blocks between a SPIRAL and its open center.")
private int spiralRadius = 4;
@MinNumber(1)
@MaxNumber(8)
@Desc("The radius in blocks of the tube swept along a SPIRAL.")
private int spiralThickness = 2;
@MinNumber(1)
@MaxNumber(32)
@Desc("How far the hooked arm of an OVERHANG projects from its base.")
private int overhangReach = 8;
@MinNumber(0)
@MaxNumber(16)
@Desc("How many blocks the tip of an OVERHANG curls downward.")
private int overhangDrop = 3;
public KList<IrisObject> getVariantObjects(IrisData data) {
return variantCache.aquire(() -> {
KList<IrisObject> baked = new KList<>();
int count = Math.max(1, variants);
for (int i = 0; i < count; i++) {
IrisObject object = FormationGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
if (object == null || object.getBlocks().isEmpty()) {
continue;
}
object.setLoadKey("procedural/" + name + "#" + i);
object.setLoader(data);
baked.add(object);
}
return baked;
});
}
public IrisObject getVariantObject(IrisData data, RNG rng) {
KList<IrisObject> baked = getVariantObjects(data);
if (baked == null || baked.isEmpty()) {
return null;
}
return baked.get(rng.i(baked.size()));
}
public IrisObjectPlacement asPlacement() {
IrisObjectPlacement placement = new IrisObjectPlacement();
placement.setMode(mode);
placement.setRotation(rotation);
placement.setClamp(clamp);
placement.setCarvingSupport(carvingSupport);
placement.setSurfaceSupportBuffer(surfaceSupportBuffer);
placement.setUnderwater(underwater);
placement.setTranslate(translate);
placement.setStiltSettings(stiltSettings);
placement.setVacuumSettings(vacuumSettings);
placement.setChance(chance);
placement.setDensity(density);
return placement;
}
public boolean isPlausible() {
return false;
}
}
@@ -1,45 +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.procedural.formation;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("The overall silhouette of a procedural natural formation. Each form drives a distinct sculpting routine in the formation generator.")
public enum IrisFormationForm {
@Desc("A tall, slender needle of rock that tapers smoothly to a point at the top (a sharp pinnacle or stone spire).")
SPIRE,
@Desc("A column with a pinched, eroded waist and a wide overhanging caprock balanced on top (the classic desert hoodoo / mushroom rock).")
HOODOO,
@Desc("Two stout legs joined by a spanning curved bridge of rock overhead (a natural stone arch).")
ARCH,
@Desc("A chunky, blocky stack that tapers gently as it rises, like an isolated pillar of rock standing in water (a sea stack).")
SEA_STACK,
@Desc("A rounded, lumpy boulder formed from a noise-perturbed ellipsoid that sits low on the terrain.")
BOULDER,
@Desc("A tightly packed cluster of several vertical, near-hexagonal columns of varying height (a basalt column formation / giant's causeway).")
BASALT_COLUMN,
@Desc("A broad, faceted mound crowned by several irregular tapered peaks, suitable for icebergs and glacial outcrops.")
ICEBERG,
@Desc("Several separated, outward-leaning shards divided by open cracks.")
FISSURE,
@Desc("A tapered tube swept around a tightening helix, leaving open air through its curled center.")
SPIRAL,
@Desc("A grounded pillar that bends into a long hooked cantilever and curls downward at its tip.")
OVERHANG
}
@@ -1,35 +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.procedural.formation;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("A width-shaping function evaluated over normalized height (0 at the base, 1 at the top). Controls how the formation radius scales between baseWidth at the bottom and topWidth at the top.")
public enum IrisFormationProfile {
@Desc("Same radius at every height (a straight cylinder of constant baseWidth).")
CONSTANT,
@Desc("Radius ramps straight from baseWidth at the bottom to topWidth at the top.")
LINEAR,
@Desc("Radius shrinks smoothly toward a point as height increases (an ease that drives the SPIRE needle and gentle SEA_STACK taper).")
TAPER,
@Desc("Radius pinches to a narrow waist near profileWaist then widens again toward the top (the eroded waist used by HOODOO columns).")
PARABOLIC,
@Desc("Radius bulges out to its maximum in the middle of the height range and narrows at both ends (a barrel / bulged column).")
BULGE
}
@@ -0,0 +1,48 @@
/*
* 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.object.procedural.formation;
import art.arcane.iris.builtin.objects.formation.Formation;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
import art.arcane.volmlib.util.math.RNG;
/** A rock formation made placeable: its variants are baked by {@link FormationGenerator}. */
public final class ResolvedFormation extends ResolvedProceduralPlacement {
private final Formation settings;
public ResolvedFormation(Formation settings) {
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
this.settings = settings;
}
@Override
protected void customize(IrisObjectPlacement placement) {
placement.setSurfaceSupportBuffer(settings.surfaceSupportBuffer());
}
@Override
protected IrisObject generate(int index, RNG rng, IrisData data) {
return FormationGenerator.generate(settings, index, rng, data);
}
}
@@ -18,8 +18,10 @@
package art.arcane.iris.engine.object.procedural.fungi;
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
import art.arcane.iris.engine.object.procedural.fungi.IrisFungusCapShape;
import com.volmit.block.PaletteSpec;
import java.util.Optional;
import art.arcane.iris.builtin.objects.fungi.FungusCapShape;
import art.arcane.iris.builtin.objects.fungi.Fungus;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
@@ -31,17 +33,17 @@ public final class FungusCapBuilder {
private FungusCapBuilder() {
}
public static void build(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, int baseRadius, double cx, int baseY, double cz, long seed) {
int radius = (int) Math.round(baseRadius + Math.max(0.0, fungus.getCapOverhang()));
int thickness = Math.max(1, Math.min(3, fungus.getCapThickness()));
double squish = Math.max(0.0, Math.min(1.0, fungus.getCapSquish()));
double droop = Math.max(0.0, fungus.getCapDroop());
IrisFungusCapShape shape = fungus.getCapShape() == null ? IrisFungusCapShape.DOME : fungus.getCapShape();
public static void build(Map<Vector3i, FungusCellRole> roles, Fungus fungus, int baseRadius, double cx, int baseY, double cz, long seed) {
int radius = (int) Math.round(baseRadius + Math.max(0.0, fungus.capOverhang()));
int thickness = Math.max(1, Math.min(3, fungus.capThickness()));
double squish = Math.max(0.0, Math.min(1.0, fungus.capSquish()));
double droop = Math.max(0.0, fungus.capDroop());
FungusCapShape shape = fungus.capShape() == null ? FungusCapShape.DOME : fungus.capShape();
int icx = (int) Math.round(cx);
int icz = (int) Math.round(cz);
boolean hasGill = blockOrPaletteSet(fungus.getGillBlock(), fungus.getGillPalette());
boolean hasSpot = blockOrPaletteSet(fungus.getSpotBlock(), fungus.getSpotPalette());
boolean hasGill = blockOrPaletteSet(fungus.gillBlock(), fungus.gillPalette());
boolean hasSpot = blockOrPaletteSet(fungus.spotBlock(), fungus.spotPalette());
double apexRise = apexRise(shape, radius) * (1.0 - 0.6 * squish);
double droopReach = Math.tan(Math.toRadians(droop)) * radius;
@@ -68,9 +70,9 @@ public final class FungusCapBuilder {
boolean underside = layer == thickness - 1;
boolean topFace = layer == 0;
if (underside && hasGill && rollNoise(icx + dx, y, icz + dz, seed + 4111L) <= fungus.getGillChance()) {
if (underside && hasGill && rollNoise(icx + dx, y, icz + dz, seed + 4111L) <= fungus.gillChance()) {
role = FungusCellRole.GILL;
} else if (topFace && hasSpot && spotNoise(icx + dx, y, icz + dz, seed + 9311L) <= fungus.getSpotChance()) {
} else if (topFace && hasSpot && spotNoise(icx + dx, y, icz + dz, seed + 9311L) <= fungus.spotChance()) {
role = FungusCellRole.SPOT;
}
@@ -80,7 +82,7 @@ public final class FungusCapBuilder {
}
}
private static double apexRise(IrisFungusCapShape shape, int radius) {
private static double apexRise(FungusCapShape shape, int radius) {
return switch (shape) {
case DOME -> radius * 0.85;
case CONICAL -> radius * 1.4;
@@ -90,7 +92,7 @@ public final class FungusCapBuilder {
};
}
private static double capSurface(IrisFungusCapShape shape, double normalized, double apexRise) {
private static double capSurface(FungusCapShape shape, double normalized, double apexRise) {
double n = Math.max(0.0, Math.min(1.0, normalized));
return switch (shape) {
case DOME -> apexRise * Math.sqrt(Math.max(0.0, 1.0 - n * n));
@@ -109,10 +111,10 @@ public final class FungusCapBuilder {
return TreeFunctions.valueNoise3D(Math.floorDiv(x, 2), y, Math.floorDiv(z, 2), seed);
}
static boolean blockOrPaletteSet(String block, IrisMaterialPalette palette) {
static boolean blockOrPaletteSet(Optional<String> block, Optional<PaletteSpec> palette) {
if (IrisProceduralBlocks.paletteSet(palette)) {
return true;
}
return block != null && !block.isEmpty();
return block.filter(name -> !name.isEmpty()).isPresent();
}
}
@@ -18,8 +18,8 @@
package art.arcane.iris.engine.object.procedural.fungi;
import art.arcane.iris.builtin.objects.fungi.Fungus;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.spi.PlatformBlockState;
@@ -33,11 +33,11 @@ public final class FungusGenerator {
private FungusGenerator() {
}
public static IrisObject generate(IrisFungus fungus, int height, RNG rng, IrisData data) {
public static IrisObject generate(Fungus fungus, int height, RNG rng, IrisData data) {
Map<Vector3i, FungusCellRole> roles = new HashMap<>();
long baseSeed = rng.getSeed();
if (fungus.isShelf()) {
if (fungus.shelf()) {
FungusShelfBuilder.build(roles, fungus, rng, baseSeed);
} else {
buildUpright(roles, fungus, height, rng, baseSeed);
@@ -47,7 +47,7 @@ public final class FungusGenerator {
return null;
}
RNG paletteRng = new RNG(fungus.getSeed());
RNG paletteRng = new RNG(fungus.seed());
Map<Vector3i, PlatformBlockState> resolved = new HashMap<>();
for (Map.Entry<Vector3i, FungusCellRole> entry : roles.entrySet()) {
Vector3i pos = entry.getKey();
@@ -61,7 +61,7 @@ public final class FungusGenerator {
return IrisProceduralBlocks.assemble(resolved);
}
private static void buildUpright(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, int height, RNG rng, long baseSeed) {
private static void buildUpright(Map<Vector3i, FungusCellRole> roles, Fungus fungus, int height, RNG rng, long baseSeed) {
int stemHeight = Math.max(1, height);
Map<Vector3i, PlatformBlockState> stemCells = new HashMap<>();
double[] top = FungusStemBuilder.build(stemCells, fungus, stemHeight, baseSeed);
@@ -76,28 +76,28 @@ public final class FungusGenerator {
FungusCapBuilder.build(roles, fungus, radius, cx, capBaseY, cz, baseSeed + 5557L);
}
private static int pickRadius(IrisFungus fungus, RNG rng) {
int lo = Math.min(fungus.getCapRadiusMin(), fungus.getCapRadiusMax());
int hi = Math.max(fungus.getCapRadiusMin(), fungus.getCapRadiusMax());
private static int pickRadius(Fungus fungus, RNG rng) {
int lo = Math.min(fungus.capRadiusMin(), fungus.capRadiusMax());
int hi = Math.max(fungus.capRadiusMin(), fungus.capRadiusMax());
lo = Math.max(1, lo);
hi = Math.max(lo, hi);
return rng.i(lo, hi + 1);
}
private static PlatformBlockState resolveRole(IrisFungus fungus, FungusCellRole role, IrisData data, Vector3i pos, RNG paletteRng) {
private static PlatformBlockState resolveRole(Fungus fungus, FungusCellRole role, IrisData data, Vector3i pos, RNG paletteRng) {
int x = pos.getBlockX();
int y = pos.getBlockY();
int z = pos.getBlockZ();
return switch (role) {
case STEM -> IrisProceduralBlocks.resolve(fungus.getStem(), fungus.getStemPalette(), data, x, y, z, paletteRng);
case CAP -> IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
case STEM -> IrisProceduralBlocks.resolve(fungus.stem(), fungus.stemPalette(), data, x, y, z, paletteRng);
case CAP -> IrisProceduralBlocks.resolve(fungus.cap(), fungus.capPalette(), data, x, y, z, paletteRng);
case GILL -> {
PlatformBlockState gill = IrisProceduralBlocks.resolve(fungus.getGillBlock(), fungus.getGillPalette(), data, x, y, z, paletteRng);
yield gill != null ? gill : IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
PlatformBlockState gill = IrisProceduralBlocks.resolve(fungus.gillBlock(), fungus.gillPalette(), data, x, y, z, paletteRng);
yield gill != null ? gill : IrisProceduralBlocks.resolve(fungus.cap(), fungus.capPalette(), data, x, y, z, paletteRng);
}
case SPOT -> {
PlatformBlockState spot = IrisProceduralBlocks.resolve(fungus.getSpotBlock(), fungus.getSpotPalette(), data, x, y, z, paletteRng);
yield spot != null ? spot : IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
PlatformBlockState spot = IrisProceduralBlocks.resolve(fungus.spotBlock(), fungus.spotPalette(), data, x, y, z, paletteRng);
yield spot != null ? spot : IrisProceduralBlocks.resolve(fungus.cap(), fungus.capPalette(), data, x, y, z, paletteRng);
}
};
}
@@ -18,7 +18,7 @@
package art.arcane.iris.engine.object.procedural.fungi;
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
import art.arcane.iris.builtin.objects.fungi.Fungus;
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
import art.arcane.iris.util.common.math.Vector3i;
import art.arcane.volmlib.util.math.RNG;
@@ -29,20 +29,20 @@ public final class FungusShelfBuilder {
private FungusShelfBuilder() {
}
public static void build(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, RNG rng, long seed) {
int radius = Math.max(1, fungus.getShelfRadius());
public static void build(Map<Vector3i, FungusCellRole> roles, Fungus fungus, RNG rng, long seed) {
int radius = Math.max(1, fungus.shelfRadius());
double azimuth = rng.d(0.0, Math.PI * 2.0);
double fanX = Math.sin(azimuth);
double fanZ = Math.cos(azimuth);
int stubHeight = Math.max(0, Math.min(2, fungus.getStemWidth()));
int stubHeight = Math.max(0, Math.min(2, fungus.stemWidth()));
for (int y = 0; y < stubHeight; y++) {
roles.put(new Vector3i(0, y, 0), FungusCellRole.STEM);
}
int fanY = stubHeight;
boolean hasGill = FungusCapBuilder.blockOrPaletteSet(fungus.getGillBlock(), fungus.getGillPalette());
boolean hasSpot = FungusCapBuilder.blockOrPaletteSet(fungus.getSpotBlock(), fungus.getSpotPalette());
boolean hasGill = FungusCapBuilder.blockOrPaletteSet(fungus.gillBlock(), fungus.gillPalette());
boolean hasSpot = FungusCapBuilder.blockOrPaletteSet(fungus.spotBlock(), fungus.spotPalette());
for (int dx = -radius; dx <= radius; dx++) {
for (int dz = -radius; dz <= radius; dz++) {
@@ -59,12 +59,12 @@ public final class FungusShelfBuilder {
int y = fanY + lift;
FungusCellRole role = FungusCellRole.CAP;
if (hasSpot && spotNoise(dx, y, dz, seed + 9311L) <= fungus.getSpotChance()) {
if (hasSpot && spotNoise(dx, y, dz, seed + 9311L) <= fungus.spotChance()) {
role = FungusCellRole.SPOT;
}
roles.putIfAbsent(new Vector3i(dx, y, dz), role);
if (hasGill && rollNoise(dx, y - 1, dz, seed + 4111L) <= fungus.getGillChance()) {
if (hasGill && rollNoise(dx, y - 1, dz, seed + 4111L) <= fungus.gillChance()) {
roles.putIfAbsent(new Vector3i(dx, y - 1, dz), FungusCellRole.GILL);
}
}
@@ -18,7 +18,7 @@
package art.arcane.iris.engine.object.procedural.fungi;
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
import art.arcane.iris.builtin.objects.fungi.Fungus;
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.math.Vector3i;
@@ -29,15 +29,15 @@ public final class FungusStemBuilder {
private FungusStemBuilder() {
}
public static double[] build(Map<Vector3i, PlatformBlockState> stemCells, IrisFungus fungus, int stemHeight, long seed) {
int width = Math.max(1, Math.min(3, fungus.getStemWidth()));
double maxLean = stemHeight * Math.tan(Math.toRadians(Math.max(0.0, fungus.getStemCurve())));
double leanRad = Math.toRadians(fungus.getStemLeanAzimuth());
public static double[] build(Map<Vector3i, PlatformBlockState> stemCells, Fungus fungus, int stemHeight, long seed) {
int width = Math.max(1, Math.min(3, fungus.stemWidth()));
double maxLean = stemHeight * Math.tan(Math.toRadians(Math.max(0.0, fungus.stemCurve())));
double leanRad = Math.toRadians(fungus.stemLeanAzimuth());
double leanX = Math.sin(leanRad);
double leanZ = Math.cos(leanRad);
double waveAmp = Math.max(0.0, fungus.getStemWaveAmplitude());
double wavePeriods = fungus.getStemWavePeriods() == 0 ? 1.0 : fungus.getStemWavePeriods();
double waveAzimuth = Math.toRadians(fungus.getStemLeanAzimuth() + 90.0);
double waveAmp = Math.max(0.0, fungus.stemWaveAmplitude());
double wavePeriods = fungus.stemWavePeriods() == 0 ? 1.0 : fungus.stemWavePeriods();
double waveAzimuth = Math.toRadians(fungus.stemLeanAzimuth() + 90.0);
double waveX = Math.sin(waveAzimuth);
double waveZ = Math.cos(waveAzimuth);
@@ -1,262 +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.procedural.fungi;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.placement.IrisObjectLimit;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.placement.IrisStiltSettings;
import art.arcane.iris.engine.object.placement.IrisVacuumSettings;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.data.cache.AtomicCache;
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.RegistryListBlockType;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.iris.engine.object.procedural.fungi.FungusGenerator;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("fungus")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A single procedurally generated fungus (giant mushroom or shelf fungus). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. The fungus is built as a stem column with a cap dome grown on top, mirroring the trunk-and-canopy model used by procedural trees.")
@Data
public class IrisFungus implements IrisProceduralPlacement {
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
@Desc("A human readable name used in logs and as the variant load key.")
private String name = "fungus";
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance per chunk for this fungus to attempt placement. Use density for multiple per chunk.")
private double chance = 0.4;
@MinNumber(1)
@Desc("If the chance check passes, attempt this many placements in the chunk.")
private int density = 1;
@MinNumber(1)
@MaxNumber(64)
@Desc("How many distinct variants to pre-bake for this fungus. Higher means more variety at a small memory cost.")
private int variants = 6;
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
private long seed = 1337;
@Desc("The placement mode used to anchor the fungus to the terrain.")
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
@Desc("Rotate this fungus's placement.")
private IrisObjectRotation rotation = new IrisObjectRotation();
@Desc("Limit the max or min height of placement.")
private IrisObjectLimit clamp = new IrisObjectLimit();
@Desc("Whether this fungus may place on the terrain surface, under carvings, or both.")
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
@Desc("If true, the fungus anchors on the terrain height ignoring the water surface.")
private boolean underwater = false;
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
private IrisObjectTranslate translate = new IrisObjectTranslate();
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
private IrisStiltSettings stiltSettings;
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
private IrisVacuumSettings vacuumSettings;
@Required
@Desc("The stem block, e.g. minecraft:mushroom_stem. Ignored when stemPalette is set.")
@RegistryListBlockType
private String stem = "minecraft:mushroom_stem";
@Desc("A noise-driven palette for the stem. When set this overrides the single stem block, letting the stem mix blocks by noise.")
private IrisMaterialPalette stemPalette = null;
@Required
@Desc("The cap block, e.g. minecraft:red_mushroom_block. Ignored when capPalette is set.")
@RegistryListBlockType
private String cap = "minecraft:red_mushroom_block";
@Desc("A noise-driven palette for the cap. When set this overrides the single cap block, letting the cap mix blocks by noise.")
private IrisMaterialPalette capPalette = null;
@MinNumber(1)
@Desc("Minimum total stem height in blocks. Variants spread between this and stemHeightMax.")
private int stemHeightMin = 5;
@MinNumber(1)
@Desc("Maximum total stem height in blocks. Variants spread between stemHeightMin and this.")
private int stemHeightMax = 9;
@MinNumber(1)
@MaxNumber(3)
@Desc("Base stem width in blocks. 1 is a single column, 2 is a 2x2 stem, 3 is a chunky 3x3 trunk.")
private int stemWidth = 1;
@Desc("How far the stem leans away from vertical, in degrees. 0 is perfectly upright; small values give an organic tilt.")
private double stemCurve = 0;
@Desc("Compass direction in degrees the stem leans toward when stemCurve is non-zero.")
private double stemLeanAzimuth = 0;
@MinNumber(0)
@Desc("Amplitude in blocks of a gentle sideways wave applied up the stem so it is not a perfectly straight ruler.")
private double stemWaveAmplitude = 0.4;
@MinNumber(0.0001)
@Desc("The number of full sine wobbles applied over the stem height for the stem wave.")
private double stemWavePeriods = 1;
@Desc("The silhouette of the cap (dome, flat umbrella, funnel, cone, or wide shallow slab).")
private IrisFungusCapShape capShape = IrisFungusCapShape.DOME;
@MinNumber(1)
@Desc("Minimum cap radius in blocks (measured from the cap center to its rim).")
private int capRadiusMin = 3;
@MinNumber(1)
@Desc("Maximum cap radius in blocks (measured from the cap center to its rim).")
private int capRadiusMax = 5;
@MinNumber(1)
@MaxNumber(3)
@Desc("How many blocks thick the cap shell is. 1 is a thin skin, 3 is a fleshy slab.")
private int capThickness = 1;
@MinNumber(0)
@MaxNumber(1)
@Desc("Vertical flatten factor for the cap. 0 leaves the cap at full height, 1 squashes it flat into a disc.")
private double capSquish = 0.4;
@MinNumber(0)
@Desc("How far the cap rim droops downward, in degrees, curling the edge of the cap toward the ground.")
private double capDroop = 20;
@MinNumber(0)
@Desc("How far the cap radius extends past the stem before the rim begins, in blocks. Larger values make the cap overhang the stem more.")
private double capOverhang = 2;
@Desc("Optional block forming the gill layer on the underside of the cap (gills or a glow layer), e.g. minecraft:brown_mushroom_block or minecraft:shroomlight. Ignored when gillPalette is set or left null.")
@RegistryListBlockType
private String gillBlock = null;
@Desc("A noise-driven palette for the underside gill layer. When set this overrides the single gillBlock.")
private IrisMaterialPalette gillPalette = null;
@MinNumber(0)
@MaxNumber(1)
@Desc("The fraction of underside cap blocks replaced by the gill block when a gill block or palette is set.")
private double gillChance = 0.85;
@Desc("Optional block speckled across the top of the cap by noise (white toadstool dots, warts, glowing spots), e.g. minecraft:bone_block or minecraft:white_concrete. Ignored when spotPalette is set or left null.")
@RegistryListBlockType
private String spotBlock = null;
@Desc("A noise-driven palette for the cap top spots. When set this overrides the single spotBlock.")
private IrisMaterialPalette spotPalette = null;
@MinNumber(0)
@MaxNumber(1)
@Desc("The fraction of top cap blocks replaced by the spot block, selected by value noise so spots cluster naturally.")
private double spotChance = 0.18;
@Desc("If true, generate a bracket / shelf fungus instead of an upright mushroom: a small flat fan that grows sideways off a very short or absent stem, like a polypore clinging to a trunk.")
private boolean shelf = false;
@MinNumber(1)
@Desc("The radius in blocks of the sideways fan when shelf is true.")
private int shelfRadius = 3;
public KList<IrisObject> getVariantObjects(IrisData data) {
return variantCache.aquire(() -> {
KList<IrisObject> baked = new KList<>();
int count = Math.max(1, variants);
int lo = Math.min(stemHeightMin, stemHeightMax);
int hi = Math.max(stemHeightMin, stemHeightMax);
RNG heightRng = new RNG(seed);
for (int i = 0; i < count; i++) {
int height;
if (count == 1 || lo == hi) {
height = heightRng.i(lo, hi + 1);
} else {
double step = (hi - lo) / (double) (count - 1);
double base = lo + step * i;
double jitter = heightRng.d(-step * 0.3, step * 0.3);
height = (int) Math.round(Math.max(lo, Math.min(hi, base + jitter)));
}
IrisObject object = FungusGenerator.generate(this, Math.max(1, height), new RNG(seed + (i * 7919L)), data);
if (object == null || object.getBlocks().isEmpty()) {
continue;
}
object.setLoadKey("procedural/" + name + "#" + i);
object.setLoader(data);
baked.add(object);
}
return baked;
});
}
public IrisObject getVariantObject(IrisData data, RNG rng) {
KList<IrisObject> baked = getVariantObjects(data);
if (baked == null || baked.isEmpty()) {
return null;
}
return baked.get(rng.i(baked.size()));
}
public IrisObjectPlacement asPlacement() {
IrisObjectPlacement placement = new IrisObjectPlacement();
placement.setMode(mode);
placement.setRotation(rotation);
placement.setClamp(clamp);
placement.setCarvingSupport(carvingSupport);
placement.setUnderwater(underwater);
placement.setTranslate(translate);
placement.setStiltSettings(stiltSettings);
placement.setVacuumSettings(vacuumSettings);
placement.setChance(chance);
placement.setDensity(density);
return placement;
}
public boolean isPlausible() {
return false;
}
}
@@ -1,35 +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.procedural.fungi;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("The silhouette of the mushroom cap. Each shape drives how the cap radius and thickness vary from its apex down to the rim, giving the fungus a distinct profile.")
public enum IrisFungusCapShape {
@Desc("A rounded hemisphere cap that bulges up and curls slightly under at the rim, the classic red toadstool dome.")
DOME,
@Desc("A wide, nearly flat umbrella that holds its full radius almost to the edge before dropping, the brown-mushroom plate look.")
FLAT,
@Desc("An upturned bowl whose rim lifts higher than its center, cupping upward like a chanterelle or funnel mushroom.")
FUNNEL,
@Desc("A tall pointed cone that tapers from a broad base to a sharp apex, the witch-hat parasol silhouette.")
CONICAL,
@Desc("A very wide but shallow slab, a low overhanging shelf-like roof that spreads far past the stem with minimal vertical rise.")
FLAT_WIDE
}
@@ -0,0 +1,74 @@
/*
* 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.object.procedural.fungi;
import art.arcane.iris.builtin.objects.fungi.Fungus;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
/** A fungus made placeable: its variants are baked by {@link FungusGenerator}. */
public final class ResolvedFungus extends ResolvedProceduralPlacement {
private final Fungus settings;
public ResolvedFungus(Fungus settings) {
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
this.settings = settings;
}
@Override
protected IrisObject generate(int index, RNG rng, IrisData data) {
throw new UnsupportedOperationException("A fungus bakes its variants itself, from the stem heights");
}
@Override
protected KList<IrisObject> bake(IrisData data) {
KList<IrisObject> baked = new KList<>();
int count = variantCount();
int lo = Math.min(settings.stemHeightMin(), settings.stemHeightMax());
int hi = Math.max(settings.stemHeightMin(), settings.stemHeightMax());
RNG heightRng = new RNG(seed());
for (int i = 0; i < count; i++) {
int height;
if (count == 1 || lo == hi) {
height = heightRng.i(lo, hi + 1);
} else {
double step = (hi - lo) / (double) (count - 1);
double base = lo + step * i;
double jitter = heightRng.d(-step * 0.3, step * 0.3);
height = (int) Math.round(Math.max(lo, Math.min(hi, base + jitter)));
}
IrisObject object = FungusGenerator.generate(settings, Math.max(1, height), variantRng(i), data);
if (object == null || object.getBlocks().isEmpty()) {
continue;
}
object.setLoadKey("procedural/" + getName() + "#" + i);
object.setLoader(data);
baked.add(object);
}
return baked;
}
}
@@ -1,219 +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.procedural.ruin;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.placement.IrisObjectLimit;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.placement.IrisStiltSettings;
import art.arcane.iris.engine.object.placement.IrisVacuumSettings;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
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.Desc;
import art.arcane.iris.engine.object.annotations.MaxNumber;
import art.arcane.iris.engine.object.annotations.MinNumber;
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.iris.engine.object.procedural.ruin.RuinGenerator;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("ruin")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A single procedurally generated ruin: a crumbling man-made structure (pillar, wall, arch, foundation slab, or rubble pile). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Weathering swaps blocks for mossy or cracked variants by noise, erosion deletes blocks so the shape reads as collapsed, and a buried fraction sinks the ruin into the terrain.")
@Data
public class IrisRuin implements IrisProceduralPlacement {
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
@Desc("A human readable name used in logs and as the variant load key (procedural/<name>#<index>).")
private String name = "ruin";
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance (0-1) per chunk for this ruin to attempt placement. Use density to attempt more than one per chunk once the chance check passes.")
private double chance = 0.05;
@MinNumber(1)
@Desc("If the chance check passes, attempt this many placements in the chunk. Defaults to a single ruin per qualifying chunk.")
private int density = 1;
@MinNumber(1)
@MaxNumber(64)
@Desc("How many distinct variants to pre-bake for this ruin. Higher means more variety (different heights, gap patterns, erosion seeds) at a small memory cost.")
private int variants = 6;
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants. Every random choice (size, weathering mask, erosion mask, accents) is derived from this.")
private long seed = 1337;
@Desc("The placement mode used to anchor the ruin to the terrain. MIN_HEIGHT plants the lowest footprint corner on the ground (good for slabs and rubble on slopes); CENTER_HEIGHT averages the footprint (good for tall pillars and arches).")
private ObjectPlaceMode mode = ObjectPlaceMode.MIN_HEIGHT;
@Desc("Rotate this ruin's placement so variants do not all face the same way.")
private IrisObjectRotation rotation = new IrisObjectRotation();
@Desc("Limit the max or min terrain height at which this ruin may place.")
private IrisObjectLimit clamp = new IrisObjectLimit();
@Desc("Whether this ruin may place on the terrain surface, under carvings (caves), or both. SURFACE_ONLY keeps ruins above ground.")
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
@Desc("If true the ruin anchors on the terrain height ignoring the water surface, so it can sit submerged. If false (default) it anchors to the surface and avoids water.")
private boolean underwater = false;
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
private IrisObjectTranslate translate = new IrisObjectTranslate();
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
private IrisStiltSettings stiltSettings;
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
private IrisVacuumSettings vacuumSettings;
@Required
@Desc("The primary structural block, e.g. minecraft:cobblestone or minecraft:stone_bricks. Ignored when blockPalette is set. This is the bulk material of the ruin before weathering swaps some of it out.")
@RegistryListBlockType
private String block = "minecraft:cobblestone";
@Desc("A noise-driven palette for the primary block. When set this overrides the single block, letting the structure mix materials by noise. Palette wins over the block string via IrisProceduralBlocks.resolve.")
private IrisMaterialPalette blockPalette = null;
@Desc("The overall silhouette of the ruin: PILLAR (broken column), WALL (gapped segment), ARCH (two legs plus a curved span), FLOOR_SLAB (foundation patch), or RUBBLE (low scattered pile).")
private IrisRuinForm form = IrisRuinForm.PILLAR;
@MinNumber(1)
@Desc("Minimum structure height in blocks (PILLAR/WALL/ARCH height, slab thickness for FLOOR_SLAB, mound height for RUBBLE). Variants interpolate between this and heightMax.")
private int heightMin = 4;
@MinNumber(1)
@Desc("Maximum structure height in blocks. Variants interpolate between heightMin and this so taller and shorter ruins coexist.")
private int heightMax = 9;
@MinNumber(1)
@Desc("Minimum footprint width (X axis) in blocks: column/leg thickness for PILLAR/ARCH, wall thickness for WALL, slab width for FLOOR_SLAB, blob width for RUBBLE.")
private int widthMin = 1;
@MinNumber(1)
@Desc("Maximum footprint width (X axis) in blocks. Variants interpolate between widthMin and this.")
private int widthMax = 3;
@MinNumber(1)
@Desc("Minimum footprint length (Z axis) in blocks: wall run length, arch leg spacing, slab length, rubble blob length.")
private int lengthMin = 3;
@MinNumber(1)
@Desc("Maximum footprint length (Z axis) in blocks. Variants interpolate between lengthMin and this.")
private int lengthMax = 7;
@Desc("A palette of weathered variants (mossy/cracked block ids) blended over the structure by noise. When set this drives weathering; otherwise weatheredBlock is used.")
private IrisMaterialPalette weatheringPalette = null;
@Desc("A single weathered block id used when weatheringPalette is not set, e.g. minecraft:mossy_cobblestone. Applied to a noise-selected fraction of the structure, biased toward the lower rows.")
@RegistryListBlockType
private String weatheredBlock = "minecraft:mossy_cobblestone";
@MinNumber(0)
@MaxNumber(1)
@Desc("How much of the structure is replaced by weathered blocks (0 none, 1 nearly all). The replacement mask is value-noise driven and weighted so lower rows weather more than upper rows, mimicking moss climbing from the ground.")
private double mossiness = 0.45;
@MinNumber(0)
@MaxNumber(8)
@Desc("The scale of the weathering noise. Higher values produce smaller, busier moss/crack patches; lower values produce broad continuous weathered zones.")
private double weatheringScale = 1.0;
@MinNumber(0)
@MaxNumber(1)
@Desc("How crumbled the ruin is (0 intact, 1 mostly gone). Blocks whose value-noise falls below this threshold are deleted, so the shape reads as collapsed. Structural integrity is preserved: the bottom row and core legs are never eroded away.")
private double erosion = 0.25;
@MinNumber(0)
@MaxNumber(8)
@Desc("The scale of the erosion noise. Higher values knock out small speckled holes; lower values carve larger missing chunks out of the silhouette.")
private double erosionScale = 1.5;
@MinNumber(0)
@MaxNumber(1)
@Desc("How far the structure extends below the surface as a fraction of its height (0 sits fully on top, 1 sinks it a full height into the ground). The buried rows live at negative y so the ruin reads as settled and partly swallowed by the terrain.")
private double buriedFraction = 0.2;
@ArrayType(min = 1, type = IrisRuinDecorator.class)
@Desc("Accent decorators applied after the ruin is built and eroded (moss carpets and lanterns on broken tops, vines and lichen on the faces, rubble and growth scattered around the base).")
private KList<IrisRuinDecorator> accents = new KList<>();
public KList<IrisObject> getVariantObjects(IrisData data) {
return variantCache.aquire(() -> {
KList<IrisObject> baked = new KList<>();
int count = Math.max(1, variants);
for (int i = 0; i < count; i++) {
IrisObject object = RuinGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
if (object == null || object.getBlocks().isEmpty()) {
continue;
}
object.setLoadKey("procedural/" + name + "#" + i);
object.setLoader(data);
baked.add(object);
}
return baked;
});
}
public IrisObject getVariantObject(IrisData data, RNG rng) {
KList<IrisObject> baked = getVariantObjects(data);
if (baked == null || baked.isEmpty()) {
return null;
}
return baked.get(rng.i(baked.size()));
}
public IrisObjectPlacement asPlacement() {
IrisObjectPlacement placement = new IrisObjectPlacement();
placement.setMode(mode);
placement.setRotation(rotation);
placement.setClamp(clamp);
placement.setCarvingSupport(carvingSupport);
placement.setUnderwater(underwater);
placement.setTranslate(translate);
placement.setStiltSettings(stiltSettings);
placement.setVacuumSettings(vacuumSettings);
placement.setChance(chance);
placement.setDensity(density);
return placement;
}
public boolean isPlausible() {
return false;
}
}
@@ -1,60 +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.procedural.ruin;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
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.RegistryListBlockType;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("ruin-decorator")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("An accent block applied to a generated ruin after it is built and eroded, such as moss carpets on broken tops, vines on the faces, or rubble scattered around the base.")
@Data
public class IrisRuinDecorator {
@Desc("Where on the ruin this accent is placed. TOP sits on the highest block of each column, SURFACE clings to air-facing vertical faces, BASE_SCATTER rings the ground footprint around the base.")
private IrisRuinDecoratorTarget target = IrisRuinDecoratorTarget.TOP;
@Required
@Desc("The block id to place, e.g. minecraft:moss_carpet or minecraft:vine. Ignored when palette is set.")
@RegistryListBlockType
private String block = "";
@Desc("A noise-driven palette for this decorator. When set this overrides the single block, letting the accent mix blocks by noise. Resolved through IrisProceduralBlocks.resolve so the palette wins over the string.")
private IrisMaterialPalette palette = null;
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance (0-1) per candidate position for this decorator to actually place. 1 covers every candidate, lower values leave sparse, patchy accents.")
private double chance = 0.4;
@MinNumber(1)
@Desc("For the BASE_SCATTER target, how many blocks beyond the ruin footprint the scatter ring extends outward in each direction. Higher values fling rubble and growth further from the structure.")
private int scatterRadius = 2;
}
@@ -1,31 +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.procedural.ruin;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("Where a ruin accent block is placed after the ruin has been built and eroded.")
public enum IrisRuinDecoratorTarget {
@Desc("On top of the highest surviving block in each column (moss carpets, snow, sculk, lanterns on broken tops).")
TOP,
@Desc("On air-facing vertical sides of any surviving block (vines, glow lichen, climbing growth on the ruin faces).")
SURFACE,
@Desc("Scattered across the ground footprint around the y=0 base ring, wider than the structure itself (loose rubble, mushrooms, grass tufts ringing the ruin).")
BASE_SCATTER
}
@@ -1,35 +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.procedural.ruin;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("The overall silhouette of a procedural ruin. Each form rasterizes a different crumbling man-made shape from the same size, weathering, and erosion settings.")
public enum IrisRuinForm {
@Desc("A broken vertical column. A square trunk (widthMin..widthMax footprint) rises to a randomized height then snaps off with a jagged crown, leaving a toppled stub. Use for ancient pillars and obelisk stumps.")
PILLAR,
@Desc("A standing wall segment. A flat slab spanning lengthMin..lengthMax long and heightMin..heightMax tall, thickness widthMin..widthMax, punched through with noise-driven gaps and a ragged top edge. Use for collapsed building sides and fortifications.")
WALL,
@Desc("A freestanding arch. Two legs spaced by lengthMin..lengthMax joined at the top by a rasterized semicircular span (the lintel), so the structure literally arches. Use for gateways, aqueduct bays, and ruined doorways.")
ARCH,
@Desc("A flat foundation patch. A single (or few) block-thick slab covering a widthMin..lengthMax footprint at ground level, heavily eroded into an irregular outline. Use for floor remnants, plazas, and building foundations.")
FLOOR_SLAB,
@Desc("A low scattered debris pile. A noise blob of partial blocks mounded near the ground, tallest at the center and thinning toward the edges. Use for collapsed-structure rubble and scree.")
RUBBLE
}
@@ -0,0 +1,42 @@
/*
* 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.object.procedural.ruin;
import art.arcane.iris.builtin.objects.ruin.Ruin;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
import art.arcane.volmlib.util.math.RNG;
/** A ruin made placeable: its variants are baked by {@link RuinGenerator}. */
public final class ResolvedRuin extends ResolvedProceduralPlacement {
private final Ruin settings;
public ResolvedRuin(Ruin settings) {
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
this.settings = settings;
}
@Override
protected IrisObject generate(int index, RNG rng, IrisData data) {
return RuinGenerator.generate(settings, index, rng, data);
}
}
@@ -18,10 +18,10 @@
package art.arcane.iris.engine.object.procedural.ruin;
import art.arcane.iris.builtin.objects.ruin.RuinDecorator;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.engine.object.procedural.ruin.IrisRuinDecorator;
import art.arcane.iris.util.common.math.Vector3i;
import art.arcane.volmlib.util.math.RNG;
@@ -36,19 +36,19 @@ final class RuinDecoratorApplier {
private RuinDecoratorApplier() {
}
static void apply(RuinBlockCanvas canvas, IrisRuinDecorator decorator, IrisData data, long seed, RNG rng) {
List<Vector3i> candidates = switch (decorator.getTarget()) {
static void apply(RuinBlockCanvas canvas, RuinDecorator decorator, IrisData data, long seed, RNG rng) {
List<Vector3i> candidates = switch (decorator.target()) {
case TOP -> topCandidates(canvas);
case SURFACE -> surfaceCandidates(canvas);
case BASE_SCATTER -> baseScatterCandidates(canvas, Math.max(1, decorator.getScatterRadius()));
case BASE_SCATTER -> baseScatterCandidates(canvas, Math.max(1, decorator.scatterRadius()));
};
RNG paletteRng = new RNG(seed);
for (Vector3i v : candidates) {
if (!rng.chance(decorator.getChance())) {
if (!rng.chance(decorator.chance())) {
continue;
}
PlatformBlockState bd = IrisProceduralBlocks.resolve(decorator.getBlock(), decorator.getPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
PlatformBlockState bd = IrisProceduralBlocks.resolve(decorator.block(), decorator.palette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
if (bd != null) {
canvas.accent(v.getBlockX(), v.getBlockY(), v.getBlockZ(), bd);
}
@@ -18,11 +18,12 @@
package art.arcane.iris.engine.object.procedural.ruin;
import art.arcane.iris.builtin.objects.ruin.RuinDecorator;
import art.arcane.iris.builtin.objects.ruin.Ruin;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.engine.object.procedural.ruin.IrisRuin;
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
import art.arcane.iris.util.common.math.Vector3i;
import art.arcane.volmlib.util.math.RNG;
@@ -36,14 +37,14 @@ public final class RuinGenerator {
private RuinGenerator() {
}
public static IrisObject generate(IrisRuin ruin, int variantIndex, RNG rng, IrisData data) {
int count = Math.max(1, ruin.getVariants());
int height = pick(ruin.getHeightMin(), ruin.getHeightMax(), variantIndex, count, rng);
int width = pick(ruin.getWidthMin(), ruin.getWidthMax(), variantIndex, count, rng);
int length = pick(ruin.getLengthMin(), ruin.getLengthMax(), variantIndex, count, rng);
public static IrisObject generate(Ruin ruin, int variantIndex, RNG rng, IrisData data) {
int count = Math.max(1, ruin.variants());
int height = pick(ruin.heightMin(), ruin.heightMax(), variantIndex, count, rng);
int width = pick(ruin.widthMin(), ruin.widthMax(), variantIndex, count, rng);
int length = pick(ruin.lengthMin(), ruin.lengthMax(), variantIndex, count, rng);
RuinBlockCanvas canvas = new RuinBlockCanvas();
switch (ruin.getForm()) {
switch (ruin.form()) {
case PILLAR -> RuinShapes.pillar(canvas, Math.max(1, width), Math.max(2, height), rng);
case WALL -> RuinShapes.wall(canvas, Math.max(1, width), Math.max(2, length), Math.max(2, height), rng);
case ARCH -> RuinShapes.arch(canvas, Math.max(1, width), Math.max(3, length), Math.max(3, height), rng);
@@ -70,8 +71,8 @@ public final class RuinGenerator {
return (int) Math.round(Math.max(min, Math.min(max, base + jitter)));
}
private static void applyBurial(IrisRuin ruin, RuinBlockCanvas canvas, int height) {
double fraction = clamp01(ruin.getBuriedFraction());
private static void applyBurial(Ruin ruin, RuinBlockCanvas canvas, int height) {
double fraction = clamp01(ruin.buriedFraction());
if (fraction <= 0.0) {
return;
}
@@ -88,13 +89,13 @@ public final class RuinGenerator {
canvas.cells().putAll(moved);
}
private static void applyErosion(IrisRuin ruin, RuinBlockCanvas canvas) {
double erosion = clamp01(ruin.getErosion());
private static void applyErosion(Ruin ruin, RuinBlockCanvas canvas) {
double erosion = clamp01(ruin.erosion());
if (erosion <= 0.0) {
return;
}
double scale = Math.max(0.0001, ruin.getErosionScale());
long erosionSeed = ruin.getSeed() * 0x2545F4914F6CDD1DL + 17L;
double scale = Math.max(0.0001, ruin.erosionScale());
long erosionSeed = ruin.seed() * 0x2545F4914F6CDD1DL + 17L;
int minY = Integer.MAX_VALUE;
for (Vector3i v : canvas.cells().keySet()) {
minY = Math.min(minY, v.getBlockY());
@@ -120,25 +121,25 @@ public final class RuinGenerator {
}
}
private static void applyAccents(IrisRuin ruin, RuinBlockCanvas canvas, RNG rng, IrisData data) {
if (ruin.getAccents() == null || ruin.getAccents().isEmpty()) {
private static void applyAccents(Ruin ruin, RuinBlockCanvas canvas, RNG rng, IrisData data) {
if (ruin.accents() == null || ruin.accents().isEmpty()) {
return;
}
int decoratorIndex = 0;
for (art.arcane.iris.engine.object.procedural.ruin.IrisRuinDecorator decorator : ruin.getAccents()) {
RuinDecoratorApplier.apply(canvas, decorator, data, ruin.getSeed() + decoratorIndex * 911L, rng.nextParallelRNG(decoratorIndex + 1));
for (art.arcane.iris.builtin.objects.ruin.RuinDecorator decorator : ruin.accents()) {
RuinDecoratorApplier.apply(canvas, decorator, data, ruin.seed() + decoratorIndex * 911L, rng.nextParallelRNG(decoratorIndex + 1));
decoratorIndex++;
}
}
private static IrisObject resolve(IrisRuin ruin, RuinBlockCanvas canvas, IrisData data) {
private static IrisObject resolve(Ruin ruin, RuinBlockCanvas canvas, IrisData data) {
if (canvas.cells().isEmpty()) {
return null;
}
double scale = Math.max(0.0001, ruin.getWeatheringScale());
double mossiness = clamp01(ruin.getMossiness());
long weatherSeed = ruin.getSeed() * 0x9E3779B97F4A7C15L + 101L;
RNG paletteRng = new RNG(ruin.getSeed());
double scale = Math.max(0.0001, ruin.weatheringScale());
double mossiness = clamp01(ruin.mossiness());
long weatherSeed = ruin.seed() * 0x9E3779B97F4A7C15L + 101L;
RNG paletteRng = new RNG(ruin.seed());
int minY = Integer.MAX_VALUE;
int maxY = Integer.MIN_VALUE;
@@ -166,7 +167,7 @@ public final class RuinGenerator {
return IrisProceduralBlocks.assemble(blocks);
}
private static PlatformBlockState structuralBlock(IrisRuin ruin, RuinBlockCanvas.Cell cell, Vector3i v, IrisData data, RNG paletteRng, double scale, double mossiness, long weatherSeed, int minY, int span) {
private static PlatformBlockState structuralBlock(Ruin ruin, RuinBlockCanvas.Cell cell, Vector3i v, IrisData data, RNG paletteRng, double scale, double mossiness, long weatherSeed, int minY, int span) {
boolean weathered = false;
if (mossiness > 0.0) {
int sx = (int) Math.round(v.getBlockX() * scale);
@@ -179,12 +180,12 @@ public final class RuinGenerator {
}
if (weathered) {
PlatformBlockState wd = IrisProceduralBlocks.resolve(ruin.getWeatheredBlock(), ruin.getWeatheringPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
PlatformBlockState wd = IrisProceduralBlocks.resolve(ruin.weatheredBlock(), ruin.weatheringPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
if (wd != null) {
return wd;
}
}
return IrisProceduralBlocks.resolve(ruin.getBlock(), ruin.getBlockPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
return IrisProceduralBlocks.resolve(ruin.block(), ruin.blockPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
}
private static double clamp01(double value) {
@@ -18,17 +18,24 @@
package art.arcane.iris.engine.object.procedural.tree;
import art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf;
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
import art.arcane.iris.builtin.objects.tree.TreeCanopy;
import art.arcane.iris.builtin.objects.tree.TreeRootStyle;
import art.arcane.iris.builtin.objects.tree.TreeProfile;
import art.arcane.iris.builtin.objects.tree.TreeFunction;
import art.arcane.iris.builtin.objects.tree.TreeAzimuthMode;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.stilt.StiltSettings;
import art.arcane.iris.builtin.vacuum.VacuumSettings;
import art.arcane.iris.builtin.validate.ObjectLimit;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.placement.IrisObjectLimit;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.placement.IrisStiltSettings;
import art.arcane.iris.engine.object.placement.IrisVacuumSettings;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
import art.arcane.iris.engine.object.terrain.carving.CarvingMode;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.engine.object.annotations.ArrayType;
@@ -86,7 +93,7 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
private IrisObjectRotation rotation = new IrisObjectRotation();
@Desc("Limit the max or min height of placement.")
private IrisObjectLimit clamp = new IrisObjectLimit();
private ObjectLimit clamp = new ObjectLimit();
@Desc("Whether this tree may place on the terrain surface, under carvings, or both.")
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
@@ -98,10 +105,10 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
private IrisObjectTranslate translate = new IrisObjectTranslate();
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
private IrisStiltSettings stiltSettings;
private StiltSettings stiltSettings;
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
private IrisVacuumSettings vacuumSettings;
private VacuumSettings vacuumSettings;
@Required
@Desc("The trunk (log) block, e.g. minecraft:oak_log. Ignored when trunkPalette is set.")
@@ -120,7 +127,7 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
private IrisMaterialPalette leavesPalette = null;
@Desc("The named canopy profile that drives default crown radii and shape.")
private IrisTreeProfile profile = IrisTreeProfile.OAK;
private TreeProfile profile = TreeProfile.OAK;
@MinNumber(1)
@Desc("Minimum trunk height in blocks.")
@@ -135,7 +142,7 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
private int trunkWidth = 1;
@Desc("The function used to shape trunk width over height.")
private IrisTreeFunction trunkShape = IrisTreeFunction.CONSTANT;
private TreeFunction trunkShape = TreeFunction.CONSTANT;
@Desc("Width multiplier at the base for the LINEAR trunk shape.")
private double shapeStart = 1;
@@ -168,13 +175,13 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
private double leanAngle = 0;
@Desc("How the lean accumulates over height.")
private IrisTreeFunction trunkCurve = IrisTreeFunction.LINEAR;
private TreeFunction trunkCurve = TreeFunction.LINEAR;
@Desc("Steepness for the SIGMOID trunk curve.")
private double curveSteepness = 8;
@Desc("How the lean azimuth itself changes over height (for spiraling or wandering trunks).")
private IrisTreeAzimuthMode leanAzimuthMode = IrisTreeAzimuthMode.CONSTANT;
private TreeAzimuthMode leanAzimuthMode = TreeAzimuthMode.CONSTANT;
@Desc("Azimuth at the base for the LINEAR azimuth mode.")
private double azimuthStart = 0;
@@ -210,9 +217,9 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
@Desc("The fraction of leaves replaced by the secondary leaf block(s).")
private double secondaryLeafFraction = 0.35;
@ArrayType(min = 1, type = IrisTreeSecondaryLeaf.class)
@ArrayType(min = 1, type = TreeSecondaryLeaf.class)
@Desc("Optional weighted set of accent leaf blocks. When set this overrides the single secondaryLeaves block.")
private KList<IrisTreeSecondaryLeaf> weightedSecondaryLeaves = new KList<>();
private KList<TreeSecondaryLeaf> weightedSecondaryLeaves = new KList<>();
@Desc("A noise-driven palette for the secondary (accent) leaves. When set this overrides both secondaryLeaves and weightedSecondaryLeaves.")
private IrisMaterialPalette secondaryLeavesPalette = null;
@@ -238,7 +245,7 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
private boolean roots = true;
@Desc("How the root system is built when roots is true.")
private IrisTreeRootStyle rootStyle = IrisTreeRootStyle.BUTTRESS;
private TreeRootStyle rootStyle = TreeRootStyle.BUTTRESS;
@MinNumber(0)
@Desc("Override the root depth/reach in blocks. 0 means auto (scales with tree height).")
@@ -262,11 +269,11 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
private double forkAngle = 25;
@Desc("The leaf crown configuration.")
private IrisTreeCanopy canopy = new IrisTreeCanopy();
private TreeCanopy canopy = new TreeCanopy();
@ArrayType(min = 1, type = IrisTreeDecorator.class)
@ArrayType(min = 1, type = TreeDecorator.class)
@Desc("Accent decorators applied after the tree is built (fruit, vines, snow, glow).")
private KList<IrisTreeDecorator> decorators = new KList<>();
private KList<TreeDecorator> decorators = new KList<>();
public KList<IrisObject> getVariantObjects(IrisData data) {
return variantCache.aquire(() -> {
@@ -1,45 +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.procedural.tree;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("Controls the compass direction (azimuth) of trunk lean as it rises, or the direction each branch is thrown.")
public enum IrisTreeAzimuthMode {
@Desc("A single fixed azimuth.")
CONSTANT,
@Desc("Azimuth ramps straight from start to end with height.")
LINEAR,
@Desc("Azimuth winds around the trunk a number of turns (corkscrew).")
SPIRAL,
@Desc("Azimuth oscillates with a sine wave.")
SINE,
@Desc("Azimuth wanders using deterministic noise.")
NOISE,
@Desc("Each branch picks a uniformly random azimuth (falls back to constant for trunk lean).")
RANDOM,
@Desc("Phyllotaxis: each successive branch is offset by the 137.5 degree golden angle for the most natural spiral packing (branches).")
GOLDEN_ANGLE,
@Desc("Each successive branch is thrown to the opposite side (180 degrees apart).")
ALTERNATING,
@Desc("Branches are grouped into evenly spaced whorls of azimuthWhorlCount around each ring.")
WHORL,
@Desc("Azimuth zigzags by +/- amplitude on alternating branches.")
ZIGZAG
}
@@ -1,47 +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.procedural.tree;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("Controls how the chance of spawning a branch varies with trunk height (0 at the base, 1 at the top).")
public enum IrisTreeBranchProbability {
@Desc("Same branch chance at every height.")
CONSTANT,
@Desc("Ramps straight from base chance to crown chance.")
LINEAR,
@Desc("S-curve that switches on around a midpoint height.")
SIGMOID,
@Desc("Chance rises with height raised to an exponent, clustering branches near the crown.")
TOP_HEAVY,
@Desc("Bell curve peaking in a height band.")
GAUSSIAN,
@Desc("Irregular organic branching from deterministic noise.")
NOISE,
@Desc("Chance falls with height (1-t)^exponent, clustering branches near the base.")
BOTTOM_HEAVY,
@Desc("Regular whorl rings of branches at evenly spaced heights (periods controls count).")
PERIODIC,
@Desc("Branches only within a height window around mean +/- std.")
BAND,
@Desc("Inverse of GAUSSIAN: branches avoid the mean band and favor base and crown.")
INVERSE_GAUSSIAN,
@Desc("Exponential decay from the base upward (constant * e^-exponent*t).")
EXPONENTIAL_DECAY
}
@@ -1,131 +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.procedural.tree;
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.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("tree-branches")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A branch system that throws limbs out of the trunk and places a leaf ball at each tip. When present, branches drive the canopy and only the topmost crown disc of the profile is still placed.")
@Data
public class IrisTreeBranches {
@Desc("How branch spawn chance varies over trunk height.")
private IrisTreeBranchProbability probabilityFunction = IrisTreeBranchProbability.TOP_HEAVY;
@MinNumber(0)
@Desc("Branch chance for the CONSTANT probability function.")
private double probabilityConstant = 0.5;
@MinNumber(0)
@Desc("Branch chance at the base for the LINEAR probability function.")
private double probabilityBase = 0;
@MinNumber(0)
@Desc("Branch chance at the crown for the LINEAR probability function.")
private double probabilityCrown = 1;
@Desc("Steepness for the SIGMOID probability function.")
private double probabilitySteepness = 10;
@Desc("Midpoint height (0-1) for the SIGMOID probability function.")
private double probabilityMidpoint = 0.7;
@Desc("Exponent for the TOP_HEAVY probability function.")
private double probabilityExponent = 2;
@Desc("Mean height (0-1) for the GAUSSIAN probability function.")
private double probabilityMean = 0.7;
@Desc("Standard deviation for the GAUSSIAN probability function.")
private double probabilityStd = 0.15;
@Desc("Noise scale for the NOISE probability function.")
private double probabilityScale = 1;
@MinNumber(0)
@Desc("Number of whorl rings over the trunk height for the PERIODIC probability function.")
private double probabilityPeriods = 5;
@Desc("How branch length varies over trunk height.")
private IrisTreeFunction lengthFunction = IrisTreeFunction.LINEAR;
@MinNumber(0)
@Desc("Branch length at the base for the LINEAR length function.")
private double lengthBase = 1;
@MinNumber(0)
@Desc("Branch length at the crown for the LINEAR length function.")
private double lengthCrown = 4;
@MinNumber(0)
@Desc("Branch length for the CONSTANT length function.")
private double lengthConstant = 3;
@MinNumber(0)
@Desc("Maximum branch length for the SIGMOID, LOG and PARABOLIC length functions.")
private double lengthMax = 4;
@Desc("Steepness for the SIGMOID length function.")
private double lengthSteepness = 5;
@Desc("How the compass direction of each branch is chosen.")
private IrisTreeAzimuthMode azimuthMode = IrisTreeAzimuthMode.RANDOM;
@Desc("Fixed azimuth in degrees when azimuthMode is CONSTANT.")
private double azimuth = 0;
@Desc("Elevation angle in degrees from horizontal. 0 is flat, positive points up, negative droops down.")
private double elevation = 0;
@MinNumber(0)
@MaxNumber(1)
@Desc("How much each branch sags/droops along its length (catenary). 0 is a straight branch; higher values arc the branch and its tip downward.")
private double sag = 0;
@MinNumber(0)
@MaxNumber(6)
@Desc("How many recursive levels of sub-branches to grow. 0 is none, 1 is a single level, 2+ produces fractal branching.")
private int branchDepth = 1;
@Desc("If true, branches are clamped to never droop below horizontal (useful for upright species).")
private boolean leafStartUp = false;
@MinNumber(0)
@Desc("Leaf ball radius placed at each branch tip.")
private int clusterRadius = 2;
@Desc("How the branch tip leaf cluster fills.")
private IrisTreeLeafMode clusterMode = IrisTreeLeafMode.TRIMMED;
@MinNumber(0)
@Desc("Fill density for the branch tip leaf cluster when clusterMode is density or noise.")
private double clusterDensity = 0.85;
@Desc("Optional one level of recursive sub-branches sprouting from each branch tip.")
private IrisTreeSubBranches subBranches = null;
}
@@ -1,71 +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.procedural.tree;
import art.arcane.iris.engine.object.annotations.ArrayType;
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.Snippet;
import art.arcane.volmlib.util.collection.KList;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("tree-canopy")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("The leaf crown of a procedural tree. Built from stacked dome-shaped discs (driven by the profile or by explicit layers) and optionally a branch system.")
@Data
public class IrisTreeCanopy {
@MinNumber(0)
@MaxNumber(180)
@Desc("Elevation angle in degrees from vertical for each leaf dome. 90 is a flat disc, below 90 domes downward into a sphere, above 90 flares outward into an umbrella.")
private double startAngle = 90;
@MinNumber(0)
@MaxNumber(1)
@Desc("Vertical scale of the canopy volume. Lower values flatten the crown.")
private double squish = 1;
@Desc("How leaves fill each canopy disc.")
private IrisTreeLeafMode mode = IrisTreeLeafMode.TRIMMED;
@MinNumber(0)
@MaxNumber(1)
@Desc("Fill probability used by the density and noise leaf modes.")
private double leafDensity = 0.85;
@MinNumber(0.1)
@Desc("Horizontal X stretch of the crown for elliptical or wind-blown shapes. 1 is circular.")
private double crownStretchX = 1;
@MinNumber(0.1)
@Desc("Horizontal Z stretch of the crown for elliptical or wind-blown shapes. 1 is circular.")
private double crownStretchZ = 1;
@ArrayType(min = 1, type = IrisTreeLayer.class)
@Desc("Optional explicit crown discs. When provided these replace the profile-driven layers and let you sculpt the silhouette by hand.")
private KList<IrisTreeLayer> layers = new KList<>();
@Desc("Optional branch system. When present, branches build most of the canopy and only the topmost profile disc is still placed as a crown.")
private IrisTreeBranches branches = null;
}
@@ -1,62 +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.procedural.tree;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
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.RegistryListBlockType;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("tree-decorator")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("An accent block applied to a generated tree such as fruit on branch tips, vines on the trunk, snow on the crown, or a glowing underside.")
@Data
public class IrisTreeDecorator {
@Desc("Where this decorator is placed on the tree.")
private IrisTreeDecoratorTarget target = IrisTreeDecoratorTarget.BRANCH_TIP;
@Required
@Desc("The block id to place, e.g. minecraft:magma_block. Ignored when palette is set.")
@RegistryListBlockType
private String block = "";
@Desc("A noise-driven palette for this decorator. When set this overrides the single block.")
private IrisMaterialPalette palette = null;
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance per candidate position for this decorator to place.")
private double chance = 0.5;
@MinNumber(1)
@Desc("Maximum strand length downward for the CANOPY_HANG target (random 1..length per column).")
private int length = 1;
@Desc("If true the block's facing is oriented away from the trunk (for trunk-mounted fences/gates/banners).")
private boolean axisAware = false;
}
@@ -1,45 +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.procedural.tree;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("Where a tree decorator block is placed.")
public enum IrisTreeDecoratorTarget {
@Desc("At the tip of each generated branch (vines, fruit, lanterns).")
BRANCH_TIP,
@Desc("On air-facing sides of trunk and branch blocks (vines, moss).")
TRUNK_SURFACE,
@Desc("On top of the highest block in each column (snow, sculk).")
CANOPY_TOP,
@Desc("One block below the lowest leaf in each column (glowing underside).")
CANOPY_BOTTOM,
@Desc("Around the y=0 ring at the base of the trunk (roots, mushrooms).")
TRUNK_BASE,
@Desc("On air-facing sides of leaf blocks (berries, lights nestled in the foliage).")
LEAF_SURFACE,
@Desc("Hanging strands of up to 'length' blocks below the lowest leaf in each column (vines, icicles).")
CANOPY_HANG,
@Desc("On the top face of trunk and branch blocks (moss, snow on limbs).")
BRANCH_SURFACE,
@Desc("One block above the very top of the trunk (nest, beehive, beacon).")
TRUNK_TOP,
@Desc("Scattered across the ground footprint around the base, wider than the trunk-base ring.")
GROUND_SCATTER
}
@@ -1,47 +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.procedural.tree;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("A shaping function evaluated over normalized height (0 at the base, 1 at the top). Used for trunk width, trunk curve and branch length.")
public enum IrisTreeFunction {
@Desc("Same value at every height.")
CONSTANT,
@Desc("Ramps straight from start to end.")
LINEAR,
@Desc("S-curve transition controlled by steepness.")
SIGMOID,
@Desc("Logarithmic falloff controlled by base.")
LOG,
@Desc("Sine ripple controlled by period and amplitude.")
SINE,
@Desc("Parabolic pinch, narrowest at peakOffset.")
PARABOLIC,
@Desc("Geometric (exponential) interpolation from start to end.")
EXPONENTIAL,
@Desc("Square-root ease: fast change low, slow high.")
SQRT,
@Desc("Hard step that jumps from start to end at the threshold (peakOffset).")
STEP,
@Desc("Bell bulge peaking in the middle of the height range.")
BELL,
@Desc("Smoothstep ease-in-out (3t^2 - 2t^3).")
EASE_IN_OUT
}
@@ -1,42 +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.procedural.tree;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.MinNumber;
import art.arcane.iris.engine.object.annotations.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("tree-layer")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("An explicit canopy disc at a given vertical offset and radius. Define a list of these to bypass the profile and sculpt the crown by hand.")
@Data
public class IrisTreeLayer {
@Desc("The vertical offset of this disc, measured in blocks above the trunk base.")
private int yOffset = 0;
@MinNumber(0.5)
@Desc("The radius of this leaf disc in blocks.")
private double radius = 2;
}
@@ -1,43 +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.procedural.tree;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("How leaves fill a disc or cluster.")
public enum IrisTreeLeafMode {
@Desc("Corner-trimmed disc/sphere for a rounded silhouette.")
TRIMMED,
@Desc("Completely filled disc/sphere.")
FILLED,
@Desc("Seeded probabilistic falloff toward the edge controlled by leafDensity.")
DENSITY,
@Desc("Seeded value-noise mask controlled by leafDensity.")
NOISE,
@Desc("Only the outer shell is placed, leaving the interior hollow.")
HOLLOW,
@Desc("Quadratic radial gradient: dense at the center, thinning sharply toward the edge.")
GRADIENT,
@Desc("Coarse low-frequency noise that forms clumps and gaps of foliage.")
CLUMPED,
@Desc("Trimmed with heavy random erosion of the outer ring for a ragged, weathered look.")
TATTERED,
@Desc("Very thin scattering of leaves across the volume.")
SPARSE
}
@@ -1,53 +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.procedural.tree;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("Named canopy presets that drive default layer radii and shape, scaled to the tree height.")
public enum IrisTreeProfile {
@Desc("Rounded broadleaf crown.")
OAK,
@Desc("Slim upright broadleaf crown.")
BIRCH,
@Desc("Narrow conifer cone.")
SPRUCE,
@Desc("Tall thin crown concentrated near the very top.")
JUNGLE,
@Desc("Flat shallow umbrella crown.")
ACACIA,
@Desc("Dense rounded broadleaf crown.")
DARK_OAK,
@Desc("Flat wide umbrella crown compressed into the top quarter (vanilla dark oak look).")
DARK_OAK_FLAT,
@Desc("Extra wide flat umbrella that overlaps into a continuous roofed canopy.")
DARK_OAK_FLAT_WIDE,
@Desc("Broad rounded blossom crown.")
CHERRY,
@Desc("Bare trunk with a small tuft of fronds only at the very top.")
PALM,
@Desc("Broad crown with wide drooping radii, ideal with a low startAngle to make a weeping skirt.")
WILLOW,
@Desc("Very narrow tall crown hugging the trunk (cypress / lombardy poplar).")
COLUMNAR,
@Desc("Squat, wide, low crown for shrubs and saplings.")
BUSH,
@Desc("Giant conifer cone for 2x2 mega spruce trunks.")
MEGA_SPRUCE
}
@@ -1,31 +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.procedural.tree;
import art.arcane.iris.engine.object.annotations.Desc;
@Desc("How a procedural tree's root system is built below (and around) the trunk base.")
public enum IrisTreeRootStyle {
@Desc("A single tapering taproot straight down from the base.")
TAPROOT,
@Desc("A taproot plus a ring of flared buttress legs that splay outward as they descend (default).")
BUTTRESS,
@Desc("Visible above-ground prop roots that arch out and down from the lower trunk to the ground (mangrove style).")
STILT
}
@@ -1,46 +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.procedural.tree;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.MinNumber;
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("tree-secondary-leaf")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A weighted accent leaf or foliage block scattered through the canopy (blossoms, shroomlight, berries).")
@Data
public class IrisTreeSecondaryLeaf {
@Required
@Desc("The block id to scatter, e.g. minecraft:shroomlight")
@RegistryListBlockType
private String block = "";
@MinNumber(0)
@Desc("The relative weight of this block among the secondary leaves.")
private int weight = 1;
}
@@ -1,66 +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.procedural.tree;
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.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("tree-sub-branches")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("One recursive level of sub-branches sprouting from each primary branch tip.")
@Data
public class IrisTreeSubBranches {
@MinNumber(1)
@Desc("How many sub-branches sprout from each primary branch tip.")
private int count = 1;
@Desc("Pitch deflection in degrees applied to each sub-branch relative to its parent. Positive bends up, negative droops down. Cumulative pitch past 90 makes sub-branches point downward.")
private double pitchDelta = 0;
@Desc("Yaw (horizontal) spread in degrees fanned between sub-branches.")
private double yawDelta = 45;
@MinNumber(0)
@Desc("Sub-branch length as a fraction of its parent branch length.")
private double lengthScale = 0.5;
@MinNumber(0)
@MaxNumber(1)
@Desc("How much each sub-branch sags/droops along its length (catenary).")
private double sag = 0;
@MinNumber(0)
@Desc("Leaf ball radius placed at each sub-branch tip.")
private int clusterRadius = 1;
@Desc("How the sub-branch tip leaf cluster fills.")
private IrisTreeLeafMode clusterMode = IrisTreeLeafMode.TRIMMED;
@MinNumber(0)
@Desc("Fill density for the sub-branch leaf cluster when clusterMode is density or noise.")
private double clusterDensity = 0.85;
}
@@ -18,11 +18,13 @@
package art.arcane.iris.engine.object.procedural.tree;
import art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf;
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import com.volmit.block.PaletteSpec;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeDecorator;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.volmlib.util.math.RNG;
@@ -62,8 +64,8 @@ public final class TreeBlockResolver {
if (index < 0 || tree.getDecorators() == null || index >= tree.getDecorators().size()) {
return null;
}
IrisTreeDecorator dec = tree.getDecorators().get(index);
PlatformBlockState state = resolveBlock(dec.getBlock(), dec.getPalette(), data, pos, paletteRng);
TreeDecorator dec = tree.getDecorators().get(index);
PlatformBlockState state = resolveBlock(dec.block(), dec.palette().orElse(null), data, pos, paletteRng);
if (state != null && cell.facing() != null && IrisProceduralBlocks.hasProperty(state, "facing")) {
try {
state = state.withProperty("facing", cell.facing().toLowerCase());
@@ -110,21 +112,25 @@ public final class TreeBlockResolver {
private static String pickWeighted(IrisProceduralTree tree, RNG rng) {
int total = 0;
for (art.arcane.iris.engine.object.procedural.tree.IrisTreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
total += Math.max(0, s.getWeight());
for (art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
total += Math.max(0, s.weight());
}
if (total <= 0) {
return null;
}
double r = rng.nextDouble() * total;
double cumulative = 0;
for (art.arcane.iris.engine.object.procedural.tree.IrisTreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
cumulative += Math.max(0, s.getWeight());
for (art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
cumulative += Math.max(0, s.weight());
if (r < cumulative) {
return s.getBlock();
return s.block();
}
}
return tree.getWeightedSecondaryLeaves().get(tree.getWeightedSecondaryLeaves().size() - 1).getBlock();
return tree.getWeightedSecondaryLeaves().get(tree.getWeightedSecondaryLeaves().size() - 1).block();
}
private static PlatformBlockState resolveBlock(String block, PaletteSpec palette, IrisData data, TreeBlockCanvas.Vec pos, RNG paletteRng) {
return IrisProceduralBlocks.resolve(block, palette, data, pos.x(), pos.y(), pos.z(), paletteRng);
}
private static PlatformBlockState resolveBlock(String block, IrisMaterialPalette palette, IrisData data, TreeBlockCanvas.Vec pos, RNG paletteRng) {
@@ -18,13 +18,13 @@
package art.arcane.iris.engine.object.procedural.tree;
import art.arcane.iris.builtin.objects.tree.TreeSubBranches;
import art.arcane.iris.builtin.objects.tree.TreeLayer;
import art.arcane.iris.builtin.objects.tree.TreeCanopy;
import art.arcane.iris.builtin.objects.tree.TreeBranches;
import art.arcane.iris.builtin.objects.tree.TreeProfile;
import art.arcane.iris.builtin.objects.tree.TreeLeafMode;
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeBranches;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeCanopy;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeLayer;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeLeafMode;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeProfile;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeSubBranches;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
@@ -36,11 +36,11 @@ public final class TreeCanopyBuilder {
public static void build(TreeBlockCanvas canvas, IrisProceduralTree tree, int height, double[][] offsets,
int branchStartY, long baseSeed, List<int[]> branchEndpoints) {
IrisTreeCanopy canopy = tree.getCanopy();
TreeCanopy canopy = tree.getCanopy();
if (canopy == null) {
canopy = new IrisTreeCanopy();
canopy = new TreeCanopy();
}
IrisTreeBranches branches = canopy.getBranches();
TreeBranches branches = canopy.branches().orElse(null);
double[][] layers = resolveLayers(canopy, tree.getProfile(), height, branches != null);
@@ -69,19 +69,19 @@ public final class TreeCanopyBuilder {
maxR = Math.max(maxR, layer[1]);
}
int capRadius = Math.max(2, Math.min(3, (int) Math.round(maxR * 0.35)));
IrisTreeCanopy canopy = tree.getCanopy();
IrisTreeLeafMode mode = canopy != null ? canopy.getMode() : IrisTreeLeafMode.TRIMMED;
double density = canopy != null ? canopy.getLeafDensity() : 1.0;
TreeCanopy canopy = tree.getCanopy();
TreeLeafMode mode = canopy != null ? canopy.mode() : TreeLeafMode.TRIMMED;
double density = canopy != null ? canopy.leafDensity() : 1.0;
placeLeafCluster(canvas, tree, ocx, height - 1, ocz, capRadius, mode, density, baseSeed + 5555L);
}
private static double[][] resolveLayers(IrisTreeCanopy canopy, IrisTreeProfile profile, int height, boolean branchDriven) {
KList<IrisTreeLayer> explicit = canopy.getLayers();
private static double[][] resolveLayers(TreeCanopy canopy, TreeProfile profile, int height, boolean branchDriven) {
KList<TreeLayer> explicit = new KList<>(canopy.layers());
if (explicit != null && !explicit.isEmpty()) {
double[][] out = new double[explicit.size()][2];
for (int i = 0; i < explicit.size(); i++) {
out[i][0] = explicit.get(i).getYOffset();
out[i][1] = explicit.get(i).getRadius();
out[i][0] = explicit.get(i).yOffset();
out[i][1] = explicit.get(i).radius();
}
return out;
}
@@ -89,7 +89,7 @@ public final class TreeCanopyBuilder {
}
private static void volumeCanopy(TreeBlockCanvas canvas, IrisProceduralTree tree, double[][] layers,
IrisTreeCanopy canopy, long baseSeed, double[][] offsets) {
TreeCanopy canopy, long baseSeed, double[][] offsets) {
int ocx = 0;
int ocz = 0;
if (offsets != null && offsets.length > 0) {
@@ -97,10 +97,10 @@ public final class TreeCanopyBuilder {
ocz = (int) Math.round(offsets[offsets.length - 1][1]);
}
double startAngle = canopy.getStartAngle();
double squish = canopy.getSquish();
IrisTreeLeafMode mode = canopy.getMode();
double leafDensity = canopy.getLeafDensity();
double startAngle = canopy.startAngle();
double squish = canopy.squish();
TreeLeafMode mode = canopy.mode();
double leafDensity = canopy.leafDensity();
for (double[] layer : layers) {
int yCenter = (int) Math.round(layer[0]);
@@ -137,7 +137,7 @@ public final class TreeCanopyBuilder {
}
private static void placeLeafDisc(TreeBlockCanvas canvas, IrisProceduralTree tree, int cx, int cy, int cz,
double radius, IrisTreeLeafMode mode, double density, long seed) {
double radius, TreeLeafMode mode, double density, long seed) {
double sx = stretchX(tree);
double sz = stretchZ(tree);
RNG rng = new RNG(seed);
@@ -158,7 +158,7 @@ public final class TreeCanopyBuilder {
}
private static void placeLeafCluster(TreeBlockCanvas canvas, IrisProceduralTree tree, int cx, int cy, int cz,
int radius, IrisTreeLeafMode mode, double density, long seed) {
int radius, TreeLeafMode mode, double density, long seed) {
double sx = stretchX(tree);
double sz = stretchZ(tree);
RNG rng = new RNG(seed);
@@ -181,16 +181,16 @@ public final class TreeCanopyBuilder {
}
private static double stretchX(IrisProceduralTree tree) {
IrisTreeCanopy c = tree.getCanopy();
return c == null ? 1.0 : Math.max(0.1, c.getCrownStretchX());
TreeCanopy c = tree.getCanopy();
return c == null ? 1.0 : Math.max(0.1, c.crownStretchX());
}
private static double stretchZ(IrisProceduralTree tree) {
IrisTreeCanopy c = tree.getCanopy();
return c == null ? 1.0 : Math.max(0.1, c.getCrownStretchZ());
TreeCanopy c = tree.getCanopy();
return c == null ? 1.0 : Math.max(0.1, c.crownStretchZ());
}
private static boolean passesLeafTest(IrisTreeLeafMode mode, double dist, double radius, double density,
private static boolean passesLeafTest(TreeLeafMode mode, double dist, double radius, double density,
RNG rng, int wx, int wy, int wz, long seed, boolean corner) {
switch (mode) {
case TRIMMED -> {
@@ -258,12 +258,12 @@ public final class TreeCanopyBuilder {
}
private static void branchCanopy(TreeBlockCanvas canvas, IrisProceduralTree tree, int height,
IrisTreeBranches branches, int branchStartY, long baseSeed, double[][] offsets,
TreeBranches branches, int branchStartY, long baseSeed, double[][] offsets,
List<int[]> branchEndpoints) {
long branchSeed = baseSeed + 9999;
RNG branchRng = new RNG(branchSeed);
IrisTreeSubBranches sub = branches.getSubBranches();
int depth = branches.getBranchDepth();
TreeSubBranches sub = branches.subBranches().orElse(null);
int depth = branches.branchDepth();
int branchIndex = 0;
for (int y = Math.max(0, branchStartY); y < height; y++) {
@@ -280,38 +280,38 @@ public final class TreeCanopyBuilder {
oz = (int) Math.round(offsets[y][1]);
}
double az = TreeFunctions.azimuthDegrees(branches.getAzimuthMode(), t, branchIndex, tree, branches.getAzimuth(), branchRng);
double az = TreeFunctions.azimuthDegrees(branches.azimuthMode(), t, branchIndex, tree, branches.azimuth(), branchRng);
branchIndex++;
double branchLen = TreeFunctions.branchLength(branches, t);
double effElevation = branches.isLeafStartUp() ? Math.max(0.0, branches.getElevation()) : branches.getElevation();
double effElevation = branches.leafStartUp() ? Math.max(0.0, branches.elevation()) : branches.elevation();
int[] end = branchEndpoint(ox, y, oz, az, effElevation, branchLen);
int[] tip = rasterizeBranch(canvas, ox, y, oz, end[0], end[1], end[2], branches.getSag());
int[] tip = rasterizeBranch(canvas, ox, y, oz, end[0], end[1], end[2], branches.sag());
if (branchEndpoints != null) {
branchEndpoints.add(new int[]{tip[0], tip[1], tip[2], ox, oz});
}
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], branches.getClusterRadius(),
branches.getClusterMode(), branches.getClusterDensity(), branchSeed + y);
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], branches.clusterRadius(),
branches.clusterMode(), branches.clusterDensity(), branchSeed + y);
growSubBranches(canvas, tree, tip[0], tip[1], tip[2], az, effElevation, branchLen, sub, depth, branchSeed + y + 1000L);
}
}
private static void growSubBranches(TreeBlockCanvas canvas, IrisProceduralTree tree, int ox, int oy, int oz,
double az, double el, double len, IrisTreeSubBranches sub, int depth, long seed) {
double az, double el, double len, TreeSubBranches sub, int depth, long seed) {
if (sub == null || depth <= 0) {
return;
}
int count = Math.max(1, sub.getCount());
int count = Math.max(1, sub.count());
for (int si = 0; si < count; si++) {
double yawOffset = sub.getYawDelta() * (si - (count - 1) / 2.0);
double yawOffset = sub.yawDelta() * (si - (count - 1) / 2.0);
double subAz = az + yawOffset;
double subEl = el + sub.getPitchDelta();
double subLen = len * sub.getLengthScale();
double subEl = el + sub.pitchDelta();
double subLen = len * sub.lengthScale();
int[] end = branchEndpoint(ox, oy, oz, subAz, subEl, subLen);
int[] tip = rasterizeBranch(canvas, ox, oy, oz, end[0], end[1], end[2], sub.getSag());
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], sub.getClusterRadius(),
sub.getClusterMode(), sub.getClusterDensity(), seed + si * 131L);
int[] tip = rasterizeBranch(canvas, ox, oy, oz, end[0], end[1], end[2], sub.sag());
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], sub.clusterRadius(),
sub.clusterMode(), sub.clusterDensity(), seed + si * 131L);
growSubBranches(canvas, tree, tip[0], tip[1], tip[2], subAz, subEl, subLen, sub, depth - 1, seed + si * 131L + 17L);
}
}
@@ -18,8 +18,8 @@
package art.arcane.iris.engine.object.procedural.tree;
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeDecorator;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.collection.KMap;
import art.arcane.volmlib.util.math.RNG;
@@ -32,19 +32,19 @@ public final class TreeDecoratorApplier {
}
public static void apply(TreeBlockCanvas canvas, IrisProceduralTree tree, long baseSeed, List<int[]> branchEndpoints) {
KList<IrisTreeDecorator> decorators = tree.getDecorators();
KList<TreeDecorator> decorators = tree.getDecorators();
if (decorators == null || decorators.isEmpty()) {
return;
}
RNG rng = new RNG(baseSeed + 77777L);
for (int idx = 0; idx < decorators.size(); idx++) {
IrisTreeDecorator dec = decorators.get(idx);
boolean hasBlock = (dec.getBlock() != null && !dec.getBlock().isEmpty()) || TreeTrunkBuilder.paletteSet(dec.getPalette());
TreeDecorator dec = decorators.get(idx);
boolean hasBlock = (dec.block() != null && !dec.block().isEmpty()) || dec.palette().isPresent();
if (!hasBlock) {
continue;
}
switch (dec.getTarget()) {
switch (dec.target()) {
case BRANCH_TIP -> branchTip(canvas, dec, idx, branchEndpoints, rng);
case TRUNK_SURFACE -> trunkSurface(canvas, dec, idx, rng);
case CANOPY_TOP -> canopyTop(canvas, dec, idx, rng);
@@ -59,63 +59,63 @@ public final class TreeDecoratorApplier {
}
}
private static void branchTip(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, List<int[]> branchEndpoints, RNG rng) {
private static void branchTip(TreeBlockCanvas canvas, TreeDecorator dec, int idx, List<int[]> branchEndpoints, RNG rng) {
if (branchEndpoints == null) {
return;
}
for (int[] e : branchEndpoints) {
if (rng.nextDouble() > dec.getChance()) {
if (rng.nextDouble() > dec.chance()) {
continue;
}
if (canvas.has(e[0], e[1], e[2])) {
continue;
}
String facing = dec.isAxisAware() ? facingAway(e[3], e[4], e[0], e[2]) : null;
String facing = dec.axisAware() ? facingAway(e[3], e[4], e[0], e[2]) : null;
canvas.setDecor(e[0], e[1], e[2], idx, facing);
}
}
private static void trunkSurface(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
private static void trunkSurface(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
int[][] sides = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
String[] facings = {"west", "east", "north", "south"};
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getTrunk())) {
for (int i = 0; i < sides.length; i++) {
int nx = v.x() + sides[i][0];
int nz = v.z() + sides[i][1];
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.getChance()) {
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.chance()) {
continue;
}
canvas.setDecor(nx, v.y(), nz, idx, dec.isAxisAware() ? facings[i] : null);
canvas.setDecor(nx, v.y(), nz, idx, dec.axisAware() ? facings[i] : null);
}
}
}
private static void leafSurface(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
private static void leafSurface(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
int[][] sides = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
String[] facings = {"west", "east", "north", "south"};
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getLeaf())) {
for (int i = 0; i < sides.length; i++) {
int nx = v.x() + sides[i][0];
int nz = v.z() + sides[i][1];
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.getChance()) {
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.chance()) {
continue;
}
canvas.setDecor(nx, v.y(), nz, idx, dec.isAxisAware() ? facings[i] : null);
canvas.setDecor(nx, v.y(), nz, idx, dec.axisAware() ? facings[i] : null);
}
}
}
private static void branchSurface(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
private static void branchSurface(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getTrunk())) {
int ay = v.y() + 1;
if (canvas.has(v.x(), ay, v.z()) || rng.nextDouble() > dec.getChance()) {
if (canvas.has(v.x(), ay, v.z()) || rng.nextDouble() > dec.chance()) {
continue;
}
canvas.setDecor(v.x(), ay, v.z(), idx, null);
}
}
private static void canopyTop(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
private static void canopyTop(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
KMap<Long, Integer> colTop = new KMap<>();
for (TreeBlockCanvas.Vec v : canvas.getCells().keySet()) {
long key = pack(v.x(), v.z());
@@ -128,31 +128,31 @@ public final class TreeDecoratorApplier {
int x = unpackX(e.getKey());
int z = unpackZ(e.getKey());
int aboveY = e.getValue() + 1;
if (canvas.has(x, aboveY, z) || rng.nextDouble() > dec.getChance()) {
if (canvas.has(x, aboveY, z) || rng.nextDouble() > dec.chance()) {
continue;
}
canvas.setDecor(x, aboveY, z, idx, null);
}
}
private static void canopyBottom(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
private static void canopyBottom(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
KMap<Long, Integer> colBottom = columnLeafBottoms(canvas);
for (Map.Entry<Long, Integer> e : colBottom.entrySet()) {
int x = unpackX(e.getKey());
int z = unpackZ(e.getKey());
int belowY = e.getValue() - 1;
if (canvas.has(x, belowY, z) || rng.nextDouble() > dec.getChance()) {
if (canvas.has(x, belowY, z) || rng.nextDouble() > dec.chance()) {
continue;
}
canvas.setDecor(x, belowY, z, idx, null);
}
}
private static void canopyHang(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
int maxLen = Math.max(1, dec.getLength());
private static void canopyHang(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
int maxLen = Math.max(1, dec.length());
KMap<Long, Integer> colBottom = columnLeafBottoms(canvas);
for (Map.Entry<Long, Integer> e : colBottom.entrySet()) {
if (rng.nextDouble() > dec.getChance()) {
if (rng.nextDouble() > dec.chance()) {
continue;
}
int x = unpackX(e.getKey());
@@ -168,7 +168,7 @@ public final class TreeDecoratorApplier {
}
}
private static void trunkBase(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
private static void trunkBase(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
int[][] sides = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getTrunk())) {
if (v.y() != 0) {
@@ -177,7 +177,7 @@ public final class TreeDecoratorApplier {
for (int[] side : sides) {
int nx = v.x() + side[0];
int nz = v.z() + side[1];
if (canvas.has(nx, 0, nz) || rng.nextDouble() > dec.getChance()) {
if (canvas.has(nx, 0, nz) || rng.nextDouble() > dec.chance()) {
continue;
}
canvas.setDecor(nx, 0, nz, idx, null);
@@ -185,7 +185,7 @@ public final class TreeDecoratorApplier {
}
}
private static void trunkTop(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
private static void trunkTop(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
int maxY = Integer.MIN_VALUE;
for (TreeBlockCanvas.Vec v : canvas.getTrunk()) {
maxY = Math.max(maxY, v.y());
@@ -198,14 +198,14 @@ public final class TreeDecoratorApplier {
continue;
}
int aboveY = v.y() + 1;
if (canvas.has(v.x(), aboveY, v.z()) || rng.nextDouble() > dec.getChance()) {
if (canvas.has(v.x(), aboveY, v.z()) || rng.nextDouble() > dec.chance()) {
continue;
}
canvas.setDecor(v.x(), aboveY, v.z(), idx, null);
}
}
private static void groundScatter(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
private static void groundScatter(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
double cx = 0;
double cz = 0;
int count = 0;
@@ -237,7 +237,7 @@ public final class TreeDecoratorApplier {
}
int x = icx + dx;
int z = icz + dz;
if (canvas.has(x, 0, z) || rng.nextDouble() > dec.getChance()) {
if (canvas.has(x, 0, z) || rng.nextDouble() > dec.chance()) {
continue;
}
canvas.setDecor(x, 0, z, idx, null);
@@ -18,10 +18,10 @@
package art.arcane.iris.engine.object.procedural.tree;
import art.arcane.iris.builtin.objects.tree.TreeBranches;
import art.arcane.iris.builtin.objects.tree.TreeFunction;
import art.arcane.iris.builtin.objects.tree.TreeAzimuthMode;
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeAzimuthMode;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeBranches;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeFunction;
import art.arcane.volmlib.util.math.RNG;
public final class TreeFunctions {
@@ -65,7 +65,7 @@ public final class TreeFunctions {
};
}
public static double curveProgress(IrisTreeFunction fn, double t, double steepness) {
public static double curveProgress(TreeFunction fn, double t, double steepness) {
return switch (fn) {
case LINEAR, CONSTANT, SINE -> t;
case LOG -> Math.log(1.0 + t * (Math.E - 1.0));
@@ -78,14 +78,14 @@ public final class TreeFunctions {
};
}
public static double branchLength(IrisTreeBranches b, double t) {
double base = b.getLengthBase();
double crown = b.getLengthCrown();
double max = b.getLengthMax();
double v = switch (b.getLengthFunction()) {
case CONSTANT -> b.getLengthConstant();
public static double branchLength(TreeBranches b, double t) {
double base = b.lengthBase();
double crown = b.lengthCrown();
double max = b.lengthMax();
double v = switch (b.lengthFunction()) {
case CONSTANT -> b.lengthConstant();
case LINEAR, SINE -> base + (crown - base) * t;
case SIGMOID -> max / (1.0 + Math.exp(-b.getLengthSteepness() * (t - 0.5)));
case SIGMOID -> max / (1.0 + Math.exp(-b.lengthSteepness() * (t - 0.5)));
case LOG -> max * Math.log(1.0 + t * (Math.E - 1.0));
case PARABOLIC -> max * (1.0 - Math.pow(2.0 * t - 1.0, 2));
case EXPONENTIAL -> geometric(base, crown, t);
@@ -97,24 +97,24 @@ public final class TreeFunctions {
return Math.max(1.0, v);
}
public static double branchProbability(IrisTreeBranches b, double t, long seed) {
double std = Math.max(b.getProbabilityStd(), 1e-6);
return switch (b.getProbabilityFunction()) {
case CONSTANT -> b.getProbabilityConstant();
case LINEAR -> b.getProbabilityBase() + (b.getProbabilityCrown() - b.getProbabilityBase()) * t;
case SIGMOID -> 1.0 / (1.0 + Math.exp(-b.getProbabilitySteepness() * (t - b.getProbabilityMidpoint())));
case TOP_HEAVY -> Math.pow(t, b.getProbabilityExponent());
case GAUSSIAN -> Math.exp(-0.5 * Math.pow((t - b.getProbabilityMean()) / std, 2));
case NOISE -> valueNoise1D(t * b.getProbabilityScale(), seed);
case BOTTOM_HEAVY -> Math.pow(1.0 - t, b.getProbabilityExponent());
case PERIODIC -> b.getProbabilityConstant() * Math.pow(Math.max(0.0, Math.sin(2.0 * Math.PI * t * b.getProbabilityPeriods())), 8);
case BAND -> Math.abs(t - b.getProbabilityMean()) <= b.getProbabilityStd() ? b.getProbabilityConstant() : 0.0;
case INVERSE_GAUSSIAN -> b.getProbabilityConstant() * (1.0 - Math.exp(-0.5 * Math.pow((t - b.getProbabilityMean()) / std, 2)));
case EXPONENTIAL_DECAY -> b.getProbabilityConstant() * Math.exp(-b.getProbabilityExponent() * t);
public static double branchProbability(TreeBranches b, double t, long seed) {
double std = Math.max(b.probabilityStd(), 1e-6);
return switch (b.probabilityFunction()) {
case CONSTANT -> b.probabilityConstant();
case LINEAR -> b.probabilityBase() + (b.probabilityCrown() - b.probabilityBase()) * t;
case SIGMOID -> 1.0 / (1.0 + Math.exp(-b.probabilitySteepness() * (t - b.probabilityMidpoint())));
case TOP_HEAVY -> Math.pow(t, b.probabilityExponent());
case GAUSSIAN -> Math.exp(-0.5 * Math.pow((t - b.probabilityMean()) / std, 2));
case NOISE -> valueNoise1D(t * b.probabilityScale(), seed);
case BOTTOM_HEAVY -> Math.pow(1.0 - t, b.probabilityExponent());
case PERIODIC -> b.probabilityConstant() * Math.pow(Math.max(0.0, Math.sin(2.0 * Math.PI * t * b.probabilityPeriods())), 8);
case BAND -> Math.abs(t - b.probabilityMean()) <= b.probabilityStd() ? b.probabilityConstant() : 0.0;
case INVERSE_GAUSSIAN -> b.probabilityConstant() * (1.0 - Math.exp(-0.5 * Math.pow((t - b.probabilityMean()) / std, 2)));
case EXPONENTIAL_DECAY -> b.probabilityConstant() * Math.exp(-b.probabilityExponent() * t);
};
}
public static double azimuthDegrees(IrisTreeAzimuthMode mode, double t, int index, IrisProceduralTree tree, double constantBase, RNG rng) {
public static double azimuthDegrees(TreeAzimuthMode mode, double t, int index, IrisProceduralTree tree, double constantBase, RNG rng) {
return switch (mode) {
case CONSTANT -> constantBase;
case LINEAR -> tree.getAzimuthStart() + (tree.getAzimuthEnd() - tree.getAzimuthStart()) * t;
@@ -18,13 +18,14 @@
package art.arcane.iris.engine.object.procedural.tree;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeProfile;
import art.arcane.iris.builtin.objects.tree.TreeProfile;
public final class TreeProfiles {
private TreeProfiles() {
}
static double radiusScale(IrisTreeProfile profile) {
static double radiusScale(TreeProfile profile) {
return switch (profile) {
case OAK, DARK_OAK, CHERRY -> 1.0;
case BIRCH -> 0.7;
@@ -41,7 +42,7 @@ public final class TreeProfiles {
};
}
static double[][] fractions(IrisTreeProfile profile) {
static double[][] fractions(TreeProfile profile) {
return switch (profile) {
case OAK -> new double[][]{{0.55, 0.6}, {0.65, 0.9}, {0.75, 1.0}, {0.85, 0.9}, {0.92, 0.65}, {0.98, 0.35}};
case BIRCH -> new double[][]{{0.6, 0.45}, {0.7, 0.75}, {0.8, 0.85}, {0.88, 0.75}, {0.94, 0.45}, {0.99, 0.2}};
@@ -59,7 +60,7 @@ public final class TreeProfiles {
};
}
static double[][] presetLayers(IrisTreeProfile profile, int height, boolean branchDriven) {
static double[][] presetLayers(TreeProfile profile, int height, boolean branchDriven) {
double scale = radiusScale(profile);
int baseRadius = Math.max(3, (int) Math.round(height / 2.0 * scale));
double[][] fractions = fractions(profile);
@@ -18,8 +18,8 @@
package art.arcane.iris.engine.object.procedural.tree;
import art.arcane.iris.builtin.objects.tree.TreeRootStyle;
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeRootStyle;
import art.arcane.volmlib.util.math.RNG;
import java.util.ArrayList;
@@ -58,7 +58,7 @@ public final class TreeRootBuilder {
}
double flare = tree.getRootFlare() > 0 ? tree.getRootFlare() : baseRadius + Math.max(2.0, depth * 0.6);
IrisTreeRootStyle style = tree.getRootStyle();
TreeRootStyle style = tree.getRootStyle();
switch (style) {
case TAPROOT -> taproot(canvas, cells, cx, cz, baseRadius, depth);
case BUTTRESS -> {
@@ -18,9 +18,9 @@
package art.arcane.iris.engine.object.procedural.tree;
import art.arcane.iris.builtin.objects.tree.TreeAzimuthMode;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
import art.arcane.iris.engine.object.procedural.tree.IrisTreeAzimuthMode;
import java.util.ArrayList;
import java.util.List;
@@ -164,7 +164,7 @@ public final class TreeTrunkBuilder {
double progress = TreeFunctions.curveProgress(tree.getTrunkCurve(), t, tree.getCurveSteepness());
double maxReach = height * Math.tan(Math.toRadians(tree.getLeanAngle()));
double reach = maxReach * progress;
double azDeg = tree.getLeanAzimuthMode() == IrisTreeAzimuthMode.CONSTANT
double azDeg = tree.getLeanAzimuthMode() == TreeAzimuthMode.CONSTANT
? tree.getLeanAzimuth()
: TreeFunctions.azimuthDegrees(tree.getLeanAzimuthMode(), t, -1, tree, tree.getLeanAzimuth(), null);
double azRad = Math.toRadians(azDeg);
@@ -18,11 +18,11 @@
package art.arcane.iris.engine.object.structure;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.blocks.ObjectReplace;
import art.arcane.iris.engine.object.loot.IrisLootTable;
import art.arcane.iris.engine.object.loot.IrisObjectLoot;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.placement.IrisObjectReplace;
import art.arcane.iris.engine.object.placement.ObjectPlaceMode;
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawBranchFailurePolicy;
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawCompatibility;
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawMode;
@@ -96,9 +96,9 @@ public class IrisStructure extends IrisRegistrant {
@Desc("The place mode used when stamping each piece object into the world.")
private ObjectPlaceMode placeMode = ObjectPlaceMode.STRUCTURE_PIECE;
@ArrayType(min = 1, type = IrisObjectReplace.class)
@ArrayType(min = 1, type = ObjectReplace.class)
@Desc("Find-and-replace block edits applied to every piece of this structure, using the exact same syntax as an object's 'edit'. For example, replace stone bricks with obsidian.")
private KList<IrisObjectReplace> edit = new KList<>();
private KList<ObjectReplace> edit = new KList<>();
@ArrayType(type = String.class, min = 1)
@RegistryListResource(IrisLootTable.class)
Loaded 100 of 126 files, more files were not shown because too many files have changed in this diff. Show more