mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
iris:objects owns objects, proceduralObjects, treeSettings and the dimension's object surface-support and upper-object switches as module settings; the host reads them through ObjectPlacements
This commit is contained in:
1 parent
0d557da40f
commit
412987daf9
45 files changed
+2122
-715
No files matched your search
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlacements;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
@@ -44,14 +45,14 @@ public final class ObjectLocating implements ObjectsAt {
|
||||
Engine engine = engine(world);
|
||||
Set<String> biomes = new LinkedHashSet<>();
|
||||
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
|
||||
if (biome != null && placesObject(biome.getSurfaceObjects(), objectKey)) {
|
||||
if (biome != null && placesObject(ObjectPlacements.surface(biome), objectKey)) {
|
||||
biomes.add(biome.getLoadKey());
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> regions = new LinkedHashSet<>();
|
||||
for (IrisRegion region : engine.getDimension().getAllRegions(engine)) {
|
||||
if (region != null && placesObject(region.getSurfaceObjects(), objectKey)) {
|
||||
if (region != null && placesObject(ObjectPlacements.surface(region), objectKey)) {
|
||||
regions.add(region.getLoadKey());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
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.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.RequireSurfaceSupportSettings;
|
||||
import art.arcane.iris.builtin.objects.SurfaceSupportBufferSettings;
|
||||
import art.arcane.iris.builtin.objects.TreeGrowthSettings;
|
||||
import art.arcane.iris.builtin.objects.UpperObjectsForceSettings;
|
||||
import art.arcane.iris.builtin.objects.UpperObjectsSettings;
|
||||
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
@@ -71,14 +70,13 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle {
|
||||
log = registry.log();
|
||||
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);
|
||||
registry.registerSettings(ObjectSettings.class);
|
||||
registry.registerSettings(ProceduralObjectSettings.class);
|
||||
registry.registerSettings(TreeGrowthSettings.class);
|
||||
registry.registerSettings(RequireSurfaceSupportSettings.class);
|
||||
registry.registerSettings(SurfaceSupportBufferSettings.class);
|
||||
registry.registerSettings(UpperObjectsSettings.class);
|
||||
registry.registerSettings(UpperObjectsForceSettings.class);
|
||||
registry.registerLifecycle(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CaveProfiles;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlacements;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectVacuum;
|
||||
import art.arcane.iris.core.IrisSettings;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
@@ -43,9 +44,9 @@ 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;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.ResolvedTree;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
@@ -145,8 +146,8 @@ public class ObjectPlacing {
|
||||
+ " surfaceY=" + surfaceY
|
||||
+ " maxAnchorY=" + maxY
|
||||
+ " carvedAtCenter=" + carvedBlocks
|
||||
+ " biomeCarvingObjects=" + caveBiome.getCarvingObjects().size()
|
||||
+ " regionCarvingObjects=" + region.getCarvingObjects().size()
|
||||
+ " biomeCarvingObjects=" + ObjectPlacements.carving(caveBiome).size()
|
||||
+ " regionCarvingObjects=" + ObjectPlacements.carving(region).size()
|
||||
+ " sameBiome=" + (caveBiome == surfaceBiome || java.util.Objects.equals(caveBiome.getLoadKey(), surfaceBiome.getLoadKey())));
|
||||
}
|
||||
if (traceRegen) {
|
||||
@@ -154,16 +155,16 @@ public class ObjectPlacing {
|
||||
+ " surfaceBiome=" + surfaceBiome.getLoadKey()
|
||||
+ " caveBiome=" + caveBiome.getLoadKey()
|
||||
+ " region=" + region.getLoadKey()
|
||||
+ " biomeSurfacePlacers=" + surfaceBiome.getSurfaceObjects().size()
|
||||
+ " biomeCavePlacers=" + caveBiome.getCarvingObjects().size()
|
||||
+ " regionSurfacePlacers=" + region.getSurfaceObjects().size()
|
||||
+ " regionCavePlacers=" + region.getCarvingObjects().size());
|
||||
+ " biomeSurfacePlacers=" + ObjectPlacements.surface(surfaceBiome).size()
|
||||
+ " biomeCavePlacers=" + ObjectPlacements.carving(caveBiome).size()
|
||||
+ " regionSurfacePlacers=" + ObjectPlacements.surface(region).size()
|
||||
+ " regionCavePlacers=" + ObjectPlacements.carving(region).size());
|
||||
}
|
||||
ObjectPlacementSummary summary = placeObjects(writer, rng, x, z, surfaceBiome, caveBiome, region, complex, traceRegen);
|
||||
placeProceduralObjects(writer, rng, x, z, surfaceBiome, caveBiome, region);
|
||||
UpperDimensionContext upperCtx = engine.getUpperContext();
|
||||
IrisDimension dimension = engine.getDimension();
|
||||
if (upperCtx != null && dimension.isUpperDimensionObjects()) {
|
||||
if (upperCtx != null && ObjectPlacements.upperObjects(dimension)) {
|
||||
placeUpperObjects(writer, rng, x, z, xxx, zzz, surfaceY, upperCtx, dimension, complex, traceRegen);
|
||||
}
|
||||
if (traceRegen) {
|
||||
@@ -212,7 +213,7 @@ public class ObjectPlacing {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sampled.getCarvingObjects().isEmpty()) {
|
||||
if (!ObjectPlacements.carving(sampled).isEmpty()) {
|
||||
ladderChoice = sampled;
|
||||
}
|
||||
}
|
||||
@@ -243,7 +244,7 @@ public class ObjectPlacing {
|
||||
CaveProfile regionCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(region), CaveProfiles.declaredBy(caveBiome));
|
||||
CaveAnchorCache caveAnchorCache = new CaveAnchorCache();
|
||||
|
||||
for (IrisObjectPlacement i : surfaceBiome.getSurfaceObjects()) {
|
||||
for (IrisObjectPlacement i : ObjectPlacements.surface(surfaceBiome)) {
|
||||
biomeSurfaceChecked++;
|
||||
boolean chance = rng.chance(i.getChance() + rng.d(-0.005, 0.005));
|
||||
if (traceRegen) {
|
||||
@@ -272,7 +273,7 @@ public class ObjectPlacing {
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisObjectPlacement i : caveBiome.getCarvingObjects()) {
|
||||
for (IrisObjectPlacement i : ObjectPlacements.carving(caveBiome)) {
|
||||
if (!i.getCarvingSupport().supportsCarving()) {
|
||||
continue;
|
||||
}
|
||||
@@ -304,7 +305,7 @@ public class ObjectPlacing {
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisObjectPlacement i : region.getSurfaceObjects()) {
|
||||
for (IrisObjectPlacement i : ObjectPlacements.surface(region)) {
|
||||
regionSurfaceChecked++;
|
||||
boolean chance = rng.chance(i.getChance() + rng.d(-0.005, 0.005));
|
||||
if (traceRegen) {
|
||||
@@ -333,7 +334,7 @@ public class ObjectPlacing {
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisObjectPlacement i : region.getCarvingObjects()) {
|
||||
for (IrisObjectPlacement i : ObjectPlacements.carving(region)) {
|
||||
if (!i.getCarvingSupport().supportsCarving()) {
|
||||
continue;
|
||||
}
|
||||
@@ -386,11 +387,11 @@ public class ObjectPlacing {
|
||||
private void placeProceduralObjects(MantleWriter writer, RNG rng, int x, int z, IrisBiome surfaceBiome, IrisBiome caveBiome, IrisRegion region) {
|
||||
CaveProfile surfaceCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(surfaceBiome), CaveProfiles.declaredBy(region));
|
||||
CaveProfile regionCaveProfile = resolveCaveProfile(CaveProfiles.declaredBy(region), caveBiome == null ? null : CaveProfiles.declaredBy(caveBiome));
|
||||
placeProceduralFrom(writer, rng, x, z, surfaceBiome.getProceduralObjects(), surfaceBiome.getName(), surfaceCaveProfile, surfaceBiome.getLoadKey());
|
||||
placeProceduralFrom(writer, rng, x, z, region.getProceduralObjects(), region.getName(), regionCaveProfile, null);
|
||||
placeProceduralFrom(writer, rng, x, z, ObjectPlacements.procedural(surfaceBiome), surfaceBiome.getName(), surfaceCaveProfile, surfaceBiome.getLoadKey());
|
||||
placeProceduralFrom(writer, rng, x, z, ObjectPlacements.procedural(region), region.getName(), regionCaveProfile, null);
|
||||
if (caveBiome != null && caveBiome != surfaceBiome) {
|
||||
CaveProfile caveProfile = resolveCaveProfile(CaveProfiles.declaredBy(caveBiome), CaveProfiles.declaredBy(region));
|
||||
placeProceduralFrom(writer, rng, x, z, caveBiome.getProceduralObjects(), caveBiome.getName(), caveProfile, caveBiome.getLoadKey());
|
||||
placeProceduralFrom(writer, rng, x, z, ObjectPlacements.procedural(caveBiome), caveBiome.getName(), caveProfile, caveBiome.getLoadKey());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,7 +401,7 @@ public class ObjectPlacing {
|
||||
RNG rng,
|
||||
int x,
|
||||
int z,
|
||||
IrisProceduralObjects proceduralObjects,
|
||||
ResolvedProceduralObjects proceduralObjects,
|
||||
String scope,
|
||||
CaveProfile caveProfile,
|
||||
String expectedCaveBiomeKey
|
||||
@@ -414,7 +415,7 @@ public class ObjectPlacing {
|
||||
boolean golden = GoldenDebugObjectPlacer.isGoldenDebugChunk(x, z);
|
||||
CaveAnchorCache caveAnchorCache = new CaveAnchorCache();
|
||||
for (IrisProceduralPlacement p : proceduralObjects.getAllPlacements()) {
|
||||
boolean treePlacement = p instanceof IrisProceduralTree;
|
||||
boolean treePlacement = p instanceof ResolvedTree;
|
||||
boolean chancePassed = passesProceduralChance(rng, p.getChance());
|
||||
if (golden) {
|
||||
log.debug("Goldendebug procedural chance: chunk=" + x + "," + z
|
||||
@@ -979,9 +980,9 @@ public class ObjectPlacing {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean forcePlace = dimension.isUpperObjectsForcePlace();
|
||||
boolean forcePlace = ObjectPlacements.upperObjectsForced(dimension);
|
||||
if (upperBiome != null) {
|
||||
for (IrisObjectPlacement i : upperBiome.getSurfaceObjects()) {
|
||||
for (IrisObjectPlacement i : ObjectPlacements.surface(upperBiome)) {
|
||||
if (!rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
continue;
|
||||
}
|
||||
@@ -995,7 +996,7 @@ public class ObjectPlacing {
|
||||
}
|
||||
|
||||
if (upperRegion != null) {
|
||||
for (IrisObjectPlacement i : upperRegion.getSurfaceObjects()) {
|
||||
for (IrisObjectPlacement i : ObjectPlacements.surface(upperRegion)) {
|
||||
if (!rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
continue;
|
||||
}
|
||||
@@ -1163,8 +1164,8 @@ public class ObjectPlacing {
|
||||
/** Dimension acts as the floor: it can force support on and widen the buffer, never weaken either. */
|
||||
private IrisObjectPlacement applyDimensionSurfaceSupport(IrisObjectPlacement placement) {
|
||||
IrisDimension dimension = engine.getDimension();
|
||||
boolean require = placement.isRequireSurfaceSupport() && dimension.isRequireObjectSurfaceSupport();
|
||||
int buffer = Math.max(placement.getSurfaceSupportBuffer(), dimension.getObjectSurfaceSupportBuffer());
|
||||
boolean require = placement.isRequireSurfaceSupport() && ObjectPlacements.requiresSurfaceSupport(dimension);
|
||||
int buffer = Math.max(placement.getSurfaceSupportBuffer(), ObjectPlacements.surfaceSupportBuffer(dimension));
|
||||
if (require == placement.isRequireSurfaceSupport() && buffer == placement.getSurfaceSupportBuffer()) {
|
||||
return placement;
|
||||
}
|
||||
@@ -1432,13 +1433,13 @@ public class ObjectPlacing {
|
||||
IrisBiome biome = engine.getSurfaceBiome((x << 4) + 8, (z << 4) + 8);
|
||||
IrisRegion region = engine.getRegion((x << 4) + 8, (z << 4) + 8);
|
||||
Set<String> v = new KSet<>();
|
||||
for (IrisObjectPlacement i : biome.getSurfaceObjects()) {
|
||||
for (IrisObjectPlacement i : ObjectPlacements.surface(biome)) {
|
||||
if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
v.addAll(guessPlacedKeys(rng, x, z, i));
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisObjectPlacement i : region.getSurfaceObjects()) {
|
||||
for (IrisObjectPlacement i : ObjectPlacements.surface(region)) {
|
||||
if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
v.addAll(guessPlacedKeys(rng, x, z, i));
|
||||
}
|
||||
@@ -1457,15 +1458,15 @@ public class ObjectPlacing {
|
||||
if (region == null) {
|
||||
continue;
|
||||
}
|
||||
radius = Math.max(radius, computePlacementRadius(region.getObjects(), sizeCache, warnedLargeObjects));
|
||||
radius = Math.max(radius, computeProceduralRadius(region.getProceduralObjects()));
|
||||
radius = Math.max(radius, computePlacementRadius(ObjectPlacements.all(region), sizeCache, warnedLargeObjects));
|
||||
radius = Math.max(radius, computeProceduralRadius(ObjectPlacements.procedural(region)));
|
||||
}
|
||||
for (IrisBiome biome : dimension.getReachableBiomes(engine)) {
|
||||
if (biome == null) {
|
||||
continue;
|
||||
}
|
||||
radius = Math.max(radius, computePlacementRadius(biome.getObjects(), sizeCache, warnedLargeObjects));
|
||||
radius = Math.max(radius, computeProceduralRadius(biome.getProceduralObjects()));
|
||||
radius = Math.max(radius, computePlacementRadius(ObjectPlacements.all(biome), sizeCache, warnedLargeObjects));
|
||||
radius = Math.max(radius, computeProceduralRadius(ObjectPlacements.procedural(biome)));
|
||||
}
|
||||
|
||||
return radius;
|
||||
@@ -1500,7 +1501,7 @@ public class ObjectPlacing {
|
||||
return radius;
|
||||
}
|
||||
|
||||
private int computeProceduralRadius(IrisProceduralObjects procedural) {
|
||||
private int computeProceduralRadius(ResolvedProceduralObjects procedural) {
|
||||
if (procedural == null || procedural.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlacements;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
@@ -52,15 +53,15 @@ final class ObjectWarmUp {
|
||||
KList<IrisBiome> biomes = engine.getAllBiomes();
|
||||
biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
|
||||
for (IrisBiome biome : biomes) {
|
||||
warmPlacements(biome.getObjects());
|
||||
warmProcedural(biome.getProceduralObjects());
|
||||
warmPlacements(ObjectPlacements.all(biome));
|
||||
warmProcedural(ObjectPlacements.procedural(biome));
|
||||
}
|
||||
|
||||
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
|
||||
regions.sort(Comparator.comparing(IrisRegion::getLoadKey));
|
||||
for (IrisRegion region : regions) {
|
||||
warmPlacements(region.getObjects());
|
||||
warmProcedural(region.getProceduralObjects());
|
||||
warmPlacements(ObjectPlacements.all(region));
|
||||
warmProcedural(ObjectPlacements.procedural(region));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +79,7 @@ final class ObjectWarmUp {
|
||||
}
|
||||
}
|
||||
|
||||
private void warmProcedural(IrisProceduralObjects procedural) {
|
||||
private void warmProcedural(ResolvedProceduralObjects procedural) {
|
||||
if (procedural == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,13 @@ import art.arcane.iris.core.modules.PlatformBlockStates;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.IrisTreeSize;
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlacements;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeModes;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.ResolvedTree;
|
||||
import art.arcane.iris.builtin.objects.TreeMode;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
@@ -54,12 +55,13 @@ import java.util.Set;
|
||||
* of blocks the host then places. The same placements tell which objects are trees.
|
||||
*/
|
||||
public final class TreeGrowing implements SaplingGrowth {
|
||||
private static final IrisTreeSize SAPLING_SIZE = new IrisTreeSize(1, 1);
|
||||
private static final int SAPLING_WIDTH = 1;
|
||||
private static final int SAPLING_DEPTH = 1;
|
||||
|
||||
@Override
|
||||
public Optional<Growth> grow(PackWorld world, Sapling sapling, Surroundings surroundings) {
|
||||
Engine engine = IrisPackWorld.of(world).engine();
|
||||
if (!engine.getDimension().getTreeSettings().isEnabled()) {
|
||||
if (!ObjectPlacements.treeGrowth(engine.getDimension()).enabled()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -84,14 +86,14 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
|
||||
for (IrisRegion region : engine.getDimension().getAllRegions(engine)) {
|
||||
if (region != null) {
|
||||
collectPlacements(region.getObjects(), objects);
|
||||
collectProceduralTrees(region.getProceduralObjects(), procedural);
|
||||
collectPlacements(ObjectPlacements.all(region), objects);
|
||||
collectProceduralTrees(ObjectPlacements.procedural(region), procedural);
|
||||
}
|
||||
}
|
||||
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
|
||||
if (biome != null) {
|
||||
collectPlacements(biome.getObjects(), objects);
|
||||
collectProceduralTrees(biome.getProceduralObjects(), procedural);
|
||||
collectPlacements(ObjectPlacements.all(biome), objects);
|
||||
collectProceduralTrees(ObjectPlacements.procedural(biome), procedural);
|
||||
}
|
||||
}
|
||||
return new TreeObjects(objects, procedural);
|
||||
@@ -100,12 +102,12 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
/** One placement, picked at random, of the tree placements that grow {@code sapling}'s species; null for none. */
|
||||
private static IrisObjectPlacement pickPlacement(Engine engine, Sapling sapling) {
|
||||
KList<IrisObjectPlacement> placements = new KList<>();
|
||||
boolean useAll = engine.getDimension().getTreeSettings().getMode().equals(IrisTreeModes.ALL);
|
||||
boolean useAll = ObjectPlacements.treeGrowth(engine.getDimension()).mode() == TreeMode.ALL;
|
||||
|
||||
BlockPosition at = sapling.at();
|
||||
placements.addAll(matching(engine.getBiome(at.x(), at.y(), at.z()).getObjects(), sapling.species()));
|
||||
placements.addAll(matching(ObjectPlacements.all(engine.getBiome(at.x(), at.y(), at.z())), sapling.species()));
|
||||
if (useAll || placements.isEmpty()) {
|
||||
placements.addAll(matching(engine.getRegion(at.x(), at.z()).getObjects(), sapling.species()));
|
||||
placements.addAll(matching(ObjectPlacements.all(engine.getRegion(at.x(), at.z())), sapling.species()));
|
||||
}
|
||||
return placements.isNotEmpty() ? placements.getRandom() : null;
|
||||
}
|
||||
@@ -113,7 +115,7 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
private static KList<IrisObjectPlacement> matching(KList<IrisObjectPlacement> objects, String species) {
|
||||
KList<IrisObjectPlacement> matches = new KList<>();
|
||||
for (IrisObjectPlacement placement : objects) {
|
||||
if (placement.matches(SAPLING_SIZE, species)) {
|
||||
if (placement.matches(SAPLING_WIDTH, SAPLING_DEPTH, species)) {
|
||||
matches.add(placement);
|
||||
}
|
||||
}
|
||||
@@ -139,17 +141,18 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
}
|
||||
}
|
||||
|
||||
private static void collectProceduralTrees(IrisProceduralObjects proceduralObjects, Set<String> objectKeys) {
|
||||
private static void collectProceduralTrees(ResolvedProceduralObjects proceduralObjects, Set<String> objectKeys) {
|
||||
if (proceduralObjects == null || proceduralObjects.getTrees() == null) {
|
||||
return;
|
||||
}
|
||||
for (IrisProceduralTree tree : proceduralObjects.getTrees()) {
|
||||
if (tree == null || tree.getName() == null || tree.getName().isBlank()) {
|
||||
for (ResolvedTree resolved : proceduralObjects.getTrees()) {
|
||||
Tree tree = resolved.settings();
|
||||
if (tree.name() == null || tree.name().isBlank()) {
|
||||
continue;
|
||||
}
|
||||
int variants = Math.max(1, tree.getVariants());
|
||||
int variants = Math.max(1, tree.variants());
|
||||
for (int index = 0; index < variants; index++) {
|
||||
objectKeys.add(tree.getVariantLoadKey(index));
|
||||
objectKeys.add(resolved.getVariantLoadKey(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.objects.TreeOverride;
|
||||
import art.arcane.iris.builtin.carve.CaveAnchorMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||
@@ -63,7 +64,6 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.TreeType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
@@ -176,8 +176,8 @@ public class IrisObjectPlacement {
|
||||
@Desc("Whether the given loot tables override any and all other loot tables available in the dimension, region or biome.")
|
||||
private boolean overrideGlobalLoot = false;
|
||||
@Desc("This object / these objects override the following trees when they grow...")
|
||||
@ArrayType(min = 1, type = IrisTree.class)
|
||||
private KList<IrisTree> trees = new KList<>();
|
||||
@ArrayType(min = 1, type = TreeOverride.class)
|
||||
private KList<TreeOverride> trees = new KList<>();
|
||||
@RegistryListResource(IrisObject.class)
|
||||
@ArrayType(type = String.class)
|
||||
@Desc("List of objects to this object is allowed to collied with")
|
||||
@@ -267,14 +267,10 @@ public class IrisObjectPlacement {
|
||||
return g.getData().getObjectLoader().load(place.get(random.nextInt(place.size())));
|
||||
}
|
||||
|
||||
/** Whether a tree placement grows the species the platform calls {@code species} for a sapling area of {@code size}. */
|
||||
public boolean matches(IrisTreeSize size, String species) {
|
||||
return matches(size, TreeType.valueOf(species));
|
||||
}
|
||||
|
||||
public boolean matches(IrisTreeSize size, TreeType type) {
|
||||
for (IrisTree i : getTrees()) {
|
||||
if (i.matches(size, type)) {
|
||||
/** Whether a tree placement grows the species the platform calls {@code species} for a sapling area of {@code width} by {@code depth}. */
|
||||
public boolean matches(int width, int depth, String species) {
|
||||
for (TreeOverride tree : getTrees()) {
|
||||
if (tree.matches(width, depth, species)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +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.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
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;
|
||||
import org.bukkit.TreeType;
|
||||
|
||||
@Snippet("tree")
|
||||
@Accessors(chain = true)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Desc("Tree replace options for this object placer")
|
||||
@Data
|
||||
public class IrisTree {
|
||||
@Required
|
||||
@Desc("The types of trees overwritten by this object")
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
private KList<String> treeTypes = new KList<>();
|
||||
|
||||
|
||||
@Required
|
||||
@Desc("The size of the square of saplings this applies to (2 means a 2 * 2 sapling area)")
|
||||
@ArrayType(min = 1, type = IrisTreeSize.class)
|
||||
private KList<IrisTreeSize> sizes = new KList<>();
|
||||
|
||||
|
||||
public boolean matches(IrisTreeSize size, TreeType type) {
|
||||
if (!matchesSize(size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return matchesType(type);
|
||||
}
|
||||
|
||||
private boolean matchesSize(IrisTreeSize size) {
|
||||
for (IrisTreeSize i : getSizes()) {
|
||||
if ((i.getDepth() == size.getDepth() && i.getWidth() == size.getWidth()) || (i.getDepth() == size.getWidth() && i.getWidth() == size.getDepth())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean matchesType(TreeType type) {
|
||||
if (type == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String name = type.name();
|
||||
for (String i : getTreeTypes()) {
|
||||
if (i != null && i.equalsIgnoreCase(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +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.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-size")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Sapling override object picking options")
|
||||
@Data
|
||||
public class IrisTreeSize {
|
||||
|
||||
@Required
|
||||
@Desc("The width of the sapling area")
|
||||
int width = 1;
|
||||
|
||||
@Required
|
||||
@Desc("The depth of the sapling area")
|
||||
int depth = 1;
|
||||
|
||||
/**
|
||||
* Does the size match
|
||||
*
|
||||
* @param size the size to check match
|
||||
* @return true if it matches (fits within width and depth)
|
||||
*/
|
||||
public boolean doesMatch(IrisTreeSize size) {
|
||||
return (width == size.getWidth() && depth == size.getDepth()) || (depth == size.getWidth() && width == size.getDepth());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.RequireSurfaceSupportSettings;
|
||||
import art.arcane.iris.builtin.objects.SurfaceSupportBufferSettings;
|
||||
import art.arcane.iris.builtin.objects.TreeGrowthSettings;
|
||||
import art.arcane.iris.builtin.objects.UpperObjectsForceSettings;
|
||||
import art.arcane.iris.builtin.objects.UpperObjectsSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
* The object placements and procedural objects a region or biome declares, as Iris places them: the module settings of
|
||||
* {@code iris:objects}, made into Iris's own placements once and kept for as long as the settings live.
|
||||
*/
|
||||
public final class ObjectPlacements {
|
||||
private static final Map<ObjectSettings, Placements> PLACEMENTS = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
private static final Map<ProceduralObjectSettings, ResolvedProceduralObjects> PROCEDURAL = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
|
||||
private ObjectPlacements() {
|
||||
}
|
||||
|
||||
/** Every placement {@code owner} declares. */
|
||||
public static KList<IrisObjectPlacement> all(IrisRegistrant owner) {
|
||||
return placementsOf(owner).all;
|
||||
}
|
||||
|
||||
/** The placements of {@code owner} that place on the surface. */
|
||||
public static KList<IrisObjectPlacement> surface(IrisRegistrant owner) {
|
||||
return placementsOf(owner).surface;
|
||||
}
|
||||
|
||||
/** The placements of {@code owner} that place in carvings. */
|
||||
public static KList<IrisObjectPlacement> carving(IrisRegistrant owner) {
|
||||
return placementsOf(owner).carving;
|
||||
}
|
||||
|
||||
/** The procedural objects {@code owner} declares; none when it declares none. */
|
||||
public static ResolvedProceduralObjects procedural(IrisRegistrant owner) {
|
||||
Optional<ProceduralObjectSettings> settings = owner.getModuleSettings().find(ProceduralObjectSettings.class);
|
||||
return PROCEDURAL.computeIfAbsent(settings.orElse(NO_PROCEDURAL_OBJECTS), ResolvedProceduralObjects::new);
|
||||
}
|
||||
|
||||
/** Whether {@code dimension} places its objects in the terrain stacked above it too. */
|
||||
public static boolean upperObjects(IrisRegistrant dimension) {
|
||||
return dimension.getModuleSettings().find(UpperObjectsSettings.class).map(UpperObjectsSettings::enabled).orElse(false);
|
||||
}
|
||||
|
||||
/** Whether the objects placed in the terrain stacked above ignore placement restrictions. */
|
||||
public static boolean upperObjectsForced(IrisRegistrant dimension) {
|
||||
return dimension.getModuleSettings().find(UpperObjectsForceSettings.class).map(UpperObjectsForceSettings::force).orElse(false);
|
||||
}
|
||||
|
||||
/** Whether {@code dimension} refuses surface objects over carved openings. */
|
||||
public static boolean requiresSurfaceSupport(IrisRegistrant dimension) {
|
||||
return dimension.getModuleSettings().find(RequireSurfaceSupportSettings.class).map(RequireSurfaceSupportSettings::require)
|
||||
.orElse(NO_SURFACE_SUPPORT_REQUIREMENT.require());
|
||||
}
|
||||
|
||||
/** The least surface-support buffer {@code dimension} gives its surface objects. */
|
||||
public static int surfaceSupportBuffer(IrisRegistrant dimension) {
|
||||
return dimension.getModuleSettings().find(SurfaceSupportBufferSettings.class).map(SurfaceSupportBufferSettings::buffer)
|
||||
.orElse(NO_SURFACE_SUPPORT_BUFFER.buffer());
|
||||
}
|
||||
|
||||
/** The tree growth settings of {@code dimension}. */
|
||||
public static TreeGrowthSettings treeGrowth(IrisRegistrant dimension) {
|
||||
return dimension.getModuleSettings().find(TreeGrowthSettings.class).orElse(NO_TREE_GROWTH);
|
||||
}
|
||||
|
||||
/** Iris's placement for the settings {@code placement}, read from the JSON it was written as. */
|
||||
public static IrisObjectPlacement host(ObjectPlacement placement, IrisData data) {
|
||||
Object kept = placement.hostForm();
|
||||
if (kept instanceof IrisObjectPlacement hostPlacement) {
|
||||
return hostPlacement;
|
||||
}
|
||||
IrisObjectPlacement made = data.getGson().fromJson(placement.json(), IrisObjectPlacement.class);
|
||||
placement.hostForm(made);
|
||||
return made;
|
||||
}
|
||||
|
||||
private static final ProceduralObjectSettings NO_PROCEDURAL_OBJECTS = new ProceduralObjectSettings();
|
||||
private static final RequireSurfaceSupportSettings NO_SURFACE_SUPPORT_REQUIREMENT = new RequireSurfaceSupportSettings();
|
||||
private static final SurfaceSupportBufferSettings NO_SURFACE_SUPPORT_BUFFER = new SurfaceSupportBufferSettings();
|
||||
private static final TreeGrowthSettings NO_TREE_GROWTH = new TreeGrowthSettings();
|
||||
private static final ObjectSettings NO_OBJECTS = new ObjectSettings();
|
||||
|
||||
private static Placements placementsOf(IrisRegistrant owner) {
|
||||
ObjectSettings settings = owner.getModuleSettings().find(ObjectSettings.class).orElse(NO_OBJECTS);
|
||||
Placements found = PLACEMENTS.get(settings);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
return PLACEMENTS.computeIfAbsent(settings, declared -> new Placements(declared, owner.getLoader()));
|
||||
}
|
||||
|
||||
private record Placements(KList<IrisObjectPlacement> all, KList<IrisObjectPlacement> surface, KList<IrisObjectPlacement> carving) {
|
||||
Placements(ObjectSettings settings, IrisData data) {
|
||||
this(new KList<>(), new KList<>(), new KList<>());
|
||||
for (ObjectPlacement declared : settings.objects()) {
|
||||
IrisObjectPlacement placement = host(declared, data);
|
||||
all.add(placement);
|
||||
if (placement.getCarvingSupport().supportsSurface()) {
|
||||
surface.add(placement);
|
||||
}
|
||||
if (placement.getCarvingSupport().supportsCarving()) {
|
||||
carving.add(placement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,112 +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;
|
||||
|
||||
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;
|
||||
|
||||
@Snippet("procedural-objects")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@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 = Ruin.class)
|
||||
@Desc("Procedurally generated ruins (crumbling pillars, walls, arches, rubble).")
|
||||
private KList<Ruin> ruins = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = Formation.class)
|
||||
@Desc("Procedurally generated natural rock formations (spires, hoodoos, arches, sea stacks, boulders, basalt columns).")
|
||||
private KList<Formation> formations = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = Coral.class)
|
||||
@Desc("Procedurally generated underwater coral structures.")
|
||||
private KList<Coral> coral = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = Fungus.class)
|
||||
@Desc("Procedurally generated mushrooms and shelf fungi.")
|
||||
private KList<Fungus> fungi = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = Crystal.class)
|
||||
@Desc("Procedurally generated crystal clusters (usually placed in caves).")
|
||||
private KList<Crystal> crystals = new KList<>();
|
||||
|
||||
public KList<IrisProceduralPlacement> getAllPlacements() {
|
||||
KList<IrisProceduralPlacement> all = new KList<>();
|
||||
if (trees != null) {
|
||||
all.addAll(trees);
|
||||
}
|
||||
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,69 @@
|
||||
/*
|
||||
* 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.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.engine.object.procedural.coral.ResolvedCoral;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.ResolvedCrystal;
|
||||
import art.arcane.iris.engine.object.procedural.formation.ResolvedFormation;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.ResolvedFungus;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.ResolvedRuin;
|
||||
import art.arcane.iris.engine.object.procedural.tree.ResolvedTree;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
/** The procedural objects a region or biome declares, each made placeable once, in the order the settings list them. */
|
||||
public final class ResolvedProceduralObjects {
|
||||
private final KList<IrisProceduralPlacement> all = new KList<>();
|
||||
private final KList<ResolvedTree> trees = new KList<>();
|
||||
|
||||
public ResolvedProceduralObjects(ProceduralObjectSettings settings) {
|
||||
for (Tree tree : settings.trees()) {
|
||||
ResolvedTree resolved = new ResolvedTree(tree);
|
||||
trees.add(resolved);
|
||||
all.add(resolved);
|
||||
}
|
||||
addAll(settings.ruins(), ResolvedRuin::new);
|
||||
addAll(settings.formations(), ResolvedFormation::new);
|
||||
addAll(settings.coral(), ResolvedCoral::new);
|
||||
addAll(settings.fungi(), ResolvedFungus::new);
|
||||
addAll(settings.crystals(), ResolvedCrystal::new);
|
||||
}
|
||||
|
||||
private <S> void addAll(List<S> settings, Function<S, ResolvedProceduralPlacement> resolve) {
|
||||
for (S entry : settings) {
|
||||
all.add(resolve.apply(entry));
|
||||
}
|
||||
}
|
||||
|
||||
public KList<IrisProceduralPlacement> getAllPlacements() {
|
||||
return all;
|
||||
}
|
||||
|
||||
public KList<ResolvedTree> getTrees() {
|
||||
return trees;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return all.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -1,350 +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.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.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.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.volmlib.util.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.tree.ProceduralTreeGenerator;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
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("procedural-tree")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated tree. 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 IrisProceduralTree 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 = "procedural-tree";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance per chunk for this tree 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 tree. Higher means more variety at a small memory cost.")
|
||||
private int variants = 8;
|
||||
|
||||
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Desc("If true (default) leaves are placed with vanilla distance-from-wood values and persistent=false so leaf decay behaves naturally and the tree reads as plausible. If false, leaves are forced persistent and never decay (a raw object dump).")
|
||||
private boolean plausible = true;
|
||||
|
||||
@Desc("The placement mode used to anchor the tree to the terrain.")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Desc("Rotate this tree's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min height of placement.")
|
||||
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;
|
||||
|
||||
@Desc("If true, the tree 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 StiltSettings stiltSettings;
|
||||
|
||||
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private VacuumSettings vacuumSettings;
|
||||
|
||||
@Required
|
||||
@Desc("The trunk (log) block, e.g. minecraft:oak_log. Ignored when trunkPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String trunk = "minecraft:oak_log";
|
||||
|
||||
@Desc("A noise-driven palette for the trunk. When set this overrides the single trunk block, letting the trunk mix blocks by noise.")
|
||||
private IrisMaterialPalette trunkPalette = null;
|
||||
|
||||
@Required
|
||||
@Desc("The leaf block, e.g. minecraft:oak_leaves. Ignored when leavesPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String leaves = "minecraft:oak_leaves";
|
||||
|
||||
@Desc("A noise-driven palette for the leaves. When set this overrides the single leaf block, letting the canopy mix leaf (or other) blocks by noise. Only blocks that are actually leaves get vanilla decay distances.")
|
||||
private IrisMaterialPalette leavesPalette = null;
|
||||
|
||||
@Desc("The named canopy profile that drives default crown radii and shape.")
|
||||
private TreeProfile profile = TreeProfile.OAK;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum trunk height in blocks.")
|
||||
private int heightMin = 8;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum trunk height in blocks.")
|
||||
private int heightMax = 12;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Base trunk width in blocks. 1 is a single column, 2 is a 2x2 trunk, etc.")
|
||||
private int trunkWidth = 1;
|
||||
|
||||
@Desc("The function used to shape trunk width over height.")
|
||||
private TreeFunction trunkShape = TreeFunction.CONSTANT;
|
||||
|
||||
@Desc("Width multiplier at the base for the LINEAR trunk shape.")
|
||||
private double shapeStart = 1;
|
||||
|
||||
@Desc("Width multiplier at the top for the LINEAR trunk shape.")
|
||||
private double shapeEnd = 1;
|
||||
|
||||
@Desc("Steepness for the SIGMOID trunk shape.")
|
||||
private double shapeSteepness = 5;
|
||||
|
||||
@Desc("Base for the LOG trunk shape.")
|
||||
private double shapeBase = 2.718281828;
|
||||
|
||||
@Desc("Period for the SINE trunk shape.")
|
||||
private double shapePeriod = 1;
|
||||
|
||||
@Desc("Amplitude for the SINE trunk shape.")
|
||||
private double shapeAmplitude = 0.2;
|
||||
|
||||
@Desc("Pinch position (0-1) for the PARABOLIC trunk shape.")
|
||||
private double shapePeakOffset = 0.5;
|
||||
|
||||
@Desc("Minimum width fraction at the waist for the PARABOLIC trunk shape.")
|
||||
private double shapeFloor = 0.5;
|
||||
|
||||
@Desc("Compass direction in degrees the trunk leans toward.")
|
||||
private double leanAzimuth = 0;
|
||||
|
||||
@Desc("How far the trunk leans, in degrees from vertical. 0 is perfectly upright.")
|
||||
private double leanAngle = 0;
|
||||
|
||||
@Desc("How the lean accumulates over height.")
|
||||
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 TreeAzimuthMode leanAzimuthMode = TreeAzimuthMode.CONSTANT;
|
||||
|
||||
@Desc("Azimuth at the base for the LINEAR azimuth mode.")
|
||||
private double azimuthStart = 0;
|
||||
|
||||
@Desc("Azimuth at the top for the LINEAR azimuth mode.")
|
||||
private double azimuthEnd = 0;
|
||||
|
||||
@Desc("Number of full turns for the SPIRAL azimuth mode.")
|
||||
private double azimuthTurns = 1;
|
||||
|
||||
@Desc("Amplitude for the SINE azimuth mode.")
|
||||
private double azimuthAmplitude = 90;
|
||||
|
||||
@Desc("Period for the SINE azimuth mode.")
|
||||
private double azimuthPeriod = 1;
|
||||
|
||||
@Desc("Offset for the SINE azimuth mode.")
|
||||
private double azimuthOffset = 0;
|
||||
|
||||
@Desc("Scale for the NOISE azimuth mode.")
|
||||
private double azimuthScale = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Number of branches per whorl ring for the WHORL branch azimuth mode.")
|
||||
private int azimuthWhorlCount = 5;
|
||||
|
||||
@Desc("Optional accent leaf block scattered through the canopy (blossoms, shroomlight).")
|
||||
@RegistryListBlockType
|
||||
private String secondaryLeaves = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The fraction of leaves replaced by the secondary leaf block(s).")
|
||||
private double secondaryLeafFraction = 0.35;
|
||||
|
||||
@ArrayType(min = 1, type = TreeSecondaryLeaf.class)
|
||||
@Desc("Optional weighted set of accent leaf blocks. When set this overrides the single secondaryLeaves block.")
|
||||
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;
|
||||
|
||||
@Desc("Optional secondary trunk block used over a height band (for color-banded trunks). Ignored when secondaryTrunkPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String secondaryTrunk = null;
|
||||
|
||||
@Desc("A noise-driven palette for the secondary trunk band. When set this overrides the single secondaryTrunk block.")
|
||||
private IrisMaterialPalette secondaryTrunkPalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The normalized height where the secondary trunk band starts.")
|
||||
private double secondaryTrunkStart = 0.5;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The normalized height where the secondary trunk band ends.")
|
||||
private double secondaryTrunkEnd = 1;
|
||||
|
||||
@Desc("If true, a root system extends below (and around) the base so the tree connects to the ground on uneven terrain.")
|
||||
private boolean roots = true;
|
||||
|
||||
@Desc("How the root system is built when roots is true.")
|
||||
private TreeRootStyle rootStyle = TreeRootStyle.BUTTRESS;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Override the root depth/reach in blocks. 0 means auto (scales with tree height).")
|
||||
private int rootDepth = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Override the root flare radius in blocks. 0 means auto.")
|
||||
private double rootFlare = 0;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(6)
|
||||
@Desc("How many separate trunks the tree splits into above forkHeight. 1 is a single trunk.")
|
||||
private int trunkForks = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The normalized height where the trunk splits into forks.")
|
||||
private double forkHeight = 0.5;
|
||||
|
||||
@Desc("The outward lean angle in degrees of each fork.")
|
||||
private double forkAngle = 25;
|
||||
|
||||
@Desc("The leaf crown configuration.")
|
||||
private TreeCanopy canopy = new TreeCanopy();
|
||||
|
||||
@ArrayType(min = 1, type = TreeDecorator.class)
|
||||
@Desc("Accent decorators applied after the tree is built (fruit, vines, snow, glow).")
|
||||
private KList<TreeDecorator> decorators = new KList<>();
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
int lo = Math.min(heightMin, heightMax);
|
||||
int hi = Math.max(heightMin, heightMax);
|
||||
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 = ProceduralTreeGenerator.generate(this, Math.max(2, height), new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey(getVariantLoadKey(i));
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
if (new java.io.File("plugins/Iris/goldendebug.txt").isFile()) {
|
||||
for (IrisObject object : baked) {
|
||||
long[] digest = new long[]{0L};
|
||||
object.getBlocks().forEach((vector, state) -> {
|
||||
long position = ((long) vector.getBlockX() << 40) ^ ((long) vector.getBlockY() << 20) ^ vector.getBlockZ();
|
||||
digest[0] ^= Long.rotateLeft(position * 0x9E3779B97F4A7C15L ^ state.key().hashCode(), (int) (position & 63));
|
||||
});
|
||||
IrisLogging.debug("Goldendebug bake: " + object.getLoadKey() + " blocks=" + object.getBlocks().size() + " digest=" + Long.toHexString(digest[0]));
|
||||
}
|
||||
}
|
||||
|
||||
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 String getVariantLoadKey(int index) {
|
||||
if (index < 0) {
|
||||
throw new IllegalArgumentException("index must not be negative");
|
||||
}
|
||||
return "procedural/tree/" + name + "#" + index;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("Sapling override object picking options")
|
||||
public enum IrisTreeModes {
|
||||
@Desc("Check biome, then region, pick the first one that has options. Dimension placements are not consulted.")
|
||||
FIRST,
|
||||
|
||||
@Desc("Check biome, regions, and dimensions, and pick any option from the total list")
|
||||
ALL
|
||||
}
|
||||
@@ -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;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-settings")
|
||||
@Accessors(chain = true)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Desc("Tree growth override settings")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisTreeSettings {
|
||||
|
||||
@Required
|
||||
@Desc("Turn replacing on and off")
|
||||
boolean enabled = false;
|
||||
|
||||
@Desc("Object picking modes")
|
||||
IrisTreeModes mode = IrisTreeModes.FIRST;
|
||||
}
|
||||
+5
-5
@@ -20,7 +20,7 @@ package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -36,13 +36,13 @@ public final class ProceduralTreeGenerator {
|
||||
private ProceduralTreeGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisProceduralTree tree, int height, RNG rng, IrisData data) {
|
||||
public static IrisObject generate(Tree tree, int height, RNG rng, IrisData data) {
|
||||
TreeBlockCanvas canvas = new TreeBlockCanvas();
|
||||
long baseSeed = rng.getSeed();
|
||||
|
||||
List<TreeTrunkBuilder.Limb> limbs = TreeTrunkBuilder.build(canvas, tree, height);
|
||||
|
||||
boolean wantEndpoints = tree.getDecorators() != null && !tree.getDecorators().isEmpty();
|
||||
boolean wantEndpoints = tree.decorators() != null && !tree.decorators().isEmpty();
|
||||
List<int[]> branchEndpoints = wantEndpoints ? new ArrayList<>() : null;
|
||||
|
||||
int limbIndex = 0;
|
||||
@@ -55,11 +55,11 @@ public final class ProceduralTreeGenerator {
|
||||
TreeDecoratorApplier.apply(canvas, tree, baseSeed, branchEndpoints);
|
||||
}
|
||||
|
||||
if (tree.isRoots()) {
|
||||
if (tree.roots()) {
|
||||
TreeRootBuilder.build(canvas, tree, height, baseSeed);
|
||||
}
|
||||
|
||||
if (tree.isPlausible()) {
|
||||
if (tree.plausible()) {
|
||||
TreeSupport.ensureLeavesSupported(canvas, 24);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
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.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/** A procedural tree made placeable: its variants are baked by {@link ProceduralTreeGenerator}, at heights spread between its limits. */
|
||||
public final class ResolvedTree extends ResolvedProceduralPlacement {
|
||||
private static final long VARIANT_SEED_STRIDE = 7919L;
|
||||
private static final double HEIGHT_JITTER_FRACTION = 0.3;
|
||||
private static final int MINIMUM_HEIGHT = 2;
|
||||
|
||||
private final Tree settings;
|
||||
|
||||
public ResolvedTree(Tree 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;
|
||||
}
|
||||
|
||||
/** The key a variant is loaded under, which placement markers and the sapling tree list name. */
|
||||
public static String variantLoadKey(String name, int index) {
|
||||
if (index < 0) {
|
||||
throw new IllegalArgumentException("index must not be negative");
|
||||
}
|
||||
return "procedural/tree/" + name + "#" + index;
|
||||
}
|
||||
|
||||
public String getVariantLoadKey(int index) {
|
||||
return variantLoadKey(settings.name(), index);
|
||||
}
|
||||
|
||||
public Tree settings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlausible() {
|
||||
return settings.plausible();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
throw new UnsupportedOperationException("Tree variants are baked with heights spread over the limits");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected KList<IrisObject> bake(IrisData data) {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, settings.variants());
|
||||
int lo = Math.min(settings.heightMin(), settings.heightMax());
|
||||
int hi = Math.max(settings.heightMin(), settings.heightMax());
|
||||
RNG heightRng = new RNG(settings.seed());
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int height = variantHeight(heightRng, lo, hi, count, i);
|
||||
IrisObject object = ProceduralTreeGenerator.generate(settings, Math.max(MINIMUM_HEIGHT, height),
|
||||
new RNG(settings.seed() + (i * VARIANT_SEED_STRIDE)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey(getVariantLoadKey(i));
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
digestForGoldenDebug(baked);
|
||||
return baked;
|
||||
}
|
||||
|
||||
private static int variantHeight(RNG heightRng, int lo, int hi, int count, int index) {
|
||||
if (count == 1 || lo == hi) {
|
||||
return heightRng.i(lo, hi + 1);
|
||||
}
|
||||
double step = (hi - lo) / (double) (count - 1);
|
||||
double base = lo + step * index;
|
||||
double jitter = heightRng.d(-step * HEIGHT_JITTER_FRACTION, step * HEIGHT_JITTER_FRACTION);
|
||||
return (int) Math.round(Math.max(lo, Math.min(hi, base + jitter)));
|
||||
}
|
||||
|
||||
private static void digestForGoldenDebug(KList<IrisObject> baked) {
|
||||
if (!new File("plugins/Iris/goldendebug.txt").isFile()) {
|
||||
return;
|
||||
}
|
||||
for (IrisObject object : baked) {
|
||||
long[] digest = new long[]{0L};
|
||||
object.getBlocks().forEach((vector, state) -> {
|
||||
long position = ((long) vector.getBlockX() << 40) ^ ((long) vector.getBlockY() << 20) ^ vector.getBlockZ();
|
||||
digest[0] ^= Long.rotateLeft(position * 0x9E3779B97F4A7C15L ^ state.key().hashCode(), (int) (position & 63));
|
||||
});
|
||||
IrisLogging.debug("Goldendebug bake: " + object.getLoadKey() + " blocks=" + object.getBlocks().size() + " digest=" + Long.toHexString(digest[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
-32
@@ -21,10 +21,9 @@ 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.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -33,38 +32,38 @@ public final class TreeBlockResolver {
|
||||
private TreeBlockResolver() {
|
||||
}
|
||||
|
||||
public static PlatformBlockState resolve(IrisProceduralTree tree, IrisData data, TreeBlockCanvas.Cell cell, TreeBlockCanvas.Vec pos) {
|
||||
RNG paletteRng = new RNG(tree.getSeed());
|
||||
RNG posRng = new RNG(tree.getSeed() ^ positionHash(pos));
|
||||
public static PlatformBlockState resolve(Tree tree, IrisData data, TreeBlockCanvas.Cell cell, TreeBlockCanvas.Vec pos) {
|
||||
RNG paletteRng = new RNG(tree.seed());
|
||||
RNG posRng = new RNG(tree.seed() ^ positionHash(pos));
|
||||
|
||||
switch (cell.role()) {
|
||||
case TRUNK -> {
|
||||
PlatformBlockState state = resolveBlock(tree.getTrunk(), tree.getTrunkPalette(), data, pos, paletteRng);
|
||||
PlatformBlockState state = resolveBlock(tree.trunk(), tree.trunkPalette().orElse(null), data, pos, paletteRng);
|
||||
return finishTrunk(state, cell);
|
||||
}
|
||||
case SECONDARY_TRUNK -> {
|
||||
PlatformBlockState state = resolveBlock(tree.getSecondaryTrunk(), tree.getSecondaryTrunkPalette(), data, pos, paletteRng);
|
||||
PlatformBlockState state = resolveBlock(tree.secondaryTrunk().orElse(null), tree.secondaryTrunkPalette().orElse(null), data, pos, paletteRng);
|
||||
if (state == null) {
|
||||
state = resolveBlock(tree.getTrunk(), tree.getTrunkPalette(), data, pos, paletteRng);
|
||||
state = resolveBlock(tree.trunk(), tree.trunkPalette().orElse(null), data, pos, paletteRng);
|
||||
}
|
||||
return finishTrunk(state, cell);
|
||||
}
|
||||
case LEAF -> {
|
||||
return resolveBlock(tree.getLeaves(), tree.getLeavesPalette(), data, pos, paletteRng);
|
||||
return resolveBlock(tree.leaves(), tree.leavesPalette().orElse(null), data, pos, paletteRng);
|
||||
}
|
||||
case SECONDARY_LEAF -> {
|
||||
PlatformBlockState state = resolveSecondaryLeaf(tree, data, pos, paletteRng, posRng);
|
||||
if (state == null) {
|
||||
state = resolveBlock(tree.getLeaves(), tree.getLeavesPalette(), data, pos, paletteRng);
|
||||
state = resolveBlock(tree.leaves(), tree.leavesPalette().orElse(null), data, pos, paletteRng);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
case DECORATOR -> {
|
||||
int index = cell.decoratorIndex();
|
||||
if (index < 0 || tree.getDecorators() == null || index >= tree.getDecorators().size()) {
|
||||
if (index < 0 || tree.decorators() == null || index >= tree.decorators().size()) {
|
||||
return null;
|
||||
}
|
||||
TreeDecorator dec = tree.getDecorators().get(index);
|
||||
TreeDecorator dec = tree.decorators().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 {
|
||||
@@ -96,23 +95,24 @@ public final class TreeBlockResolver {
|
||||
return state;
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveSecondaryLeaf(IrisProceduralTree tree, IrisData data, TreeBlockCanvas.Vec pos, RNG paletteRng, RNG posRng) {
|
||||
if (TreeTrunkBuilder.paletteSet(tree.getSecondaryLeavesPalette())) {
|
||||
return tree.getSecondaryLeavesPalette().get(paletteRng, pos.x(), pos.y(), pos.z(), data);
|
||||
private static PlatformBlockState resolveSecondaryLeaf(Tree tree, IrisData data, TreeBlockCanvas.Vec pos, RNG paletteRng, RNG posRng) {
|
||||
PaletteSpec secondaryPalette = tree.secondaryLeavesPalette().orElse(null);
|
||||
if (IrisProceduralBlocks.paletteSet(secondaryPalette)) {
|
||||
return IrisProceduralBlocks.pick(secondaryPalette, data, paletteRng.getSeed(), pos.x(), pos.y(), pos.z());
|
||||
}
|
||||
if (tree.getWeightedSecondaryLeaves() != null && !tree.getWeightedSecondaryLeaves().isEmpty()) {
|
||||
if (tree.weightedSecondaryLeaves() != null && !tree.weightedSecondaryLeaves().isEmpty()) {
|
||||
String picked = pickWeighted(tree, posRng);
|
||||
return picked == null ? null : B.getStateOrNull(picked, false);
|
||||
}
|
||||
if (tree.getSecondaryLeaves() != null && !tree.getSecondaryLeaves().isEmpty()) {
|
||||
return B.getStateOrNull(tree.getSecondaryLeaves(), false);
|
||||
if (tree.secondaryLeaves().isPresent() && !tree.secondaryLeaves().get().isEmpty()) {
|
||||
return B.getStateOrNull(tree.secondaryLeaves().get(), false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String pickWeighted(IrisProceduralTree tree, RNG rng) {
|
||||
private static String pickWeighted(Tree tree, RNG rng) {
|
||||
int total = 0;
|
||||
for (art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
|
||||
for (art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf s : tree.weightedSecondaryLeaves()) {
|
||||
total += Math.max(0, s.weight());
|
||||
}
|
||||
if (total <= 0) {
|
||||
@@ -120,29 +120,19 @@ public final class TreeBlockResolver {
|
||||
}
|
||||
double r = rng.nextDouble() * total;
|
||||
double cumulative = 0;
|
||||
for (art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
|
||||
for (art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf s : tree.weightedSecondaryLeaves()) {
|
||||
cumulative += Math.max(0, s.weight());
|
||||
if (r < cumulative) {
|
||||
return s.block();
|
||||
}
|
||||
}
|
||||
return tree.getWeightedSecondaryLeaves().get(tree.getWeightedSecondaryLeaves().size() - 1).block();
|
||||
return tree.weightedSecondaryLeaves().get(tree.weightedSecondaryLeaves().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) {
|
||||
if (TreeTrunkBuilder.paletteSet(palette)) {
|
||||
return palette.get(paletteRng, pos.x(), pos.y(), pos.z(), data);
|
||||
}
|
||||
if (block != null && !block.isEmpty()) {
|
||||
return B.getStateOrNull(block, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static PlatformBlockState woodCap(PlatformBlockState state) {
|
||||
String key = state.key();
|
||||
int bracket = key.indexOf('[');
|
||||
|
||||
+22
-21
@@ -24,7 +24,8 @@ 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.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
@@ -34,15 +35,15 @@ public final class TreeCanopyBuilder {
|
||||
private TreeCanopyBuilder() {
|
||||
}
|
||||
|
||||
public static void build(TreeBlockCanvas canvas, IrisProceduralTree tree, int height, double[][] offsets,
|
||||
public static void build(TreeBlockCanvas canvas, Tree tree, int height, double[][] offsets,
|
||||
int branchStartY, long baseSeed, List<int[]> branchEndpoints) {
|
||||
TreeCanopy canopy = tree.getCanopy();
|
||||
TreeCanopy canopy = tree.canopy();
|
||||
if (canopy == null) {
|
||||
canopy = new TreeCanopy();
|
||||
}
|
||||
TreeBranches branches = canopy.branches().orElse(null);
|
||||
|
||||
double[][] layers = resolveLayers(canopy, tree.getProfile(), height, branches != null);
|
||||
double[][] layers = resolveLayers(canopy, tree.profile(), height, branches != null);
|
||||
|
||||
if (branches != null) {
|
||||
if (layers.length > 0) {
|
||||
@@ -56,7 +57,7 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void placeApexCap(TreeBlockCanvas canvas, IrisProceduralTree tree, int height, double[][] layers,
|
||||
private static void placeApexCap(TreeBlockCanvas canvas, Tree tree, int height, double[][] layers,
|
||||
double[][] offsets, long baseSeed) {
|
||||
int ocx = 0;
|
||||
int ocz = 0;
|
||||
@@ -69,7 +70,7 @@ public final class TreeCanopyBuilder {
|
||||
maxR = Math.max(maxR, layer[1]);
|
||||
}
|
||||
int capRadius = Math.max(2, Math.min(3, (int) Math.round(maxR * 0.35)));
|
||||
TreeCanopy canopy = tree.getCanopy();
|
||||
TreeCanopy canopy = tree.canopy();
|
||||
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);
|
||||
@@ -88,7 +89,7 @@ public final class TreeCanopyBuilder {
|
||||
return TreeProfiles.presetLayers(profile, height, branchDriven);
|
||||
}
|
||||
|
||||
private static void volumeCanopy(TreeBlockCanvas canvas, IrisProceduralTree tree, double[][] layers,
|
||||
private static void volumeCanopy(TreeBlockCanvas canvas, Tree tree, double[][] layers,
|
||||
TreeCanopy canopy, long baseSeed, double[][] offsets) {
|
||||
int ocx = 0;
|
||||
int ocz = 0;
|
||||
@@ -136,7 +137,7 @@ public final class TreeCanopyBuilder {
|
||||
return (int) Math.ceil(radius * squish);
|
||||
}
|
||||
|
||||
private static void placeLeafDisc(TreeBlockCanvas canvas, IrisProceduralTree tree, int cx, int cy, int cz,
|
||||
private static void placeLeafDisc(TreeBlockCanvas canvas, Tree tree, int cx, int cy, int cz,
|
||||
double radius, TreeLeafMode mode, double density, long seed) {
|
||||
double sx = stretchX(tree);
|
||||
double sz = stretchZ(tree);
|
||||
@@ -157,7 +158,7 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void placeLeafCluster(TreeBlockCanvas canvas, IrisProceduralTree tree, int cx, int cy, int cz,
|
||||
private static void placeLeafCluster(TreeBlockCanvas canvas, Tree tree, int cx, int cy, int cz,
|
||||
int radius, TreeLeafMode mode, double density, long seed) {
|
||||
double sx = stretchX(tree);
|
||||
double sz = stretchZ(tree);
|
||||
@@ -180,13 +181,13 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static double stretchX(IrisProceduralTree tree) {
|
||||
TreeCanopy c = tree.getCanopy();
|
||||
private static double stretchX(Tree tree) {
|
||||
TreeCanopy c = tree.canopy();
|
||||
return c == null ? 1.0 : Math.max(0.1, c.crownStretchX());
|
||||
}
|
||||
|
||||
private static double stretchZ(IrisProceduralTree tree) {
|
||||
TreeCanopy c = tree.getCanopy();
|
||||
private static double stretchZ(Tree tree) {
|
||||
TreeCanopy c = tree.canopy();
|
||||
return c == null ? 1.0 : Math.max(0.1, c.crownStretchZ());
|
||||
}
|
||||
|
||||
@@ -244,20 +245,20 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static TreeBlockCanvas.Role resolveLeaf(IrisProceduralTree tree, RNG rng) {
|
||||
boolean hasSecondary = TreeTrunkBuilder.paletteSet(tree.getSecondaryLeavesPalette())
|
||||
|| (tree.getWeightedSecondaryLeaves() != null && !tree.getWeightedSecondaryLeaves().isEmpty())
|
||||
|| (tree.getSecondaryLeaves() != null && !tree.getSecondaryLeaves().isEmpty());
|
||||
if (!hasSecondary || tree.getSecondaryLeafFraction() <= 0.0) {
|
||||
private static TreeBlockCanvas.Role resolveLeaf(Tree tree, RNG rng) {
|
||||
boolean hasSecondary = IrisProceduralBlocks.paletteSet(tree.secondaryLeavesPalette())
|
||||
|| (tree.weightedSecondaryLeaves() != null && !tree.weightedSecondaryLeaves().isEmpty())
|
||||
|| tree.secondaryLeaves().filter(leaves -> !leaves.isEmpty()).isPresent();
|
||||
if (!hasSecondary || tree.secondaryLeafFraction() <= 0.0) {
|
||||
return TreeBlockCanvas.Role.LEAF;
|
||||
}
|
||||
if (rng.nextDouble() >= tree.getSecondaryLeafFraction()) {
|
||||
if (rng.nextDouble() >= tree.secondaryLeafFraction()) {
|
||||
return TreeBlockCanvas.Role.LEAF;
|
||||
}
|
||||
return TreeBlockCanvas.Role.SECONDARY_LEAF;
|
||||
}
|
||||
|
||||
private static void branchCanopy(TreeBlockCanvas canvas, IrisProceduralTree tree, int height,
|
||||
private static void branchCanopy(TreeBlockCanvas canvas, Tree tree, int height,
|
||||
TreeBranches branches, int branchStartY, long baseSeed, double[][] offsets,
|
||||
List<int[]> branchEndpoints) {
|
||||
long branchSeed = baseSeed + 9999;
|
||||
@@ -297,7 +298,7 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void growSubBranches(TreeBlockCanvas canvas, IrisProceduralTree tree, int ox, int oy, int oz,
|
||||
private static void growSubBranches(TreeBlockCanvas canvas, Tree tree, int ox, int oy, int oz,
|
||||
double az, double el, double len, TreeSubBranches sub, int depth, long seed) {
|
||||
if (sub == null || depth <= 0) {
|
||||
return;
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@
|
||||
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.builtin.objects.tree.Tree;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -31,8 +31,8 @@ public final class TreeDecoratorApplier {
|
||||
private TreeDecoratorApplier() {
|
||||
}
|
||||
|
||||
public static void apply(TreeBlockCanvas canvas, IrisProceduralTree tree, long baseSeed, List<int[]> branchEndpoints) {
|
||||
KList<TreeDecorator> decorators = tree.getDecorators();
|
||||
public static void apply(TreeBlockCanvas canvas, Tree tree, long baseSeed, List<int[]> branchEndpoints) {
|
||||
List<TreeDecorator> decorators = tree.decorators();
|
||||
if (decorators == null || decorators.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ 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.builtin.objects.tree.Tree;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
public final class TreeFunctions {
|
||||
@@ -30,27 +30,27 @@ public final class TreeFunctions {
|
||||
private TreeFunctions() {
|
||||
}
|
||||
|
||||
public static double trunkWidthMultiplier(IrisProceduralTree tree, double t) {
|
||||
double start = tree.getShapeStart();
|
||||
double end = tree.getShapeEnd();
|
||||
return switch (tree.getTrunkShape()) {
|
||||
public static double trunkWidthMultiplier(Tree tree, double t) {
|
||||
double start = tree.shapeStart();
|
||||
double end = tree.shapeEnd();
|
||||
return switch (tree.trunkShape()) {
|
||||
case CONSTANT -> 1.0;
|
||||
case LINEAR -> start + (end - start) * t;
|
||||
case SIGMOID -> 1.0 / (1.0 + Math.exp(tree.getShapeSteepness() * (t - 0.5)));
|
||||
case SIGMOID -> 1.0 / (1.0 + Math.exp(tree.shapeSteepness() * (t - 0.5)));
|
||||
case LOG -> {
|
||||
double base = Math.max(1.0001, tree.getShapeBase());
|
||||
double base = Math.max(1.0001, tree.shapeBase());
|
||||
if (t <= 0.0) {
|
||||
yield 1.0;
|
||||
}
|
||||
yield Math.max(0.0, 1.0 - Math.log(1.0 + t * (base - 1.0)) / Math.log(base));
|
||||
}
|
||||
case SINE -> {
|
||||
double period = tree.getShapePeriod() == 0 ? 1.0 : tree.getShapePeriod();
|
||||
yield 1.0 + tree.getShapeAmplitude() * Math.sin(2.0 * Math.PI * t / period);
|
||||
double period = tree.shapePeriod() == 0 ? 1.0 : tree.shapePeriod();
|
||||
yield 1.0 + tree.shapeAmplitude() * Math.sin(2.0 * Math.PI * t / period);
|
||||
}
|
||||
case PARABOLIC -> {
|
||||
double peak = tree.getShapePeakOffset();
|
||||
double floor = tree.getShapeFloor();
|
||||
double peak = tree.shapePeakOffset();
|
||||
double floor = tree.shapeFloor();
|
||||
double denom = Math.pow(Math.max(peak, 1.0 - peak), 2);
|
||||
if (denom == 0) {
|
||||
denom = 1;
|
||||
@@ -59,7 +59,7 @@ public final class TreeFunctions {
|
||||
}
|
||||
case EXPONENTIAL -> geometric(start, end, t);
|
||||
case SQRT -> start + (end - start) * Math.sqrt(t);
|
||||
case STEP -> t < tree.getShapePeakOffset() ? start : end;
|
||||
case STEP -> t < tree.shapePeakOffset() ? start : end;
|
||||
case BELL -> start + (end - start) * bell(t);
|
||||
case EASE_IN_OUT -> start + (end - start) * smoothstep(t);
|
||||
};
|
||||
@@ -114,24 +114,24 @@ public final class TreeFunctions {
|
||||
};
|
||||
}
|
||||
|
||||
public static double azimuthDegrees(TreeAzimuthMode mode, double t, int index, IrisProceduralTree tree, double constantBase, RNG rng) {
|
||||
public static double azimuthDegrees(TreeAzimuthMode mode, double t, int index, Tree tree, double constantBase, RNG rng) {
|
||||
return switch (mode) {
|
||||
case CONSTANT -> constantBase;
|
||||
case LINEAR -> tree.getAzimuthStart() + (tree.getAzimuthEnd() - tree.getAzimuthStart()) * t;
|
||||
case SPIRAL -> tree.getAzimuthStart() + tree.getAzimuthTurns() * 360.0 * t;
|
||||
case LINEAR -> tree.azimuthStart() + (tree.azimuthEnd() - tree.azimuthStart()) * t;
|
||||
case SPIRAL -> tree.azimuthStart() + tree.azimuthTurns() * 360.0 * t;
|
||||
case SINE -> {
|
||||
double period = tree.getAzimuthPeriod() == 0 ? 1.0 : tree.getAzimuthPeriod();
|
||||
yield tree.getAzimuthOffset() + tree.getAzimuthAmplitude() * Math.sin(2.0 * Math.PI * t / period);
|
||||
double period = tree.azimuthPeriod() == 0 ? 1.0 : tree.azimuthPeriod();
|
||||
yield tree.azimuthOffset() + tree.azimuthAmplitude() * Math.sin(2.0 * Math.PI * t / period);
|
||||
}
|
||||
case NOISE -> noiseAzimuth(t, tree.getAzimuthScale(), tree.getSeed());
|
||||
case NOISE -> noiseAzimuth(t, tree.azimuthScale(), tree.seed());
|
||||
case RANDOM -> rng != null ? rng.d(0.0, 360.0) : constantBase;
|
||||
case GOLDEN_ANGLE -> index >= 0 ? constantBase + index * GOLDEN_ANGLE : constantBase;
|
||||
case ALTERNATING -> index >= 0 ? constantBase + (index % 2) * 180.0 : constantBase;
|
||||
case WHORL -> {
|
||||
int count = Math.max(1, tree.getAzimuthWhorlCount());
|
||||
int count = Math.max(1, tree.azimuthWhorlCount());
|
||||
yield index >= 0 ? constantBase + (index % count) * (360.0 / count) : constantBase;
|
||||
}
|
||||
case ZIGZAG -> index >= 0 ? constantBase + ((index % 2 == 0) ? -tree.getAzimuthAmplitude() : tree.getAzimuthAmplitude()) : constantBase;
|
||||
case ZIGZAG -> index >= 0 ? constantBase + ((index % 2 == 0) ? -tree.azimuthAmplitude() : tree.azimuthAmplitude()) : constantBase;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
@@ -38,7 +38,7 @@ public final class TreePlausibility {
|
||||
}
|
||||
|
||||
public static void apply(Map<TreeBlockCanvas.Vec, PlatformBlockState> resolved, Set<TreeBlockCanvas.Vec> trunkPositions,
|
||||
Set<TreeBlockCanvas.Vec> leafPositions, IrisProceduralTree tree) {
|
||||
Set<TreeBlockCanvas.Vec> leafPositions, Tree tree) {
|
||||
Set<TreeBlockCanvas.Vec> realLeaves = new HashSet<>();
|
||||
for (TreeBlockCanvas.Vec v : leafPositions) {
|
||||
PlatformBlockState state = resolved.get(v);
|
||||
@@ -55,7 +55,7 @@ public final class TreePlausibility {
|
||||
for (TreeBlockCanvas.Vec v : realLeaves) {
|
||||
PlatformBlockState leaf = resolved.get(v);
|
||||
Integer d = distance.get(v);
|
||||
if (!tree.isPlausible()) {
|
||||
if (!tree.plausible()) {
|
||||
leaf = leaf.withProperty("persistent", "true").withProperty("distance", "1");
|
||||
} else if (d != null && d < MAX_DISTANCE) {
|
||||
leaf = leaf.withProperty("persistent", "false").withProperty("distance", String.valueOf(Math.max(1, d)));
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
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.builtin.objects.tree.Tree;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -29,7 +29,7 @@ public final class TreeRootBuilder {
|
||||
private TreeRootBuilder() {
|
||||
}
|
||||
|
||||
public static void build(TreeBlockCanvas canvas, IrisProceduralTree tree, int height, long baseSeed) {
|
||||
public static void build(TreeBlockCanvas canvas, Tree tree, int height, long baseSeed) {
|
||||
List<int[]> cells = new ArrayList<>();
|
||||
for (TreeBlockCanvas.Vec v : canvas.getTrunk()) {
|
||||
if (v.y() == 0) {
|
||||
@@ -40,7 +40,7 @@ public final class TreeRootBuilder {
|
||||
return;
|
||||
}
|
||||
|
||||
int depth = tree.getRootDepth() > 0 ? tree.getRootDepth() : autoDepth(height);
|
||||
int depth = tree.rootDepth() > 0 ? tree.rootDepth() : autoDepth(height);
|
||||
RNG rng = new RNG(baseSeed ^ 0x5009L);
|
||||
|
||||
double cx = 0;
|
||||
@@ -56,9 +56,9 @@ public final class TreeRootBuilder {
|
||||
for (int[] c : cells) {
|
||||
baseRadius = Math.max(baseRadius, Math.hypot(c[0] - cx, c[1] - cz) + 0.5);
|
||||
}
|
||||
double flare = tree.getRootFlare() > 0 ? tree.getRootFlare() : baseRadius + Math.max(2.0, depth * 0.6);
|
||||
double flare = tree.rootFlare() > 0 ? tree.rootFlare() : baseRadius + Math.max(2.0, depth * 0.6);
|
||||
|
||||
TreeRootStyle style = tree.getRootStyle();
|
||||
TreeRootStyle style = tree.rootStyle();
|
||||
switch (style) {
|
||||
case TAPROOT -> taproot(canvas, cells, cx, cz, baseRadius, depth);
|
||||
case BUTTRESS -> {
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
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.IrisProceduralBlocks;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -32,10 +32,10 @@ public final class TreeTrunkBuilder {
|
||||
private TreeTrunkBuilder() {
|
||||
}
|
||||
|
||||
public static List<Limb> build(TreeBlockCanvas canvas, IrisProceduralTree tree, int height) {
|
||||
public static List<Limb> build(TreeBlockCanvas canvas, Tree tree, int height) {
|
||||
boolean hasSecondary = hasSecondaryTrunk(tree);
|
||||
double[][] mainOffsets = leanPath(tree, height);
|
||||
int forks = Math.max(1, tree.getTrunkForks());
|
||||
int forks = Math.max(1, tree.trunkForks());
|
||||
|
||||
List<Limb> limbs = new ArrayList<>();
|
||||
if (forks == 1) {
|
||||
@@ -45,12 +45,12 @@ public final class TreeTrunkBuilder {
|
||||
return limbs;
|
||||
}
|
||||
|
||||
int forkY = Math.max(1, Math.min(height - 2, (int) Math.round(tree.getForkHeight() * (height - 1))));
|
||||
int forkY = Math.max(1, Math.min(height - 2, (int) Math.round(tree.forkHeight() * (height - 1))));
|
||||
placeColumn(canvas, tree, mainOffsets, height, 0, forkY, hasSecondary);
|
||||
|
||||
double baseCx = mainOffsets[forkY][0];
|
||||
double baseCz = mainOffsets[forkY][1];
|
||||
double reachMax = (height - forkY) * Math.tan(Math.toRadians(tree.getForkAngle()));
|
||||
double reachMax = (height - forkY) * Math.tan(Math.toRadians(tree.forkAngle()));
|
||||
|
||||
for (int f = 0; f < forks; f++) {
|
||||
double az = Math.toRadians((360.0 / forks) * f);
|
||||
@@ -73,7 +73,7 @@ public final class TreeTrunkBuilder {
|
||||
return limbs;
|
||||
}
|
||||
|
||||
private static double[][] leanPath(IrisProceduralTree tree, int height) {
|
||||
private static double[][] leanPath(Tree tree, int height) {
|
||||
double[][] offsets = new double[height][2];
|
||||
for (int y = 0; y < height; y++) {
|
||||
double[] lean = leanOffset(tree, y, height);
|
||||
@@ -83,7 +83,7 @@ public final class TreeTrunkBuilder {
|
||||
return offsets;
|
||||
}
|
||||
|
||||
private static void placeColumn(TreeBlockCanvas canvas, IrisProceduralTree tree, double[][] offsets, int height,
|
||||
private static void placeColumn(TreeBlockCanvas canvas, Tree tree, double[][] offsets, int height,
|
||||
int yStart, int yEnd, boolean hasSecondary) {
|
||||
double prevCx = yStart > 0 ? offsets[yStart - 1][0] : 0.0;
|
||||
double prevCz = yStart > 0 ? offsets[yStart - 1][1] : 0.0;
|
||||
@@ -128,45 +128,41 @@ public final class TreeTrunkBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static int widthAt(IrisProceduralTree tree, int y, int height) {
|
||||
private static int widthAt(Tree tree, int y, int height) {
|
||||
double t = y / (double) Math.max(height - 1, 1);
|
||||
double multiplier = TreeFunctions.trunkWidthMultiplier(tree, t);
|
||||
return Math.max(1, (int) Math.round(tree.getTrunkWidth() * multiplier));
|
||||
return Math.max(1, (int) Math.round(tree.trunkWidth() * multiplier));
|
||||
}
|
||||
|
||||
private static TreeBlockCanvas.Role trunkRole(IrisProceduralTree tree, boolean hasSecondary, int y, int height) {
|
||||
private static TreeBlockCanvas.Role trunkRole(Tree tree, boolean hasSecondary, int y, int height) {
|
||||
if (!hasSecondary) {
|
||||
return TreeBlockCanvas.Role.TRUNK;
|
||||
}
|
||||
double t = y / (double) Math.max(height - 1, 1);
|
||||
if (tree.getSecondaryTrunkStart() <= t && t <= tree.getSecondaryTrunkEnd()) {
|
||||
if (tree.secondaryTrunkStart() <= t && t <= tree.secondaryTrunkEnd()) {
|
||||
return TreeBlockCanvas.Role.SECONDARY_TRUNK;
|
||||
}
|
||||
return TreeBlockCanvas.Role.TRUNK;
|
||||
}
|
||||
|
||||
private static boolean hasSecondaryTrunk(IrisProceduralTree tree) {
|
||||
if (paletteSet(tree.getSecondaryTrunkPalette())) {
|
||||
private static boolean hasSecondaryTrunk(Tree tree) {
|
||||
if (IrisProceduralBlocks.paletteSet(tree.secondaryTrunkPalette())) {
|
||||
return true;
|
||||
}
|
||||
return tree.getSecondaryTrunk() != null && !tree.getSecondaryTrunk().isEmpty();
|
||||
return tree.secondaryTrunk().filter(trunk -> !trunk.isEmpty()).isPresent();
|
||||
}
|
||||
|
||||
static boolean paletteSet(IrisMaterialPalette palette) {
|
||||
return palette != null && palette.getPalette() != null && !palette.getPalette().isEmpty();
|
||||
}
|
||||
|
||||
private static double[] leanOffset(IrisProceduralTree tree, int y, int height) {
|
||||
if (tree.getLeanAngle() == 0.0 || height <= 1) {
|
||||
private static double[] leanOffset(Tree tree, int y, int height) {
|
||||
if (tree.leanAngle() == 0.0 || height <= 1) {
|
||||
return new double[]{0.0, 0.0};
|
||||
}
|
||||
double t = y / (double) Math.max(height - 1, 1);
|
||||
double progress = TreeFunctions.curveProgress(tree.getTrunkCurve(), t, tree.getCurveSteepness());
|
||||
double maxReach = height * Math.tan(Math.toRadians(tree.getLeanAngle()));
|
||||
double progress = TreeFunctions.curveProgress(tree.trunkCurve(), t, tree.curveSteepness());
|
||||
double maxReach = height * Math.tan(Math.toRadians(tree.leanAngle()));
|
||||
double reach = maxReach * progress;
|
||||
double azDeg = tree.getLeanAzimuthMode() == TreeAzimuthMode.CONSTANT
|
||||
? tree.getLeanAzimuth()
|
||||
: TreeFunctions.azimuthDegrees(tree.getLeanAzimuthMode(), t, -1, tree, tree.getLeanAzimuth(), null);
|
||||
double azDeg = tree.leanAzimuthMode() == TreeAzimuthMode.CONSTANT
|
||||
? tree.leanAzimuth()
|
||||
: TreeFunctions.azimuthDegrees(tree.leanAzimuthMode(), t, -1, tree, tree.leanAzimuth(), null);
|
||||
double azRad = Math.toRadians(azDeg);
|
||||
double dx = reach * Math.sin(azRad);
|
||||
double dz = reach * Math.cos(azRad);
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.terrain.floating;
|
||||
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlacements;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
@@ -171,7 +172,7 @@ public final class ResolvedFloatingChild implements IRare {
|
||||
}
|
||||
|
||||
public KList<IrisObjectPlacement> resolveTopObjects(IrisBiome target) {
|
||||
KList<IrisObjectPlacement> surfaceObjects = (settings.inheritObjects() && target != null) ? target.getSurfaceObjects() : new KList<>();
|
||||
KList<IrisObjectPlacement> surfaceObjects = (settings.inheritObjects() && target != null) ? ObjectPlacements.surface(target) : new KList<>();
|
||||
return resolveTopObjectsFromSurface(surfaceObjects);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@ package art.arcane.iris.engine.object.world.biome;
|
||||
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.value.IRare;
|
||||
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
|
||||
@@ -80,8 +78,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
private final transient AtomicCache<KMap<String, IrisBiomeGeneratorLink>> genCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<KMap<String, Integer>> genCacheMax = new AtomicCache<>();
|
||||
private final transient AtomicCache<KMap<String, Integer>> genCacheMin = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisObjectPlacement>> surfaceObjectsCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisObjectPlacement>> carveObjectsCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<Color> cacheColor = new AtomicCache<>();
|
||||
private final transient AtomicCache<Color> cacheColorObjectDensity = new AtomicCache<>();
|
||||
private final transient AtomicCache<Color> cacheColorDecoratorLoad = new AtomicCache<>();
|
||||
@@ -141,11 +137,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("List any biome names (file names without.json) here as children. Portions of this biome can sometimes morph into their children. Iris supports cyclic relationships such as A > B > A > B. Iris will stop checking 4 biomes down the tree.")
|
||||
private KList<String> children = new KList<>();
|
||||
@ArrayType(min = 1, type = IrisObjectPlacement.class)
|
||||
@Desc("Objects define what schematics (iob files) iris will place in this biome")
|
||||
private KList<IrisObjectPlacement> objects = new KList<>();
|
||||
@Desc("Procedural objects (such as trees) iris generates from scratch and places in this biome, instead of loading them from iob files")
|
||||
private IrisProceduralObjects proceduralObjects = new IrisProceduralObjects();
|
||||
@ArrayType(min = 1, type = IrisStructurePlacement.class)
|
||||
@Desc("Structures define jigsaw or vanilla/datapack structures iris will place in this biome")
|
||||
private KList<IrisStructurePlacement> structures = new KList<>();
|
||||
@@ -264,36 +255,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
return IrisBiomeGenLinks.getGenLink(this, loadKey);
|
||||
}
|
||||
|
||||
public KList<IrisObjectPlacement> getSurfaceObjects() {
|
||||
return getSurfaceObjectsCache().aquire(() ->
|
||||
{
|
||||
KList<IrisObjectPlacement> o = getObjects().copy();
|
||||
|
||||
for (IrisObjectPlacement i : o.copy()) {
|
||||
if (!i.getCarvingSupport().supportsSurface()) {
|
||||
o.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
});
|
||||
}
|
||||
|
||||
public KList<IrisObjectPlacement> getCarvingObjects() {
|
||||
return getCarveObjectsCache().aquire(() ->
|
||||
{
|
||||
KList<IrisObjectPlacement> o = getObjects().copy();
|
||||
|
||||
for (IrisObjectPlacement i : o.copy()) {
|
||||
if (!i.getCarvingSupport().supportsCarving()) {
|
||||
o.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
});
|
||||
}
|
||||
|
||||
public double getHeight(Engine xg, double x, double z, long seed) {
|
||||
double height = 0;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.world.biome;
|
||||
|
||||
import art.arcane.iris.engine.object.placement.ObjectPlacements;
|
||||
import art.arcane.iris.engine.decorator.BiomeDecorators;
|
||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
@@ -68,7 +69,7 @@ final class IrisBiomeColorRenderer {
|
||||
return biome.getCacheColorObjectDensity().aquire(() -> {
|
||||
double density = 0;
|
||||
|
||||
for (IrisObjectPlacement i : biome.getObjects()) {
|
||||
for (IrisObjectPlacement i : ObjectPlacements.all(biome)) {
|
||||
density += i.getDensity() * i.getChance();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import art.arcane.iris.engine.object.image.IrisImageMapBinding;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.IrisShapedGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeSettings;
|
||||
import art.arcane.iris.engine.object.runtime.StudioMode;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
@@ -123,8 +122,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@MaxNumber(16)
|
||||
@Desc("Every X/Z % debugCrossSectionsMod == 0 cuts the chunk")
|
||||
private int debugCrossSectionsMod = 3;
|
||||
@Desc("Tree growth override settings")
|
||||
private IrisTreeSettings treeSettings = new IrisTreeSettings();
|
||||
@MinNumber(0)
|
||||
@Desc("The version of this dimension. Changing this will stop users from accidentally upgrading (and breaking their worlds).")
|
||||
private int version = 1;
|
||||
@@ -150,12 +147,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private boolean debugSmartBore = false;
|
||||
@Desc("Generate decorations or not")
|
||||
private boolean decorate = true;
|
||||
@Desc("Refuse to place surface objects and trees over carved surface openings.")
|
||||
private boolean requireObjectSurfaceSupport = true;
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@Desc("Minimum surface-support buffer, in blocks, applied to every surface object placement in this dimension. A placement may ask for more but never less.")
|
||||
private int objectSurfaceSupportBuffer = 2;
|
||||
@Desc("The world environment")
|
||||
private IrisEnvironment environment = IrisEnvironment.NORMAL;
|
||||
@RegistryListResource(IrisRegion.class)
|
||||
@@ -188,10 +179,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private int upperDimensionGap = 32;
|
||||
@Desc("When true, cave carving will cut through the upper dimension terrain. When false, the upper terrain is a solid untouched mass.")
|
||||
private boolean upperDimensionCarving = false;
|
||||
@Desc("When true, objects from the mantle (structures, trees, etc.) can be placed in the upper dimension terrain zone. When false, the upper terrain is protected from object placement.")
|
||||
private boolean upperDimensionObjects = false;
|
||||
@Desc("When true, upper-dimension objects force-place regardless of placement restrictions (slope, underwater, clamp, collisions, carving). Normal dimension objects always place first; upper objects place second and may clip or occlude lower-dimension placements when this is enabled.")
|
||||
private boolean upperObjectsForcePlace = false;
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Keep this either undefined or empty. Setting any biome name into this will force iris to only generate the specified biome. Great for testing.")
|
||||
private String focus = "";
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.object.world.region;
|
||||
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||
import art.arcane.iris.engine.object.value.IRare;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
@@ -58,8 +56,6 @@ import java.util.Random;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
private final transient AtomicCache<KList<IrisObjectPlacement>> surfaceObjectsCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisObjectPlacement>> carveObjectsCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<String>> cacheRidge = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<String>> cacheSpot = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> shoreHeightGenerator = new AtomicCache<>();
|
||||
@@ -76,11 +72,6 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
@MaxNumber(128)
|
||||
@Desc("The rarity of the region")
|
||||
private int rarity = 1;
|
||||
@ArrayType(min = 1, type = IrisObjectPlacement.class)
|
||||
@Desc("Objects define what schematics (iob files) iris will place in this region")
|
||||
private KList<IrisObjectPlacement> objects = new KList<>();
|
||||
@Desc("Procedural objects (trees, ruins, formations, coral, fungi, crystals) iris generates from scratch and places across this region")
|
||||
private IrisProceduralObjects proceduralObjects = new IrisProceduralObjects();
|
||||
@ArrayType(min = 1, type = IrisStructurePlacement.class)
|
||||
@Desc("Structures define jigsaw or vanilla/datapack structures iris will place in this region")
|
||||
private KList<IrisStructurePlacement> structures = new KList<>();
|
||||
@@ -129,36 +120,6 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
return name;
|
||||
}
|
||||
|
||||
public KList<IrisObjectPlacement> getSurfaceObjects() {
|
||||
return getSurfaceObjectsCache().aquire(() ->
|
||||
{
|
||||
KList<IrisObjectPlacement> o = getObjects().copy();
|
||||
|
||||
for (IrisObjectPlacement i : o.copy()) {
|
||||
if (!i.getCarvingSupport().supportsSurface()) {
|
||||
o.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
});
|
||||
}
|
||||
|
||||
public KList<IrisObjectPlacement> getCarvingObjects() {
|
||||
return getCarveObjectsCache().aquire(() ->
|
||||
{
|
||||
KList<IrisObjectPlacement> o = getObjects().copy();
|
||||
|
||||
for (IrisObjectPlacement i : o.copy()) {
|
||||
if (!i.getCarvingSupport().supportsCarving()) {
|
||||
o.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
});
|
||||
}
|
||||
|
||||
public CNG getShoreHeightGenerator() {
|
||||
return shoreHeightGenerator.aquire(() ->
|
||||
CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612))));
|
||||
|
||||
Reference in new issue
Block a user