mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Procedural object settings as module-owned IrisApi types: coral, crystal, formation, fungus, ruin and the tree profile classes; ResolvedProceduralPlacement bakes and places them
This commit is contained in:
1 parent
feaa1e88c4
commit
1f3e1c9aba
62 files changed
+2309
-1003
No files matched your search
+173
-78
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,44 +16,29 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
package art.arcane.iris.builtin.objects.coral;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.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.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.engine.object.procedural.coral.CoralGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Snippet("coral")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated coral reef structure. Iris bakes a pool of deterministic variants from these settings and scatters them across the seafloor at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Mirrors the procedural tree system but tuned for underwater reefs: structural blocks are waterlogged so the coral stays alive, and placement defaults to anchoring on the terrain beneath the water surface.")
|
||||
@Data
|
||||
public class IrisCoral implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
public final class Coral {
|
||||
@Desc("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "coral";
|
||||
|
||||
@@ -78,7 +63,7 @@ public class IrisCoral implements IrisProceduralPlacement {
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Desc("Rotate this coral's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
private ObjectRotation rotation = new ObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min height of placement.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
@@ -90,7 +75,7 @@ public class IrisCoral implements IrisProceduralPlacement {
|
||||
private boolean underwater = true;
|
||||
|
||||
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the seafloor.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
private ObjectTranslate translate = new ObjectTranslate();
|
||||
|
||||
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private StiltSettings stiltSettings;
|
||||
@@ -102,22 +87,22 @@ public class IrisCoral implements IrisProceduralPlacement {
|
||||
private boolean waterlogged = true;
|
||||
|
||||
@Desc("The overall silhouette this coral grows into (branching, fan, brain, pillar, tendril). Each form runs a different generation routine.")
|
||||
private IrisCoralForm form = IrisCoralForm.BRANCHING;
|
||||
private CoralForm form = CoralForm.BRANCHING;
|
||||
|
||||
@Required
|
||||
@Desc("The structural coral block (the living wood of the reef), e.g. minecraft:tube_coral_block. Ignored when blockPalette is set.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String block = "minecraft:tube_coral_block";
|
||||
|
||||
@Desc("A noise-driven palette for the structural coral block. When set this overrides the single block, letting the reef mix tube/brain/bubble/fire/horn coral_block tones across its body.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
private PaletteSpec blockPalette;
|
||||
|
||||
@Desc("Optional tip block placed at branch tips and at the very top of the structure, e.g. coral fans or minecraft:sea_pickle. Ignored when tipPalette is set. Null disables tips.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String tipBlock = null;
|
||||
|
||||
@Desc("A noise-driven palette for the tip block. When set this overrides the single tipBlock, letting tips mix fan / pickle decorations.")
|
||||
private IrisMaterialPalette tipPalette = null;
|
||||
private PaletteSpec tipPalette;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@@ -156,7 +141,7 @@ public class IrisCoral implements IrisProceduralPlacement {
|
||||
private double branchElevation = 55;
|
||||
|
||||
@Desc("BRANCHING only: how the arms are distributed around the stalk by azimuth.")
|
||||
private IrisCoralBranchAzimuth branchAzimuth = IrisCoralBranchAzimuth.GOLDEN_ANGLE;
|
||||
private CoralBranchAzimuth branchAzimuth = CoralBranchAzimuth.GOLDEN_ANGLE;
|
||||
|
||||
@Desc("BRANCHING only: if true, each arm splits once into a small fan of sub-arms for a bushier reef.")
|
||||
private boolean subBranches = true;
|
||||
@@ -201,49 +186,159 @@ public class IrisCoral implements IrisProceduralPlacement {
|
||||
@Desc("TENDRIL only: how many thin wavy stalks rise from the base.")
|
||||
private int tendrilCount = 4;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = CoralGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
public Coral() {
|
||||
}
|
||||
|
||||
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 name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
public int density() {
|
||||
return density;
|
||||
}
|
||||
|
||||
public int variants() {
|
||||
return variants;
|
||||
}
|
||||
|
||||
public long seed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
public ObjectPlaceMode mode() {
|
||||
return mode == null ? ObjectPlaceMode.CENTER_HEIGHT : mode;
|
||||
}
|
||||
|
||||
public ObjectRotation rotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public ObjectLimit clamp() {
|
||||
return clamp;
|
||||
}
|
||||
|
||||
public CarvingMode carvingSupport() {
|
||||
return carvingSupport == null ? CarvingMode.SURFACE_ONLY : carvingSupport;
|
||||
}
|
||||
|
||||
public boolean underwater() {
|
||||
return underwater;
|
||||
}
|
||||
|
||||
public ObjectTranslate translate() {
|
||||
return translate;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<StiltSettings> stiltSettings() {
|
||||
return Optional.ofNullable(stiltSettings);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<VacuumSettings> vacuumSettings() {
|
||||
return Optional.ofNullable(vacuumSettings);
|
||||
}
|
||||
|
||||
public boolean waterlogged() {
|
||||
return waterlogged;
|
||||
}
|
||||
|
||||
public CoralForm form() {
|
||||
return form == null ? CoralForm.BRANCHING : form;
|
||||
}
|
||||
|
||||
public String block() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> blockPalette() {
|
||||
return Optional.ofNullable(blockPalette);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<String> tipBlock() {
|
||||
return Optional.ofNullable(tipBlock);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> tipPalette() {
|
||||
return Optional.ofNullable(tipPalette);
|
||||
}
|
||||
|
||||
public double tipChance() {
|
||||
return tipChance;
|
||||
}
|
||||
|
||||
public int heightMin() {
|
||||
return heightMin;
|
||||
}
|
||||
|
||||
public int heightMax() {
|
||||
return heightMax;
|
||||
}
|
||||
|
||||
public double spread() {
|
||||
return spread;
|
||||
}
|
||||
|
||||
public double sway() {
|
||||
return sway;
|
||||
}
|
||||
|
||||
public int branchCount() {
|
||||
return branchCount;
|
||||
}
|
||||
|
||||
public double branchLength() {
|
||||
return branchLength;
|
||||
}
|
||||
|
||||
public double branchElevation() {
|
||||
return branchElevation;
|
||||
}
|
||||
|
||||
public CoralBranchAzimuth branchAzimuth() {
|
||||
return branchAzimuth == null ? CoralBranchAzimuth.GOLDEN_ANGLE : branchAzimuth;
|
||||
}
|
||||
|
||||
public boolean subBranches() {
|
||||
return subBranches;
|
||||
}
|
||||
|
||||
public int subBranchCount() {
|
||||
return subBranchCount;
|
||||
}
|
||||
|
||||
public double subBranchScale() {
|
||||
return subBranchScale;
|
||||
}
|
||||
|
||||
public int tipClusterRadius() {
|
||||
return tipClusterRadius;
|
||||
}
|
||||
|
||||
public int brainRadius() {
|
||||
return brainRadius;
|
||||
}
|
||||
|
||||
public double brainRoughness() {
|
||||
return brainRoughness;
|
||||
}
|
||||
|
||||
public int pillarRadius() {
|
||||
return pillarRadius;
|
||||
}
|
||||
|
||||
public int fanWidth() {
|
||||
return fanWidth;
|
||||
}
|
||||
|
||||
public int tendrilCount() {
|
||||
return tendrilCount;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
package art.arcane.iris.builtin.objects.coral;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("How the arms of a BRANCHING coral are distributed around the central stalk by compass azimuth.")
|
||||
public enum IrisCoralBranchAzimuth {
|
||||
public enum CoralBranchAzimuth {
|
||||
@Desc("Distribute arms by the golden angle (about 137.5 degrees per arm) for a natural phyllotactic spiral where no two arms overlap.")
|
||||
GOLDEN_ANGLE,
|
||||
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
package art.arcane.iris.builtin.objects.coral;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("The overall silhouette a procedural coral grows into. Each form drives a completely different generation routine in the coral generator, from tree-like branching arms to rounded brain blobs and thin wavy tendrils.")
|
||||
public enum IrisCoralForm {
|
||||
public enum CoralForm {
|
||||
@Desc("A tree-like coral built from a stout central stalk that sprouts several upward-leaning arms (distributed by golden angle or randomly), each optionally splitting once into sub-arms, with small coral tip clusters (fans / sea pickles) at the ends. The most structurally complex form and the closest analogue to a procedural tree.")
|
||||
BRANCHING,
|
||||
|
||||
+165
-81
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,44 +16,29 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
package art.arcane.iris.builtin.objects.crystal;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.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.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.CrystalGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Snippet("crystal")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated crystal cluster: a budding base blob with faceted, tapered shards radiating from it (geode / amethyst-style). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Built for caves.")
|
||||
@Data
|
||||
public class IrisCrystal implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
public final class Crystal {
|
||||
@Desc("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "crystal";
|
||||
|
||||
@@ -78,7 +63,7 @@ public class IrisCrystal implements IrisProceduralPlacement {
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Desc("Rotate this crystal cluster's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
private ObjectRotation rotation = new ObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min height of placement.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
@@ -90,7 +75,7 @@ public class IrisCrystal implements IrisProceduralPlacement {
|
||||
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();
|
||||
private ObjectTranslate translate = new ObjectTranslate();
|
||||
|
||||
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private StiltSettings stiltSettings;
|
||||
@@ -99,22 +84,22 @@ public class IrisCrystal implements IrisProceduralPlacement {
|
||||
private VacuumSettings vacuumSettings;
|
||||
|
||||
@Desc("The surface this crystal grows from (FLOOR shards up, CEILING shards down, WALL shards outward). This orients the baked geometry only.")
|
||||
private IrisCrystalSurface growthSurface = IrisCrystalSurface.FLOOR;
|
||||
private CrystalSurface growthSurface = CrystalSurface.FLOOR;
|
||||
|
||||
@Required
|
||||
@Desc("The primary crystal shard block, e.g. minecraft:amethyst_block. Ignored when blockPalette is set.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String block = "minecraft:amethyst_block";
|
||||
|
||||
@Desc("A noise-driven palette for the crystal shards (a prismatic mix, e.g. amethyst_block, calcite, tinted_glass). When set this overrides the single block, letting the shards mix blocks by noise. Palette wins.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
private PaletteSpec blockPalette;
|
||||
|
||||
@Desc("Optional block placed at the very tip of each shard for a different colored or sparkling point (e.g. minecraft:amethyst_cluster or glowstone). Ignored when tipPalette is set. If unset and glow is true, a light-emitting block is sprinkled among the tips instead.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String tipBlock = null;
|
||||
|
||||
@Desc("A noise-driven palette for the shard tips. When set this overrides the single tipBlock. Palette wins.")
|
||||
private IrisMaterialPalette tipPalette = null;
|
||||
private PaletteSpec tipPalette;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@@ -125,15 +110,15 @@ public class IrisCrystal implements IrisProceduralPlacement {
|
||||
private boolean glow = false;
|
||||
|
||||
@Desc("The light-emitting block sprinkled among the tips when glow is true and no tip block is configured.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String glowBlock = "minecraft:glowstone";
|
||||
|
||||
@Desc("Optional block for the budding base blob the shards grow from, e.g. minecraft:budding_amethyst or calcite. Ignored when basePalette is set. If unset, the base is built from the primary shard block.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String baseBlock = "minecraft:budding_amethyst";
|
||||
|
||||
@Desc("A noise-driven palette for the budding base blob. When set this overrides the single baseBlock. Palette wins.")
|
||||
private IrisMaterialPalette basePalette = null;
|
||||
private PaletteSpec basePalette;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Radius in blocks of the budding base blob the shards radiate from. 0 places no base blob (shards spring from a single point).")
|
||||
@@ -175,56 +160,155 @@ public class IrisCrystal implements IrisProceduralPlacement {
|
||||
private double spreadAngle = 45;
|
||||
|
||||
@Desc("How the shard azimuths are distributed around the normal (RANDOM for a chaotic clump, GOLDEN_ANGLE for an evenly spaced rosette).")
|
||||
private IrisCrystalDistribution distribution = IrisCrystalDistribution.GOLDEN_ANGLE;
|
||||
private CrystalDistribution distribution = CrystalDistribution.GOLDEN_ANGLE;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Per-shard angular randomness (0-1) added on top of the chosen distribution so the cluster never looks mechanically regular. 0 is perfectly distributed; 1 is heavily jittered.")
|
||||
private double jitter = 0.25;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = CrystalGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
public Crystal() {
|
||||
}
|
||||
|
||||
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 name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
public int density() {
|
||||
return density;
|
||||
}
|
||||
|
||||
public int variants() {
|
||||
return variants;
|
||||
}
|
||||
|
||||
public long seed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
public ObjectPlaceMode mode() {
|
||||
return mode == null ? ObjectPlaceMode.CENTER_HEIGHT : mode;
|
||||
}
|
||||
|
||||
public ObjectRotation rotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public ObjectLimit clamp() {
|
||||
return clamp;
|
||||
}
|
||||
|
||||
public CarvingMode carvingSupport() {
|
||||
return carvingSupport == null ? CarvingMode.CARVING_ONLY : carvingSupport;
|
||||
}
|
||||
|
||||
public boolean underwater() {
|
||||
return underwater;
|
||||
}
|
||||
|
||||
public ObjectTranslate translate() {
|
||||
return translate;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<StiltSettings> stiltSettings() {
|
||||
return Optional.ofNullable(stiltSettings);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<VacuumSettings> vacuumSettings() {
|
||||
return Optional.ofNullable(vacuumSettings);
|
||||
}
|
||||
|
||||
public CrystalSurface growthSurface() {
|
||||
return growthSurface == null ? CrystalSurface.FLOOR : growthSurface;
|
||||
}
|
||||
|
||||
public String block() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> blockPalette() {
|
||||
return Optional.ofNullable(blockPalette);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<String> tipBlock() {
|
||||
return Optional.ofNullable(tipBlock);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> tipPalette() {
|
||||
return Optional.ofNullable(tipPalette);
|
||||
}
|
||||
|
||||
public double tipChance() {
|
||||
return tipChance;
|
||||
}
|
||||
|
||||
public boolean glow() {
|
||||
return glow;
|
||||
}
|
||||
|
||||
public String glowBlock() {
|
||||
return glowBlock;
|
||||
}
|
||||
|
||||
public String baseBlock() {
|
||||
return baseBlock;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> basePalette() {
|
||||
return Optional.ofNullable(basePalette);
|
||||
}
|
||||
|
||||
public double baseRadius() {
|
||||
return baseRadius;
|
||||
}
|
||||
|
||||
public double baseNoise() {
|
||||
return baseNoise;
|
||||
}
|
||||
|
||||
public int shardCountMin() {
|
||||
return shardCountMin;
|
||||
}
|
||||
|
||||
public int shardCountMax() {
|
||||
return shardCountMax;
|
||||
}
|
||||
|
||||
public int shardLengthMin() {
|
||||
return shardLengthMin;
|
||||
}
|
||||
|
||||
public int shardLengthMax() {
|
||||
return shardLengthMax;
|
||||
}
|
||||
|
||||
public double shardBaseRadius() {
|
||||
return shardBaseRadius;
|
||||
}
|
||||
|
||||
public double shardTaper() {
|
||||
return shardTaper;
|
||||
}
|
||||
|
||||
public double spreadAngle() {
|
||||
return spreadAngle;
|
||||
}
|
||||
|
||||
public CrystalDistribution distribution() {
|
||||
return distribution == null ? CrystalDistribution.GOLDEN_ANGLE : distribution;
|
||||
}
|
||||
|
||||
public double jitter() {
|
||||
return jitter;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
package art.arcane.iris.builtin.objects.crystal;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("How the shards of a crystal cluster are angularly distributed around the surface normal.")
|
||||
public enum IrisCrystalDistribution {
|
||||
public enum CrystalDistribution {
|
||||
@Desc("Each shard gets a uniformly random azimuth around the normal. Produces a chaotic, naturally clumped cluster.")
|
||||
RANDOM,
|
||||
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
package art.arcane.iris.builtin.objects.crystal;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("The surface a crystal cluster grows from. This only orients the baked geometry (which way the shards point); placement of the object into a cave is handled by the placement system, not here.")
|
||||
public enum IrisCrystalSurface {
|
||||
public enum CrystalSurface {
|
||||
@Desc("Grows from a cave floor. The budding base sits at the bottom and the shards point upward, fanning within the spread cone around the up axis. Built with positive py so the cluster grows up from the base layer.")
|
||||
FLOOR,
|
||||
|
||||
+223
-80
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,44 +16,29 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
package art.arcane.iris.builtin.objects.formation;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.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.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.engine.object.procedural.formation.FormationGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Snippet("formation")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated natural formation, including rock landmarks and magical glacial silhouettes. Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file.")
|
||||
@Data
|
||||
public class IrisFormation implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
public final class Formation {
|
||||
@Desc("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "formation";
|
||||
|
||||
@@ -78,7 +63,7 @@ public class IrisFormation implements IrisProceduralPlacement {
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Desc("Rotate this formation's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
private ObjectRotation rotation = new ObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min height of placement.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
@@ -95,7 +80,7 @@ public class IrisFormation implements IrisProceduralPlacement {
|
||||
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();
|
||||
private ObjectTranslate translate = new ObjectTranslate();
|
||||
|
||||
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private StiltSettings stiltSettings;
|
||||
@@ -104,25 +89,25 @@ public class IrisFormation implements IrisProceduralPlacement {
|
||||
private VacuumSettings vacuumSettings;
|
||||
|
||||
@Desc("The overall silhouette of the formation. Drives which sculpting routine the generator uses.")
|
||||
private IrisFormationForm form = IrisFormationForm.SPIRE;
|
||||
private FormationForm form = FormationForm.SPIRE;
|
||||
|
||||
@Required
|
||||
@Desc("The main rock block, e.g. minecraft:stone. Ignored when blockPalette is set.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String block = "minecraft:stone";
|
||||
|
||||
@Desc("A noise-driven palette for the main rock body. When set this overrides the single block, letting the body mix blocks by noise.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
private PaletteSpec blockPalette;
|
||||
|
||||
@Desc("Optional caprock block placed on the top crown of the formation (and the wide overhanging cap for HOODOO). Ignored when capPalette is set. When null and capPalette is unset, the formation uses its main rock everywhere.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String capBlock = null;
|
||||
|
||||
@Desc("A noise-driven palette for the caprock. When set this overrides the single capBlock.")
|
||||
private IrisMaterialPalette capPalette = null;
|
||||
private PaletteSpec capPalette;
|
||||
|
||||
@Desc("Optional palette of strata (horizontal colored bands) blended into the rock body by y level. When set, every strataThickness blocks of height switches to the next strata block, producing the signature banded look. Falls back to the main block where unset.")
|
||||
private IrisMaterialPalette strataPalette = null;
|
||||
private PaletteSpec strataPalette;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(32)
|
||||
@@ -150,7 +135,7 @@ public class IrisFormation implements IrisProceduralPlacement {
|
||||
private int topWidth = 0;
|
||||
|
||||
@Desc("The function used to shape the formation radius over its height.")
|
||||
private IrisFormationProfile profile = IrisFormationProfile.TAPER;
|
||||
private FormationProfile profile = FormationProfile.TAPER;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@@ -255,50 +240,208 @@ public class IrisFormation implements IrisProceduralPlacement {
|
||||
@Desc("How many blocks the tip of an OVERHANG curls downward.")
|
||||
private int overhangDrop = 3;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = FormationGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
public Formation() {
|
||||
}
|
||||
|
||||
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 name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setSurfaceSupportBuffer(surfaceSupportBuffer);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
public int density() {
|
||||
return density;
|
||||
}
|
||||
|
||||
public int variants() {
|
||||
return variants;
|
||||
}
|
||||
|
||||
public long seed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
public ObjectPlaceMode mode() {
|
||||
return mode == null ? ObjectPlaceMode.CENTER_HEIGHT : mode;
|
||||
}
|
||||
|
||||
public ObjectRotation rotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public ObjectLimit clamp() {
|
||||
return clamp;
|
||||
}
|
||||
|
||||
public CarvingMode carvingSupport() {
|
||||
return carvingSupport == null ? CarvingMode.SURFACE_ONLY : carvingSupport;
|
||||
}
|
||||
|
||||
public int surfaceSupportBuffer() {
|
||||
return surfaceSupportBuffer;
|
||||
}
|
||||
|
||||
public boolean underwater() {
|
||||
return underwater;
|
||||
}
|
||||
|
||||
public ObjectTranslate translate() {
|
||||
return translate;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<StiltSettings> stiltSettings() {
|
||||
return Optional.ofNullable(stiltSettings);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<VacuumSettings> vacuumSettings() {
|
||||
return Optional.ofNullable(vacuumSettings);
|
||||
}
|
||||
|
||||
public FormationForm form() {
|
||||
return form == null ? FormationForm.SPIRE : form;
|
||||
}
|
||||
|
||||
public String block() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> blockPalette() {
|
||||
return Optional.ofNullable(blockPalette);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<String> capBlock() {
|
||||
return Optional.ofNullable(capBlock);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> capPalette() {
|
||||
return Optional.ofNullable(capPalette);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> strataPalette() {
|
||||
return Optional.ofNullable(strataPalette);
|
||||
}
|
||||
|
||||
public int strataThickness() {
|
||||
return strataThickness;
|
||||
}
|
||||
|
||||
public int heightMin() {
|
||||
return heightMin;
|
||||
}
|
||||
|
||||
public int heightMax() {
|
||||
return heightMax;
|
||||
}
|
||||
|
||||
public int baseWidthMin() {
|
||||
return baseWidthMin;
|
||||
}
|
||||
|
||||
public int baseWidthMax() {
|
||||
return baseWidthMax;
|
||||
}
|
||||
|
||||
public int topWidth() {
|
||||
return topWidth;
|
||||
}
|
||||
|
||||
public FormationProfile profile() {
|
||||
return profile == null ? FormationProfile.TAPER : profile;
|
||||
}
|
||||
|
||||
public double profileWaist() {
|
||||
return profileWaist;
|
||||
}
|
||||
|
||||
public double profileWaistFloor() {
|
||||
return profileWaistFloor;
|
||||
}
|
||||
|
||||
public double lean() {
|
||||
return lean;
|
||||
}
|
||||
|
||||
public double leanAzimuth() {
|
||||
return leanAzimuth;
|
||||
}
|
||||
|
||||
public double roughness() {
|
||||
return roughness;
|
||||
}
|
||||
|
||||
public double jitter() {
|
||||
return jitter;
|
||||
}
|
||||
|
||||
public int hoodooCapRadius() {
|
||||
return hoodooCapRadius;
|
||||
}
|
||||
|
||||
public int hoodooCapHeight() {
|
||||
return hoodooCapHeight;
|
||||
}
|
||||
|
||||
public int archSpan() {
|
||||
return archSpan;
|
||||
}
|
||||
|
||||
public int archThickness() {
|
||||
return archThickness;
|
||||
}
|
||||
|
||||
public double archAsymmetry() {
|
||||
return archAsymmetry;
|
||||
}
|
||||
|
||||
public int basaltColumns() {
|
||||
return basaltColumns;
|
||||
}
|
||||
|
||||
public int basaltColumnRadius() {
|
||||
return basaltColumnRadius;
|
||||
}
|
||||
|
||||
public double basaltHeightVariance() {
|
||||
return basaltHeightVariance;
|
||||
}
|
||||
|
||||
public int icebergPeaks() {
|
||||
return icebergPeaks;
|
||||
}
|
||||
|
||||
public int fractureCount() {
|
||||
return fractureCount;
|
||||
}
|
||||
|
||||
public int fractureSeparation() {
|
||||
return fractureSeparation;
|
||||
}
|
||||
|
||||
public double spiralTurns() {
|
||||
return spiralTurns;
|
||||
}
|
||||
|
||||
public int spiralRadius() {
|
||||
return spiralRadius;
|
||||
}
|
||||
|
||||
public int spiralThickness() {
|
||||
return spiralThickness;
|
||||
}
|
||||
|
||||
public int overhangReach() {
|
||||
return overhangReach;
|
||||
}
|
||||
|
||||
public int overhangDrop() {
|
||||
return overhangDrop;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
package art.arcane.iris.builtin.objects.formation;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("The overall silhouette of a procedural natural formation. Each form drives a distinct sculpting routine in the formation generator.")
|
||||
public enum IrisFormationForm {
|
||||
public enum FormationForm {
|
||||
@Desc("A tall, slender needle of rock that tapers smoothly to a point at the top (a sharp pinnacle or stone spire).")
|
||||
SPIRE,
|
||||
@Desc("A column with a pinched, eroded waist and a wide overhanging caprock balanced on top (the classic desert hoodoo / mushroom rock).")
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
package art.arcane.iris.builtin.objects.formation;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("A width-shaping function evaluated over normalized height (0 at the base, 1 at the top). Controls how the formation radius scales between baseWidth at the bottom and topWidth at the top.")
|
||||
public enum IrisFormationProfile {
|
||||
public enum FormationProfile {
|
||||
@Desc("Same radius at every height (a straight cylinder of constant baseWidth).")
|
||||
CONSTANT,
|
||||
@Desc("Radius ramps straight from baseWidth at the bottom to topWidth at the top.")
|
||||
+187
-94
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,44 +16,29 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
package art.arcane.iris.builtin.objects.fungi;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.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.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.FungusGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Snippet("fungus")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated fungus (giant mushroom or shelf fungus). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. The fungus is built as a stem column with a cap dome grown on top, mirroring the trunk-and-canopy model used by procedural trees.")
|
||||
@Data
|
||||
public class IrisFungus implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
public final class Fungus {
|
||||
@Desc("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "fungus";
|
||||
|
||||
@@ -78,7 +63,7 @@ public class IrisFungus implements IrisProceduralPlacement {
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Desc("Rotate this fungus's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
private ObjectRotation rotation = new ObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min height of placement.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
@@ -90,7 +75,7 @@ public class IrisFungus implements IrisProceduralPlacement {
|
||||
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();
|
||||
private ObjectTranslate translate = new ObjectTranslate();
|
||||
|
||||
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private StiltSettings stiltSettings;
|
||||
@@ -100,19 +85,19 @@ public class IrisFungus implements IrisProceduralPlacement {
|
||||
|
||||
@Required
|
||||
@Desc("The stem block, e.g. minecraft:mushroom_stem. Ignored when stemPalette is set.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String stem = "minecraft:mushroom_stem";
|
||||
|
||||
@Desc("A noise-driven palette for the stem. When set this overrides the single stem block, letting the stem mix blocks by noise.")
|
||||
private IrisMaterialPalette stemPalette = null;
|
||||
private PaletteSpec stemPalette;
|
||||
|
||||
@Required
|
||||
@Desc("The cap block, e.g. minecraft:red_mushroom_block. Ignored when capPalette is set.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String cap = "minecraft:red_mushroom_block";
|
||||
|
||||
@Desc("A noise-driven palette for the cap. When set this overrides the single cap block, letting the cap mix blocks by noise.")
|
||||
private IrisMaterialPalette capPalette = null;
|
||||
private PaletteSpec capPalette;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum total stem height in blocks. Variants spread between this and stemHeightMax.")
|
||||
@@ -142,7 +127,7 @@ public class IrisFungus implements IrisProceduralPlacement {
|
||||
private double stemWavePeriods = 1;
|
||||
|
||||
@Desc("The silhouette of the cap (dome, flat umbrella, funnel, cone, or wide shallow slab).")
|
||||
private IrisFungusCapShape capShape = IrisFungusCapShape.DOME;
|
||||
private FungusCapShape capShape = FungusCapShape.DOME;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum cap radius in blocks (measured from the cap center to its rim).")
|
||||
@@ -171,11 +156,11 @@ public class IrisFungus implements IrisProceduralPlacement {
|
||||
private double capOverhang = 2;
|
||||
|
||||
@Desc("Optional block forming the gill layer on the underside of the cap (gills or a glow layer), e.g. minecraft:brown_mushroom_block or minecraft:shroomlight. Ignored when gillPalette is set or left null.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String gillBlock = null;
|
||||
|
||||
@Desc("A noise-driven palette for the underside gill layer. When set this overrides the single gillBlock.")
|
||||
private IrisMaterialPalette gillPalette = null;
|
||||
private PaletteSpec gillPalette;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@@ -183,11 +168,11 @@ public class IrisFungus implements IrisProceduralPlacement {
|
||||
private double gillChance = 0.85;
|
||||
|
||||
@Desc("Optional block speckled across the top of the cap by noise (white toadstool dots, warts, glowing spots), e.g. minecraft:bone_block or minecraft:white_concrete. Ignored when spotPalette is set or left null.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String spotBlock = null;
|
||||
|
||||
@Desc("A noise-driven palette for the cap top spots. When set this overrides the single spotBlock.")
|
||||
private IrisMaterialPalette spotPalette = null;
|
||||
private PaletteSpec spotPalette;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@@ -201,62 +186,170 @@ public class IrisFungus implements IrisProceduralPlacement {
|
||||
@Desc("The radius in blocks of the sideways fan when shelf is true.")
|
||||
private int shelfRadius = 3;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
int lo = Math.min(stemHeightMin, stemHeightMax);
|
||||
int hi = Math.max(stemHeightMin, stemHeightMax);
|
||||
RNG heightRng = new RNG(seed);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int height;
|
||||
if (count == 1 || lo == hi) {
|
||||
height = heightRng.i(lo, hi + 1);
|
||||
} else {
|
||||
double step = (hi - lo) / (double) (count - 1);
|
||||
double base = lo + step * i;
|
||||
double jitter = heightRng.d(-step * 0.3, step * 0.3);
|
||||
height = (int) Math.round(Math.max(lo, Math.min(hi, base + jitter)));
|
||||
}
|
||||
|
||||
IrisObject object = FungusGenerator.generate(this, Math.max(1, height), new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
public Fungus() {
|
||||
}
|
||||
|
||||
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 name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
public int density() {
|
||||
return density;
|
||||
}
|
||||
|
||||
public int variants() {
|
||||
return variants;
|
||||
}
|
||||
|
||||
public long seed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
public ObjectPlaceMode mode() {
|
||||
return mode == null ? ObjectPlaceMode.CENTER_HEIGHT : mode;
|
||||
}
|
||||
|
||||
public ObjectRotation rotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public ObjectLimit clamp() {
|
||||
return clamp;
|
||||
}
|
||||
|
||||
public CarvingMode carvingSupport() {
|
||||
return carvingSupport == null ? CarvingMode.SURFACE_ONLY : carvingSupport;
|
||||
}
|
||||
|
||||
public boolean underwater() {
|
||||
return underwater;
|
||||
}
|
||||
|
||||
public ObjectTranslate translate() {
|
||||
return translate;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<StiltSettings> stiltSettings() {
|
||||
return Optional.ofNullable(stiltSettings);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<VacuumSettings> vacuumSettings() {
|
||||
return Optional.ofNullable(vacuumSettings);
|
||||
}
|
||||
|
||||
public String stem() {
|
||||
return stem;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> stemPalette() {
|
||||
return Optional.ofNullable(stemPalette);
|
||||
}
|
||||
|
||||
public String cap() {
|
||||
return cap;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> capPalette() {
|
||||
return Optional.ofNullable(capPalette);
|
||||
}
|
||||
|
||||
public int stemHeightMin() {
|
||||
return stemHeightMin;
|
||||
}
|
||||
|
||||
public int stemHeightMax() {
|
||||
return stemHeightMax;
|
||||
}
|
||||
|
||||
public int stemWidth() {
|
||||
return stemWidth;
|
||||
}
|
||||
|
||||
public double stemCurve() {
|
||||
return stemCurve;
|
||||
}
|
||||
|
||||
public double stemLeanAzimuth() {
|
||||
return stemLeanAzimuth;
|
||||
}
|
||||
|
||||
public double stemWaveAmplitude() {
|
||||
return stemWaveAmplitude;
|
||||
}
|
||||
|
||||
public double stemWavePeriods() {
|
||||
return stemWavePeriods;
|
||||
}
|
||||
|
||||
public FungusCapShape capShape() {
|
||||
return capShape == null ? FungusCapShape.DOME : capShape;
|
||||
}
|
||||
|
||||
public int capRadiusMin() {
|
||||
return capRadiusMin;
|
||||
}
|
||||
|
||||
public int capRadiusMax() {
|
||||
return capRadiusMax;
|
||||
}
|
||||
|
||||
public int capThickness() {
|
||||
return capThickness;
|
||||
}
|
||||
|
||||
public double capSquish() {
|
||||
return capSquish;
|
||||
}
|
||||
|
||||
public double capDroop() {
|
||||
return capDroop;
|
||||
}
|
||||
|
||||
public double capOverhang() {
|
||||
return capOverhang;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<String> gillBlock() {
|
||||
return Optional.ofNullable(gillBlock);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> gillPalette() {
|
||||
return Optional.ofNullable(gillPalette);
|
||||
}
|
||||
|
||||
public double gillChance() {
|
||||
return gillChance;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<String> spotBlock() {
|
||||
return Optional.ofNullable(spotBlock);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> spotPalette() {
|
||||
return Optional.ofNullable(spotPalette);
|
||||
}
|
||||
|
||||
public double spotChance() {
|
||||
return spotChance;
|
||||
}
|
||||
|
||||
public boolean shelf() {
|
||||
return shelf;
|
||||
}
|
||||
|
||||
public int shelfRadius() {
|
||||
return shelfRadius;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
package art.arcane.iris.builtin.objects.fungi;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("The silhouette of the mushroom cap. Each shape drives how the cap radius and thickness vary from its apex down to the rim, giving the fungus a distinct profile.")
|
||||
public enum IrisFungusCapShape {
|
||||
public enum FungusCapShape {
|
||||
@Desc("A rounded hemisphere cap that bulges up and curls slightly under at the rim, the classic red toadstool dome.")
|
||||
DOME,
|
||||
@Desc("A wide, nearly flat umbrella that holds its full radius almost to the edge before dropping, the brown-mushroom plate look.")
|
||||
+148
-81
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,46 +16,32 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
package art.arcane.iris.builtin.objects.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.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.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.RuinGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinItems;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Snippet("ruin")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated ruin: a crumbling man-made structure (pillar, wall, arch, foundation slab, or rubble pile). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Weathering swaps blocks for mossy or cracked variants by noise, erosion deletes blocks so the shape reads as collapsed, and a buried fraction sinks the ruin into the terrain.")
|
||||
@Data
|
||||
public class IrisRuin implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
public final class Ruin {
|
||||
@Desc("A human readable name used in logs and as the variant load key (procedural/<name>#<index>).")
|
||||
private String name = "ruin";
|
||||
|
||||
@@ -80,7 +66,7 @@ public class IrisRuin implements IrisProceduralPlacement {
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.MIN_HEIGHT;
|
||||
|
||||
@Desc("Rotate this ruin's placement so variants do not all face the same way.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
private ObjectRotation rotation = new ObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min terrain height at which this ruin may place.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
@@ -92,7 +78,7 @@ public class IrisRuin implements IrisProceduralPlacement {
|
||||
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();
|
||||
private ObjectTranslate translate = new ObjectTranslate();
|
||||
|
||||
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private StiltSettings stiltSettings;
|
||||
@@ -102,14 +88,14 @@ public class IrisRuin implements IrisProceduralPlacement {
|
||||
|
||||
@Required
|
||||
@Desc("The primary structural block, e.g. minecraft:cobblestone or minecraft:stone_bricks. Ignored when blockPalette is set. This is the bulk material of the ruin before weathering swaps some of it out.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String block = "minecraft:cobblestone";
|
||||
|
||||
@Desc("A noise-driven palette for the primary block. When set this overrides the single block, letting the structure mix materials by noise. Palette wins over the block string via IrisProceduralBlocks.resolve.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
private PaletteSpec blockPalette;
|
||||
|
||||
@Desc("The overall silhouette of the ruin: PILLAR (broken column), WALL (gapped segment), ARCH (two legs plus a curved span), FLOOR_SLAB (foundation patch), or RUBBLE (low scattered pile).")
|
||||
private IrisRuinForm form = IrisRuinForm.PILLAR;
|
||||
private RuinForm form = RuinForm.PILLAR;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum structure height in blocks (PILLAR/WALL/ARCH height, slab thickness for FLOOR_SLAB, mound height for RUBBLE). Variants interpolate between this and heightMax.")
|
||||
@@ -136,10 +122,10 @@ public class IrisRuin implements IrisProceduralPlacement {
|
||||
private int lengthMax = 7;
|
||||
|
||||
@Desc("A palette of weathered variants (mossy/cracked block ids) blended over the structure by noise. When set this drives weathering; otherwise weatheredBlock is used.")
|
||||
private IrisMaterialPalette weatheringPalette = null;
|
||||
private PaletteSpec weatheringPalette;
|
||||
|
||||
@Desc("A single weathered block id used when weatheringPalette is not set, e.g. minecraft:mossy_cobblestone. Applied to a noise-selected fraction of the structure, biased toward the lower rows.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String weatheredBlock = "minecraft:mossy_cobblestone";
|
||||
|
||||
@MinNumber(0)
|
||||
@@ -167,53 +153,134 @@ public class IrisRuin implements IrisProceduralPlacement {
|
||||
@Desc("How far the structure extends below the surface as a fraction of its height (0 sits fully on top, 1 sinks it a full height into the ground). The buried rows live at negative y so the ruin reads as settled and partly swallowed by the terrain.")
|
||||
private double buriedFraction = 0.2;
|
||||
|
||||
@ArrayType(min = 1, type = IrisRuinDecorator.class)
|
||||
@MinItems(1)
|
||||
@Desc("Accent decorators applied after the ruin is built and eroded (moss carpets and lanterns on broken tops, vines and lichen on the faces, rubble and growth scattered around the base).")
|
||||
private KList<IrisRuinDecorator> accents = new KList<>();
|
||||
private List<RuinDecorator> accents = List.of();
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = RuinGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
public Ruin() {
|
||||
}
|
||||
|
||||
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 name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
public int density() {
|
||||
return density;
|
||||
}
|
||||
|
||||
public int variants() {
|
||||
return variants;
|
||||
}
|
||||
|
||||
public long seed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
public ObjectPlaceMode mode() {
|
||||
return mode == null ? ObjectPlaceMode.MIN_HEIGHT : mode;
|
||||
}
|
||||
|
||||
public ObjectRotation rotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public ObjectLimit clamp() {
|
||||
return clamp;
|
||||
}
|
||||
|
||||
public CarvingMode carvingSupport() {
|
||||
return carvingSupport == null ? CarvingMode.SURFACE_ONLY : carvingSupport;
|
||||
}
|
||||
|
||||
public boolean underwater() {
|
||||
return underwater;
|
||||
}
|
||||
|
||||
public ObjectTranslate translate() {
|
||||
return translate;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<StiltSettings> stiltSettings() {
|
||||
return Optional.ofNullable(stiltSettings);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<VacuumSettings> vacuumSettings() {
|
||||
return Optional.ofNullable(vacuumSettings);
|
||||
}
|
||||
|
||||
public String block() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> blockPalette() {
|
||||
return Optional.ofNullable(blockPalette);
|
||||
}
|
||||
|
||||
public RuinForm form() {
|
||||
return form == null ? RuinForm.PILLAR : form;
|
||||
}
|
||||
|
||||
public int heightMin() {
|
||||
return heightMin;
|
||||
}
|
||||
|
||||
public int heightMax() {
|
||||
return heightMax;
|
||||
}
|
||||
|
||||
public int widthMin() {
|
||||
return widthMin;
|
||||
}
|
||||
|
||||
public int widthMax() {
|
||||
return widthMax;
|
||||
}
|
||||
|
||||
public int lengthMin() {
|
||||
return lengthMin;
|
||||
}
|
||||
|
||||
public int lengthMax() {
|
||||
return lengthMax;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> weatheringPalette() {
|
||||
return Optional.ofNullable(weatheringPalette);
|
||||
}
|
||||
|
||||
public String weatheredBlock() {
|
||||
return weatheredBlock;
|
||||
}
|
||||
|
||||
public double mossiness() {
|
||||
return mossiness;
|
||||
}
|
||||
|
||||
public double weatheringScale() {
|
||||
return weatheringScale;
|
||||
}
|
||||
|
||||
public double erosion() {
|
||||
return erosion;
|
||||
}
|
||||
|
||||
public double erosionScale() {
|
||||
return erosionScale;
|
||||
}
|
||||
|
||||
public double buriedFraction() {
|
||||
return buriedFraction;
|
||||
}
|
||||
|
||||
public List<RuinDecorator> accents() {
|
||||
return accents == null ? List.of() : Collections.unmodifiableList(accents);
|
||||
}
|
||||
}
|
||||
+41
-23
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,38 +16,32 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
package art.arcane.iris.builtin.objects.ruin;
|
||||
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Snippet("ruin-decorator")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("An accent block applied to a generated ruin after it is built and eroded, such as moss carpets on broken tops, vines on the faces, or rubble scattered around the base.")
|
||||
@Data
|
||||
public class IrisRuinDecorator {
|
||||
public final class RuinDecorator {
|
||||
@Desc("Where on the ruin this accent is placed. TOP sits on the highest block of each column, SURFACE clings to air-facing vertical faces, BASE_SCATTER rings the ground footprint around the base.")
|
||||
private IrisRuinDecoratorTarget target = IrisRuinDecoratorTarget.TOP;
|
||||
private RuinDecoratorTarget target = RuinDecoratorTarget.TOP;
|
||||
|
||||
@Required
|
||||
@Desc("The block id to place, e.g. minecraft:moss_carpet or minecraft:vine. Ignored when palette is set.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String block = "";
|
||||
|
||||
@Desc("A noise-driven palette for this decorator. When set this overrides the single block, letting the accent mix blocks by noise. Resolved through IrisProceduralBlocks.resolve so the palette wins over the string.")
|
||||
private IrisMaterialPalette palette = null;
|
||||
private PaletteSpec palette;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@@ -57,4 +51,28 @@ public class IrisRuinDecorator {
|
||||
@MinNumber(1)
|
||||
@Desc("For the BASE_SCATTER target, how many blocks beyond the ruin footprint the scatter ring extends outward in each direction. Higher values fling rubble and growth further from the structure.")
|
||||
private int scatterRadius = 2;
|
||||
|
||||
public RuinDecorator() {
|
||||
}
|
||||
|
||||
public RuinDecoratorTarget target() {
|
||||
return target == null ? RuinDecoratorTarget.TOP : target;
|
||||
}
|
||||
|
||||
public String block() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> palette() {
|
||||
return Optional.ofNullable(palette);
|
||||
}
|
||||
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public int scatterRadius() {
|
||||
return scatterRadius;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
package art.arcane.iris.builtin.objects.ruin;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Where a ruin accent block is placed after the ruin has been built and eroded.")
|
||||
public enum IrisRuinDecoratorTarget {
|
||||
public enum RuinDecoratorTarget {
|
||||
@Desc("On top of the highest surviving block in each column (moss carpets, snow, sculk, lanterns on broken tops).")
|
||||
TOP,
|
||||
@Desc("On air-facing vertical sides of any surviving block (vines, glow lichen, climbing growth on the ruin faces).")
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
package art.arcane.iris.builtin.objects.ruin;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("The overall silhouette of a procedural ruin. Each form rasterizes a different crumbling man-made shape from the same size, weathering, and erosion settings.")
|
||||
public enum IrisRuinForm {
|
||||
public enum RuinForm {
|
||||
@Desc("A broken vertical column. A square trunk (widthMin..widthMax footprint) rises to a randomized height then snaps off with a jagged crown, leaving a toppled stub. Use for ancient pillars and obelisk stumps.")
|
||||
PILLAR,
|
||||
@Desc("A standing wall segment. A flat slab spanning lengthMin..lengthMax long and heightMin..heightMax tall, thickness widthMin..widthMax, punched through with noise-driven gaps and a ragged top edge. Use for collapsed building sides and fortifications.")
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Controls the compass direction (azimuth) of trunk lean as it rises, or the direction each branch is thrown.")
|
||||
public enum IrisTreeAzimuthMode {
|
||||
public enum TreeAzimuthMode {
|
||||
@Desc("A single fixed azimuth.")
|
||||
CONSTANT,
|
||||
@Desc("Azimuth ramps straight from start to end with height.")
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Controls how the chance of spawning a branch varies with trunk height (0 at the base, 1 at the top).")
|
||||
public enum IrisTreeBranchProbability {
|
||||
public enum TreeBranchProbability {
|
||||
@Desc("Same branch chance at every height.")
|
||||
CONSTANT,
|
||||
@Desc("Ramps straight from base chance to crown chance.")
|
||||
+127
-21
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,26 +16,20 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Snippet("tree-branches")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A branch system that throws limbs out of the trunk and places a leaf ball at each tip. When present, branches drive the canopy and only the topmost crown disc of the profile is still placed.")
|
||||
@Data
|
||||
public class IrisTreeBranches {
|
||||
public final class TreeBranches {
|
||||
@Desc("How branch spawn chance varies over trunk height.")
|
||||
private IrisTreeBranchProbability probabilityFunction = IrisTreeBranchProbability.TOP_HEAVY;
|
||||
private TreeBranchProbability probabilityFunction = TreeBranchProbability.TOP_HEAVY;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Branch chance for the CONSTANT probability function.")
|
||||
@@ -72,7 +66,7 @@ public class IrisTreeBranches {
|
||||
private double probabilityPeriods = 5;
|
||||
|
||||
@Desc("How branch length varies over trunk height.")
|
||||
private IrisTreeFunction lengthFunction = IrisTreeFunction.LINEAR;
|
||||
private TreeFunction lengthFunction = TreeFunction.LINEAR;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Branch length at the base for the LINEAR length function.")
|
||||
@@ -94,7 +88,7 @@ public class IrisTreeBranches {
|
||||
private double lengthSteepness = 5;
|
||||
|
||||
@Desc("How the compass direction of each branch is chosen.")
|
||||
private IrisTreeAzimuthMode azimuthMode = IrisTreeAzimuthMode.RANDOM;
|
||||
private TreeAzimuthMode azimuthMode = TreeAzimuthMode.RANDOM;
|
||||
|
||||
@Desc("Fixed azimuth in degrees when azimuthMode is CONSTANT.")
|
||||
private double azimuth = 0;
|
||||
@@ -120,12 +114,124 @@ public class IrisTreeBranches {
|
||||
private int clusterRadius = 2;
|
||||
|
||||
@Desc("How the branch tip leaf cluster fills.")
|
||||
private IrisTreeLeafMode clusterMode = IrisTreeLeafMode.TRIMMED;
|
||||
private TreeLeafMode clusterMode = TreeLeafMode.TRIMMED;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Fill density for the branch tip leaf cluster when clusterMode is density or noise.")
|
||||
private double clusterDensity = 0.85;
|
||||
|
||||
@Desc("Optional one level of recursive sub-branches sprouting from each branch tip.")
|
||||
private IrisTreeSubBranches subBranches = null;
|
||||
private TreeSubBranches subBranches = null;
|
||||
|
||||
public TreeBranches() {
|
||||
}
|
||||
|
||||
public TreeBranchProbability probabilityFunction() {
|
||||
return probabilityFunction == null ? TreeBranchProbability.TOP_HEAVY : probabilityFunction;
|
||||
}
|
||||
|
||||
public double probabilityConstant() {
|
||||
return probabilityConstant;
|
||||
}
|
||||
|
||||
public double probabilityBase() {
|
||||
return probabilityBase;
|
||||
}
|
||||
|
||||
public double probabilityCrown() {
|
||||
return probabilityCrown;
|
||||
}
|
||||
|
||||
public double probabilitySteepness() {
|
||||
return probabilitySteepness;
|
||||
}
|
||||
|
||||
public double probabilityMidpoint() {
|
||||
return probabilityMidpoint;
|
||||
}
|
||||
|
||||
public double probabilityExponent() {
|
||||
return probabilityExponent;
|
||||
}
|
||||
|
||||
public double probabilityMean() {
|
||||
return probabilityMean;
|
||||
}
|
||||
|
||||
public double probabilityStd() {
|
||||
return probabilityStd;
|
||||
}
|
||||
|
||||
public double probabilityScale() {
|
||||
return probabilityScale;
|
||||
}
|
||||
|
||||
public double probabilityPeriods() {
|
||||
return probabilityPeriods;
|
||||
}
|
||||
|
||||
public TreeFunction lengthFunction() {
|
||||
return lengthFunction == null ? TreeFunction.LINEAR : lengthFunction;
|
||||
}
|
||||
|
||||
public double lengthBase() {
|
||||
return lengthBase;
|
||||
}
|
||||
|
||||
public double lengthCrown() {
|
||||
return lengthCrown;
|
||||
}
|
||||
|
||||
public double lengthConstant() {
|
||||
return lengthConstant;
|
||||
}
|
||||
|
||||
public double lengthMax() {
|
||||
return lengthMax;
|
||||
}
|
||||
|
||||
public double lengthSteepness() {
|
||||
return lengthSteepness;
|
||||
}
|
||||
|
||||
public TreeAzimuthMode azimuthMode() {
|
||||
return azimuthMode == null ? TreeAzimuthMode.RANDOM : azimuthMode;
|
||||
}
|
||||
|
||||
public double azimuth() {
|
||||
return azimuth;
|
||||
}
|
||||
|
||||
public double elevation() {
|
||||
return elevation;
|
||||
}
|
||||
|
||||
public double sag() {
|
||||
return sag;
|
||||
}
|
||||
|
||||
public int branchDepth() {
|
||||
return branchDepth;
|
||||
}
|
||||
|
||||
public boolean leafStartUp() {
|
||||
return leafStartUp;
|
||||
}
|
||||
|
||||
public int clusterRadius() {
|
||||
return clusterRadius;
|
||||
}
|
||||
|
||||
public TreeLeafMode clusterMode() {
|
||||
return clusterMode == null ? TreeLeafMode.TRIMMED : clusterMode;
|
||||
}
|
||||
|
||||
public double clusterDensity() {
|
||||
return clusterDensity;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<TreeSubBranches> subBranches() {
|
||||
return Optional.ofNullable(subBranches);
|
||||
}
|
||||
}
|
||||
+53
-22
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,26 +16,21 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinItems;
|
||||
import com.volmit.config.MinNumber;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Snippet("tree-canopy")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("The leaf crown of a procedural tree. Built from stacked dome-shaped discs (driven by the profile or by explicit layers) and optionally a branch system.")
|
||||
@Data
|
||||
public class IrisTreeCanopy {
|
||||
public final class TreeCanopy {
|
||||
@MinNumber(0)
|
||||
@MaxNumber(180)
|
||||
@Desc("Elevation angle in degrees from vertical for each leaf dome. 90 is a flat disc, below 90 domes downward into a sphere, above 90 flares outward into an umbrella.")
|
||||
@@ -47,7 +42,7 @@ public class IrisTreeCanopy {
|
||||
private double squish = 1;
|
||||
|
||||
@Desc("How leaves fill each canopy disc.")
|
||||
private IrisTreeLeafMode mode = IrisTreeLeafMode.TRIMMED;
|
||||
private TreeLeafMode mode = TreeLeafMode.TRIMMED;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@@ -62,10 +57,46 @@ public class IrisTreeCanopy {
|
||||
@Desc("Horizontal Z stretch of the crown for elliptical or wind-blown shapes. 1 is circular.")
|
||||
private double crownStretchZ = 1;
|
||||
|
||||
@ArrayType(min = 1, type = IrisTreeLayer.class)
|
||||
@MinItems(1)
|
||||
@Desc("Optional explicit crown discs. When provided these replace the profile-driven layers and let you sculpt the silhouette by hand.")
|
||||
private KList<IrisTreeLayer> layers = new KList<>();
|
||||
private List<TreeLayer> layers = List.of();
|
||||
|
||||
@Desc("Optional branch system. When present, branches build most of the canopy and only the topmost profile disc is still placed as a crown.")
|
||||
private IrisTreeBranches branches = null;
|
||||
private TreeBranches branches = null;
|
||||
|
||||
public TreeCanopy() {
|
||||
}
|
||||
|
||||
public double startAngle() {
|
||||
return startAngle;
|
||||
}
|
||||
|
||||
public double squish() {
|
||||
return squish;
|
||||
}
|
||||
|
||||
public TreeLeafMode mode() {
|
||||
return mode == null ? TreeLeafMode.TRIMMED : mode;
|
||||
}
|
||||
|
||||
public double leafDensity() {
|
||||
return leafDensity;
|
||||
}
|
||||
|
||||
public double crownStretchX() {
|
||||
return crownStretchX;
|
||||
}
|
||||
|
||||
public double crownStretchZ() {
|
||||
return crownStretchZ;
|
||||
}
|
||||
|
||||
public List<TreeLayer> layers() {
|
||||
return layers == null ? List.of() : Collections.unmodifiableList(layers);
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<TreeBranches> branches() {
|
||||
return Optional.ofNullable(branches);
|
||||
}
|
||||
}
|
||||
+45
-22
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,37 +16,32 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Snippet("tree-decorator")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("An accent block applied to a generated tree such as fruit on branch tips, vines on the trunk, snow on the crown, or a glowing underside.")
|
||||
@Data
|
||||
public class IrisTreeDecorator {
|
||||
public final class TreeDecorator {
|
||||
@Desc("Where this decorator is placed on the tree.")
|
||||
private IrisTreeDecoratorTarget target = IrisTreeDecoratorTarget.BRANCH_TIP;
|
||||
private TreeDecoratorTarget target = TreeDecoratorTarget.BRANCH_TIP;
|
||||
|
||||
@Required
|
||||
@Desc("The block id to place, e.g. minecraft:magma_block. Ignored when palette is set.")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String block = "";
|
||||
|
||||
@Desc("A noise-driven palette for this decorator. When set this overrides the single block.")
|
||||
private IrisMaterialPalette palette = null;
|
||||
private PaletteSpec palette;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@@ -59,4 +54,32 @@ public class IrisTreeDecorator {
|
||||
|
||||
@Desc("If true the block's facing is oriented away from the trunk (for trunk-mounted fences/gates/banners).")
|
||||
private boolean axisAware = false;
|
||||
|
||||
public TreeDecorator() {
|
||||
}
|
||||
|
||||
public TreeDecoratorTarget target() {
|
||||
return target == null ? TreeDecoratorTarget.BRANCH_TIP : target;
|
||||
}
|
||||
|
||||
public String block() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/** Empty where the pack sets none. */
|
||||
public Optional<PaletteSpec> palette() {
|
||||
return Optional.ofNullable(palette);
|
||||
}
|
||||
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public boolean axisAware() {
|
||||
return axisAware;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Where a tree decorator block is placed.")
|
||||
public enum IrisTreeDecoratorTarget {
|
||||
public enum TreeDecoratorTarget {
|
||||
@Desc("At the tip of each generated branch (vines, fruit, lanterns).")
|
||||
BRANCH_TIP,
|
||||
@Desc("On air-facing sides of trunk and branch blocks (vines, moss).")
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("A shaping function evaluated over normalized height (0 at the base, 1 at the top). Used for trunk width, trunk curve and branch length.")
|
||||
public enum IrisTreeFunction {
|
||||
public enum TreeFunction {
|
||||
@Desc("Same value at every height.")
|
||||
CONSTANT,
|
||||
@Desc("Ramps straight from start to end.")
|
||||
+18
-15
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,27 +16,30 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MinNumber;
|
||||
|
||||
@Snippet("tree-layer")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("An explicit canopy disc at a given vertical offset and radius. Define a list of these to bypass the profile and sculpt the crown by hand.")
|
||||
@Data
|
||||
public class IrisTreeLayer {
|
||||
public final class TreeLayer {
|
||||
@Desc("The vertical offset of this disc, measured in blocks above the trunk base.")
|
||||
private int yOffset = 0;
|
||||
|
||||
@MinNumber(0.5)
|
||||
@Desc("The radius of this leaf disc in blocks.")
|
||||
private double radius = 2;
|
||||
|
||||
public TreeLayer() {
|
||||
}
|
||||
|
||||
public int yOffset() {
|
||||
return yOffset;
|
||||
}
|
||||
|
||||
public double radius() {
|
||||
return radius;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("How leaves fill a disc or cluster.")
|
||||
public enum IrisTreeLeafMode {
|
||||
public enum TreeLeafMode {
|
||||
@Desc("Corner-trimmed disc/sphere for a rounded silhouette.")
|
||||
TRIMMED,
|
||||
@Desc("Completely filled disc/sphere.")
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Named canopy presets that drive default layer radii and shape, scaled to the tree height.")
|
||||
public enum IrisTreeProfile {
|
||||
public enum TreeProfile {
|
||||
@Desc("Rounded broadleaf crown.")
|
||||
OAK,
|
||||
@Desc("Slim upright broadleaf crown.")
|
||||
+3
-3
@@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("How a procedural tree's root system is built below (and around) the trunk base.")
|
||||
public enum IrisTreeRootStyle {
|
||||
public enum TreeRootStyle {
|
||||
@Desc("A single tapering taproot straight down from the base.")
|
||||
TAPROOT,
|
||||
@Desc("A taproot plus a ring of flared buttress legs that splay outward as they descend (default).")
|
||||
+22
-18
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,31 +16,35 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
|
||||
@Snippet("tree-secondary-leaf")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A weighted accent leaf or foliage block scattered through the canopy (blossoms, shroomlight, berries).")
|
||||
@Data
|
||||
public class IrisTreeSecondaryLeaf {
|
||||
public final class TreeSecondaryLeaf {
|
||||
@Required
|
||||
@Desc("The block id to scatter, e.g. minecraft:shroomlight")
|
||||
@RegistryListBlockType
|
||||
@Ref(Reference.BLOCK)
|
||||
private String block = "";
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("The relative weight of this block among the secondary leaves.")
|
||||
private int weight = 1;
|
||||
|
||||
public TreeSecondaryLeaf() {
|
||||
}
|
||||
|
||||
public String block() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public int weight() {
|
||||
return weight;
|
||||
}
|
||||
}
|
||||
+44
-17
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,24 +16,16 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
package art.arcane.iris.builtin.objects.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
|
||||
@Snippet("tree-sub-branches")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("One recursive level of sub-branches sprouting from each primary branch tip.")
|
||||
@Data
|
||||
public class IrisTreeSubBranches {
|
||||
public final class TreeSubBranches {
|
||||
@MinNumber(1)
|
||||
@Desc("How many sub-branches sprout from each primary branch tip.")
|
||||
private int count = 1;
|
||||
@@ -58,9 +50,44 @@ public class IrisTreeSubBranches {
|
||||
private int clusterRadius = 1;
|
||||
|
||||
@Desc("How the sub-branch tip leaf cluster fills.")
|
||||
private IrisTreeLeafMode clusterMode = IrisTreeLeafMode.TRIMMED;
|
||||
private TreeLeafMode clusterMode = TreeLeafMode.TRIMMED;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Fill density for the sub-branch leaf cluster when clusterMode is density or noise.")
|
||||
private double clusterDensity = 0.85;
|
||||
|
||||
public TreeSubBranches() {
|
||||
}
|
||||
|
||||
public int count() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public double pitchDelta() {
|
||||
return pitchDelta;
|
||||
}
|
||||
|
||||
public double yawDelta() {
|
||||
return yawDelta;
|
||||
}
|
||||
|
||||
public double lengthScale() {
|
||||
return lengthScale;
|
||||
}
|
||||
|
||||
public double sag() {
|
||||
return sag;
|
||||
}
|
||||
|
||||
public int clusterRadius() {
|
||||
return clusterRadius;
|
||||
}
|
||||
|
||||
public TreeLeafMode clusterMode() {
|
||||
return clusterMode == null ? TreeLeafMode.TRIMMED : clusterMode;
|
||||
}
|
||||
|
||||
public double clusterDensity() {
|
||||
return clusterDensity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.prepare;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
/** How an object is turned around each axis, written as a placement's {@code rotation}. */
|
||||
@Snippet("object-rotator")
|
||||
@Desc("Configures rotation for iris")
|
||||
public final class ObjectRotation {
|
||||
private static final double QUARTER_TURN_DEGREES = 90;
|
||||
|
||||
@Desc("If this rotator is enabled or not")
|
||||
private boolean enabled = true;
|
||||
|
||||
@Desc("The x axis rotation")
|
||||
private AxisRotationClamp xAxis = new AxisRotationClamp();
|
||||
|
||||
@Desc("The y axis rotation")
|
||||
private AxisRotationClamp yAxis = AxisRotationClamp.of(true, false, 0, 0, QUARTER_TURN_DEGREES);
|
||||
|
||||
@Desc("The z axis rotation")
|
||||
private AxisRotationClamp zAxis = new AxisRotationClamp();
|
||||
|
||||
public ObjectRotation() {
|
||||
}
|
||||
|
||||
public boolean enabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public AxisRotationClamp xAxis() {
|
||||
return xAxis;
|
||||
}
|
||||
|
||||
public AxisRotationClamp yAxis() {
|
||||
return yAxis;
|
||||
}
|
||||
|
||||
public AxisRotationClamp zAxis() {
|
||||
return zAxis;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.prepare;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
/** How far an object is shifted from where it would be placed, written as a placement's {@code translate}. */
|
||||
@Snippet("object-translator")
|
||||
@Desc("Translate objects")
|
||||
public final class ObjectTranslate {
|
||||
@MinNumber(-128)
|
||||
@MaxNumber(128)
|
||||
@Desc("The x shift in blocks")
|
||||
private int x = 0;
|
||||
|
||||
@Required
|
||||
@MinNumber(-128)
|
||||
@MaxNumber(128)
|
||||
@Desc("The y shift in blocks")
|
||||
private int y = 0;
|
||||
|
||||
@MinNumber(-128)
|
||||
@MaxNumber(128)
|
||||
@Desc("Adds an additional amount of height randomly (translateY + rand(0 - yRandom))")
|
||||
private int yRandom = 0;
|
||||
|
||||
@MinNumber(-128)
|
||||
@MaxNumber(128)
|
||||
@Desc("The z shift in blocks")
|
||||
private int z = 0;
|
||||
|
||||
public ObjectTranslate() {
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int yRandom() {
|
||||
return yRandom;
|
||||
}
|
||||
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,14 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeCanopy;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf;
|
||||
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
@@ -56,6 +64,14 @@ public final class ObjectModule implements IrisModule {
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerService(ObjectsAt.class, ObjectModule::objectsAt);
|
||||
registry.registerHeldType(TreeCanopy.class);
|
||||
registry.registerHeldType(TreeDecorator.class);
|
||||
registry.registerHeldType(TreeSecondaryLeaf.class);
|
||||
registry.registerHeldType(Coral.class);
|
||||
registry.registerHeldType(Crystal.class);
|
||||
registry.registerHeldType(Formation.class);
|
||||
registry.registerHeldType(Fungus.class);
|
||||
registry.registerHeldType(Ruin.class);
|
||||
}
|
||||
|
||||
private static void place(MantleStageContext context) {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural;
|
||||
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -26,8 +25,10 @@ import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.common.math.IrisBlockVector;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Shared low-level helpers for building procedural objects in memory: resolving a
|
||||
@@ -52,13 +53,26 @@ public final class IrisProceduralBlocks {
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean paletteSet(IrisMaterialPalette palette) {
|
||||
return palette != null && palette.getPalette() != null && !palette.getPalette().isEmpty();
|
||||
public static boolean paletteSet(PaletteSpec palette) {
|
||||
return palette != null && !palette.palette().isEmpty();
|
||||
}
|
||||
|
||||
public static PlatformBlockState resolve(String block, IrisMaterialPalette palette, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
public static boolean paletteSet(Optional<PaletteSpec> palette) {
|
||||
return palette.filter(IrisProceduralBlocks::paletteSet).isPresent();
|
||||
}
|
||||
|
||||
public static PlatformBlockState resolve(String block, Optional<PaletteSpec> palette, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
return resolve(block, palette.orElse(null), data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
public static PlatformBlockState resolve(Optional<String> block, Optional<PaletteSpec> palette, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
return resolve(block.orElse(null), palette.orElse(null), data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
/** The block of {@code palette} at the position, picked with the seed of {@code paletteRng} as the palette's old class did; else {@code block}. */
|
||||
public static PlatformBlockState resolve(String block, PaletteSpec palette, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
if (paletteSet(palette)) {
|
||||
return palette.get(paletteRng, x, y, z, data);
|
||||
return pick(palette, data, paletteRng.getSeed(), x, y, z);
|
||||
}
|
||||
if (block != null && !block.isEmpty()) {
|
||||
return B.getStateOrNull(block, false);
|
||||
@@ -66,6 +80,11 @@ public final class IrisProceduralBlocks {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The block {@code palette} gives at the position when its noise is seeded with {@code seed}. */
|
||||
public static PlatformBlockState pick(PaletteSpec palette, IrisData data, long seed, int x, int y, int z) {
|
||||
return B.getState(data.getPackResources().blocks().palette(palette, seed).at(x, y, z).key());
|
||||
}
|
||||
|
||||
public static boolean hasProperty(PlatformBlockState state, String property) {
|
||||
String key = state.key();
|
||||
int start = propertyStart(key, property);
|
||||
|
||||
@@ -18,18 +18,31 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.coral.IrisCoral;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.IrisRuin;
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.ResolvedRuin;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.ResolvedFungus;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.engine.object.procedural.formation.ResolvedFormation;
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.ResolvedCrystal;
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.engine.object.procedural.coral.ResolvedCoral;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@@ -40,53 +53,59 @@ import lombok.experimental.Accessors;
|
||||
@Desc("Procedurally generated objects placed in a biome or region. Unlike the objects block (which loads iob files), these are generated from scratch at world-gen time.")
|
||||
@Data
|
||||
public class IrisProceduralObjects {
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
@EqualsAndHashCode.Exclude
|
||||
private final transient Map<Object, ResolvedProceduralPlacement> placeables = new ConcurrentHashMap<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisProceduralTree.class)
|
||||
@Desc("Procedurally generated trees.")
|
||||
private KList<IrisProceduralTree> trees = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisRuin.class)
|
||||
@ArrayType(min = 1, type = Ruin.class)
|
||||
@Desc("Procedurally generated ruins (crumbling pillars, walls, arches, rubble).")
|
||||
private KList<IrisRuin> ruins = new KList<>();
|
||||
private KList<Ruin> ruins = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisFormation.class)
|
||||
@ArrayType(min = 1, type = Formation.class)
|
||||
@Desc("Procedurally generated natural rock formations (spires, hoodoos, arches, sea stacks, boulders, basalt columns).")
|
||||
private KList<IrisFormation> formations = new KList<>();
|
||||
private KList<Formation> formations = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisCoral.class)
|
||||
@ArrayType(min = 1, type = Coral.class)
|
||||
@Desc("Procedurally generated underwater coral structures.")
|
||||
private KList<IrisCoral> coral = new KList<>();
|
||||
private KList<Coral> coral = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisFungus.class)
|
||||
@ArrayType(min = 1, type = Fungus.class)
|
||||
@Desc("Procedurally generated mushrooms and shelf fungi.")
|
||||
private KList<IrisFungus> fungi = new KList<>();
|
||||
private KList<Fungus> fungi = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisCrystal.class)
|
||||
@ArrayType(min = 1, type = Crystal.class)
|
||||
@Desc("Procedurally generated crystal clusters (usually placed in caves).")
|
||||
private KList<IrisCrystal> crystals = new KList<>();
|
||||
private KList<Crystal> crystals = new KList<>();
|
||||
|
||||
public KList<IrisProceduralPlacement> getAllPlacements() {
|
||||
KList<IrisProceduralPlacement> all = new KList<>();
|
||||
if (trees != null) {
|
||||
all.addAll(trees);
|
||||
}
|
||||
if (ruins != null) {
|
||||
all.addAll(ruins);
|
||||
}
|
||||
if (formations != null) {
|
||||
all.addAll(formations);
|
||||
}
|
||||
if (coral != null) {
|
||||
all.addAll(coral);
|
||||
}
|
||||
if (fungi != null) {
|
||||
all.addAll(fungi);
|
||||
}
|
||||
if (crystals != null) {
|
||||
all.addAll(crystals);
|
||||
}
|
||||
addPlaceable(all, ruins, ResolvedRuin::new);
|
||||
addPlaceable(all, formations, ResolvedFormation::new);
|
||||
addPlaceable(all, coral, ResolvedCoral::new);
|
||||
addPlaceable(all, fungi, ResolvedFungus::new);
|
||||
addPlaceable(all, crystals, ResolvedCrystal::new);
|
||||
return all;
|
||||
}
|
||||
|
||||
/** The settings in {@code settings}, each made placeable once, in order. */
|
||||
@SuppressWarnings("unchecked")
|
||||
private <S> void addPlaceable(KList<IrisProceduralPlacement> all, KList<S> settings, Function<S, ResolvedProceduralPlacement> resolve) {
|
||||
if (settings == null) {
|
||||
return;
|
||||
}
|
||||
for (S entry : settings) {
|
||||
all.add(placeables.computeIfAbsent(entry, key -> resolve.apply((S) key)));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return getAllPlacements().isEmpty();
|
||||
}
|
||||
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/**
|
||||
* A procedural object's settings made placeable: bakes a deterministic pool of variants from them, once, and turns
|
||||
* the placement options into the object placement the engine scatters. The settings classes held the same cache
|
||||
* and methods before they became module settings.
|
||||
*/
|
||||
public abstract class ResolvedProceduralPlacement implements IrisProceduralPlacement {
|
||||
private static final long VARIANT_SEED_STRIDE = 7919L;
|
||||
|
||||
/** The options every procedural placement shares with an object placement. */
|
||||
public record Shape(String name, double chance, int density, long seed, int variants, ObjectPlaceMode mode,
|
||||
ObjectRotation rotation, ObjectLimit clamp, CarvingMode carvingSupport, boolean underwater,
|
||||
ObjectTranslate translate, StiltSettings stiltSettings, VacuumSettings vacuumSettings) {
|
||||
}
|
||||
|
||||
private final Shape shape;
|
||||
private final AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
protected ResolvedProceduralPlacement(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
/** The object variant {@code index} is baked as, from its own seeded stream. */
|
||||
protected abstract IrisObject generate(int index, RNG rng, IrisData data);
|
||||
|
||||
/** The number of variants to bake; the settings' count, at least one. */
|
||||
protected int variantCount() {
|
||||
return Math.max(1, shape.variants());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return shape.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getChance() {
|
||||
return shape.chance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDensity() {
|
||||
return shape.density();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> bake(data));
|
||||
}
|
||||
|
||||
/** Bakes every variant; the default draws variant {@code i} from {@code seed + i * stride}. */
|
||||
protected KList<IrisObject> bake(IrisData data) {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = variantCount();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = generate(i, variantRng(i), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + shape.name() + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
}
|
||||
|
||||
protected final RNG variantRng(int index) {
|
||||
return new RNG(shape.seed() + (index * VARIANT_SEED_STRIDE));
|
||||
}
|
||||
|
||||
protected final long seed() {
|
||||
return shape.seed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(shape.mode());
|
||||
placement.setRotation(irisRotation(shape.rotation()));
|
||||
placement.setClamp(shape.clamp());
|
||||
placement.setCarvingSupport(shape.carvingSupport());
|
||||
placement.setUnderwater(shape.underwater());
|
||||
placement.setTranslate(irisTranslate(shape.translate()));
|
||||
placement.setStiltSettings(shape.stiltSettings());
|
||||
placement.setVacuumSettings(shape.vacuumSettings());
|
||||
placement.setChance(shape.chance());
|
||||
placement.setDensity(shape.density());
|
||||
customize(placement);
|
||||
return placement;
|
||||
}
|
||||
|
||||
/** Sets what this kind of placement adds to the common options. */
|
||||
protected void customize(IrisObjectPlacement placement) {
|
||||
}
|
||||
|
||||
private static IrisObjectRotation irisRotation(ObjectRotation rotation) {
|
||||
return new IrisObjectRotation()
|
||||
.setEnabled(rotation.enabled())
|
||||
.setXAxis(rotation.xAxis())
|
||||
.setYAxis(rotation.yAxis())
|
||||
.setZAxis(rotation.zAxis());
|
||||
}
|
||||
|
||||
private static IrisObjectTranslate irisTranslate(ObjectTranslate translate) {
|
||||
return new IrisObjectTranslate(translate.x(), translate.y(), translate.yRandom(), translate.z());
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.coral.IrisCoral;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
@@ -36,14 +36,14 @@ public final class CoralGenerator {
|
||||
private CoralGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisCoral coral, int variantIndex, RNG rng, IrisData data) {
|
||||
int lo = Math.min(coral.getHeightMin(), coral.getHeightMax());
|
||||
int hi = Math.max(coral.getHeightMin(), coral.getHeightMax());
|
||||
public static IrisObject generate(Coral coral, int variantIndex, RNG rng, IrisData data) {
|
||||
int lo = Math.min(coral.heightMin(), coral.heightMax());
|
||||
int hi = Math.max(coral.heightMin(), coral.heightMax());
|
||||
int height = Math.max(2, rng.i(lo, hi + 1));
|
||||
long shapeSeed = rng.getSeed() + variantIndex * 31L;
|
||||
|
||||
CoralCanvas canvas = new CoralCanvas();
|
||||
switch (coral.getForm()) {
|
||||
switch (coral.form()) {
|
||||
case BRANCHING -> buildBranching(canvas, coral, height, shapeSeed, rng);
|
||||
case FAN -> buildFan(canvas, coral, height, shapeSeed);
|
||||
case BRAIN -> buildBrain(canvas, coral, height, shapeSeed);
|
||||
@@ -55,39 +55,39 @@ public final class CoralGenerator {
|
||||
return IrisProceduralBlocks.assemble(resolved);
|
||||
}
|
||||
|
||||
private static void buildBranching(CoralCanvas canvas, IrisCoral coral, int height, long seed, RNG rng) {
|
||||
private static void buildBranching(CoralCanvas canvas, Coral coral, int height, long seed, RNG rng) {
|
||||
int stalkTop = Math.max(1, (int) Math.round(height * 0.5));
|
||||
for (int y = 0; y < stalkTop; y++) {
|
||||
placeWavy(canvas, coral, 0, y, 0, y, seed, CoralCanvas.Role.STRUCTURE);
|
||||
}
|
||||
|
||||
int count = Math.max(1, coral.getBranchCount());
|
||||
int count = Math.max(1, coral.branchCount());
|
||||
for (int b = 0; b < count; b++) {
|
||||
double az = branchAzimuth(coral, b, count, rng);
|
||||
int startY = stalkTop - 1 + (int) Math.round((b % 2) * 1.0);
|
||||
double[] tip = rasterizeArm(canvas, coral, 0, startY, 0, az,
|
||||
coral.getBranchElevation(), coral.getBranchLength(), seed + b * 131L);
|
||||
coral.branchElevation(), coral.branchLength(), seed + b * 131L);
|
||||
|
||||
placeTipCluster(canvas, coral, (int) Math.round(tip[0]), (int) Math.round(tip[1]), (int) Math.round(tip[2]),
|
||||
coral.getTipClusterRadius(), seed + b * 977L);
|
||||
coral.tipClusterRadius(), seed + b * 977L);
|
||||
|
||||
if (coral.isSubBranches()) {
|
||||
int subCount = Math.max(1, coral.getSubBranchCount());
|
||||
if (coral.subBranches()) {
|
||||
int subCount = Math.max(1, coral.subBranchCount());
|
||||
for (int s = 0; s < subCount; s++) {
|
||||
double subAz = az + (s - (subCount - 1) / 2.0) * 35.0;
|
||||
double subLen = coral.getBranchLength() * coral.getSubBranchScale();
|
||||
double subLen = coral.branchLength() * coral.subBranchScale();
|
||||
double[] subTip = rasterizeArm(canvas, coral,
|
||||
(int) Math.round(tip[0]), (int) Math.round(tip[1]), (int) Math.round(tip[2]),
|
||||
subAz, coral.getBranchElevation() + 10.0, subLen, seed + b * 131L + s * 17L + 5000L);
|
||||
subAz, coral.branchElevation() + 10.0, subLen, seed + b * 131L + s * 17L + 5000L);
|
||||
placeTipCluster(canvas, coral, (int) Math.round(subTip[0]), (int) Math.round(subTip[1]), (int) Math.round(subTip[2]),
|
||||
Math.max(0, coral.getTipClusterRadius() - 1), seed + b * 977L + s * 53L);
|
||||
Math.max(0, coral.tipClusterRadius() - 1), seed + b * 977L + s * 53L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildFan(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
|
||||
int half = Math.max(1, coral.getFanWidth());
|
||||
private static void buildFan(CoralCanvas canvas, Coral coral, int height, long seed) {
|
||||
int half = Math.max(1, coral.fanWidth());
|
||||
for (int y = 0; y < height; y++) {
|
||||
double t = y / (double) Math.max(1, height - 1);
|
||||
double profile = Math.sin(Math.PI * t);
|
||||
@@ -101,10 +101,10 @@ public final class CoralGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildBrain(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
|
||||
int r = Math.max(1, coral.getBrainRadius());
|
||||
private static void buildBrain(CoralCanvas canvas, Coral coral, int height, long seed) {
|
||||
int r = Math.max(1, coral.brainRadius());
|
||||
int ry = Math.max(1, Math.min(r, (int) Math.round(height * 0.6)));
|
||||
double rough = coral.getBrainRoughness();
|
||||
double rough = coral.brainRoughness();
|
||||
for (int dx = -r; dx <= r; dx++) {
|
||||
for (int dz = -r; dz <= r; dz++) {
|
||||
for (int dy = 0; dy <= ry * 2; dy++) {
|
||||
@@ -121,8 +121,8 @@ public final class CoralGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildPillar(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
|
||||
int r = Math.max(1, coral.getPillarRadius());
|
||||
private static void buildPillar(CoralCanvas canvas, Coral coral, int height, long seed) {
|
||||
int r = Math.max(1, coral.pillarRadius());
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int dx = -r; dx <= r; dx++) {
|
||||
for (int dz = -r; dz <= r; dz++) {
|
||||
@@ -132,12 +132,12 @@ public final class CoralGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
placeTipCluster(canvas, coral, 0, height - 1, 0, coral.getTipClusterRadius(), seed);
|
||||
placeTipCluster(canvas, coral, 0, height - 1, 0, coral.tipClusterRadius(), seed);
|
||||
}
|
||||
|
||||
private static void buildTendril(CoralCanvas canvas, IrisCoral coral, int height, long seed, RNG rng) {
|
||||
int count = Math.max(1, coral.getTendrilCount());
|
||||
double radius = Math.max(0.0, coral.getSpread());
|
||||
private static void buildTendril(CoralCanvas canvas, Coral coral, int height, long seed, RNG rng) {
|
||||
int count = Math.max(1, coral.tendrilCount());
|
||||
double radius = Math.max(0.0, coral.spread());
|
||||
for (int c = 0; c < count; c++) {
|
||||
double az = Math.toRadians(c * (360.0 / count));
|
||||
double bx = Math.cos(az) * radius * 0.5;
|
||||
@@ -153,7 +153,7 @@ public final class CoralGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static double[] rasterizeArm(CoralCanvas canvas, IrisCoral coral, int ox, int oy, int oz,
|
||||
private static double[] rasterizeArm(CoralCanvas canvas, Coral coral, int ox, int oy, int oz,
|
||||
double azimuthDeg, double elevationDeg, double length, long seed) {
|
||||
double azRad = Math.toRadians(azimuthDeg);
|
||||
double elRad = Math.toRadians(elevationDeg);
|
||||
@@ -175,23 +175,23 @@ public final class CoralGenerator {
|
||||
return tip;
|
||||
}
|
||||
|
||||
private static void placeWavy(CoralCanvas canvas, IrisCoral coral, int x, int y, int z, double phase, long seed, CoralCanvas.Role role) {
|
||||
private static void placeWavy(CoralCanvas canvas, Coral coral, int x, int y, int z, double phase, long seed, CoralCanvas.Role role) {
|
||||
double sway = swayOffset(coral, phase, seed);
|
||||
int sx = (int) Math.round(sway);
|
||||
int sz = (int) Math.round(swayOffset(coral, phase + 53.0, seed + 7L));
|
||||
canvas.set(x + sx, y, z + sz, role);
|
||||
}
|
||||
|
||||
private static double swayOffset(IrisCoral coral, double phase, long seed) {
|
||||
double amount = Math.max(0.0, Math.min(1.0, coral.getSway()));
|
||||
private static double swayOffset(Coral coral, double phase, long seed) {
|
||||
double amount = Math.max(0.0, Math.min(1.0, coral.sway()));
|
||||
if (amount <= 0.0) {
|
||||
return 0.0;
|
||||
}
|
||||
double n = TreeFunctions.valueNoise1D(phase * 0.35, seed) - 0.5;
|
||||
return n * 2.0 * amount * (1.0 + coral.getSpread() * 0.25);
|
||||
return n * 2.0 * amount * (1.0 + coral.spread() * 0.25);
|
||||
}
|
||||
|
||||
private static void placeTipCluster(CoralCanvas canvas, IrisCoral coral, int cx, int cy, int cz, int radius, long seed) {
|
||||
private static void placeTipCluster(CoralCanvas canvas, Coral coral, int cx, int cy, int cz, int radius, long seed) {
|
||||
if (radius <= 0) {
|
||||
placeTip(canvas, coral, cx, cy, cz, seed);
|
||||
return;
|
||||
@@ -208,31 +208,31 @@ public final class CoralGenerator {
|
||||
placeTip(canvas, coral, cx, cy + radius + 1, cz, seed);
|
||||
}
|
||||
|
||||
private static void placeTip(CoralCanvas canvas, IrisCoral coral, int x, int y, int z, long seed) {
|
||||
private static void placeTip(CoralCanvas canvas, Coral coral, int x, int y, int z, long seed) {
|
||||
if (!hasTip(coral)) {
|
||||
return;
|
||||
}
|
||||
if (TreeFunctions.valueNoise1D(x * 31.0 + y * 17.0 + z * 13.0, seed) <= coral.getTipChance()) {
|
||||
if (TreeFunctions.valueNoise1D(x * 31.0 + y * 17.0 + z * 13.0, seed) <= coral.tipChance()) {
|
||||
canvas.set(x, y, z, CoralCanvas.Role.TIP);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasTip(IrisCoral coral) {
|
||||
return IrisProceduralBlocks.paletteSet(coral.getTipPalette())
|
||||
|| (coral.getTipBlock() != null && !coral.getTipBlock().isEmpty());
|
||||
private static boolean hasTip(Coral coral) {
|
||||
return IrisProceduralBlocks.paletteSet(coral.tipPalette())
|
||||
|| (coral.tipBlock() != null && !coral.tipBlock().isEmpty());
|
||||
}
|
||||
|
||||
private static double branchAzimuth(IrisCoral coral, int index, int count, RNG rng) {
|
||||
return switch (coral.getBranchAzimuth()) {
|
||||
private static double branchAzimuth(Coral coral, int index, int count, RNG rng) {
|
||||
return switch (coral.branchAzimuth()) {
|
||||
case GOLDEN_ANGLE -> index * GOLDEN_ANGLE;
|
||||
case EVEN -> index * (360.0 / count);
|
||||
case RANDOM -> rng.d(0.0, 360.0);
|
||||
};
|
||||
}
|
||||
|
||||
private static Map<Vector3i, PlatformBlockState> resolve(CoralCanvas canvas, IrisCoral coral, IrisData data) {
|
||||
private static Map<Vector3i, PlatformBlockState> resolve(CoralCanvas canvas, Coral coral, IrisData data) {
|
||||
Map<Vector3i, PlatformBlockState> out = new HashMap<>();
|
||||
RNG paletteRng = new RNG(coral.getSeed());
|
||||
RNG paletteRng = new RNG(coral.seed());
|
||||
for (Map.Entry<Long, CoralCanvas.Role> entry : canvas.getCells().entrySet()) {
|
||||
int[] xyz = CoralCanvas.decode(entry.getKey());
|
||||
int x = xyz[0];
|
||||
@@ -240,17 +240,17 @@ public final class CoralGenerator {
|
||||
int z = xyz[2];
|
||||
PlatformBlockState state;
|
||||
if (entry.getValue() == CoralCanvas.Role.TIP) {
|
||||
state = IrisProceduralBlocks.resolve(coral.getTipBlock(), coral.getTipPalette(), data, x, y, z, paletteRng);
|
||||
state = IrisProceduralBlocks.resolve(coral.tipBlock(), coral.tipPalette(), data, x, y, z, paletteRng);
|
||||
if (state == null) {
|
||||
state = IrisProceduralBlocks.resolve(coral.getBlock(), coral.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
state = IrisProceduralBlocks.resolve(coral.block(), coral.blockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
} else {
|
||||
state = IrisProceduralBlocks.resolve(coral.getBlock(), coral.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
state = IrisProceduralBlocks.resolve(coral.block(), coral.blockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
if (state == null) {
|
||||
continue;
|
||||
}
|
||||
if (coral.isWaterlogged() && IrisProceduralBlocks.hasProperty(state, "waterlogged")) {
|
||||
if (coral.waterlogged() && IrisProceduralBlocks.hasProperty(state, "waterlogged")) {
|
||||
try {
|
||||
state = state.withProperty("waterlogged", "true");
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A coral reef made placeable: its variants are baked by {@link CoralGenerator}. */
|
||||
public final class ResolvedCoral extends ResolvedProceduralPlacement {
|
||||
private final Coral settings;
|
||||
|
||||
public ResolvedCoral(Coral settings) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
return CoralGenerator.generate(settings, index, rng, data);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -18,21 +18,21 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
|
||||
public final class CrystalBaseBuilder {
|
||||
private CrystalBaseBuilder() {
|
||||
}
|
||||
|
||||
public static void build(CrystalCanvas canvas, IrisCrystal crystal, long seed) {
|
||||
double radius = crystal.getBaseRadius();
|
||||
public static void build(CrystalCanvas canvas, Crystal crystal, long seed) {
|
||||
double radius = crystal.baseRadius();
|
||||
if (radius <= 0.0) {
|
||||
canvas.set(0, 0, 0, CrystalRole.BASE);
|
||||
return;
|
||||
}
|
||||
|
||||
double noiseStrength = crystal.getBaseNoise();
|
||||
double noiseStrength = crystal.baseNoise();
|
||||
int reach = (int) Math.ceil(radius + 1.0);
|
||||
for (int x = -reach; x <= reach; x++) {
|
||||
for (int y = -reach; y <= reach; y++) {
|
||||
|
||||
+20
-19
@@ -18,8 +18,9 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -33,7 +34,7 @@ public final class CrystalGenerator {
|
||||
private CrystalGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisCrystal crystal, int variantIndex, RNG rng, IrisData data) {
|
||||
public static IrisObject generate(Crystal crystal, int variantIndex, RNG rng, IrisData data) {
|
||||
CrystalCanvas canvas = new CrystalCanvas();
|
||||
long structureSeed = rng.getSeed();
|
||||
|
||||
@@ -41,8 +42,8 @@ public final class CrystalGenerator {
|
||||
CrystalShardBuilder.build(canvas, crystal, rng);
|
||||
|
||||
Map<Vector3i, PlatformBlockState> resolved = new HashMap<>();
|
||||
RNG paletteRng = new RNG(crystal.getSeed());
|
||||
RNG tipRng = new RNG(crystal.getSeed() + (variantIndex * 31337L) + 4099L);
|
||||
RNG paletteRng = new RNG(crystal.seed());
|
||||
RNG tipRng = new RNG(crystal.seed() + (variantIndex * 31337L) + 4099L);
|
||||
|
||||
for (Map.Entry<Vector3i, CrystalRole> entry : canvas.getCells().entrySet()) {
|
||||
Vector3i position = entry.getKey();
|
||||
@@ -59,7 +60,7 @@ public final class CrystalGenerator {
|
||||
return IrisProceduralBlocks.assemble(resolved);
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveRole(IrisCrystal crystal, CrystalRole role, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
|
||||
private static PlatformBlockState resolveRole(Crystal crystal, CrystalRole role, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
|
||||
return switch (role) {
|
||||
case BASE -> resolveBase(crystal, data, x, y, z, paletteRng);
|
||||
case SHARD -> resolveShard(crystal, data, x, y, z, paletteRng);
|
||||
@@ -67,11 +68,11 @@ public final class CrystalGenerator {
|
||||
};
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveBase(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
boolean hasBase = IrisProceduralBlocks.paletteSet(crystal.getBasePalette())
|
||||
|| (crystal.getBaseBlock() != null && !crystal.getBaseBlock().isEmpty());
|
||||
private static PlatformBlockState resolveBase(Crystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
boolean hasBase = IrisProceduralBlocks.paletteSet(crystal.basePalette())
|
||||
|| (crystal.baseBlock() != null && !crystal.baseBlock().isEmpty());
|
||||
if (hasBase) {
|
||||
PlatformBlockState base = IrisProceduralBlocks.resolve(crystal.getBaseBlock(), crystal.getBasePalette(), data, x, y, z, paletteRng);
|
||||
PlatformBlockState base = IrisProceduralBlocks.resolve(crystal.baseBlock(), crystal.basePalette(), data, x, y, z, paletteRng);
|
||||
if (base != null) {
|
||||
return base;
|
||||
}
|
||||
@@ -79,17 +80,17 @@ public final class CrystalGenerator {
|
||||
return resolveShard(crystal, data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveShard(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
return IrisProceduralBlocks.resolve(crystal.getBlock(), crystal.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
private static PlatformBlockState resolveShard(Crystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
return IrisProceduralBlocks.resolve(crystal.block(), crystal.blockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveTip(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
|
||||
boolean hasTip = IrisProceduralBlocks.paletteSet(crystal.getTipPalette())
|
||||
|| (crystal.getTipBlock() != null && !crystal.getTipBlock().isEmpty());
|
||||
private static PlatformBlockState resolveTip(Crystal crystal, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
|
||||
boolean hasTip = IrisProceduralBlocks.paletteSet(crystal.tipPalette())
|
||||
|| (crystal.tipBlock() != null && !crystal.tipBlock().isEmpty());
|
||||
|
||||
if (hasTip) {
|
||||
if (tipRng.chance(crystal.getTipChance())) {
|
||||
PlatformBlockState tip = IrisProceduralBlocks.resolve(crystal.getTipBlock(), crystal.getTipPalette(), data, x, y, z, paletteRng);
|
||||
if (tipRng.chance(crystal.tipChance())) {
|
||||
PlatformBlockState tip = IrisProceduralBlocks.resolve(crystal.tipBlock(), crystal.tipPalette(), data, x, y, z, paletteRng);
|
||||
if (tip != null) {
|
||||
return tip;
|
||||
}
|
||||
@@ -97,9 +98,9 @@ public final class CrystalGenerator {
|
||||
return resolveShard(crystal, data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
if (crystal.isGlow() && crystal.getGlowBlock() != null && !crystal.getGlowBlock().isEmpty()) {
|
||||
if (tipRng.chance(crystal.getTipChance())) {
|
||||
PlatformBlockState glow = IrisProceduralBlocks.resolve(crystal.getGlowBlock(), null, data, x, y, z, paletteRng);
|
||||
if (crystal.glow() && crystal.glowBlock() != null && !crystal.glowBlock().isEmpty()) {
|
||||
if (tipRng.chance(crystal.tipChance())) {
|
||||
PlatformBlockState glow = IrisProceduralBlocks.resolve(crystal.glowBlock(), (PaletteSpec) null, data, x, y, z, paletteRng);
|
||||
if (glow != null) {
|
||||
return glow;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystalSurface;
|
||||
import art.arcane.iris.builtin.objects.crystal.CrystalSurface;
|
||||
|
||||
|
||||
public final class CrystalGeometry {
|
||||
private CrystalGeometry() {
|
||||
}
|
||||
|
||||
public static double[] surfaceNormal(IrisCrystalSurface surface) {
|
||||
public static double[] surfaceNormal(CrystalSurface surface) {
|
||||
return switch (surface) {
|
||||
case FLOOR -> new double[]{0.0, 1.0, 0.0};
|
||||
case CEILING -> new double[]{0.0, -1.0, 0.0};
|
||||
|
||||
+17
-17
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystalDistribution;
|
||||
import art.arcane.iris.builtin.objects.crystal.CrystalDistribution;
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
public final class CrystalShardBuilder {
|
||||
@@ -28,24 +28,24 @@ public final class CrystalShardBuilder {
|
||||
private CrystalShardBuilder() {
|
||||
}
|
||||
|
||||
public static void build(CrystalCanvas canvas, IrisCrystal crystal, RNG rng) {
|
||||
double[] normal = CrystalGeometry.surfaceNormal(crystal.getGrowthSurface());
|
||||
public static void build(CrystalCanvas canvas, Crystal crystal, RNG rng) {
|
||||
double[] normal = CrystalGeometry.surfaceNormal(crystal.growthSurface());
|
||||
double[] u = CrystalGeometry.orthonormalBasisU(normal);
|
||||
double[] v = CrystalGeometry.orthonormalBasisV(normal, u);
|
||||
|
||||
int countLo = Math.min(crystal.getShardCountMin(), crystal.getShardCountMax());
|
||||
int countHi = Math.max(crystal.getShardCountMin(), crystal.getShardCountMax());
|
||||
int countLo = Math.min(crystal.shardCountMin(), crystal.shardCountMax());
|
||||
int countHi = Math.max(crystal.shardCountMin(), crystal.shardCountMax());
|
||||
int shardCount = Math.max(1, rng.i(countLo, countHi + 1));
|
||||
|
||||
int lengthLo = Math.min(crystal.getShardLengthMin(), crystal.getShardLengthMax());
|
||||
int lengthHi = Math.max(crystal.getShardLengthMin(), crystal.getShardLengthMax());
|
||||
int lengthLo = Math.min(crystal.shardLengthMin(), crystal.shardLengthMax());
|
||||
int lengthHi = Math.max(crystal.shardLengthMin(), crystal.shardLengthMax());
|
||||
|
||||
double spreadRadians = Math.toRadians(Math.max(0.0, Math.min(90.0, crystal.getSpreadAngle())));
|
||||
double jitterAmount = Math.max(0.0, Math.min(1.0, crystal.getJitter()));
|
||||
double emitRadius = Math.max(0.0, crystal.getBaseRadius() * 0.6);
|
||||
double spreadRadians = Math.toRadians(Math.max(0.0, Math.min(90.0, crystal.spreadAngle())));
|
||||
double jitterAmount = Math.max(0.0, Math.min(1.0, crystal.jitter()));
|
||||
double emitRadius = Math.max(0.0, crystal.baseRadius() * 0.6);
|
||||
|
||||
for (int i = 0; i < shardCount; i++) {
|
||||
double azimuth = azimuth(crystal.getDistribution(), i, rng);
|
||||
double azimuth = azimuth(crystal.distribution(), i, rng);
|
||||
azimuth += rng.d(-Math.PI, Math.PI) * jitterAmount * 0.5;
|
||||
|
||||
double cone = spreadRadians * fanFraction(shardCount, i, rng);
|
||||
@@ -63,9 +63,9 @@ public final class CrystalShardBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void rasterizeShard(CrystalCanvas canvas, IrisCrystal crystal, double ox, double oy, double oz, double[] direction, int length) {
|
||||
double baseRadius = Math.max(0.5, crystal.getShardBaseRadius());
|
||||
double taper = Math.max(0.0, Math.min(1.0, crystal.getShardTaper()));
|
||||
private static void rasterizeShard(CrystalCanvas canvas, Crystal crystal, double ox, double oy, double oz, double[] direction, int length) {
|
||||
double baseRadius = Math.max(0.5, crystal.shardBaseRadius());
|
||||
double taper = Math.max(0.0, Math.min(1.0, crystal.shardTaper()));
|
||||
|
||||
int samples = Math.max(1, length * 3);
|
||||
|
||||
@@ -108,8 +108,8 @@ public final class CrystalShardBuilder {
|
||||
canvas.set(tipX, tipY, tipZ, CrystalRole.TIP);
|
||||
}
|
||||
|
||||
private static double azimuth(IrisCrystalDistribution distribution, int index, RNG rng) {
|
||||
if (distribution == IrisCrystalDistribution.GOLDEN_ANGLE) {
|
||||
private static double azimuth(CrystalDistribution distribution, int index, RNG rng) {
|
||||
if (distribution == CrystalDistribution.GOLDEN_ANGLE) {
|
||||
return Math.toRadians(index * GOLDEN_ANGLE);
|
||||
}
|
||||
return rng.d(0.0, Math.PI * 2.0);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A crystal cluster made placeable: its variants are baked by {@link CrystalGenerator}. */
|
||||
public final class ResolvedCrystal extends ResolvedProceduralPlacement {
|
||||
private final Crystal settings;
|
||||
|
||||
public ResolvedCrystal(Crystal settings) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
return CrystalGenerator.generate(settings, index, rng, data);
|
||||
}
|
||||
}
|
||||
+14
-12
@@ -18,8 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import java.util.Optional;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -30,37 +32,37 @@ public final class FormationBlockResolver {
|
||||
private FormationBlockResolver() {
|
||||
}
|
||||
|
||||
public static PlatformBlockState resolve(IrisFormation f, IrisData data, FormationCanvas.Role role, Vector3i raw) {
|
||||
public static PlatformBlockState resolve(Formation f, IrisData data, FormationCanvas.Role role, Vector3i raw) {
|
||||
int x = raw.getBlockX();
|
||||
int y = raw.getBlockY();
|
||||
int z = raw.getBlockZ();
|
||||
RNG paletteRng = new RNG(f.getSeed());
|
||||
RNG paletteRng = new RNG(f.seed());
|
||||
|
||||
if (role == FormationCanvas.Role.CAP && capDefined(f)) {
|
||||
PlatformBlockState cap = IrisProceduralBlocks.resolve(f.getCapBlock(), f.getCapPalette(), data, x, y, z, paletteRng);
|
||||
PlatformBlockState cap = IrisProceduralBlocks.resolve(f.capBlock(), f.capPalette(), data, x, y, z, paletteRng);
|
||||
if (cap != null) {
|
||||
return cap;
|
||||
}
|
||||
}
|
||||
|
||||
if (strataDefined(f)) {
|
||||
IrisMaterialPalette strata = f.getStrataPalette();
|
||||
int thickness = Math.max(1, f.getStrataThickness());
|
||||
PaletteSpec strata = f.strataPalette().orElseThrow();
|
||||
int thickness = Math.max(1, f.strataThickness());
|
||||
int band = Math.floorDiv(y, thickness);
|
||||
PlatformBlockState strataState = strata.get(new RNG(f.getSeed() + (band * 31L)), x, band, z, data);
|
||||
PlatformBlockState strataState = IrisProceduralBlocks.pick(strata, data, f.seed() + (band * 31L), x, band, z);
|
||||
if (strataState != null) {
|
||||
return strataState;
|
||||
}
|
||||
}
|
||||
|
||||
return IrisProceduralBlocks.resolve(f.getBlock(), f.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
return IrisProceduralBlocks.resolve(f.block(), f.blockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
private static boolean capDefined(IrisFormation f) {
|
||||
return IrisProceduralBlocks.paletteSet(f.getCapPalette()) || (f.getCapBlock() != null && !f.getCapBlock().isEmpty());
|
||||
private static boolean capDefined(Formation f) {
|
||||
return IrisProceduralBlocks.paletteSet(f.capPalette()) || f.capBlock().filter(block -> !block.isEmpty()).isPresent();
|
||||
}
|
||||
|
||||
private static boolean strataDefined(IrisFormation f) {
|
||||
return IrisProceduralBlocks.paletteSet(f.getStrataPalette());
|
||||
private static boolean strataDefined(Formation f) {
|
||||
return IrisProceduralBlocks.paletteSet(f.strataPalette());
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -33,18 +33,18 @@ public final class FormationGenerator {
|
||||
private FormationGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisFormation f, int variantIndex, RNG rng, IrisData data) {
|
||||
int lo = Math.min(f.getHeightMin(), f.getHeightMax());
|
||||
int hi = Math.max(f.getHeightMin(), f.getHeightMax());
|
||||
public static IrisObject generate(Formation f, int variantIndex, RNG rng, IrisData data) {
|
||||
int lo = Math.min(f.heightMin(), f.heightMax());
|
||||
int hi = Math.max(f.heightMin(), f.heightMax());
|
||||
int height = Math.max(3, rng.i(lo, hi + 1));
|
||||
|
||||
int wLo = Math.min(f.getBaseWidthMin(), f.getBaseWidthMax());
|
||||
int wHi = Math.max(f.getBaseWidthMin(), f.getBaseWidthMax());
|
||||
int wLo = Math.min(f.baseWidthMin(), f.baseWidthMax());
|
||||
int wHi = Math.max(f.baseWidthMin(), f.baseWidthMax());
|
||||
double baseRadius = Math.max(1, rng.i(wLo, wHi + 1));
|
||||
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
|
||||
switch (f.getForm()) {
|
||||
switch (f.form()) {
|
||||
case SPIRE -> FormationShapeBuilder.spire(canvas, f, height, baseRadius, rng);
|
||||
case HOODOO -> FormationShapeBuilder.hoodoo(canvas, f, height, baseRadius, rng);
|
||||
case ARCH -> FormationShapeBuilder.arch(canvas, f, height, baseRadius, rng);
|
||||
|
||||
+7
-6
@@ -18,15 +18,16 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
|
||||
|
||||
public final class FormationProfiles {
|
||||
private FormationProfiles() {
|
||||
}
|
||||
|
||||
public static double radiusAt(IrisFormation f, double baseRadius, double topRadius, double t) {
|
||||
public static double radiusAt(Formation f, double baseRadius, double topRadius, double t) {
|
||||
double clamped = Math.max(0.0, Math.min(1.0, t));
|
||||
return switch (f.getProfile()) {
|
||||
return switch (f.profile()) {
|
||||
case CONSTANT -> baseRadius;
|
||||
case LINEAR -> baseRadius + (topRadius - baseRadius) * clamped;
|
||||
case TAPER -> baseRadius + (topRadius - baseRadius) * smoothstep(clamped);
|
||||
@@ -35,9 +36,9 @@ public final class FormationProfiles {
|
||||
};
|
||||
}
|
||||
|
||||
private static double parabolic(IrisFormation f, double baseRadius, double topRadius, double t) {
|
||||
double waist = Math.max(0.0, Math.min(1.0, f.getProfileWaist()));
|
||||
double floor = Math.max(0.0, Math.min(1.0, f.getProfileWaistFloor()));
|
||||
private static double parabolic(Formation f, double baseRadius, double topRadius, double t) {
|
||||
double waist = Math.max(0.0, Math.min(1.0, f.profileWaist()));
|
||||
double floor = Math.max(0.0, Math.min(1.0, f.profileWaistFloor()));
|
||||
double denom = Math.pow(Math.max(waist, 1.0 - waist), 2);
|
||||
if (denom == 0) {
|
||||
denom = 1;
|
||||
|
||||
+53
-53
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -30,11 +30,11 @@ public final class FormationShapeBuilder {
|
||||
private FormationShapeBuilder() {
|
||||
}
|
||||
|
||||
public static void spire(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = f.getTopWidth();
|
||||
public static void spire(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = f.topWidth();
|
||||
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, true);
|
||||
double lean = Math.toRadians(f.getLean());
|
||||
double azimuth = Math.toRadians(f.getLeanAzimuth());
|
||||
double lean = Math.toRadians(f.lean());
|
||||
double azimuth = Math.toRadians(f.leanAzimuth());
|
||||
int previousX = 0;
|
||||
int previousZ = 0;
|
||||
for (int y = 0; y < height; y++) {
|
||||
@@ -53,25 +53,25 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void seaStack(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
public static void seaStack(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = Math.max(1.0, baseRadius * 0.55);
|
||||
if (f.getTopWidth() > 0) {
|
||||
topRadius = f.getTopWidth();
|
||||
if (f.topWidth() > 0) {
|
||||
topRadius = f.topWidth();
|
||||
}
|
||||
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, true);
|
||||
}
|
||||
|
||||
public static void hoodoo(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = f.getTopWidth() > 0 ? f.getTopWidth() : Math.max(1.0, baseRadius * 0.7);
|
||||
public static void hoodoo(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = f.topWidth() > 0 ? f.topWidth() : Math.max(1.0, baseRadius * 0.7);
|
||||
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, false);
|
||||
|
||||
int capRadius = f.getHoodooCapRadius();
|
||||
int capRadius = f.hoodooCapRadius();
|
||||
if (capRadius <= 0) {
|
||||
return;
|
||||
}
|
||||
int capHeight = Math.max(1, f.getHoodooCapHeight());
|
||||
double lean = Math.toRadians(f.getLean());
|
||||
double azimuth = Math.toRadians(f.getLeanAzimuth());
|
||||
int capHeight = Math.max(1, f.hoodooCapHeight());
|
||||
double lean = Math.toRadians(f.lean());
|
||||
double azimuth = Math.toRadians(f.leanAzimuth());
|
||||
double shear = Math.tan(lean) * height;
|
||||
double topOffX = Math.cos(azimuth) * shear;
|
||||
double topOffZ = Math.sin(azimuth) * shear;
|
||||
@@ -85,12 +85,12 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void boulder(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
public static void boulder(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
double rx = baseRadius;
|
||||
double ry = Math.max(2.0, height * 0.5);
|
||||
double rz = baseRadius * (0.8 + rng.d(0.0, 0.3));
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
long noiseSeed = f.getSeed() + 4201L;
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
|
||||
long noiseSeed = f.seed() + 4201L;
|
||||
|
||||
int maxR = (int) Math.ceil(Math.max(rx, Math.max(ry, rz))) + 2;
|
||||
for (int x = -maxR; x <= maxR; x++) {
|
||||
@@ -109,10 +109,10 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void arch(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double span = Math.max(2.0, f.getArchSpan());
|
||||
double tubeRadius = Math.max(0.75, f.getArchThickness() * 0.5);
|
||||
double asymmetry = Math.max(0.0, Math.min(1.0, f.getArchAsymmetry()));
|
||||
public static void arch(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
double span = Math.max(2.0, f.archSpan());
|
||||
double tubeRadius = Math.max(0.75, f.archThickness() * 0.5);
|
||||
double asymmetry = Math.max(0.0, Math.min(1.0, f.archAsymmetry()));
|
||||
double leftFootX = -span * 0.5 - tubeRadius - rng.d(0.0, span * 0.16) * asymmetry;
|
||||
double rightFootX = span * 0.5 + tubeRadius + rng.d(0.0, span * 0.16) * asymmetry;
|
||||
double leftFootZ = rng.d(-tubeRadius * 0.45, tubeRadius * 0.45) * asymmetry;
|
||||
@@ -164,10 +164,10 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void basaltColumns(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
int count = Math.max(2, f.getBasaltColumns());
|
||||
int colRadius = Math.max(1, f.getBasaltColumnRadius());
|
||||
double variance = Math.max(0.0, Math.min(1.0, f.getBasaltHeightVariance()));
|
||||
public static void basaltColumns(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
int count = Math.max(2, f.basaltColumns());
|
||||
int colRadius = Math.max(1, f.basaltColumnRadius());
|
||||
double variance = Math.max(0.0, Math.min(1.0, f.basaltHeightVariance()));
|
||||
int spread = (int) Math.ceil(baseRadius);
|
||||
|
||||
for (int c = 0; c < count; c++) {
|
||||
@@ -194,14 +194,14 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void iceberg(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
public static void iceberg(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
long noiseSeed = rng.nextLong();
|
||||
double bodyHeight = Math.max(2.0, height * 0.42);
|
||||
double radiusX = baseRadius * rng.d(1.15, 1.5);
|
||||
double radiusZ = baseRadius * rng.d(1.0, 1.35);
|
||||
ellipsoid(canvas, radiusX, bodyHeight, radiusZ, bodyHeight * 0.36, noiseSeed, f.getRoughness());
|
||||
ellipsoid(canvas, radiusX, bodyHeight, radiusZ, bodyHeight * 0.36, noiseSeed, f.roughness());
|
||||
|
||||
int peaks = Math.max(1, f.getIcebergPeaks());
|
||||
int peaks = Math.max(1, f.icebergPeaks());
|
||||
double phase = rng.d(0.0, Math.PI * 2.0);
|
||||
for (int i = 0; i < peaks; i++) {
|
||||
double angle = phase + (Math.PI * 2.0 * i / peaks) + rng.d(-0.35, 0.35);
|
||||
@@ -215,9 +215,9 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void fissure(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
int count = Math.max(2, f.getFractureCount());
|
||||
double separation = Math.max(1.0, f.getFractureSeparation());
|
||||
public static void fissure(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
int count = Math.max(2, f.fractureCount());
|
||||
double separation = Math.max(1.0, f.fractureSeparation());
|
||||
double shardRadius = Math.max(1.0, baseRadius / Math.max(1.6, count * 0.72));
|
||||
double phase = rng.d(0.0, Math.PI * 2.0);
|
||||
|
||||
@@ -233,11 +233,11 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void spiral(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
public static void spiral(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
int steps = Math.max(12, height * 4);
|
||||
double turns = Math.max(0.25, f.getSpiralTurns());
|
||||
double startRadius = Math.max(1.0, f.getSpiralRadius());
|
||||
double startThickness = Math.max(1.0, f.getSpiralThickness());
|
||||
double turns = Math.max(0.25, f.spiralTurns());
|
||||
double startRadius = Math.max(1.0, f.spiralRadius());
|
||||
double startThickness = Math.max(1.0, f.spiralThickness());
|
||||
double phase = rng.d(0.0, Math.PI * 2.0);
|
||||
long noiseSeed = rng.nextLong();
|
||||
|
||||
@@ -257,11 +257,11 @@ public final class FormationShapeBuilder {
|
||||
(int) Math.round(Math.sin(phase) * startRadius), footRadius, false, rng);
|
||||
}
|
||||
|
||||
public static void overhang(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
public static void overhang(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
int steps = Math.max(12, height * 4);
|
||||
double reach = Math.max(1.0, f.getOverhangReach());
|
||||
double drop = Math.max(0.0, f.getOverhangDrop());
|
||||
double phase = Math.toRadians(f.getLeanAzimuth()) + rng.d(-0.18, 0.18);
|
||||
double reach = Math.max(1.0, f.overhangReach());
|
||||
double drop = Math.max(0.0, f.overhangDrop());
|
||||
double phase = Math.toRadians(f.leanAzimuth()) + rng.d(-0.18, 0.18);
|
||||
double trunkHeight = Math.max(3.0, height * 0.62);
|
||||
long noiseSeed = rng.nextLong();
|
||||
|
||||
@@ -285,12 +285,12 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void column(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, double topRadius, int extraBaseX, int extraBaseZ, RNG rng, boolean capTop) {
|
||||
double lean = Math.toRadians(f.getLean());
|
||||
double azimuth = Math.toRadians(f.getLeanAzimuth());
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
|
||||
long noiseSeed = f.getSeed() + 9001L;
|
||||
private static void column(FormationCanvas canvas, Formation f, int height, double baseRadius, double topRadius, int extraBaseX, int extraBaseZ, RNG rng, boolean capTop) {
|
||||
double lean = Math.toRadians(f.lean());
|
||||
double azimuth = Math.toRadians(f.leanAzimuth());
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.jitter()));
|
||||
long noiseSeed = f.seed() + 9001L;
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
double t = height <= 1 ? 1.0 : (y / (double) (height - 1));
|
||||
@@ -311,7 +311,7 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void ringDisc(FormationCanvas canvas, IrisFormation f, int cx, int y, int cz, double radius, double roughness, double jitter, long noiseSeed, boolean cap, RNG rng) {
|
||||
private static void ringDisc(FormationCanvas canvas, Formation f, int cx, int y, int cz, double radius, double roughness, double jitter, long noiseSeed, boolean cap, RNG rng) {
|
||||
int r = (int) Math.ceil(radius) + 1;
|
||||
for (int x = -r; x <= r; x++) {
|
||||
for (int z = -r; z <= r; z++) {
|
||||
@@ -332,7 +332,7 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void disc(FormationCanvas canvas, IrisFormation f, int cx, int y, int cz, double radius, boolean cap, RNG rng) {
|
||||
private static void disc(FormationCanvas canvas, Formation f, int cx, int y, int cz, double radius, boolean cap, RNG rng) {
|
||||
int r = (int) Math.ceil(radius) + 1;
|
||||
for (int x = -r; x <= r; x++) {
|
||||
for (int z = -r; z <= r; z++) {
|
||||
@@ -347,11 +347,11 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void taperedPeak(FormationCanvas canvas, IrisFormation f, int height, double radius,
|
||||
private static void taperedPeak(FormationCanvas canvas, Formation f, int height, double radius,
|
||||
int offsetX, int offsetZ, double leanAngle, double leanDistance, RNG rng) {
|
||||
long noiseSeed = rng.nextLong();
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.jitter()));
|
||||
for (int y = 0; y < height; y++) {
|
||||
double t = height <= 1 ? 1.0 : y / (double) (height - 1);
|
||||
int x = offsetX + (int) Math.round(Math.cos(leanAngle) * leanDistance * t * t);
|
||||
@@ -383,11 +383,11 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void ball(FormationCanvas canvas, IrisFormation f, int centerX, int centerY, int centerZ,
|
||||
private static void ball(FormationCanvas canvas, Formation f, int centerX, int centerY, int centerZ,
|
||||
double radius, boolean cap, long noiseSeed, RNG rng) {
|
||||
int extent = (int) Math.ceil(radius);
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.jitter()));
|
||||
for (int x = -extent; x <= extent; x++) {
|
||||
for (int y = -extent; y <= extent; y++) {
|
||||
for (int z = -extent; z <= extent; z++) {
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A rock formation made placeable: its variants are baked by {@link FormationGenerator}. */
|
||||
public final class ResolvedFormation extends ResolvedProceduralPlacement {
|
||||
private final Formation settings;
|
||||
|
||||
public ResolvedFormation(Formation settings) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customize(IrisObjectPlacement placement) {
|
||||
placement.setSurfaceSupportBuffer(settings.surfaceSupportBuffer());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
return FormationGenerator.generate(settings, index, rng, data);
|
||||
}
|
||||
}
|
||||
+18
-16
@@ -18,8 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungusCapShape;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import java.util.Optional;
|
||||
import art.arcane.iris.builtin.objects.fungi.FungusCapShape;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
@@ -31,17 +33,17 @@ public final class FungusCapBuilder {
|
||||
private FungusCapBuilder() {
|
||||
}
|
||||
|
||||
public static void build(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, int baseRadius, double cx, int baseY, double cz, long seed) {
|
||||
int radius = (int) Math.round(baseRadius + Math.max(0.0, fungus.getCapOverhang()));
|
||||
int thickness = Math.max(1, Math.min(3, fungus.getCapThickness()));
|
||||
double squish = Math.max(0.0, Math.min(1.0, fungus.getCapSquish()));
|
||||
double droop = Math.max(0.0, fungus.getCapDroop());
|
||||
IrisFungusCapShape shape = fungus.getCapShape() == null ? IrisFungusCapShape.DOME : fungus.getCapShape();
|
||||
public static void build(Map<Vector3i, FungusCellRole> roles, Fungus fungus, int baseRadius, double cx, int baseY, double cz, long seed) {
|
||||
int radius = (int) Math.round(baseRadius + Math.max(0.0, fungus.capOverhang()));
|
||||
int thickness = Math.max(1, Math.min(3, fungus.capThickness()));
|
||||
double squish = Math.max(0.0, Math.min(1.0, fungus.capSquish()));
|
||||
double droop = Math.max(0.0, fungus.capDroop());
|
||||
FungusCapShape shape = fungus.capShape() == null ? FungusCapShape.DOME : fungus.capShape();
|
||||
int icx = (int) Math.round(cx);
|
||||
int icz = (int) Math.round(cz);
|
||||
|
||||
boolean hasGill = blockOrPaletteSet(fungus.getGillBlock(), fungus.getGillPalette());
|
||||
boolean hasSpot = blockOrPaletteSet(fungus.getSpotBlock(), fungus.getSpotPalette());
|
||||
boolean hasGill = blockOrPaletteSet(fungus.gillBlock(), fungus.gillPalette());
|
||||
boolean hasSpot = blockOrPaletteSet(fungus.spotBlock(), fungus.spotPalette());
|
||||
|
||||
double apexRise = apexRise(shape, radius) * (1.0 - 0.6 * squish);
|
||||
double droopReach = Math.tan(Math.toRadians(droop)) * radius;
|
||||
@@ -68,9 +70,9 @@ public final class FungusCapBuilder {
|
||||
boolean underside = layer == thickness - 1;
|
||||
boolean topFace = layer == 0;
|
||||
|
||||
if (underside && hasGill && rollNoise(icx + dx, y, icz + dz, seed + 4111L) <= fungus.getGillChance()) {
|
||||
if (underside && hasGill && rollNoise(icx + dx, y, icz + dz, seed + 4111L) <= fungus.gillChance()) {
|
||||
role = FungusCellRole.GILL;
|
||||
} else if (topFace && hasSpot && spotNoise(icx + dx, y, icz + dz, seed + 9311L) <= fungus.getSpotChance()) {
|
||||
} else if (topFace && hasSpot && spotNoise(icx + dx, y, icz + dz, seed + 9311L) <= fungus.spotChance()) {
|
||||
role = FungusCellRole.SPOT;
|
||||
}
|
||||
|
||||
@@ -80,7 +82,7 @@ public final class FungusCapBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static double apexRise(IrisFungusCapShape shape, int radius) {
|
||||
private static double apexRise(FungusCapShape shape, int radius) {
|
||||
return switch (shape) {
|
||||
case DOME -> radius * 0.85;
|
||||
case CONICAL -> radius * 1.4;
|
||||
@@ -90,7 +92,7 @@ public final class FungusCapBuilder {
|
||||
};
|
||||
}
|
||||
|
||||
private static double capSurface(IrisFungusCapShape shape, double normalized, double apexRise) {
|
||||
private static double capSurface(FungusCapShape shape, double normalized, double apexRise) {
|
||||
double n = Math.max(0.0, Math.min(1.0, normalized));
|
||||
return switch (shape) {
|
||||
case DOME -> apexRise * Math.sqrt(Math.max(0.0, 1.0 - n * n));
|
||||
@@ -109,10 +111,10 @@ public final class FungusCapBuilder {
|
||||
return TreeFunctions.valueNoise3D(Math.floorDiv(x, 2), y, Math.floorDiv(z, 2), seed);
|
||||
}
|
||||
|
||||
static boolean blockOrPaletteSet(String block, IrisMaterialPalette palette) {
|
||||
static boolean blockOrPaletteSet(Optional<String> block, Optional<PaletteSpec> palette) {
|
||||
if (IrisProceduralBlocks.paletteSet(palette)) {
|
||||
return true;
|
||||
}
|
||||
return block != null && !block.isEmpty();
|
||||
return block.filter(name -> !name.isEmpty()).isPresent();
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -33,11 +33,11 @@ public final class FungusGenerator {
|
||||
private FungusGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisFungus fungus, int height, RNG rng, IrisData data) {
|
||||
public static IrisObject generate(Fungus fungus, int height, RNG rng, IrisData data) {
|
||||
Map<Vector3i, FungusCellRole> roles = new HashMap<>();
|
||||
long baseSeed = rng.getSeed();
|
||||
|
||||
if (fungus.isShelf()) {
|
||||
if (fungus.shelf()) {
|
||||
FungusShelfBuilder.build(roles, fungus, rng, baseSeed);
|
||||
} else {
|
||||
buildUpright(roles, fungus, height, rng, baseSeed);
|
||||
@@ -47,7 +47,7 @@ public final class FungusGenerator {
|
||||
return null;
|
||||
}
|
||||
|
||||
RNG paletteRng = new RNG(fungus.getSeed());
|
||||
RNG paletteRng = new RNG(fungus.seed());
|
||||
Map<Vector3i, PlatformBlockState> resolved = new HashMap<>();
|
||||
for (Map.Entry<Vector3i, FungusCellRole> entry : roles.entrySet()) {
|
||||
Vector3i pos = entry.getKey();
|
||||
@@ -61,7 +61,7 @@ public final class FungusGenerator {
|
||||
return IrisProceduralBlocks.assemble(resolved);
|
||||
}
|
||||
|
||||
private static void buildUpright(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, int height, RNG rng, long baseSeed) {
|
||||
private static void buildUpright(Map<Vector3i, FungusCellRole> roles, Fungus fungus, int height, RNG rng, long baseSeed) {
|
||||
int stemHeight = Math.max(1, height);
|
||||
Map<Vector3i, PlatformBlockState> stemCells = new HashMap<>();
|
||||
double[] top = FungusStemBuilder.build(stemCells, fungus, stemHeight, baseSeed);
|
||||
@@ -76,28 +76,28 @@ public final class FungusGenerator {
|
||||
FungusCapBuilder.build(roles, fungus, radius, cx, capBaseY, cz, baseSeed + 5557L);
|
||||
}
|
||||
|
||||
private static int pickRadius(IrisFungus fungus, RNG rng) {
|
||||
int lo = Math.min(fungus.getCapRadiusMin(), fungus.getCapRadiusMax());
|
||||
int hi = Math.max(fungus.getCapRadiusMin(), fungus.getCapRadiusMax());
|
||||
private static int pickRadius(Fungus fungus, RNG rng) {
|
||||
int lo = Math.min(fungus.capRadiusMin(), fungus.capRadiusMax());
|
||||
int hi = Math.max(fungus.capRadiusMin(), fungus.capRadiusMax());
|
||||
lo = Math.max(1, lo);
|
||||
hi = Math.max(lo, hi);
|
||||
return rng.i(lo, hi + 1);
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveRole(IrisFungus fungus, FungusCellRole role, IrisData data, Vector3i pos, RNG paletteRng) {
|
||||
private static PlatformBlockState resolveRole(Fungus fungus, FungusCellRole role, IrisData data, Vector3i pos, RNG paletteRng) {
|
||||
int x = pos.getBlockX();
|
||||
int y = pos.getBlockY();
|
||||
int z = pos.getBlockZ();
|
||||
return switch (role) {
|
||||
case STEM -> IrisProceduralBlocks.resolve(fungus.getStem(), fungus.getStemPalette(), data, x, y, z, paletteRng);
|
||||
case CAP -> IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
|
||||
case STEM -> IrisProceduralBlocks.resolve(fungus.stem(), fungus.stemPalette(), data, x, y, z, paletteRng);
|
||||
case CAP -> IrisProceduralBlocks.resolve(fungus.cap(), fungus.capPalette(), data, x, y, z, paletteRng);
|
||||
case GILL -> {
|
||||
PlatformBlockState gill = IrisProceduralBlocks.resolve(fungus.getGillBlock(), fungus.getGillPalette(), data, x, y, z, paletteRng);
|
||||
yield gill != null ? gill : IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
|
||||
PlatformBlockState gill = IrisProceduralBlocks.resolve(fungus.gillBlock(), fungus.gillPalette(), data, x, y, z, paletteRng);
|
||||
yield gill != null ? gill : IrisProceduralBlocks.resolve(fungus.cap(), fungus.capPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
case SPOT -> {
|
||||
PlatformBlockState spot = IrisProceduralBlocks.resolve(fungus.getSpotBlock(), fungus.getSpotPalette(), data, x, y, z, paletteRng);
|
||||
yield spot != null ? spot : IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
|
||||
PlatformBlockState spot = IrisProceduralBlocks.resolve(fungus.spotBlock(), fungus.spotPalette(), data, x, y, z, paletteRng);
|
||||
yield spot != null ? spot : IrisProceduralBlocks.resolve(fungus.cap(), fungus.capPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+8
-8
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -29,20 +29,20 @@ public final class FungusShelfBuilder {
|
||||
private FungusShelfBuilder() {
|
||||
}
|
||||
|
||||
public static void build(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, RNG rng, long seed) {
|
||||
int radius = Math.max(1, fungus.getShelfRadius());
|
||||
public static void build(Map<Vector3i, FungusCellRole> roles, Fungus fungus, RNG rng, long seed) {
|
||||
int radius = Math.max(1, fungus.shelfRadius());
|
||||
double azimuth = rng.d(0.0, Math.PI * 2.0);
|
||||
double fanX = Math.sin(azimuth);
|
||||
double fanZ = Math.cos(azimuth);
|
||||
int stubHeight = Math.max(0, Math.min(2, fungus.getStemWidth()));
|
||||
int stubHeight = Math.max(0, Math.min(2, fungus.stemWidth()));
|
||||
|
||||
for (int y = 0; y < stubHeight; y++) {
|
||||
roles.put(new Vector3i(0, y, 0), FungusCellRole.STEM);
|
||||
}
|
||||
|
||||
int fanY = stubHeight;
|
||||
boolean hasGill = FungusCapBuilder.blockOrPaletteSet(fungus.getGillBlock(), fungus.getGillPalette());
|
||||
boolean hasSpot = FungusCapBuilder.blockOrPaletteSet(fungus.getSpotBlock(), fungus.getSpotPalette());
|
||||
boolean hasGill = FungusCapBuilder.blockOrPaletteSet(fungus.gillBlock(), fungus.gillPalette());
|
||||
boolean hasSpot = FungusCapBuilder.blockOrPaletteSet(fungus.spotBlock(), fungus.spotPalette());
|
||||
|
||||
for (int dx = -radius; dx <= radius; dx++) {
|
||||
for (int dz = -radius; dz <= radius; dz++) {
|
||||
@@ -59,12 +59,12 @@ public final class FungusShelfBuilder {
|
||||
int y = fanY + lift;
|
||||
|
||||
FungusCellRole role = FungusCellRole.CAP;
|
||||
if (hasSpot && spotNoise(dx, y, dz, seed + 9311L) <= fungus.getSpotChance()) {
|
||||
if (hasSpot && spotNoise(dx, y, dz, seed + 9311L) <= fungus.spotChance()) {
|
||||
role = FungusCellRole.SPOT;
|
||||
}
|
||||
roles.putIfAbsent(new Vector3i(dx, y, dz), role);
|
||||
|
||||
if (hasGill && rollNoise(dx, y - 1, dz, seed + 4111L) <= fungus.getGillChance()) {
|
||||
if (hasGill && rollNoise(dx, y - 1, dz, seed + 4111L) <= fungus.gillChance()) {
|
||||
roles.putIfAbsent(new Vector3i(dx, y - 1, dz), FungusCellRole.GILL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
@@ -29,15 +29,15 @@ public final class FungusStemBuilder {
|
||||
private FungusStemBuilder() {
|
||||
}
|
||||
|
||||
public static double[] build(Map<Vector3i, PlatformBlockState> stemCells, IrisFungus fungus, int stemHeight, long seed) {
|
||||
int width = Math.max(1, Math.min(3, fungus.getStemWidth()));
|
||||
double maxLean = stemHeight * Math.tan(Math.toRadians(Math.max(0.0, fungus.getStemCurve())));
|
||||
double leanRad = Math.toRadians(fungus.getStemLeanAzimuth());
|
||||
public static double[] build(Map<Vector3i, PlatformBlockState> stemCells, Fungus fungus, int stemHeight, long seed) {
|
||||
int width = Math.max(1, Math.min(3, fungus.stemWidth()));
|
||||
double maxLean = stemHeight * Math.tan(Math.toRadians(Math.max(0.0, fungus.stemCurve())));
|
||||
double leanRad = Math.toRadians(fungus.stemLeanAzimuth());
|
||||
double leanX = Math.sin(leanRad);
|
||||
double leanZ = Math.cos(leanRad);
|
||||
double waveAmp = Math.max(0.0, fungus.getStemWaveAmplitude());
|
||||
double wavePeriods = fungus.getStemWavePeriods() == 0 ? 1.0 : fungus.getStemWavePeriods();
|
||||
double waveAzimuth = Math.toRadians(fungus.getStemLeanAzimuth() + 90.0);
|
||||
double waveAmp = Math.max(0.0, fungus.stemWaveAmplitude());
|
||||
double wavePeriods = fungus.stemWavePeriods() == 0 ? 1.0 : fungus.stemWavePeriods();
|
||||
double waveAzimuth = Math.toRadians(fungus.stemLeanAzimuth() + 90.0);
|
||||
double waveX = Math.sin(waveAzimuth);
|
||||
double waveZ = Math.cos(waveAzimuth);
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A fungus made placeable: its variants are baked by {@link FungusGenerator}. */
|
||||
public final class ResolvedFungus extends ResolvedProceduralPlacement {
|
||||
private final Fungus settings;
|
||||
|
||||
public ResolvedFungus(Fungus settings) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
throw new UnsupportedOperationException("A fungus bakes its variants itself, from the stem heights");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected KList<IrisObject> bake(IrisData data) {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = variantCount();
|
||||
int lo = Math.min(settings.stemHeightMin(), settings.stemHeightMax());
|
||||
int hi = Math.max(settings.stemHeightMin(), settings.stemHeightMax());
|
||||
RNG heightRng = new RNG(seed());
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int height;
|
||||
if (count == 1 || lo == hi) {
|
||||
height = heightRng.i(lo, hi + 1);
|
||||
} else {
|
||||
double step = (hi - lo) / (double) (count - 1);
|
||||
double base = lo + step * i;
|
||||
double jitter = heightRng.d(-step * 0.3, step * 0.3);
|
||||
height = (int) Math.round(Math.max(lo, Math.min(hi, base + jitter)));
|
||||
}
|
||||
|
||||
IrisObject object = FungusGenerator.generate(settings, Math.max(1, height), variantRng(i), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + getName() + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A ruin made placeable: its variants are baked by {@link RuinGenerator}. */
|
||||
public final class ResolvedRuin extends ResolvedProceduralPlacement {
|
||||
private final Ruin settings;
|
||||
|
||||
public ResolvedRuin(Ruin settings) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
return RuinGenerator.generate(settings, index, rng, data);
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -18,10 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ruin.RuinDecorator;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.IrisRuinDecorator;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
@@ -36,19 +36,19 @@ final class RuinDecoratorApplier {
|
||||
private RuinDecoratorApplier() {
|
||||
}
|
||||
|
||||
static void apply(RuinBlockCanvas canvas, IrisRuinDecorator decorator, IrisData data, long seed, RNG rng) {
|
||||
List<Vector3i> candidates = switch (decorator.getTarget()) {
|
||||
static void apply(RuinBlockCanvas canvas, RuinDecorator decorator, IrisData data, long seed, RNG rng) {
|
||||
List<Vector3i> candidates = switch (decorator.target()) {
|
||||
case TOP -> topCandidates(canvas);
|
||||
case SURFACE -> surfaceCandidates(canvas);
|
||||
case BASE_SCATTER -> baseScatterCandidates(canvas, Math.max(1, decorator.getScatterRadius()));
|
||||
case BASE_SCATTER -> baseScatterCandidates(canvas, Math.max(1, decorator.scatterRadius()));
|
||||
};
|
||||
|
||||
RNG paletteRng = new RNG(seed);
|
||||
for (Vector3i v : candidates) {
|
||||
if (!rng.chance(decorator.getChance())) {
|
||||
if (!rng.chance(decorator.chance())) {
|
||||
continue;
|
||||
}
|
||||
PlatformBlockState bd = IrisProceduralBlocks.resolve(decorator.getBlock(), decorator.getPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
PlatformBlockState bd = IrisProceduralBlocks.resolve(decorator.block(), decorator.palette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
if (bd != null) {
|
||||
canvas.accent(v.getBlockX(), v.getBlockY(), v.getBlockZ(), bd);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ruin.RuinDecorator;
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.IrisRuin;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -36,14 +37,14 @@ public final class RuinGenerator {
|
||||
private RuinGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisRuin ruin, int variantIndex, RNG rng, IrisData data) {
|
||||
int count = Math.max(1, ruin.getVariants());
|
||||
int height = pick(ruin.getHeightMin(), ruin.getHeightMax(), variantIndex, count, rng);
|
||||
int width = pick(ruin.getWidthMin(), ruin.getWidthMax(), variantIndex, count, rng);
|
||||
int length = pick(ruin.getLengthMin(), ruin.getLengthMax(), variantIndex, count, rng);
|
||||
public static IrisObject generate(Ruin ruin, int variantIndex, RNG rng, IrisData data) {
|
||||
int count = Math.max(1, ruin.variants());
|
||||
int height = pick(ruin.heightMin(), ruin.heightMax(), variantIndex, count, rng);
|
||||
int width = pick(ruin.widthMin(), ruin.widthMax(), variantIndex, count, rng);
|
||||
int length = pick(ruin.lengthMin(), ruin.lengthMax(), variantIndex, count, rng);
|
||||
|
||||
RuinBlockCanvas canvas = new RuinBlockCanvas();
|
||||
switch (ruin.getForm()) {
|
||||
switch (ruin.form()) {
|
||||
case PILLAR -> RuinShapes.pillar(canvas, Math.max(1, width), Math.max(2, height), rng);
|
||||
case WALL -> RuinShapes.wall(canvas, Math.max(1, width), Math.max(2, length), Math.max(2, height), rng);
|
||||
case ARCH -> RuinShapes.arch(canvas, Math.max(1, width), Math.max(3, length), Math.max(3, height), rng);
|
||||
@@ -70,8 +71,8 @@ public final class RuinGenerator {
|
||||
return (int) Math.round(Math.max(min, Math.min(max, base + jitter)));
|
||||
}
|
||||
|
||||
private static void applyBurial(IrisRuin ruin, RuinBlockCanvas canvas, int height) {
|
||||
double fraction = clamp01(ruin.getBuriedFraction());
|
||||
private static void applyBurial(Ruin ruin, RuinBlockCanvas canvas, int height) {
|
||||
double fraction = clamp01(ruin.buriedFraction());
|
||||
if (fraction <= 0.0) {
|
||||
return;
|
||||
}
|
||||
@@ -88,13 +89,13 @@ public final class RuinGenerator {
|
||||
canvas.cells().putAll(moved);
|
||||
}
|
||||
|
||||
private static void applyErosion(IrisRuin ruin, RuinBlockCanvas canvas) {
|
||||
double erosion = clamp01(ruin.getErosion());
|
||||
private static void applyErosion(Ruin ruin, RuinBlockCanvas canvas) {
|
||||
double erosion = clamp01(ruin.erosion());
|
||||
if (erosion <= 0.0) {
|
||||
return;
|
||||
}
|
||||
double scale = Math.max(0.0001, ruin.getErosionScale());
|
||||
long erosionSeed = ruin.getSeed() * 0x2545F4914F6CDD1DL + 17L;
|
||||
double scale = Math.max(0.0001, ruin.erosionScale());
|
||||
long erosionSeed = ruin.seed() * 0x2545F4914F6CDD1DL + 17L;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
for (Vector3i v : canvas.cells().keySet()) {
|
||||
minY = Math.min(minY, v.getBlockY());
|
||||
@@ -120,25 +121,25 @@ public final class RuinGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyAccents(IrisRuin ruin, RuinBlockCanvas canvas, RNG rng, IrisData data) {
|
||||
if (ruin.getAccents() == null || ruin.getAccents().isEmpty()) {
|
||||
private static void applyAccents(Ruin ruin, RuinBlockCanvas canvas, RNG rng, IrisData data) {
|
||||
if (ruin.accents() == null || ruin.accents().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int decoratorIndex = 0;
|
||||
for (art.arcane.iris.engine.object.procedural.ruin.IrisRuinDecorator decorator : ruin.getAccents()) {
|
||||
RuinDecoratorApplier.apply(canvas, decorator, data, ruin.getSeed() + decoratorIndex * 911L, rng.nextParallelRNG(decoratorIndex + 1));
|
||||
for (art.arcane.iris.builtin.objects.ruin.RuinDecorator decorator : ruin.accents()) {
|
||||
RuinDecoratorApplier.apply(canvas, decorator, data, ruin.seed() + decoratorIndex * 911L, rng.nextParallelRNG(decoratorIndex + 1));
|
||||
decoratorIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
private static IrisObject resolve(IrisRuin ruin, RuinBlockCanvas canvas, IrisData data) {
|
||||
private static IrisObject resolve(Ruin ruin, RuinBlockCanvas canvas, IrisData data) {
|
||||
if (canvas.cells().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
double scale = Math.max(0.0001, ruin.getWeatheringScale());
|
||||
double mossiness = clamp01(ruin.getMossiness());
|
||||
long weatherSeed = ruin.getSeed() * 0x9E3779B97F4A7C15L + 101L;
|
||||
RNG paletteRng = new RNG(ruin.getSeed());
|
||||
double scale = Math.max(0.0001, ruin.weatheringScale());
|
||||
double mossiness = clamp01(ruin.mossiness());
|
||||
long weatherSeed = ruin.seed() * 0x9E3779B97F4A7C15L + 101L;
|
||||
RNG paletteRng = new RNG(ruin.seed());
|
||||
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
@@ -166,7 +167,7 @@ public final class RuinGenerator {
|
||||
return IrisProceduralBlocks.assemble(blocks);
|
||||
}
|
||||
|
||||
private static PlatformBlockState structuralBlock(IrisRuin ruin, RuinBlockCanvas.Cell cell, Vector3i v, IrisData data, RNG paletteRng, double scale, double mossiness, long weatherSeed, int minY, int span) {
|
||||
private static PlatformBlockState structuralBlock(Ruin ruin, RuinBlockCanvas.Cell cell, Vector3i v, IrisData data, RNG paletteRng, double scale, double mossiness, long weatherSeed, int minY, int span) {
|
||||
boolean weathered = false;
|
||||
if (mossiness > 0.0) {
|
||||
int sx = (int) Math.round(v.getBlockX() * scale);
|
||||
@@ -179,12 +180,12 @@ public final class RuinGenerator {
|
||||
}
|
||||
|
||||
if (weathered) {
|
||||
PlatformBlockState wd = IrisProceduralBlocks.resolve(ruin.getWeatheredBlock(), ruin.getWeatheringPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
PlatformBlockState wd = IrisProceduralBlocks.resolve(ruin.weatheredBlock(), ruin.weatheringPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
if (wd != null) {
|
||||
return wd;
|
||||
}
|
||||
}
|
||||
return IrisProceduralBlocks.resolve(ruin.getBlock(), ruin.getBlockPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
return IrisProceduralBlocks.resolve(ruin.block(), ruin.blockPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
}
|
||||
|
||||
private static double clamp01(double value) {
|
||||
|
||||
+17
-10
@@ -18,6 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
|
||||
import art.arcane.iris.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;
|
||||
@@ -120,7 +127,7 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private IrisMaterialPalette leavesPalette = null;
|
||||
|
||||
@Desc("The named canopy profile that drives default crown radii and shape.")
|
||||
private IrisTreeProfile profile = IrisTreeProfile.OAK;
|
||||
private TreeProfile profile = TreeProfile.OAK;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum trunk height in blocks.")
|
||||
@@ -135,7 +142,7 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private int trunkWidth = 1;
|
||||
|
||||
@Desc("The function used to shape trunk width over height.")
|
||||
private IrisTreeFunction trunkShape = IrisTreeFunction.CONSTANT;
|
||||
private TreeFunction trunkShape = TreeFunction.CONSTANT;
|
||||
|
||||
@Desc("Width multiplier at the base for the LINEAR trunk shape.")
|
||||
private double shapeStart = 1;
|
||||
@@ -168,13 +175,13 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private double leanAngle = 0;
|
||||
|
||||
@Desc("How the lean accumulates over height.")
|
||||
private IrisTreeFunction trunkCurve = IrisTreeFunction.LINEAR;
|
||||
private TreeFunction trunkCurve = TreeFunction.LINEAR;
|
||||
|
||||
@Desc("Steepness for the SIGMOID trunk curve.")
|
||||
private double curveSteepness = 8;
|
||||
|
||||
@Desc("How the lean azimuth itself changes over height (for spiraling or wandering trunks).")
|
||||
private IrisTreeAzimuthMode leanAzimuthMode = IrisTreeAzimuthMode.CONSTANT;
|
||||
private TreeAzimuthMode leanAzimuthMode = TreeAzimuthMode.CONSTANT;
|
||||
|
||||
@Desc("Azimuth at the base for the LINEAR azimuth mode.")
|
||||
private double azimuthStart = 0;
|
||||
@@ -210,9 +217,9 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
@Desc("The fraction of leaves replaced by the secondary leaf block(s).")
|
||||
private double secondaryLeafFraction = 0.35;
|
||||
|
||||
@ArrayType(min = 1, type = IrisTreeSecondaryLeaf.class)
|
||||
@ArrayType(min = 1, type = TreeSecondaryLeaf.class)
|
||||
@Desc("Optional weighted set of accent leaf blocks. When set this overrides the single secondaryLeaves block.")
|
||||
private KList<IrisTreeSecondaryLeaf> weightedSecondaryLeaves = new KList<>();
|
||||
private KList<TreeSecondaryLeaf> weightedSecondaryLeaves = new KList<>();
|
||||
|
||||
@Desc("A noise-driven palette for the secondary (accent) leaves. When set this overrides both secondaryLeaves and weightedSecondaryLeaves.")
|
||||
private IrisMaterialPalette secondaryLeavesPalette = null;
|
||||
@@ -238,7 +245,7 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private boolean roots = true;
|
||||
|
||||
@Desc("How the root system is built when roots is true.")
|
||||
private IrisTreeRootStyle rootStyle = IrisTreeRootStyle.BUTTRESS;
|
||||
private TreeRootStyle rootStyle = TreeRootStyle.BUTTRESS;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Override the root depth/reach in blocks. 0 means auto (scales with tree height).")
|
||||
@@ -262,11 +269,11 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private double forkAngle = 25;
|
||||
|
||||
@Desc("The leaf crown configuration.")
|
||||
private IrisTreeCanopy canopy = new IrisTreeCanopy();
|
||||
private TreeCanopy canopy = new TreeCanopy();
|
||||
|
||||
@ArrayType(min = 1, type = IrisTreeDecorator.class)
|
||||
@ArrayType(min = 1, type = TreeDecorator.class)
|
||||
@Desc("Accent decorators applied after the tree is built (fruit, vines, snow, glow).")
|
||||
private KList<IrisTreeDecorator> decorators = new KList<>();
|
||||
private KList<TreeDecorator> decorators = new KList<>();
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeDecorator;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -62,8 +64,8 @@ public final class TreeBlockResolver {
|
||||
if (index < 0 || tree.getDecorators() == null || index >= tree.getDecorators().size()) {
|
||||
return null;
|
||||
}
|
||||
IrisTreeDecorator dec = tree.getDecorators().get(index);
|
||||
PlatformBlockState state = resolveBlock(dec.getBlock(), dec.getPalette(), data, pos, paletteRng);
|
||||
TreeDecorator dec = tree.getDecorators().get(index);
|
||||
PlatformBlockState state = resolveBlock(dec.block(), dec.palette().orElse(null), data, pos, paletteRng);
|
||||
if (state != null && cell.facing() != null && IrisProceduralBlocks.hasProperty(state, "facing")) {
|
||||
try {
|
||||
state = state.withProperty("facing", cell.facing().toLowerCase());
|
||||
@@ -110,21 +112,25 @@ public final class TreeBlockResolver {
|
||||
|
||||
private static String pickWeighted(IrisProceduralTree tree, RNG rng) {
|
||||
int total = 0;
|
||||
for (art.arcane.iris.engine.object.procedural.tree.IrisTreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
|
||||
total += Math.max(0, s.getWeight());
|
||||
for (art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
|
||||
total += Math.max(0, s.weight());
|
||||
}
|
||||
if (total <= 0) {
|
||||
return null;
|
||||
}
|
||||
double r = rng.nextDouble() * total;
|
||||
double cumulative = 0;
|
||||
for (art.arcane.iris.engine.object.procedural.tree.IrisTreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
|
||||
cumulative += Math.max(0, s.getWeight());
|
||||
for (art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
|
||||
cumulative += Math.max(0, s.weight());
|
||||
if (r < cumulative) {
|
||||
return s.getBlock();
|
||||
return s.block();
|
||||
}
|
||||
}
|
||||
return tree.getWeightedSecondaryLeaves().get(tree.getWeightedSecondaryLeaves().size() - 1).getBlock();
|
||||
return tree.getWeightedSecondaryLeaves().get(tree.getWeightedSecondaryLeaves().size() - 1).block();
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveBlock(String block, PaletteSpec palette, IrisData data, TreeBlockCanvas.Vec pos, RNG paletteRng) {
|
||||
return IrisProceduralBlocks.resolve(block, palette, data, pos.x(), pos.y(), pos.z(), paletteRng);
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveBlock(String block, IrisMaterialPalette palette, IrisData data, TreeBlockCanvas.Vec pos, RNG paletteRng) {
|
||||
|
||||
+44
-44
@@ -18,13 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSubBranches;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeLayer;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeCanopy;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeBranches;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeProfile;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeLeafMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeBranches;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeCanopy;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeLayer;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeLeafMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeProfile;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeSubBranches;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
@@ -36,11 +36,11 @@ public final class TreeCanopyBuilder {
|
||||
|
||||
public static void build(TreeBlockCanvas canvas, IrisProceduralTree tree, int height, double[][] offsets,
|
||||
int branchStartY, long baseSeed, List<int[]> branchEndpoints) {
|
||||
IrisTreeCanopy canopy = tree.getCanopy();
|
||||
TreeCanopy canopy = tree.getCanopy();
|
||||
if (canopy == null) {
|
||||
canopy = new IrisTreeCanopy();
|
||||
canopy = new TreeCanopy();
|
||||
}
|
||||
IrisTreeBranches branches = canopy.getBranches();
|
||||
TreeBranches branches = canopy.branches().orElse(null);
|
||||
|
||||
double[][] layers = resolveLayers(canopy, tree.getProfile(), height, branches != null);
|
||||
|
||||
@@ -69,19 +69,19 @@ public final class TreeCanopyBuilder {
|
||||
maxR = Math.max(maxR, layer[1]);
|
||||
}
|
||||
int capRadius = Math.max(2, Math.min(3, (int) Math.round(maxR * 0.35)));
|
||||
IrisTreeCanopy canopy = tree.getCanopy();
|
||||
IrisTreeLeafMode mode = canopy != null ? canopy.getMode() : IrisTreeLeafMode.TRIMMED;
|
||||
double density = canopy != null ? canopy.getLeafDensity() : 1.0;
|
||||
TreeCanopy canopy = tree.getCanopy();
|
||||
TreeLeafMode mode = canopy != null ? canopy.mode() : TreeLeafMode.TRIMMED;
|
||||
double density = canopy != null ? canopy.leafDensity() : 1.0;
|
||||
placeLeafCluster(canvas, tree, ocx, height - 1, ocz, capRadius, mode, density, baseSeed + 5555L);
|
||||
}
|
||||
|
||||
private static double[][] resolveLayers(IrisTreeCanopy canopy, IrisTreeProfile profile, int height, boolean branchDriven) {
|
||||
KList<IrisTreeLayer> explicit = canopy.getLayers();
|
||||
private static double[][] resolveLayers(TreeCanopy canopy, TreeProfile profile, int height, boolean branchDriven) {
|
||||
KList<TreeLayer> explicit = new KList<>(canopy.layers());
|
||||
if (explicit != null && !explicit.isEmpty()) {
|
||||
double[][] out = new double[explicit.size()][2];
|
||||
for (int i = 0; i < explicit.size(); i++) {
|
||||
out[i][0] = explicit.get(i).getYOffset();
|
||||
out[i][1] = explicit.get(i).getRadius();
|
||||
out[i][0] = explicit.get(i).yOffset();
|
||||
out[i][1] = explicit.get(i).radius();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
|
||||
private static void volumeCanopy(TreeBlockCanvas canvas, IrisProceduralTree tree, double[][] layers,
|
||||
IrisTreeCanopy canopy, long baseSeed, double[][] offsets) {
|
||||
TreeCanopy canopy, long baseSeed, double[][] offsets) {
|
||||
int ocx = 0;
|
||||
int ocz = 0;
|
||||
if (offsets != null && offsets.length > 0) {
|
||||
@@ -97,10 +97,10 @@ public final class TreeCanopyBuilder {
|
||||
ocz = (int) Math.round(offsets[offsets.length - 1][1]);
|
||||
}
|
||||
|
||||
double startAngle = canopy.getStartAngle();
|
||||
double squish = canopy.getSquish();
|
||||
IrisTreeLeafMode mode = canopy.getMode();
|
||||
double leafDensity = canopy.getLeafDensity();
|
||||
double startAngle = canopy.startAngle();
|
||||
double squish = canopy.squish();
|
||||
TreeLeafMode mode = canopy.mode();
|
||||
double leafDensity = canopy.leafDensity();
|
||||
|
||||
for (double[] layer : layers) {
|
||||
int yCenter = (int) Math.round(layer[0]);
|
||||
@@ -137,7 +137,7 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
|
||||
private static void placeLeafDisc(TreeBlockCanvas canvas, IrisProceduralTree tree, int cx, int cy, int cz,
|
||||
double radius, IrisTreeLeafMode mode, double density, long seed) {
|
||||
double radius, TreeLeafMode mode, double density, long seed) {
|
||||
double sx = stretchX(tree);
|
||||
double sz = stretchZ(tree);
|
||||
RNG rng = new RNG(seed);
|
||||
@@ -158,7 +158,7 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
|
||||
private static void placeLeafCluster(TreeBlockCanvas canvas, IrisProceduralTree tree, int cx, int cy, int cz,
|
||||
int radius, IrisTreeLeafMode mode, double density, long seed) {
|
||||
int radius, TreeLeafMode mode, double density, long seed) {
|
||||
double sx = stretchX(tree);
|
||||
double sz = stretchZ(tree);
|
||||
RNG rng = new RNG(seed);
|
||||
@@ -181,16 +181,16 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
|
||||
private static double stretchX(IrisProceduralTree tree) {
|
||||
IrisTreeCanopy c = tree.getCanopy();
|
||||
return c == null ? 1.0 : Math.max(0.1, c.getCrownStretchX());
|
||||
TreeCanopy c = tree.getCanopy();
|
||||
return c == null ? 1.0 : Math.max(0.1, c.crownStretchX());
|
||||
}
|
||||
|
||||
private static double stretchZ(IrisProceduralTree tree) {
|
||||
IrisTreeCanopy c = tree.getCanopy();
|
||||
return c == null ? 1.0 : Math.max(0.1, c.getCrownStretchZ());
|
||||
TreeCanopy c = tree.getCanopy();
|
||||
return c == null ? 1.0 : Math.max(0.1, c.crownStretchZ());
|
||||
}
|
||||
|
||||
private static boolean passesLeafTest(IrisTreeLeafMode mode, double dist, double radius, double density,
|
||||
private static boolean passesLeafTest(TreeLeafMode mode, double dist, double radius, double density,
|
||||
RNG rng, int wx, int wy, int wz, long seed, boolean corner) {
|
||||
switch (mode) {
|
||||
case TRIMMED -> {
|
||||
@@ -258,12 +258,12 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
|
||||
private static void branchCanopy(TreeBlockCanvas canvas, IrisProceduralTree tree, int height,
|
||||
IrisTreeBranches branches, int branchStartY, long baseSeed, double[][] offsets,
|
||||
TreeBranches branches, int branchStartY, long baseSeed, double[][] offsets,
|
||||
List<int[]> branchEndpoints) {
|
||||
long branchSeed = baseSeed + 9999;
|
||||
RNG branchRng = new RNG(branchSeed);
|
||||
IrisTreeSubBranches sub = branches.getSubBranches();
|
||||
int depth = branches.getBranchDepth();
|
||||
TreeSubBranches sub = branches.subBranches().orElse(null);
|
||||
int depth = branches.branchDepth();
|
||||
int branchIndex = 0;
|
||||
|
||||
for (int y = Math.max(0, branchStartY); y < height; y++) {
|
||||
@@ -280,38 +280,38 @@ public final class TreeCanopyBuilder {
|
||||
oz = (int) Math.round(offsets[y][1]);
|
||||
}
|
||||
|
||||
double az = TreeFunctions.azimuthDegrees(branches.getAzimuthMode(), t, branchIndex, tree, branches.getAzimuth(), branchRng);
|
||||
double az = TreeFunctions.azimuthDegrees(branches.azimuthMode(), t, branchIndex, tree, branches.azimuth(), branchRng);
|
||||
branchIndex++;
|
||||
double branchLen = TreeFunctions.branchLength(branches, t);
|
||||
double effElevation = branches.isLeafStartUp() ? Math.max(0.0, branches.getElevation()) : branches.getElevation();
|
||||
double effElevation = branches.leafStartUp() ? Math.max(0.0, branches.elevation()) : branches.elevation();
|
||||
int[] end = branchEndpoint(ox, y, oz, az, effElevation, branchLen);
|
||||
int[] tip = rasterizeBranch(canvas, ox, y, oz, end[0], end[1], end[2], branches.getSag());
|
||||
int[] tip = rasterizeBranch(canvas, ox, y, oz, end[0], end[1], end[2], branches.sag());
|
||||
|
||||
if (branchEndpoints != null) {
|
||||
branchEndpoints.add(new int[]{tip[0], tip[1], tip[2], ox, oz});
|
||||
}
|
||||
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], branches.getClusterRadius(),
|
||||
branches.getClusterMode(), branches.getClusterDensity(), branchSeed + y);
|
||||
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], branches.clusterRadius(),
|
||||
branches.clusterMode(), branches.clusterDensity(), branchSeed + y);
|
||||
|
||||
growSubBranches(canvas, tree, tip[0], tip[1], tip[2], az, effElevation, branchLen, sub, depth, branchSeed + y + 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
private static void growSubBranches(TreeBlockCanvas canvas, IrisProceduralTree tree, int ox, int oy, int oz,
|
||||
double az, double el, double len, IrisTreeSubBranches sub, int depth, long seed) {
|
||||
double az, double el, double len, TreeSubBranches sub, int depth, long seed) {
|
||||
if (sub == null || depth <= 0) {
|
||||
return;
|
||||
}
|
||||
int count = Math.max(1, sub.getCount());
|
||||
int count = Math.max(1, sub.count());
|
||||
for (int si = 0; si < count; si++) {
|
||||
double yawOffset = sub.getYawDelta() * (si - (count - 1) / 2.0);
|
||||
double yawOffset = sub.yawDelta() * (si - (count - 1) / 2.0);
|
||||
double subAz = az + yawOffset;
|
||||
double subEl = el + sub.getPitchDelta();
|
||||
double subLen = len * sub.getLengthScale();
|
||||
double subEl = el + sub.pitchDelta();
|
||||
double subLen = len * sub.lengthScale();
|
||||
int[] end = branchEndpoint(ox, oy, oz, subAz, subEl, subLen);
|
||||
int[] tip = rasterizeBranch(canvas, ox, oy, oz, end[0], end[1], end[2], sub.getSag());
|
||||
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], sub.getClusterRadius(),
|
||||
sub.getClusterMode(), sub.getClusterDensity(), seed + si * 131L);
|
||||
int[] tip = rasterizeBranch(canvas, ox, oy, oz, end[0], end[1], end[2], sub.sag());
|
||||
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], sub.clusterRadius(),
|
||||
sub.clusterMode(), sub.clusterDensity(), seed + si * 131L);
|
||||
growSubBranches(canvas, tree, tip[0], tip[1], tip[2], subAz, subEl, subLen, sub, depth - 1, seed + si * 131L + 17L);
|
||||
}
|
||||
}
|
||||
|
||||
+29
-29
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeDecorator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -32,19 +32,19 @@ public final class TreeDecoratorApplier {
|
||||
}
|
||||
|
||||
public static void apply(TreeBlockCanvas canvas, IrisProceduralTree tree, long baseSeed, List<int[]> branchEndpoints) {
|
||||
KList<IrisTreeDecorator> decorators = tree.getDecorators();
|
||||
KList<TreeDecorator> decorators = tree.getDecorators();
|
||||
if (decorators == null || decorators.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
RNG rng = new RNG(baseSeed + 77777L);
|
||||
|
||||
for (int idx = 0; idx < decorators.size(); idx++) {
|
||||
IrisTreeDecorator dec = decorators.get(idx);
|
||||
boolean hasBlock = (dec.getBlock() != null && !dec.getBlock().isEmpty()) || TreeTrunkBuilder.paletteSet(dec.getPalette());
|
||||
TreeDecorator dec = decorators.get(idx);
|
||||
boolean hasBlock = (dec.block() != null && !dec.block().isEmpty()) || dec.palette().isPresent();
|
||||
if (!hasBlock) {
|
||||
continue;
|
||||
}
|
||||
switch (dec.getTarget()) {
|
||||
switch (dec.target()) {
|
||||
case BRANCH_TIP -> branchTip(canvas, dec, idx, branchEndpoints, rng);
|
||||
case TRUNK_SURFACE -> trunkSurface(canvas, dec, idx, rng);
|
||||
case CANOPY_TOP -> canopyTop(canvas, dec, idx, rng);
|
||||
@@ -59,63 +59,63 @@ public final class TreeDecoratorApplier {
|
||||
}
|
||||
}
|
||||
|
||||
private static void branchTip(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, List<int[]> branchEndpoints, RNG rng) {
|
||||
private static void branchTip(TreeBlockCanvas canvas, TreeDecorator dec, int idx, List<int[]> branchEndpoints, RNG rng) {
|
||||
if (branchEndpoints == null) {
|
||||
return;
|
||||
}
|
||||
for (int[] e : branchEndpoints) {
|
||||
if (rng.nextDouble() > dec.getChance()) {
|
||||
if (rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
if (canvas.has(e[0], e[1], e[2])) {
|
||||
continue;
|
||||
}
|
||||
String facing = dec.isAxisAware() ? facingAway(e[3], e[4], e[0], e[2]) : null;
|
||||
String facing = dec.axisAware() ? facingAway(e[3], e[4], e[0], e[2]) : null;
|
||||
canvas.setDecor(e[0], e[1], e[2], idx, facing);
|
||||
}
|
||||
}
|
||||
|
||||
private static void trunkSurface(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void trunkSurface(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
int[][] sides = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
String[] facings = {"west", "east", "north", "south"};
|
||||
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getTrunk())) {
|
||||
for (int i = 0; i < sides.length; i++) {
|
||||
int nx = v.x() + sides[i][0];
|
||||
int nz = v.z() + sides[i][1];
|
||||
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(nx, v.y(), nz, idx, dec.isAxisAware() ? facings[i] : null);
|
||||
canvas.setDecor(nx, v.y(), nz, idx, dec.axisAware() ? facings[i] : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void leafSurface(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void leafSurface(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
int[][] sides = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
String[] facings = {"west", "east", "north", "south"};
|
||||
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getLeaf())) {
|
||||
for (int i = 0; i < sides.length; i++) {
|
||||
int nx = v.x() + sides[i][0];
|
||||
int nz = v.z() + sides[i][1];
|
||||
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(nx, v.y(), nz, idx, dec.isAxisAware() ? facings[i] : null);
|
||||
canvas.setDecor(nx, v.y(), nz, idx, dec.axisAware() ? facings[i] : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void branchSurface(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void branchSurface(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getTrunk())) {
|
||||
int ay = v.y() + 1;
|
||||
if (canvas.has(v.x(), ay, v.z()) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(v.x(), ay, v.z()) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(v.x(), ay, v.z(), idx, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void canopyTop(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void canopyTop(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
KMap<Long, Integer> colTop = new KMap<>();
|
||||
for (TreeBlockCanvas.Vec v : canvas.getCells().keySet()) {
|
||||
long key = pack(v.x(), v.z());
|
||||
@@ -128,31 +128,31 @@ public final class TreeDecoratorApplier {
|
||||
int x = unpackX(e.getKey());
|
||||
int z = unpackZ(e.getKey());
|
||||
int aboveY = e.getValue() + 1;
|
||||
if (canvas.has(x, aboveY, z) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(x, aboveY, z) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(x, aboveY, z, idx, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void canopyBottom(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void canopyBottom(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
KMap<Long, Integer> colBottom = columnLeafBottoms(canvas);
|
||||
for (Map.Entry<Long, Integer> e : colBottom.entrySet()) {
|
||||
int x = unpackX(e.getKey());
|
||||
int z = unpackZ(e.getKey());
|
||||
int belowY = e.getValue() - 1;
|
||||
if (canvas.has(x, belowY, z) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(x, belowY, z) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(x, belowY, z, idx, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void canopyHang(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
int maxLen = Math.max(1, dec.getLength());
|
||||
private static void canopyHang(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
int maxLen = Math.max(1, dec.length());
|
||||
KMap<Long, Integer> colBottom = columnLeafBottoms(canvas);
|
||||
for (Map.Entry<Long, Integer> e : colBottom.entrySet()) {
|
||||
if (rng.nextDouble() > dec.getChance()) {
|
||||
if (rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
int x = unpackX(e.getKey());
|
||||
@@ -168,7 +168,7 @@ public final class TreeDecoratorApplier {
|
||||
}
|
||||
}
|
||||
|
||||
private static void trunkBase(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void trunkBase(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
int[][] sides = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
|
||||
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getTrunk())) {
|
||||
if (v.y() != 0) {
|
||||
@@ -177,7 +177,7 @@ public final class TreeDecoratorApplier {
|
||||
for (int[] side : sides) {
|
||||
int nx = v.x() + side[0];
|
||||
int nz = v.z() + side[1];
|
||||
if (canvas.has(nx, 0, nz) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(nx, 0, nz) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(nx, 0, nz, idx, null);
|
||||
@@ -185,7 +185,7 @@ public final class TreeDecoratorApplier {
|
||||
}
|
||||
}
|
||||
|
||||
private static void trunkTop(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void trunkTop(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
for (TreeBlockCanvas.Vec v : canvas.getTrunk()) {
|
||||
maxY = Math.max(maxY, v.y());
|
||||
@@ -198,14 +198,14 @@ public final class TreeDecoratorApplier {
|
||||
continue;
|
||||
}
|
||||
int aboveY = v.y() + 1;
|
||||
if (canvas.has(v.x(), aboveY, v.z()) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(v.x(), aboveY, v.z()) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(v.x(), aboveY, v.z(), idx, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void groundScatter(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void groundScatter(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
double cx = 0;
|
||||
double cz = 0;
|
||||
int count = 0;
|
||||
@@ -237,7 +237,7 @@ public final class TreeDecoratorApplier {
|
||||
}
|
||||
int x = icx + dx;
|
||||
int z = icz + dz;
|
||||
if (canvas.has(x, 0, z) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(x, 0, z) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(x, 0, z, idx, null);
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeBranches;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeFunction;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeAzimuthMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeAzimuthMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeBranches;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeFunction;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
public final class TreeFunctions {
|
||||
@@ -65,7 +65,7 @@ public final class TreeFunctions {
|
||||
};
|
||||
}
|
||||
|
||||
public static double curveProgress(IrisTreeFunction fn, double t, double steepness) {
|
||||
public static double curveProgress(TreeFunction fn, double t, double steepness) {
|
||||
return switch (fn) {
|
||||
case LINEAR, CONSTANT, SINE -> t;
|
||||
case LOG -> Math.log(1.0 + t * (Math.E - 1.0));
|
||||
@@ -78,14 +78,14 @@ public final class TreeFunctions {
|
||||
};
|
||||
}
|
||||
|
||||
public static double branchLength(IrisTreeBranches b, double t) {
|
||||
double base = b.getLengthBase();
|
||||
double crown = b.getLengthCrown();
|
||||
double max = b.getLengthMax();
|
||||
double v = switch (b.getLengthFunction()) {
|
||||
case CONSTANT -> b.getLengthConstant();
|
||||
public static double branchLength(TreeBranches b, double t) {
|
||||
double base = b.lengthBase();
|
||||
double crown = b.lengthCrown();
|
||||
double max = b.lengthMax();
|
||||
double v = switch (b.lengthFunction()) {
|
||||
case CONSTANT -> b.lengthConstant();
|
||||
case LINEAR, SINE -> base + (crown - base) * t;
|
||||
case SIGMOID -> max / (1.0 + Math.exp(-b.getLengthSteepness() * (t - 0.5)));
|
||||
case SIGMOID -> max / (1.0 + Math.exp(-b.lengthSteepness() * (t - 0.5)));
|
||||
case LOG -> max * Math.log(1.0 + t * (Math.E - 1.0));
|
||||
case PARABOLIC -> max * (1.0 - Math.pow(2.0 * t - 1.0, 2));
|
||||
case EXPONENTIAL -> geometric(base, crown, t);
|
||||
@@ -97,24 +97,24 @@ public final class TreeFunctions {
|
||||
return Math.max(1.0, v);
|
||||
}
|
||||
|
||||
public static double branchProbability(IrisTreeBranches b, double t, long seed) {
|
||||
double std = Math.max(b.getProbabilityStd(), 1e-6);
|
||||
return switch (b.getProbabilityFunction()) {
|
||||
case CONSTANT -> b.getProbabilityConstant();
|
||||
case LINEAR -> b.getProbabilityBase() + (b.getProbabilityCrown() - b.getProbabilityBase()) * t;
|
||||
case SIGMOID -> 1.0 / (1.0 + Math.exp(-b.getProbabilitySteepness() * (t - b.getProbabilityMidpoint())));
|
||||
case TOP_HEAVY -> Math.pow(t, b.getProbabilityExponent());
|
||||
case GAUSSIAN -> Math.exp(-0.5 * Math.pow((t - b.getProbabilityMean()) / std, 2));
|
||||
case NOISE -> valueNoise1D(t * b.getProbabilityScale(), seed);
|
||||
case BOTTOM_HEAVY -> Math.pow(1.0 - t, b.getProbabilityExponent());
|
||||
case PERIODIC -> b.getProbabilityConstant() * Math.pow(Math.max(0.0, Math.sin(2.0 * Math.PI * t * b.getProbabilityPeriods())), 8);
|
||||
case BAND -> Math.abs(t - b.getProbabilityMean()) <= b.getProbabilityStd() ? b.getProbabilityConstant() : 0.0;
|
||||
case INVERSE_GAUSSIAN -> b.getProbabilityConstant() * (1.0 - Math.exp(-0.5 * Math.pow((t - b.getProbabilityMean()) / std, 2)));
|
||||
case EXPONENTIAL_DECAY -> b.getProbabilityConstant() * Math.exp(-b.getProbabilityExponent() * t);
|
||||
public static double branchProbability(TreeBranches b, double t, long seed) {
|
||||
double std = Math.max(b.probabilityStd(), 1e-6);
|
||||
return switch (b.probabilityFunction()) {
|
||||
case CONSTANT -> b.probabilityConstant();
|
||||
case LINEAR -> b.probabilityBase() + (b.probabilityCrown() - b.probabilityBase()) * t;
|
||||
case SIGMOID -> 1.0 / (1.0 + Math.exp(-b.probabilitySteepness() * (t - b.probabilityMidpoint())));
|
||||
case TOP_HEAVY -> Math.pow(t, b.probabilityExponent());
|
||||
case GAUSSIAN -> Math.exp(-0.5 * Math.pow((t - b.probabilityMean()) / std, 2));
|
||||
case NOISE -> valueNoise1D(t * b.probabilityScale(), seed);
|
||||
case BOTTOM_HEAVY -> Math.pow(1.0 - t, b.probabilityExponent());
|
||||
case PERIODIC -> b.probabilityConstant() * Math.pow(Math.max(0.0, Math.sin(2.0 * Math.PI * t * b.probabilityPeriods())), 8);
|
||||
case BAND -> Math.abs(t - b.probabilityMean()) <= b.probabilityStd() ? b.probabilityConstant() : 0.0;
|
||||
case INVERSE_GAUSSIAN -> b.probabilityConstant() * (1.0 - Math.exp(-0.5 * Math.pow((t - b.probabilityMean()) / std, 2)));
|
||||
case EXPONENTIAL_DECAY -> b.probabilityConstant() * Math.exp(-b.probabilityExponent() * t);
|
||||
};
|
||||
}
|
||||
|
||||
public static double azimuthDegrees(IrisTreeAzimuthMode mode, double t, int index, IrisProceduralTree tree, double constantBase, RNG rng) {
|
||||
public static double azimuthDegrees(TreeAzimuthMode mode, double t, int index, IrisProceduralTree tree, double constantBase, RNG rng) {
|
||||
return switch (mode) {
|
||||
case CONSTANT -> constantBase;
|
||||
case LINEAR -> tree.getAzimuthStart() + (tree.getAzimuthEnd() - tree.getAzimuthStart()) * t;
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeProfile;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeProfile;
|
||||
|
||||
|
||||
public final class TreeProfiles {
|
||||
private TreeProfiles() {
|
||||
}
|
||||
|
||||
static double radiusScale(IrisTreeProfile profile) {
|
||||
static double radiusScale(TreeProfile profile) {
|
||||
return switch (profile) {
|
||||
case OAK, DARK_OAK, CHERRY -> 1.0;
|
||||
case BIRCH -> 0.7;
|
||||
@@ -41,7 +42,7 @@ public final class TreeProfiles {
|
||||
};
|
||||
}
|
||||
|
||||
static double[][] fractions(IrisTreeProfile profile) {
|
||||
static double[][] fractions(TreeProfile profile) {
|
||||
return switch (profile) {
|
||||
case OAK -> new double[][]{{0.55, 0.6}, {0.65, 0.9}, {0.75, 1.0}, {0.85, 0.9}, {0.92, 0.65}, {0.98, 0.35}};
|
||||
case BIRCH -> new double[][]{{0.6, 0.45}, {0.7, 0.75}, {0.8, 0.85}, {0.88, 0.75}, {0.94, 0.45}, {0.99, 0.2}};
|
||||
@@ -59,7 +60,7 @@ public final class TreeProfiles {
|
||||
};
|
||||
}
|
||||
|
||||
static double[][] presetLayers(IrisTreeProfile profile, int height, boolean branchDriven) {
|
||||
static double[][] presetLayers(TreeProfile profile, int height, boolean branchDriven) {
|
||||
double scale = radiusScale(profile);
|
||||
int baseRadius = Math.max(3, (int) Math.round(height / 2.0 * scale));
|
||||
double[][] fractions = fractions(profile);
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeRootStyle;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeRootStyle;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -58,7 +58,7 @@ public final class TreeRootBuilder {
|
||||
}
|
||||
double flare = tree.getRootFlare() > 0 ? tree.getRootFlare() : baseRadius + Math.max(2.0, depth * 0.6);
|
||||
|
||||
IrisTreeRootStyle style = tree.getRootStyle();
|
||||
TreeRootStyle style = tree.getRootStyle();
|
||||
switch (style) {
|
||||
case TAPROOT -> taproot(canvas, cells, cx, cz, baseRadius, depth);
|
||||
case BUTTRESS -> {
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeAzimuthMode;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeAzimuthMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -164,7 +164,7 @@ public final class TreeTrunkBuilder {
|
||||
double progress = TreeFunctions.curveProgress(tree.getTrunkCurve(), t, tree.getCurveSteepness());
|
||||
double maxReach = height * Math.tan(Math.toRadians(tree.getLeanAngle()));
|
||||
double reach = maxReach * progress;
|
||||
double azDeg = tree.getLeanAzimuthMode() == IrisTreeAzimuthMode.CONSTANT
|
||||
double azDeg = tree.getLeanAzimuthMode() == TreeAzimuthMode.CONSTANT
|
||||
? tree.getLeanAzimuth()
|
||||
: TreeFunctions.azimuthDegrees(tree.getLeanAzimuthMode(), t, -1, tree, tree.getLeanAzimuth(), null);
|
||||
double azRad = Math.toRadians(azDeg);
|
||||
|
||||
Reference in new issue
Block a user