Port parts-based procedural objects

- Add the v5 parts system under generation/procedural
- Load procedural/<path>.json as a pack resource
- Resolve procedural/<path> and procedural/<path>#<n> object keys
- List procedural keys with the pack's objects
- Rebake procedural objects when pack caches are cleared
- Use v4 noise for procedural palettes
This commit is contained in:
piexel committed 2026-11-14 15:43:31 +01:00
1 parent 832070cd69
commit bdf6ad7cd0
128 files changed
+14432 -2

No files matched your search

@@ -0,0 +1,85 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural;
/**
* How long baking a pool of variants took, stage by stage, added up over every variant. {@link #NONE} times nothing,
* so world generation bakes at full speed.
*/
public class BakeProfile {
public static final BakeProfile NONE = new BakeProfile() {
@Override
public void startVariant() {
}
@Override
public void lap(Stage stage) {
}
};
/** The steps a variant is baked in, in order. */
public enum Stage {
PARTS("Parts"),
PAINT("Paint"),
DECORATE("Decorate"),
LEAVES("Leaves"),
BUILD("Build");
private final String label;
Stage(String label) {
this.label = label;
}
public String label() {
return label;
}
}
private final long[] nanosByStage = new long[Stage.values().length];
private long lapStartNanos;
private int variantCount;
public void startVariant() {
variantCount++;
lapStartNanos = System.nanoTime();
}
/** Adds the time since the variant started, or since the last lap, to {@code stage}. */
public void lap(Stage stage) {
long now = System.nanoTime();
nanosByStage[stage.ordinal()] += now - lapStartNanos;
lapStartNanos = now;
}
public long nanos(Stage stage) {
return nanosByStage[stage.ordinal()];
}
public long totalNanos() {
long total = 0L;
for (long nanos : nanosByStage) {
total += nanos;
}
return total;
}
public int variantCount() {
return variantCount;
}
}
@@ -0,0 +1,79 @@
/*
* 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.generation.procedural;
import art.arcane.iris.generation.block.B;
import art.arcane.iris.generation.geometry.IrisBlockVector;
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.structure.object.IrisObject;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.volmlib.util.math.RNG;
import java.util.HashMap;
import java.util.Map;
/** Builds objects block by block for the procedural objects, with blocks as the platform has them. */
public final class ObjectBuilder {
private final IrisData data;
private final Map<Long, RNG> paletteRngs = new HashMap<>();
public ObjectBuilder(IrisData data) {
this.data = data;
}
/** The platform's state for {@code key}; null when the platform has no such block. */
public NativeBlockState block(String key) {
return B.getStateOrNull(key, false);
}
/** The block {@code palette} gives at the position when its noise is seeded with {@code seed}. */
public NativeBlockState pick(IrisMaterialPalette palette, long seed, int x, int y, int z) {
return palette.get(paletteRngs.computeIfAbsent(seed, RNG::new), x, y, z, data);
}
public boolean isAir(NativeBlockState state) {
return B.isAir(state);
}
/** Whether {@code state} is wood: a block of a tree that is not a leaf. */
public boolean isLog(NativeBlockState state) {
return state.isTreeBlock() && !ProceduralBlocks.hasProperty(state, "distance");
}
/** {@code state} with the property set, as the platform sets it; {@code state} itself when the block does not accept it. */
public NativeBlockState withPropertyIfAccepted(NativeBlockState state, String name, String value) {
try {
return state.withProperty(name, value);
} catch (IllegalArgumentException notAccepted) {
return state;
}
}
/** The object of {@code blocks}, put in their order, {@code width} by {@code height} by {@code depth}. */
public IrisObject build(String name, ProceduralShape shape) {
IrisObject object = new IrisObject(shape.width(), shape.height(), shape.depth());
object.setLoadKey(name);
object.setLoader(data);
for (ProceduralBlock block : shape.blocks()) {
object.getBlocks().put(new IrisBlockVector(block.x(), block.y(), block.z()), block.state());
}
return object;
}
}
@@ -0,0 +1,25 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
/** One block of a procedural object, at its position around the object's anchor. */
public record ProceduralBlock(int x, int y, int z, NativeBlockState state) {
}
@@ -0,0 +1,102 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural;
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.volmlib.util.math.Vector3i;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* Block helpers for baking procedural objects: reading a state's properties, and assembling a raw block map into a
* shape centered on x and z with its lowest layer one block above the anchor.
*/
public final class ProceduralBlocks {
/** The distance vanilla gives a leaf with no wood near enough to keep it. */
public static final int UNREACHED_LEAF_DISTANCE = 7;
private ProceduralBlocks() {
}
public static boolean isLeafTooFarFromWood(NativeBlockState state) {
return hasProperty(state, "persistent") && String.valueOf(UNREACHED_LEAF_DISTANCE).equals(propertyValue(state, "distance"));
}
public static boolean paletteSet(IrisMaterialPalette palette) {
return IrisProceduralBlocks.paletteSet(palette);
}
public static boolean hasProperty(NativeBlockState state, String property) {
return IrisProceduralBlocks.hasProperty(state, property);
}
public static String propertyValue(NativeBlockState state, String property) {
return IrisProceduralBlocks.propertyValue(state, property);
}
/** The blocks centered on x and z, with their lowest layer one block above the anchor; null when there are none. */
public static ProceduralShape assemble(Map<Vector3i, NativeBlockState> blocks) {
if (blocks == null || blocks.isEmpty()) {
return null;
}
Anchor anchor = Anchor.of(blocks.keySet());
List<ProceduralBlock> placed = new ArrayList<>(blocks.size());
for (Map.Entry<Vector3i, NativeBlockState> entry : blocks.entrySet()) {
placed.add(anchor.place(entry.getKey(), entry.getValue()));
}
return new ProceduralShape(anchor.width(), anchor.height(), anchor.depth(), placed);
}
/** Where {@link #assemble} moves each block of a set: centered on x and z, its lowest layer one block above the anchor. */
public record Anchor(int minX, int minZ, int width, int height, int depth) {
public static Anchor of(Collection<Vector3i> positions) {
int minX = Integer.MAX_VALUE;
int minY = Integer.MAX_VALUE;
int minZ = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE;
int maxY = Integer.MIN_VALUE;
int maxZ = Integer.MIN_VALUE;
for (Vector3i v : positions) {
minX = Math.min(minX, v.getBlockX());
minY = Math.min(minY, v.getBlockY());
minZ = Math.min(minZ, v.getBlockZ());
maxX = Math.max(maxX, v.getBlockX());
maxY = Math.max(maxY, v.getBlockY());
maxZ = Math.max(maxZ, v.getBlockZ());
}
return new Anchor(minX, minZ, maxX - minX + 1, maxY - minY + 1, maxZ - minZ + 1);
}
public ProceduralBlock place(Vector3i position, NativeBlockState state) {
return new ProceduralBlock(position.getBlockX() - minX - width / 2, position.getBlockY() - height / 2 + 1,
position.getBlockZ() - minZ - depth / 2, state);
}
public ProceduralBlock place(Vector3i position) {
return place(position, null);
}
}
}
@@ -0,0 +1,135 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural;
import art.arcane.iris.generation.procedural.part.ProceduralObject;
import art.arcane.iris.generation.procedural.part.ResolvedProceduralObject;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.pack.loading.ResourceLoader;
import art.arcane.iris.structure.object.IrisObject;
import art.arcane.volmlib.util.math.RNG;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
/**
* The pack's procedural objects, each read from {@code procedural/<path>.json} and placed from any object placement
* as {@code procedural/<path>}, or one variant as {@code procedural/<path>#<index>}. Variants are baked on first use.
*/
public final class ProceduralObjectCatalog {
public static final String KEY_PREFIX = "procedural/";
public static final char VARIANT_SEPARATOR = '#';
private final IrisData data;
private final Map<String, Optional<ProceduralVariants>> variantsByPath = new ConcurrentHashMap<>();
public ProceduralObjectCatalog(IrisData data) {
this.data = data;
}
/** Whether {@code key} names a procedural object rather than a pack object. */
public static boolean isProceduralKey(String key) {
return key != null && key.startsWith(KEY_PREFIX);
}
/** The variant {@code key} pins, or for a key naming the whole pool the one {@code rng} picks; empty when none. */
public Optional<IrisObject> object(String key, RNG rng) {
ObjectKey parsed = ObjectKey.parse(key);
return variantsNamedBy(parsed).flatMap(variants -> parsed.isPinned() ? variants.variant(parsed.variantIndex()) : variants.variant(rng));
}
/**
* The variant {@code key} pins, or for a key naming the whole pool its first variant, so a caller without a random
* stream still gets the same object every time; empty when none.
*/
public Optional<IrisObject> object(String key) {
ObjectKey parsed = ObjectKey.parse(key);
return variantsNamedBy(parsed).flatMap(variants -> parsed.isPinned()
? variants.variant(parsed.variantIndex())
: variants.variants().stream().findFirst());
}
/** The variants {@code key} names, pinned to one or not; empty when the pack has no such object. */
public Optional<ProceduralVariants> variants(String key) {
return variantsNamedBy(ObjectKey.parse(key));
}
/** Every variant {@code key} may place: the one it pins, or the whole pool. */
public List<IrisObject> placeable(String key) {
ObjectKey parsed = ObjectKey.parse(key);
return variantsNamedBy(parsed).map(variants -> parsed.isPinned()
? variants.variant(parsed.variantIndex()).stream().toList()
: variants.variants()).orElse(List.of());
}
/** The key of every definition the pack has, naming its whole variant pool. */
public List<String> definitionKeys() {
ResourceLoader<ProceduralObject> loader = data.getProceduralObjectLoader();
if (loader == null) {
return List.of();
}
return Arrays.stream(loader.getPossibleKeys()).map(path -> KEY_PREFIX + path).toList();
}
/** Forgets every baked variant, so the next lookup bakes from the definitions as they are now. */
public void invalidate() {
variantsByPath.clear();
}
private Optional<ProceduralVariants> variantsNamedBy(ObjectKey key) {
return variantsByPath.computeIfAbsent(key.path(), this::resolve);
}
private Optional<ProceduralVariants> resolve(String path) {
ResourceLoader<ProceduralObject> loader = data.getProceduralObjectLoader();
if (loader == null) {
return Optional.empty();
}
ProceduralObject definition = loader.load(path, false);
if (definition == null) {
return Optional.empty();
}
return Optional.of(new ResolvedProceduralObject(path, definition, data));
}
/** A procedural object key split into the definition's path and, when it pins one, a variant index. */
private record ObjectKey(String path, int variantIndex) {
private static final int UNPINNED = -1;
static ObjectKey parse(String key) {
String path = key.substring(KEY_PREFIX.length());
int separator = path.lastIndexOf(VARIANT_SEPARATOR);
if (separator < 0) {
return new ObjectKey(path, UNPINNED);
}
try {
return new ObjectKey(path.substring(0, separator), Integer.parseInt(path.substring(separator + 1)));
} catch (NumberFormatException notAnIndex) {
return new ObjectKey(path, UNPINNED);
}
}
boolean isPinned() {
return variantIndex != UNPINNED;
}
}
}
@@ -0,0 +1,25 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural;
import java.util.List;
/** A procedural object's blocks around its anchor, in the order they were made, and the size of the box they fill. */
public record ProceduralShape(int width, int height, int depth, List<ProceduralBlock> blocks) {
}
@@ -0,0 +1,142 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.structure.object.IrisObject;
import art.arcane.volmlib.util.math.RNG;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* The pool of variants one procedural definition bakes, placed through the object key {@code procedural/<path>}: a
* placement picks one variant per object it places, or always the same one with {@code procedural/<path>#<index>}.
*/
public abstract class ProceduralVariants {
private static final long VARIANT_SEED_STRIDE = 7919L;
private final String path;
private final long seed;
private final int variantCount;
private final IrisData data;
private volatile List<IrisObject> baked;
protected ProceduralVariants(String path, long seed, int variantCount, IrisData data) {
this.path = path;
this.seed = seed;
this.variantCount = Math.max(1, variantCount);
this.data = data;
}
/** The shape variant {@code index} is baked as, from its own seeded stream; null when it has no blocks. */
protected abstract ProceduralShape generate(int index, RNG rng, ObjectBuilder blocks, BakeProfile profile);
/** Where the pack keeps the definition, under {@code procedural/}, like {@code trees/oak}. */
public String path() {
return path;
}
/** The key placements name the whole pool by, like {@code procedural/trees/oak}. */
public String key() {
return ProceduralObjectCatalog.KEY_PREFIX + path;
}
/** The key variant {@code index} is placed under, like {@code procedural/trees/oak#0}. */
public String variantKey(int index) {
return key() + ProceduralObjectCatalog.VARIANT_SEPARATOR + index;
}
/** How many variants the definition asks for, known without baking; a variant may still bake no blocks. */
public int variantCount() {
return variantCount;
}
/** Every variant, baked on first use. */
public List<IrisObject> variants() {
List<IrisObject> known = baked;
if (known != null) {
return known;
}
synchronized (this) {
if (baked == null) {
baked = List.copyOf(bake(newBuilder(), BakeProfile.NONE));
}
return baked;
}
}
/** Bakes every variant again the way world generation does, without keeping them, and times each stage. */
public BakeProfile profile() {
BakeProfile profile = new BakeProfile();
bake(newBuilder(), profile);
return profile;
}
/** One of the variants, picked with {@code rng}; empty when none baked. */
public Optional<IrisObject> variant(RNG rng) {
List<IrisObject> all = variants();
return all.isEmpty() ? Optional.empty() : Optional.of(all.get(rng.i(all.size())));
}
/** The variant baked at {@code index}; empty when it baked no blocks or the definition asks for fewer. */
public Optional<IrisObject> variant(int index) {
String key = variantKey(index);
return variants().stream().filter(variant -> key.equals(variant.getLoadKey())).findFirst();
}
/** Bakes every variant; variant {@code i} is drawn from {@code seed + i * stride}. */
private List<IrisObject> bake(ObjectBuilder blocks, BakeProfile profile) {
List<IrisObject> all = new ArrayList<>();
for (int i = 0; i < variantCount; i++) {
profile.startVariant();
ProceduralShape generated = generate(i, variantRng(i), blocks, profile);
if (generated == null || generated.blocks().isEmpty()) {
continue;
}
all.add(blocks.build(variantKey(i), generated));
profile.lap(BakeProfile.Stage.BUILD);
}
return all;
}
protected final RNG variantRng(int index) {
return new RNG(seed + (index * VARIANT_SEED_STRIDE));
}
/** The index {@code variant} was baked at; -1 when it is not one of these variants. */
protected final int bakeIndexOf(IrisObject variant) {
for (int index = 0; index < variantCount; index++) {
if (variantKey(index).equals(variant.getLoadKey())) {
return index;
}
}
return -1;
}
protected final ObjectBuilder newBuilder() {
return new ObjectBuilder(data);
}
/** The seed every variant is baked from. */
public final long seed() {
return seed;
}
}
@@ -0,0 +1,160 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.math.RNG;
/**
* A blob: a volume around a center whose horizontal cross-section is scaled by a profile from its bottom to its top,
* an ellipsoid unless the pack shapes it, optionally hollowed into a shell.
*/
final class BlobShape implements PartShape {
private static final double LARGEST_RADIUS_BLOCKS = 96;
private static final double MINIMUM_RADIUS_BLOCKS = 0.05;
private static final int[][] SHELL_DIRECTIONS = {{1, 0, 0}, {-1, 0, 0}, {0, 0, 1}, {0, 0, -1}, {0, 1, 0}, {0, -1, 0}};
private static final int[][] OPEN_SHELL_DIRECTIONS = {{1, 0, 0}, {-1, 0, 0}, {0, 0, 1}, {0, 0, -1}, {0, 1, 0}};
private final double[] center;
private final double radiusX;
private final double radiusZ;
private final double up;
private final double down;
private final ProceduralValue profile;
private final PartSection section;
private final double shell;
private final boolean open;
private final double outward;
private BlobShape(double[] center, double radiusX, double radiusZ, double up, double down, ProceduralValue profile,
PartSection section, double shell, boolean open, double outward) {
this.center = center;
this.radiusX = radiusX;
this.radiusZ = radiusZ;
this.up = up;
this.down = down;
this.profile = profile;
this.section = section;
this.shell = shell;
this.open = open;
this.outward = outward;
}
static BlobShape trace(PartBlob blob, PartSpot spot, RNG rng) {
double t = spot.parentT();
double radius = clampRadius(blob.radius().sample(rng, t));
double up = blob.height() == null ? radius : clampRadius(blob.height().sample(rng, t));
double down = blob.depth() == null ? up : Math.max(0, Math.min(LARGEST_RADIUS_BLOCKS, blob.depth().sample(rng, t)));
double shell = Math.max(0, blob.shell().sample(rng, t));
double outward = spot.hasOutward() ? spot.outward() : rng.d(0, 360);
return new BlobShape(spot.origin(), Math.max(MINIMUM_RADIUS_BLOCKS, radius * blob.stretchX()),
Math.max(MINIMUM_RADIUS_BLOCKS, radius * blob.stretchZ()), up, down,
blob.profile() == null ? null : blob.profile().fix(rng), blob.section(), shell, blob.open(), outward);
}
void draw(PartFill fill, double roughness, double jitter) {
int reachX = (int) Math.ceil(radiusX * (1 + roughness) + 1);
int reachZ = (int) Math.ceil(radiusZ * (1 + roughness) + 1);
int cx = (int) Math.round(center[0]);
int cy = (int) Math.round(center[1]);
int cz = (int) Math.round(center[2]);
for (int y = cy - (int) Math.ceil(down) - 1; y <= cy + (int) Math.ceil(up) + 1; y++) {
for (int x = cx - reachX; x <= cx + reachX; x++) {
for (int z = cz - reachZ; z <= cz + reachZ; z++) {
drawBlock(fill, x, y, z, roughness, jitter);
}
}
}
}
private void drawBlock(PartFill fill, int x, int y, int z, double roughness, double jitter) {
if (!inside(x, y, z, roughness, fill.seed())) {
return;
}
if (shell > 0 && !nearSurface(x, y, z, roughness, fill.seed())) {
return;
}
double dx = x - center[0];
double dy = y - center[1];
double dz = z - center[2];
double edge = edge(dx, dy, dz);
if (jitter > 0 && edge > 1 - 1 / (Math.max(radiusX, radiusZ) + 1) && PartNoise.hash(x, y, z, fill.seed() + 77L) < jitter * 0.35) {
return;
}
double height = (dy + down + 0.5) / (up + down + 1);
double falloffEdge = Math.sqrt(sq(dx / (radiusX + 1)) + sq(dy / ((dy >= 0 ? up : down) + 1)) + sq(dz / (radiusZ + 1)));
fill.place(x, y, z, falloffEdge, height, PartCanvas.Axis.Y);
}
private boolean inside(int x, int y, int z, double roughness, long seed) {
double wobble = roughness <= 0 ? 0 : (PartNoise.hash(x, y, z, seed + 4201L) - 0.5) * roughness * 1.2;
return edge(x - center[0], y - center[1], z - center[2]) <= 1 + wobble;
}
/** Whether the outside lies within the shell's thickness, looking up and sideways, and down unless the shell is open. */
private boolean nearSurface(int x, int y, int z, double roughness, long seed) {
int thickness = Math.max(1, (int) Math.round(shell));
int[][] directions = open ? OPEN_SHELL_DIRECTIONS : SHELL_DIRECTIONS;
for (int step = 1; step <= thickness; step++) {
for (int[] direction : directions) {
if (!inside(x + direction[0] * step, y + direction[1] * step, z + direction[2] * step, roughness, seed)) {
return true;
}
}
}
return false;
}
/** How far out a point is, where 1 is the surface; above 1 is outside. */
private double edge(double dx, double dy, double dz) {
double vertical = dy >= 0 ? dy / (up + 0.5) : dy / (down + 0.5);
if (Math.abs(vertical) > 1) {
return Double.MAX_VALUE;
}
double width = profile == null
? Math.sqrt(1 - vertical * vertical)
: Math.max(0, profile.at((dy + down + 0.5) / (up + down + 1)));
if (width <= 0) {
return Double.MAX_VALUE;
}
return Sections.norm(section, dx / radiusX, dz / radiusZ) / width;
}
@Override
public PartSpot spotAt(double t) {
double y = center[1] - down + Math.max(0, Math.min(1, t)) * (up + down);
return new PartSpot(new double[]{center[0], y, center[2]}, Vectors.UP.clone(), t, up + down + 1, outward);
}
@Override
public double length() {
return up + down + 1;
}
@Override
public double defaultAt() {
return 1;
}
private static double clampRadius(double radius) {
return Math.max(0, Math.min(LARGEST_RADIUS_BLOCKS, radius));
}
private static double sq(double value) {
return value * value;
}
}
@@ -0,0 +1,45 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.iris.generation.procedural.ProceduralBlocks;
import art.arcane.iris.generation.procedural.ObjectBuilder;
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
/** A block or a noise palette to take one from, optionally banded by height for strata. */
record BlockChoice(String block, IrisMaterialPalette palette, int bands) {
/** The block at the position; null when neither block nor palette names one. */
NativeBlockState at(ObjectBuilder blocks, long seed, int x, int y, int z) {
if (ProceduralBlocks.paletteSet(palette)) {
if (bands > 0) {
int band = Math.floorDiv(y, bands);
return blocks.pick(palette, seed + band * 31L, x, band, z);
}
return blocks.pick(palette, seed, x, y, z);
}
if (block == null || block.isEmpty()) {
return null;
}
return blocks.block(block);
}
boolean isSet() {
return ProceduralBlocks.paletteSet(palette) || (block != null && !block.isEmpty());
}
}
@@ -0,0 +1,28 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
/** The six sides of a block; the lower-cased name is the block state property value that faces that way. */
enum BlockFace {
UP,
DOWN,
NORTH,
SOUTH,
EAST,
WEST
}
@@ -0,0 +1,36 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
@Description("Which way around its parent each new branch points.")
public enum BranchAzimuth {
@Description("Any direction.")
RANDOM,
@Description("Each branch turns the golden angle (about 137.5 degrees) from the last, so none line up.")
GOLDEN,
@Description("Each branch points opposite the last.")
ALTERNATE,
@Description("Branches come in rings of 'whorl' evenly spaced branches.")
WHORL,
@Description("All branches are spread evenly around the parent.")
EVEN,
@Description("Branches fan out side by side around the parent's own direction, 'fan' degrees apart.")
FAN
}
@@ -0,0 +1,32 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
@Description("How the parts of a cluster are laid out around its center.")
public enum ClusterLayout {
@Description("Anywhere inside the radius.")
RANDOM,
@Description("Evenly spaced on a circle of the radius.")
RING,
@Description("In a row across the radius.")
LINE,
@Description("A sunflower spiral filling the radius evenly.")
GOLDEN
}
@@ -0,0 +1,38 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
@Description("Where a decoration is placed on the object.")
public enum DecorationSpot {
@Description("On every block that is open above.")
ABOVE,
@Description("Under every block that is open below; set length for hanging strands.")
BELOW,
@Description("Against every open horizontal side.")
SIDE,
@Description("On the highest block of each column.")
TOP,
@Description("Under the lowest block of each column; set length for hanging strands.")
BOTTOM,
@Description("Just past the end of every stem.")
TIPS,
@Description("On the ground around where the object stands, out to the radius.")
GROUND
}
@@ -0,0 +1,269 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.iris.generation.procedural.ProceduralBlocks;
import art.arcane.iris.generation.procedural.ObjectBuilder;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
/**
* Places decorations against the painted object. A decoration attaches to the block it rests on: vines and lichen
* grow toward it, directional blocks face away from it and lanterns hang under it.
*/
final class Decorator {
private static final long DECORATION_SEED_STRIDE = 911L;
private static final BlockFace[] SIDES = {BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH};
private final PartCanvas canvas;
private final Map<Long, NativeBlockState> painted;
private final ObjectBuilder blocks;
private final long paletteSeed;
private final int groundY;
/** @param groundY the lowest height above the terrain; anything below it ends up buried, so nothing decorates there */
Decorator(PartCanvas canvas, Map<Long, NativeBlockState> painted, ObjectBuilder blocks, long paletteSeed, int groundY) {
this.canvas = canvas;
this.painted = painted;
this.blocks = blocks;
this.paletteSeed = paletteSeed;
this.groundY = groundY;
}
void decorate(List<ProceduralDecoration> decorations, long seed) {
for (int index = 0; index < decorations.size(); index++) {
ProceduralDecoration decoration = decorations.get(index);
if (!decoration.choice().isSet()) {
continue;
}
long decorationSeed = seed + index * DECORATION_SEED_STRIDE;
RNG rng = new RNG(decorationSeed);
for (Spot spot : spots(decoration, rng)) {
if (spot.y() >= groundY && PartNoise.passes(decoration.pattern(), decoration.chance(), decoration.scale(), spot.x(), spot.y(), spot.z(), decorationSeed)) {
place(decoration, spot, rng);
}
}
}
}
private void place(ProceduralDecoration decoration, Spot spot, RNG rng) {
boolean hangs = decoration.at() == DecorationSpot.BELOW || decoration.at() == DecorationSpot.BOTTOM;
int strand = hangs ? Math.max(1, (int) Math.round(decoration.length().sample(rng, 0))) : 1;
for (int step = 0; step < strand; step++) {
int y = spot.y() - step;
long key = PartCanvas.key(spot.x(), y, spot.z());
if (y < groundY || painted.containsKey(key)) {
return;
}
NativeBlockState state = decoration.choice().at(blocks, paletteSeed, spot.x(), y, spot.z());
if (state == null || blocks.isAir(state)) {
return;
}
painted.put(key, attached(state, spot.support()));
}
}
private List<Spot> spots(ProceduralDecoration decoration, RNG rng) {
List<Long> decorated = decoratedBlocks(decoration);
return switch (decoration.at()) {
case ABOVE -> besideEach(decorated, BlockFace.UP);
case BELOW -> besideEach(decorated, BlockFace.DOWN);
case SIDE -> besideEach(decorated, SIDES);
case TOP -> columnEnds(decorated, true);
case BOTTOM -> columnEnds(decorated, false);
case TIPS -> tips(decoration);
case GROUND -> ground(decoration.radius().sample(rng, 0));
};
}
/** The painted blocks of the roles the decoration is for, in a stable order. */
private List<Long> decoratedBlocks(ProceduralDecoration decoration) {
Set<Integer> roles = new HashSet<>();
for (String role : decoration.on()) {
roles.add(canvas.role(role));
}
List<Long> decorated = new ArrayList<>();
for (long key : painted.keySet()) {
PartCanvas.Cell cell = canvas.get(key);
if (cell != null && (roles.isEmpty() || roles.contains(cell.role()))) {
decorated.add(key);
}
}
decorated.sort(Long::compare);
return decorated;
}
private List<Spot> besideEach(List<Long> decorated, BlockFace... faces) {
List<Spot> spots = new ArrayList<>();
Set<Long> taken = new HashSet<>();
for (long key : decorated) {
for (BlockFace face : faces) {
int[] step = stepToward(face);
int x = PartCanvas.x(key) + step[0];
int y = PartCanvas.y(key) + step[1];
int z = PartCanvas.z(key) + step[2];
long spotKey = PartCanvas.key(x, y, z);
if (!painted.containsKey(spotKey) && taken.add(spotKey)) {
spots.add(new Spot(x, y, z, opposite(face)));
}
}
}
return spots;
}
private List<Spot> columnEnds(List<Long> decorated, boolean top) {
Map<Long, Integer> endByColumn = new HashMap<>();
for (long key : decorated) {
long column = PartCanvas.key(PartCanvas.x(key), 0, PartCanvas.z(key));
int y = PartCanvas.y(key);
endByColumn.merge(column, y, top ? Math::max : Math::min);
}
List<Spot> spots = new ArrayList<>();
endByColumn.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(entry -> {
int x = PartCanvas.x(entry.getKey());
int z = PartCanvas.z(entry.getKey());
int y = entry.getValue() + (top ? 1 : -1);
if (!painted.containsKey(PartCanvas.key(x, y, z))) {
spots.add(new Spot(x, y, z, top ? BlockFace.DOWN : BlockFace.UP));
}
});
return spots;
}
private List<Spot> tips(ProceduralDecoration decoration) {
Set<Integer> roles = new HashSet<>();
for (String role : decoration.on()) {
roles.add(canvas.role(role));
}
List<Spot> spots = new ArrayList<>();
for (PartCanvas.Tip tip : canvas.tips()) {
if (!roles.isEmpty() && !roles.contains(tip.role())) {
continue;
}
int x = tip.x() + (int) Math.round(tip.heading()[0]);
int y = tip.y() + (int) Math.round(tip.heading()[1]);
int z = tip.z() + (int) Math.round(tip.heading()[2]);
if (!painted.containsKey(PartCanvas.key(x, y, z))) {
spots.add(new Spot(x, y, z, supportToward(tip.x() - x, tip.y() - y, tip.z() - z)));
}
}
return spots;
}
/** Every open ground spot within the radius of where the object stands, so an arch gets plants around both feet. */
private List<Spot> ground(double radius) {
int reach = (int) Math.ceil(radius);
Set<Long> nearby = new TreeSet<>();
for (long foot : footprint()) {
int footX = PartCanvas.x(foot);
int footZ = PartCanvas.z(foot);
for (int x = footX - reach; x <= footX + reach; x++) {
for (int z = footZ - reach; z <= footZ + reach; z++) {
if (Math.hypot(x - footX, z - footZ) <= radius) {
nearby.add(PartCanvas.key(x, groundY, z));
}
}
}
}
List<Spot> spots = new ArrayList<>();
for (long key : nearby) {
int x = PartCanvas.x(key);
int z = PartCanvas.z(key);
if (!painted.containsKey(key) && !painted.containsKey(PartCanvas.key(x, groundY + 1, z))) {
spots.add(new Spot(x, groundY, z, BlockFace.DOWN));
}
}
return spots;
}
/** The columns where the object meets the ground, or its origin if it does not reach the ground. */
private Set<Long> footprint() {
Set<Long> footprint = new TreeSet<>();
for (long key : painted.keySet()) {
if (PartCanvas.y(key) == groundY) {
footprint.add(PartCanvas.key(PartCanvas.x(key), groundY, PartCanvas.z(key)));
}
}
if (footprint.isEmpty()) {
footprint.add(PartCanvas.key(0, groundY, 0));
}
return footprint;
}
private static BlockFace supportToward(int dx, int dy, int dz) {
if (dy > 0) {
return BlockFace.UP;
}
if (dy < 0) {
return BlockFace.DOWN;
}
if (Math.abs(dx) >= Math.abs(dz)) {
return dx >= 0 ? BlockFace.EAST : BlockFace.WEST;
}
return dz >= 0 ? BlockFace.SOUTH : BlockFace.NORTH;
}
/** {@code state} turned to rest on the block toward {@code support}. */
private NativeBlockState attached(NativeBlockState state, BlockFace support) {
String side = support.name().toLowerCase();
if ("false".equals(ProceduralBlocks.propertyValue(state, side))) {
return blocks.withPropertyIfAccepted(state, side, "true");
}
if (support == BlockFace.UP && ProceduralBlocks.hasProperty(state, "hanging")) {
return blocks.withPropertyIfAccepted(state, "hanging", "true");
}
if (ProceduralBlocks.hasProperty(state, "facing")) {
return blocks.withPropertyIfAccepted(state, "facing",opposite(support).name().toLowerCase());
}
return state;
}
private static int[] stepToward(BlockFace face) {
return switch (face) {
case UP -> new int[]{0, 1, 0};
case DOWN -> new int[]{0, -1, 0};
case NORTH -> new int[]{0, 0, -1};
case SOUTH -> new int[]{0, 0, 1};
case EAST -> new int[]{1, 0, 0};
case WEST -> new int[]{-1, 0, 0};
};
}
private static BlockFace opposite(BlockFace face) {
return switch (face) {
case UP -> BlockFace.DOWN;
case DOWN -> BlockFace.UP;
case NORTH -> BlockFace.SOUTH;
case SOUTH -> BlockFace.NORTH;
case EAST -> BlockFace.WEST;
case WEST -> BlockFace.EAST;
};
}
/** An empty block a decoration may go in, and the side its support is on. */
private record Spot(int x, int y, int z, BlockFace support) {
}
}
@@ -0,0 +1,131 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.iris.generation.procedural.ProceduralBlocks;
import art.arcane.iris.generation.procedural.ObjectBuilder;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Gives leaves the state vanilla decay expects: every leaf is told its distance to wood. Leaves farther from wood than
* vanilla keeps are made persistent, so they stay; the pack's parts should keep wood near them instead.
*/
final class LeafDecay {
private static final int UNREACHED_DISTANCE = ProceduralBlocks.UNREACHED_LEAF_DISTANCE;
private static final int[][] NEIGHBORS = {{1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}};
private final Map<Long, NativeBlockState> blocks;
private final ObjectBuilder builder;
private final Set<Long> leaves = new LinkedHashSet<>();
private LeafDecay(Map<Long, NativeBlockState> blocks, ObjectBuilder builder) {
this.blocks = blocks;
this.builder = builder;
List<Long> keys = new ArrayList<>(blocks.keySet());
keys.sort(Long::compare);
for (long key : keys) {
if (isLeaf(blocks.get(key))) {
leaves.add(key);
}
}
}
/** Leaves that decay naturally, except those too far from wood, which are kept persistent. */
static void supportLeaves(Map<Long, NativeBlockState> blocks, ObjectBuilder builder) {
LeafDecay decay = new LeafDecay(blocks, builder);
if (decay.leaves.isEmpty()) {
return;
}
decay.markDistances();
}
/** Leaves that never decay. */
static void persistLeaves(Map<Long, NativeBlockState> blocks, ObjectBuilder builder) {
LeafDecay decay = new LeafDecay(blocks, builder);
for (long leaf : decay.leaves) {
decay.setLeafState(leaf, true, 1);
}
}
private void markDistances() {
Map<Long, Integer> distance = distances();
for (long leaf : leaves) {
Integer d = distance.get(leaf);
if (d != null && d < UNREACHED_DISTANCE) {
setLeafState(leaf, false, Math.max(1, d));
} else {
setLeafState(leaf, true, UNREACHED_DISTANCE);
}
}
}
/** How many leaf steps each leaf is from wood, up to the farthest vanilla tracks. */
private Map<Long, Integer> distances() {
Map<Long, Integer> distance = new HashMap<>();
ArrayDeque<Long> queue = new ArrayDeque<>();
for (long leaf : leaves) {
for (int[] n : NEIGHBORS) {
NativeBlockState neighbor = blocks.get(PartCanvas.key(PartCanvas.x(leaf) + n[0], PartCanvas.y(leaf) + n[1], PartCanvas.z(leaf) + n[2]));
if (neighbor != null && builder.isLog(neighbor)) {
distance.put(leaf, 1);
queue.add(leaf);
break;
}
}
}
while (!queue.isEmpty()) {
long leaf = queue.poll();
int d = distance.get(leaf);
if (d >= UNREACHED_DISTANCE) {
continue;
}
for (int[] n : NEIGHBORS) {
long next = PartCanvas.key(PartCanvas.x(leaf) + n[0], PartCanvas.y(leaf) + n[1], PartCanvas.z(leaf) + n[2]);
NativeBlockState state = blocks.get(next);
if (state == null || !isLeaf(state)) {
continue;
}
Integer known = distance.get(next);
if (known == null || known > d + 1) {
distance.put(next, d + 1);
queue.add(next);
}
}
}
return distance;
}
private void setLeafState(long leaf, boolean persistent, int distance) {
NativeBlockState state = blocks.get(leaf);
state = builder.withPropertyIfAccepted(state, "persistent", String.valueOf(persistent));
blocks.put(leaf, builder.withPropertyIfAccepted(state, "distance", String.valueOf(distance)));
}
private static boolean isLeaf(NativeBlockState state) {
return ProceduralBlocks.hasProperty(state, "persistent") && ProceduralBlocks.hasProperty(state, "distance");
}
}
@@ -0,0 +1,134 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.iris.generation.procedural.ProceduralBlocks;
import art.arcane.iris.generation.procedural.ObjectBuilder;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** Turns the canvas into block data: each block takes its role's material, or the first of its rules that applies. */
final class MaterialPainter {
private static final long RULE_SEED_STRIDE = 7907L;
private static final int[][] SIDES = {{1, 0, 0}, {-1, 0, 0}, {0, 0, 1}, {0, 0, -1}};
private final PartCanvas canvas;
private final Map<Integer, ProceduralMaterial> materialByRole = new HashMap<>();
private final ProceduralMaterial fallback;
private final ObjectBuilder blocks;
private final long paletteSeed;
private final long ruleSeed;
private final int lowestY;
private final int heightSpan;
MaterialPainter(PartCanvas canvas, List<ProceduralMaterial> materials, ObjectBuilder blocks, long paletteSeed, long ruleSeed) {
this.canvas = canvas;
this.blocks = blocks;
this.paletteSeed = paletteSeed;
this.ruleSeed = ruleSeed;
this.fallback = materials.isEmpty() ? null : materials.getFirst();
for (ProceduralMaterial material : materials) {
materialByRole.putIfAbsent(canvas.role(material.role()), material);
}
int lowest = Integer.MAX_VALUE;
int highest = Integer.MIN_VALUE;
for (long key : canvas.cells().keySet()) {
lowest = Math.min(lowest, PartCanvas.y(key));
highest = Math.max(highest, PartCanvas.y(key));
}
this.lowestY = lowest;
this.heightSpan = Math.max(1, highest - lowest);
}
/** The block of every claimed position, leaving out those a rule turned to air. */
Map<Long, NativeBlockState> paint() {
Map<Long, NativeBlockState> painted = new HashMap<>();
for (Map.Entry<Long, PartCanvas.Cell> entry : canvas.cells().entrySet()) {
NativeBlockState state = blockFor(entry.getKey(), entry.getValue());
if (state != null && !blocks.isAir(state)) {
painted.put(entry.getKey(), state);
}
}
return painted;
}
private NativeBlockState blockFor(long key, PartCanvas.Cell cell) {
ProceduralMaterial material = materialByRole.getOrDefault(cell.role(), fallback);
if (material == null) {
return null;
}
int x = PartCanvas.x(key);
int y = PartCanvas.y(key);
int z = PartCanvas.z(key);
BlockChoice choice = material.choice();
List<MaterialRule> rules = material.rules();
for (int index = 0; index < rules.size(); index++) {
if (applies(rules.get(index), index, x, y, z, cell)) {
choice = rules.get(index).choice();
break;
}
}
NativeBlockState state = choice.at(blocks, paletteSeed, x, y, z);
if (state == null || blocks.isAir(state)) {
return state;
}
return alignedToAxis(state, cell.axis());
}
private boolean applies(MaterialRule rule, int index, int x, int y, int z, PartCanvas.Cell cell) {
double height = (y - lowestY) / (double) heightSpan;
if (rule.height() != null && !rule.height().contains(height)) {
return false;
}
if (rule.along() != null && !rule.along().contains(cell.along())) {
return false;
}
if (rule.face() != null && !open(rule.face(), x, y, z)) {
return false;
}
return PartNoise.passes(rule.pattern(), rule.chance().at(height), rule.scale(), x, y, z, ruleSeed + index * RULE_SEED_STRIDE);
}
private boolean open(RuleFace face, int x, int y, int z) {
return switch (face) {
case UP -> !canvas.has(x, y + 1, z);
case DOWN -> !canvas.has(x, y - 1, z);
case SIDE -> openSide(x, y, z);
case ANY -> openSide(x, y, z) || !canvas.has(x, y + 1, z) || !canvas.has(x, y - 1, z);
};
}
private boolean openSide(int x, int y, int z) {
for (int[] side : SIDES) {
if (!canvas.has(x + side[0], y, z + side[2])) {
return true;
}
}
return false;
}
private NativeBlockState alignedToAxis(NativeBlockState state, PartCanvas.Axis axis) {
if (axis == PartCanvas.Axis.NONE || !ProceduralBlocks.hasProperty(state, "axis")) {
return state;
}
return blocks.withPropertyIfAccepted(state, "axis",axis.name().toLowerCase());
}
}
@@ -0,0 +1,84 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.MinNumber;
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
@Description("Swaps a material's block where its conditions hold, such as moss on top faces or a cap on the highest blocks. Use minecraft:air to erode blocks away.")
public final class MaterialRule {
@RegistryListBlockType
@Description("The block to swap in. Ignored when palette is set.")
private String block;
@Description("A noise palette to swap in.")
private IrisMaterialPalette palette;
@MinNumber(0)
@Description("If above 0, the palette changes every this many blocks of height, for strata.")
private int bands = 0;
@Description("The chance a block that meets the conditions is swapped. A curve runs from the bottom (0) to the top (1) of the object.")
private ProceduralValue chance = ProceduralValue.constant(1);
@Description("How the chance is spread over the blocks.")
private PartPattern pattern = PartPattern.RANDOM;
@MinNumber(1)
@Description("The size of the patches in blocks for the PATCHES pattern.")
private double scale = 3;
@Description("Only swaps blocks within this stretch of the object's height, from the bottom (0) to the top (1).")
private ProceduralSpan height;
@Description("Only swaps blocks within this stretch of their own part, from its base (0) to its tip (1).")
private ProceduralSpan along;
@Description("Only swaps blocks open to the air on this side.")
private RuleFace face;
public BlockChoice choice() {
return new BlockChoice(block, palette, bands);
}
public ProceduralValue chance() {
return chance == null ? ProceduralValue.constant(1) : chance;
}
public PartPattern pattern() {
return pattern == null ? PartPattern.RANDOM : pattern;
}
public double scale() {
return scale;
}
public ProceduralSpan height() {
return height;
}
public ProceduralSpan along() {
return along;
}
public RuleFace face() {
return face;
}
}
@@ -0,0 +1,120 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.iris.generation.procedural.BakeProfile;
import art.arcane.iris.generation.procedural.ProceduralBlock;
import art.arcane.iris.generation.procedural.ProceduralBlocks;
import art.arcane.iris.generation.procedural.ObjectBuilder;
import art.arcane.iris.generation.procedural.ProceduralShape;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.util.math.Vector3i;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import java.util.HashMap;
import java.util.Map;
/** Bakes one variant of a procedural object: grows its parts, paints them, decorates them and settles the leaves. */
final class ObjectBaker {
private static final long DECORATION_SEED_SALT = 77777L;
private static final long RULE_SEED_SALT = 4111L;
private ObjectBaker() {
}
static ProceduralShape bake(ProceduralObject definition, PartOutline outline, RNG rng, ObjectBuilder blocks, BakeProfile profile) {
BakedBlocks baked = bakeBlocks(definition, outline, rng, blocks, profile);
return baked == null ? null : ProceduralBlocks.assemble(baked.placed());
}
/** Bakes the variant {@code rng} draws, the same as {@link #bake}, and tells which part placed each of its blocks. */
static PartTrace trace(ProceduralObject definition, PartOutline outline, RNG rng, ObjectBuilder blocks) {
BakedBlocks baked = bakeBlocks(definition, outline, rng, blocks, BakeProfile.NONE);
if (baked == null) {
return PartTrace.EMPTY;
}
ProceduralBlocks.Anchor anchor = ProceduralBlocks.Anchor.of(baked.placed().keySet());
Map<Long, Integer> partsByBlock = new HashMap<>();
for (long key : baked.painted().keySet()) {
PartCanvas.Cell cell = baked.canvas().get(key);
if (cell == null) {
continue;
}
ProceduralBlock position = anchor.place(baked.sunkPosition(key));
partsByBlock.put(PartCanvas.key(position.x(), position.y(), position.z()), cell.part());
}
return new PartTrace(partsByBlock);
}
private static BakedBlocks bakeBlocks(ProceduralObject definition, PartOutline outline, RNG rng, ObjectBuilder blocks,
BakeProfile profile) {
PartCanvas canvas = new PartCanvas();
long variantSeed = rng.nextLong();
new PartGrower(canvas, definition.defaultRole(), outline).growRoots(definition.parts(), variantSeed);
profile.lap(BakeProfile.Stage.PARTS);
if (canvas.isEmpty()) {
return null;
}
Map<Long, NativeBlockState> painted = new MaterialPainter(canvas, definition.materials(), blocks, definition.seed(),
variantSeed + RULE_SEED_SALT).paint();
int sinkDepth = sinkDepth(painted, definition.sink());
profile.lap(BakeProfile.Stage.PAINT);
new Decorator(canvas, painted, blocks, definition.seed(), sinkDepth).decorate(definition.decorations(), variantSeed + DECORATION_SEED_SALT);
profile.lap(BakeProfile.Stage.DECORATE);
if (definition.leafDecay()) {
LeafDecay.supportLeaves(painted, blocks);
} else {
LeafDecay.persistLeaves(painted, blocks);
}
if (definition.waterlogged()) {
waterlog(painted, blocks);
}
profile.lap(BakeProfile.Stage.LEAVES);
return new BakedBlocks(canvas, painted, sinkDepth);
}
private static void waterlog(Map<Long, NativeBlockState> painted, ObjectBuilder blocks) {
painted.replaceAll((key, state) -> "false".equals(ProceduralBlocks.propertyValue(state, "waterlogged"))
? blocks.withPropertyIfAccepted(state, "waterlogged", "true") : state);
}
/** How far the object sinks: a fraction of its height. Heights below it end up underground. */
private static int sinkDepth(Map<Long, NativeBlockState> painted, double sink) {
int lowest = Integer.MAX_VALUE;
int highest = Integer.MIN_VALUE;
for (long key : painted.keySet()) {
lowest = Math.min(lowest, PartCanvas.y(key));
highest = Math.max(highest, PartCanvas.y(key));
}
return (int) Math.round(Math.max(0, Math.min(1, sink)) * (highest - lowest + 1));
}
/** A variant's blocks before they are anchored: the parts' canvas, the painted blocks and how far they sink. */
private record BakedBlocks(PartCanvas canvas, Map<Long, NativeBlockState> painted, int sinkDepth) {
Map<Vector3i, NativeBlockState> placed() {
Map<Vector3i, NativeBlockState> placed = new HashMap<>();
painted.forEach((key, state) -> placed.put(sunkPosition(key), state));
return placed;
}
Vector3i sunkPosition(long key) {
return new Vector3i(PartCanvas.x(key), PartCanvas.y(key) - sinkDepth, PartCanvas.z(key));
}
}
}
@@ -0,0 +1,108 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.MaxNumber;
import art.arcane.iris.pack.schema.annotation.MinNumber;
@Description("A rounded volume centered where the part sits: a leaf crown, boulder, cap, coral head or base. Values given as a curve run over where the blob sits on its parent.")
public final class PartBlob {
@Description("The horizontal radius in blocks.")
private ProceduralValue radius = ProceduralValue.constant(2);
@Description("How far the blob reaches above its center, in blocks. Unset, it matches the radius.")
private ProceduralValue height;
@Description("How far the blob reaches below its center, in blocks. Unset, it matches the height; 0 makes a dome.")
private ProceduralValue depth;
@MinNumber(0)
@Description("Stretches the blob along east-west; 0.1 flattens it into a north-south fan.")
private double stretchX = 1;
@MinNumber(0)
@Description("Stretches the blob along north-south; 0.1 flattens it into an east-west fan.")
private double stretchZ = 1;
@Description("A multiplier on the radius from the bottom (0) to the top (1) of the blob. Unset, the blob is an ellipsoid; [[0, 1], [1, 0]] makes a cone, [[0, 1], [1, 1]] a cylinder.")
private ProceduralValue profile;
@Description("The horizontal cross-section of the blob.")
private PartSection section = PartSection.ROUND;
@Description("If above 0, the blob is hollow, keeping only the blocks this many blocks or fewer from its surface.")
private ProceduralValue shell = ProceduralValue.constant(0);
@Description("If true the shell has no floor: only the surface above and around counts, like a mushroom cap.")
private boolean open = false;
@MinNumber(0)
@MaxNumber(1)
@Description("How lumpy the surface is, from 0 (smooth) to 1 (very lumpy).")
private double roughness = 0;
@MinNumber(0)
@MaxNumber(1)
@Description("How many blocks along the surface are knocked off at random, from 0 to 1.")
private double jitter = 0;
public ProceduralValue radius() {
return radius == null ? ProceduralValue.constant(2) : radius;
}
public ProceduralValue height() {
return height;
}
public ProceduralValue depth() {
return depth;
}
public double stretchX() {
return stretchX;
}
public double stretchZ() {
return stretchZ;
}
public ProceduralValue profile() {
return profile;
}
public PartSection section() {
return section == null ? PartSection.ROUND : section;
}
public ProceduralValue shell() {
return shell == null ? ProceduralValue.constant(0) : shell;
}
public boolean open() {
return open;
}
public double roughness() {
return roughness;
}
public double jitter() {
return jitter;
}
}
@@ -0,0 +1,107 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.MaxNumber;
import art.arcane.iris.pack.schema.annotation.MinNumber;
import art.arcane.iris.pack.schema.annotation.Required;
@Description("Grows copies of a part out of its parent: branches off a trunk, arms off a coral stalk, forks at a tip. Values given as a curve run from the parent's base (0) to its tip (1).")
public final class PartBranches {
@Description("How many copies grow. Ignored when chance is set.")
private ProceduralValue count = ProceduralValue.constant(4);
@Description("If set, every block along the parent rolls this chance to grow a copy, such as {\"shape\": \"power\", \"exponent\": 2} for more toward the top.")
private ProceduralValue chance;
@Description("The stretch of the parent copies grow from; from 1 to 1 grows them all at the tip.")
private ProceduralSpan along = new ProceduralSpan();
@Description("Which way around the parent each copy points.")
private BranchAzimuth azimuth = BranchAzimuth.RANDOM;
@Description("Turns every copy this many degrees further around the parent.")
private ProceduralValue azimuthOffset = ProceduralValue.constant(0);
@MinNumber(1)
@Description("How many copies make a ring for the WHORL azimuth.")
private int whorl = 4;
@Description("The degrees between copies for the FAN azimuth.")
private double fan = 40;
@Description("The angle in degrees above the horizon each copy grows toward; negative droops. With relative set, the angle is added to the parent's own.")
private ProceduralValue pitch = ProceduralValue.constant(0);
@Description("If true the copies point relative to the parent's direction instead of the compass, as forks and twigs do.")
private boolean relative = false;
@MinNumber(1)
@MaxNumber(6)
@Description("How many times branching repeats: 2 grows copies off the copies too, and so on.")
private int depth = 1;
@Required
@Description("The part each copy is made of.")
private ProceduralPart part;
public ProceduralValue count() {
return count == null ? ProceduralValue.constant(4) : count;
}
public ProceduralValue chance() {
return chance;
}
public ProceduralSpan along() {
return along == null ? new ProceduralSpan() : along;
}
public BranchAzimuth azimuth() {
return azimuth == null ? BranchAzimuth.RANDOM : azimuth;
}
public ProceduralValue azimuthOffset() {
return azimuthOffset == null ? ProceduralValue.constant(0) : azimuthOffset;
}
public int whorl() {
return Math.max(1, whorl);
}
public double fan() {
return fan;
}
public ProceduralValue pitch() {
return pitch == null ? ProceduralValue.constant(0) : pitch;
}
public boolean relative() {
return relative;
}
public int depth() {
return Math.max(1, Math.min(6, depth));
}
public ProceduralPart part() {
return part;
}
}
@@ -0,0 +1,140 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The blocks the parts of one variant claim, before materials turn them into block data: each with the role of the
* part that placed it, how far along that part it sits, and the axis a log there would follow.
*/
final class PartCanvas {
/** Enough for any sensible object; a typo asking for more stops growing instead of baking for minutes. */
static final int MAXIMUM_BLOCKS = 1_500_000;
enum Axis {
NONE, X, Y, Z;
/** The axis a log along {@code direction} lies on, leaning toward upright as trees do. */
static Axis along(double[] direction) {
double x = Math.abs(direction[0]);
double y = Math.abs(direction[1]) * 1.8;
double z = Math.abs(direction[2]);
if (y >= x && y >= z) {
return Y;
}
return x >= z ? X : Z;
}
}
/** @param part the {@link PartOutline} id of the part that placed the block */
record Cell(int role, float along, Axis axis, int part) {
}
/** The end of a stem, where tip decorations go. */
record Tip(int x, int y, int z, double[] heading, int role) {
}
private final Map<Long, Cell> cells = new HashMap<>();
private final List<Tip> tips = new ArrayList<>();
private final List<String> roles = new ArrayList<>();
private boolean full;
int role(String name) {
int index = roles.indexOf(name);
if (index >= 0) {
return index;
}
roles.add(name);
return roles.size() - 1;
}
String roleName(int role) {
return roles.get(role);
}
void place(int x, int y, int z, PartMode mode, Cell cell) {
long key = key(x, y, z);
switch (mode) {
case ADD -> {
if (!full || cells.containsKey(key)) {
cells.put(key, cell);
}
}
case FILL -> {
if (!full && !cells.containsKey(key)) {
cells.put(key, cell);
}
}
case CARVE -> cells.remove(key);
}
full = cells.size() >= MAXIMUM_BLOCKS;
}
boolean has(int x, int y, int z) {
return cells.containsKey(key(x, y, z));
}
Cell get(long key) {
return cells.get(key);
}
Map<Long, Cell> cells() {
return Collections.unmodifiableMap(cells);
}
void addTip(Tip tip) {
tips.add(tip);
}
List<Tip> tips() {
return Collections.unmodifiableList(tips);
}
boolean isEmpty() {
return cells.isEmpty();
}
boolean isFull() {
return full;
}
static long key(int x, int y, int z) {
return ((long) (x & 0x1FFFFF)) | ((long) (y & 0x1FFFFF) << 21) | ((long) (z & 0x1FFFFF) << 42);
}
static int x(long key) {
return signed((int) (key & 0x1FFFFF));
}
static int y(long key) {
return signed((int) ((key >>> 21) & 0x1FFFFF));
}
static int z(long key) {
return signed((int) ((key >>> 42) & 0x1FFFFF));
}
private static int signed(int value) {
return (value << 11) >> 11;
}
}
@@ -0,0 +1,60 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.Required;
@Description("Places copies of a part around a center: columns in a causeway, peaks on an iceberg, shards on a crystal. Each copy leans away from the center unless its stem says otherwise.")
public final class PartCluster {
@Description("How many copies to place.")
private ProceduralValue count = ProceduralValue.constant(5);
@Description("How far from the center copies are placed, in blocks.")
private ProceduralValue radius = ProceduralValue.constant(2);
@Description("How the copies are laid out.")
private ClusterLayout layout = ClusterLayout.RANDOM;
@Description("How far each copy tilts away from the center, in degrees from straight up. A range gives each copy its own tilt; a curve runs from the center (0) to the edge (1).")
private ProceduralValue tilt = ProceduralValue.constant(0);
@Required
@Description("The part each copy is made of.")
private ProceduralPart part;
public ProceduralValue count() {
return count == null ? ProceduralValue.constant(5) : count;
}
public ProceduralValue radius() {
return radius == null ? ProceduralValue.constant(2) : radius;
}
public ClusterLayout layout() {
return layout == null ? ClusterLayout.RANDOM : layout;
}
public ProceduralValue tilt() {
return tilt == null ? ProceduralValue.constant(0) : tilt;
}
public ProceduralPart part() {
return part;
}
}
@@ -0,0 +1,41 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
/** How one part writes its blocks: the mode it combines with, and the density that thins it. */
record PartFill(PartCanvas canvas, PartMode mode, int role, int partId, double density, PartPattern pattern, double scale,
double falloff, long seed) {
static PartFill of(PartCanvas canvas, ProceduralPart part, int partId, int role, long seed) {
return new PartFill(canvas, part.mode(), role, partId, part.density(), part.pattern(), part.scale(), part.falloff(), seed);
}
/**
* Places the block if the density lets it; {@code edge} is how far toward the shape's edge it is, from 0 at the
* center to 1 at the edge, for the falloff.
*/
void place(int x, int y, int z, double edge, double along, PartCanvas.Axis axis) {
double chance = density;
if (falloff > 0) {
chance *= Math.pow(Math.max(0, 1 - edge), falloff);
}
if (!PartNoise.passes(pattern, chance, scale, x, y, z, seed)) {
return;
}
canvas.place(x, y, z, mode, new PartCanvas.Cell(role, (float) along, axis, partId));
}
}
@@ -0,0 +1,201 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.math.RNG;
import java.util.ArrayList;
import java.util.List;
/**
* Grows a part tree onto a canvas: each part is drawn from where it sits on its parent, then its children grow from it.
* Every part draws from its own seed, taken from its parent's in order, so adding a part only changes what grows after it.
*/
final class PartGrower {
private static final double GOLDEN_ANGLE_DEGREES = 137.50776405003785;
private static final int MOST_COPIES = 256;
private static final int DEEPEST_NESTING = 24;
private final PartCanvas canvas;
private final String defaultRole;
private final PartOutline outline;
PartGrower(PartCanvas canvas, String defaultRole, PartOutline outline) {
this.canvas = canvas;
this.defaultRole = defaultRole;
this.outline = outline;
}
void growRoots(List<ProceduralPart> parts, long seed) {
RNG seeds = new RNG(seed);
for (ProceduralPart part : parts) {
growChild(part, PartShape.ROOT, canvas.role(defaultRole), seeds.nextLong(), 0);
}
}
/** Grows a part that sits on its parent where its own 'at' and 'offset' say. */
private void growChild(ProceduralPart part, PartShape parent, int parentRole, long seed, int nesting) {
if (part == null || canvas.isFull()) {
return;
}
RNG rng = new RNG(seed);
double at = part.at() == null ? parent.defaultAt() : part.at().sample(rng, 0);
PartSpot spot = parent.spotAt(at);
if (part.offset() != null) {
spot = spot.movedBy(part.offset().roll(rng));
}
grow(part, parent, spot, parentRole, rng, List.of(), nesting);
}
/** Grows a part at {@code spot}, then its children, then any branching it repeats from its own copy. */
private void grow(ProceduralPart part, PartShape parent, PartSpot spot, int parentRole, RNG rng,
List<Repeat> repeats, int nesting) {
if (nesting > DEEPEST_NESTING || canvas.isFull()) {
return;
}
int role = part.role() == null || part.role().isBlank() ? parentRole : canvas.role(part.role());
PartFill fill = PartFill.of(canvas, part, outline.idOf(part), role, rng.nextLong());
PartShape shape = parent;
if (part.stem() != null) {
StemShape stem = StemShape.trace(part.stem(), spot, rng);
stem.draw(fill, part.stem().section(), part.stem().roughness(), part.stem().jitter());
shape = stem;
} else if (part.blob() != null) {
BlobShape blob = BlobShape.trace(part.blob(), spot, rng);
blob.draw(fill, part.blob().roughness(), part.blob().jitter());
shape = blob;
} else if (part.branches() != null) {
branch(part.branches(), parent, role, rng, part.branches().depth(), nesting);
} else if (part.cluster() != null) {
cluster(part.cluster(), spot, role, rng, nesting);
}
for (ProceduralPart child : part.children()) {
growChild(child, shape, role, rng.nextLong(), nesting + 1);
}
for (Repeat repeat : repeats) {
branch(repeat.branches(), shape, role, rng, repeat.depthLeft(), nesting);
}
}
private void branch(PartBranches branches, PartShape parent, int role, RNG rng, int depthLeft, int nesting) {
if (branches.part() == null || depthLeft <= 0) {
return;
}
List<Double> positions = branchPositions(branches, parent, rng);
List<Repeat> repeats = depthLeft > 1 ? List.of(new Repeat(branches, depthLeft - 1)) : List.of();
double azimuthOffset = branches.azimuthOffset().sample(rng, 0);
for (int index = 0; index < positions.size(); index++) {
double t = positions.get(index);
PartSpot onParent = parent.spotAt(t);
double pitch = branches.pitch().sample(rng, t);
double[] heading = branchHeading(branches, onParent, index, positions.size(), azimuthOffset, pitch, rng);
PartSpot spot = new PartSpot(onParent.origin(), heading, t, parent.length(), Vectors.azimuth(heading));
RNG copyRng = new RNG(rng.nextLong());
ProceduralPart copy = branches.part();
if (copy.offset() != null) {
spot = spot.movedBy(copy.offset().roll(copyRng));
}
grow(copy, parent, spot, role, copyRng, repeats, nesting + 1);
}
}
private static List<Double> branchPositions(PartBranches branches, PartShape parent, RNG rng) {
ProceduralSpan along = branches.along();
List<Double> positions = new ArrayList<>();
if (branches.chance() != null) {
double blocks = Math.max(1, parent.length());
int first = (int) Math.ceil(along.from() * blocks);
int last = (int) Math.floor(along.to() * blocks);
for (int block = first; block <= last && positions.size() < MOST_COPIES; block++) {
double t = Math.min(1, block / blocks);
if (rng.nextDouble() < branches.chance().at(t)) {
positions.add(t);
}
}
return positions;
}
int count = Math.min(MOST_COPIES, Math.max(0, (int) Math.round(branches.count().sample(rng, 0))));
for (int index = 0; index < count; index++) {
double fraction = along.to() - along.from() < 1e-9 ? 0 : (index + rng.d(0.25, 0.75)) / count;
positions.add(along.from() + (along.to() - along.from()) * fraction);
}
return positions;
}
private static double[] branchHeading(PartBranches branches, PartSpot onParent, int index, int count,
double azimuthOffset, double pitch, RNG rng) {
double parentAzimuth = Vectors.isVertical(onParent.heading()) && onParent.hasOutward()
? onParent.outward() : Vectors.azimuth(onParent.heading());
double turn = switch (branches.azimuth()) {
case RANDOM -> rng.d(0, 360);
case GOLDEN -> index * GOLDEN_ANGLE_DEGREES;
case ALTERNATE -> (index % 2) * 180.0;
case WHORL -> (index % branches.whorl()) * (360.0 / branches.whorl());
case EVEN -> index * (360.0 / Math.max(1, count));
case FAN -> branches.fan() * (index - (count - 1) / 2.0);
};
boolean relative = branches.relative() || branches.azimuth() == BranchAzimuth.FAN;
double azimuth = (relative ? parentAzimuth : 0) + turn + azimuthOffset;
double finalPitch = branches.relative() ? Vectors.pitch(onParent.heading()) + pitch : pitch;
return Vectors.direction(azimuth, Math.max(-90, Math.min(90, finalPitch)));
}
private void cluster(PartCluster cluster, PartSpot spot, int role, RNG rng, int nesting) {
if (cluster.part() == null) {
return;
}
int count = Math.min(MOST_COPIES, Math.max(0, (int) Math.round(cluster.count().sample(rng, 0))));
double radius = Math.max(0, cluster.radius().sample(rng, 0));
double phase = rng.d(0, 360);
for (int index = 0; index < count; index++) {
Placed placed = placeInCluster(cluster.layout(), index, count, radius, phase, rng);
double[] origin = Vectors.add(spot.origin(), Vectors.scale(Vectors.direction(placed.azimuth(), 0), placed.distance()));
RNG copyRng = new RNG(rng.nextLong());
double fromCenter = radius <= 0 ? 0 : Math.min(1, placed.distance() / radius);
double tilt = cluster.tilt().sample(copyRng, fromCenter);
double[] heading = tilt == 0 ? spot.heading().clone() : Vectors.tilted(spot.heading(), placed.azimuth(), tilt);
PartSpot copySpot = new PartSpot(origin, heading, fromCenter, Math.max(1, radius), placed.azimuth());
ProceduralPart copy = cluster.part();
if (copy.offset() != null) {
copySpot = copySpot.movedBy(copy.offset().roll(copyRng));
}
grow(copy, PartShape.ROOT, copySpot, role, copyRng, List.of(), nesting + 1);
}
}
private static Placed placeInCluster(ClusterLayout layout, int index, int count, double radius, double phase, RNG rng) {
return switch (layout) {
case RANDOM -> new Placed(rng.d(0, 360), radius * Math.sqrt(rng.nextDouble()));
case RING -> new Placed(phase + index * 360.0 / Math.max(1, count), radius);
case GOLDEN -> new Placed(phase + index * GOLDEN_ANGLE_DEGREES, radius * Math.sqrt((index + 0.5) / Math.max(1, count)));
case LINE -> {
double lane = count <= 1 ? 0 : -radius + 2 * radius * index / (count - 1.0);
yield new Placed(lane < 0 ? phase + 180 : phase, Math.abs(lane));
}
};
}
/** A branching that repeats on the copies it grows, with how many more times it may. */
private record Repeat(PartBranches branches, int depthLeft) {
}
/** Where a cluster copy sits: which way from the center, and how far. */
private record Placed(double azimuth, double distance) {
}
}
@@ -0,0 +1,30 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
@Description("How a part's blocks combine with the blocks already there.")
public enum PartMode {
@Description("Places blocks, replacing whatever earlier parts put there.")
ADD,
@Description("Places blocks only where nothing is yet, like leaves around wood.")
FILL,
@Description("Removes the blocks earlier parts put inside this part's shape.")
CARVE
}
@@ -0,0 +1,98 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
/** Seeded noise for parts: a hash per block for speckle, and smooth value noise for patches and wandering. */
final class PartNoise {
private static final double PATCH_CONTRAST = 1.8;
private PartNoise() {
}
/** A value from 0 to 1 that is the same for the same block and seed. */
static double hash(int x, int y, int z, long seed) {
long h = mix(seed);
h = mix(h + x * 0x9E3779B97F4A7C15L);
h = mix(h + y * 0xC2B2AE3D27D4EB4FL);
h = mix(h + z * 0x165667B19E3779F9L);
return unit(h);
}
/** Smooth value noise from 0 to 1 with features {@code scale} blocks across, stretched so thresholds split it evenly. */
static double patches(double x, double y, double z, double scale, long seed) {
double size = Math.max(1, scale);
double value = smooth(x / size, y / size, z / size, seed);
return Math.max(0, Math.min(1, (value - 0.5) * PATCH_CONTRAST + 0.5));
}
/** Smooth value noise from 0 to 1 along a line. */
static double line(double t, long seed) {
int cell = (int) Math.floor(t);
double blend = fade(t - cell);
double a = hash(cell, 0, 0, seed);
double b = hash(cell + 1, 0, 0, seed);
return a + (b - a) * blend;
}
/** Whether a block passes a chance under a pattern. */
static boolean passes(PartPattern pattern, double chance, double scale, int x, int y, int z, long seed) {
if (chance >= 1) {
return true;
}
if (chance <= 0) {
return false;
}
double roll = pattern == PartPattern.PATCHES ? patches(x, y, z, scale, seed) : hash(x, y, z, seed);
return roll < chance;
}
private static double smooth(double x, double y, double z, long seed) {
int x0 = (int) Math.floor(x);
int y0 = (int) Math.floor(y);
int z0 = (int) Math.floor(z);
double fx = fade(x - x0);
double fy = fade(y - y0);
double fz = fade(z - z0);
double c00 = lerp(hash(x0, y0, z0, seed), hash(x0 + 1, y0, z0, seed), fx);
double c10 = lerp(hash(x0, y0 + 1, z0, seed), hash(x0 + 1, y0 + 1, z0, seed), fx);
double c01 = lerp(hash(x0, y0, z0 + 1, seed), hash(x0 + 1, y0, z0 + 1, seed), fx);
double c11 = lerp(hash(x0, y0 + 1, z0 + 1, seed), hash(x0 + 1, y0 + 1, z0 + 1, seed), fx);
return lerp(lerp(c00, c10, fy), lerp(c01, c11, fy), fz);
}
private static double fade(double t) {
return t * t * (3 - 2 * t);
}
private static double lerp(double a, double b, double t) {
return a + (b - a) * t;
}
static long mix(long a) {
a ^= (a >>> 33);
a *= 0xff51afd7ed558ccdL;
a ^= (a >>> 33);
a *= 0xc4ceb9fe1a85ec53L;
a ^= (a >>> 33);
return a;
}
private static double unit(long h) {
return (h >>> 11) * 0x1.0p-53;
}
}
@@ -0,0 +1,41 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.volmlib.util.math.RNG;
@Description("A shift in blocks along each axis. Each axis takes a number or a [min, max] range.")
public final class PartOffset {
@Description("Blocks east (negative is west).")
private ProceduralValue x;
@Description("Blocks up (negative is down).")
private ProceduralValue y;
@Description("Blocks south (negative is north).")
private ProceduralValue z;
public double[] roll(RNG rng) {
return new double[]{roll(x, rng), roll(y, rng), roll(z, rng)};
}
private static double roll(ProceduralValue value, RNG rng) {
return value == null ? 0 : value.sample(rng, 0);
}
}
@@ -0,0 +1,134 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
/**
* The part tree of a procedural object as a viewer lists it, with an id per node that {@link PartTrace} tags blocks
* with. A part that copies another, like branches, shares its node with the copied part, so the tree reads one level
* shallower than the settings. Ids number the nodes in order, so they stay the same across seeds and variants.
*/
public final class PartOutline {
public static final int NO_PART = -1;
/**
* One row of the tree.
*
* @param shape what the part is, like {@code Branches ×12 · Stem}
* @param detail the role its blocks get, and whether it carves them away instead
*/
public record Node(int id, String shape, String detail, List<Node> children) {
}
private final Map<ProceduralPart, Integer> idsByPart = new IdentityHashMap<>();
private final List<Node> roots;
private int nodeCount;
private PartOutline(ProceduralObject definition) {
this.roots = nodesFor(definition.parts(), definition.defaultRole());
}
public static PartOutline of(ProceduralObject definition) {
return new PartOutline(definition);
}
public List<Node> roots() {
return roots;
}
public int nodeCount() {
return nodeCount;
}
public int idOf(ProceduralPart part) {
return idsByPart.getOrDefault(part, NO_PART);
}
private List<Node> nodesFor(List<ProceduralPart> parts, String parentRole) {
List<Node> nodes = new ArrayList<>();
for (ProceduralPart part : parts) {
if (part != null) {
nodes.add(nodeFor(part, parentRole));
}
}
return nodes;
}
// Children follow the order the grower draws them in: the copies' own children first, then the part's.
private Node nodeFor(ProceduralPart part, String parentRole) {
int id = nodeCount++;
idsByPart.put(part, id);
String role = roleOf(part, parentRole);
ProceduralPart copied = copiedPart(part);
List<Node> children = new ArrayList<>();
String shape;
String detail;
if (copied != null && copiedPart(copied) == null) {
idsByPart.put(copied, id);
String copiedRole = roleOf(copied, role);
shape = copiesLabel(part) + " · " + shapeName(copied);
detail = detailOf(copied, copiedRole);
children.addAll(nodesFor(copied.children(), copiedRole));
} else {
shape = copied != null ? copiesLabel(part) : shapeName(part);
detail = detailOf(part, role);
if (copied != null) {
children.add(nodeFor(copied, role));
}
}
children.addAll(nodesFor(part.children(), role));
return new Node(id, shape, detail, List.copyOf(children));
}
private static String roleOf(ProceduralPart part, String parentRole) {
return part.role() == null || part.role().isBlank() ? parentRole : part.role();
}
private static ProceduralPart copiedPart(ProceduralPart part) {
if (part.branches() != null) {
return part.branches().part();
}
return part.cluster() != null ? part.cluster().part() : null;
}
private static String copiesLabel(ProceduralPart part) {
if (part.branches() != null) {
return part.branches().chance() != null ? "Branches by chance" : "Branches ×" + part.branches().count().summary();
}
return "Cluster ×" + part.cluster().count().summary();
}
private static String shapeName(ProceduralPart part) {
if (part.stem() != null) {
return "Stem";
}
if (part.blob() != null) {
return "Blob";
}
return "Group";
}
// Carving places no blocks, so it is named to explain why nothing lights up.
private static String detailOf(ProceduralPart part, String role) {
return part.mode() == PartMode.CARVE ? role + " · carve" : role;
}
}
@@ -0,0 +1,28 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
@Description("How a chance is spread over blocks.")
public enum PartPattern {
@Description("Every block rolls on its own, for an even speckle.")
RANDOM,
@Description("Smooth noise decides, so blocks come in patches the size of the scale.")
PATCHES
}
@@ -0,0 +1,32 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
@Description("The cross-section of a stem or blob.")
public enum PartSection {
@Description("A circle.")
ROUND,
@Description("A square, like a vanilla trunk.")
SQUARE,
@Description("A diamond (a square turned 45 degrees).")
DIAMOND,
@Description("A hexagon, like a basalt column.")
HEX
}
@@ -0,0 +1,48 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
/** A drawn part that others can grow from. */
interface PartShape {
/** Where a child sitting at {@code t}, from the base (0) to the tip (1), starts. */
PartSpot spotAt(double t);
/** The length children measure against, in blocks. */
double length();
/** Where children sit when they do not say. */
double defaultAt();
/** The parent of the object's root parts: a single point at the base, pointing up. */
PartShape ROOT = new PartShape() {
@Override
public PartSpot spotAt(double t) {
return PartSpot.root();
}
@Override
public double length() {
return 0;
}
@Override
public double defaultAt() {
return 0;
}
};
}
@@ -0,0 +1,36 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
/**
* Where a part starts: its position, the direction it grows, where it sits on its parent from base (0) to tip (1),
* how long that parent is, and the compass direction pointing away from the parent's center (NaN when there is none).
*/
record PartSpot(double[] origin, double[] heading, double parentT, double parentLength, double outward) {
static PartSpot root() {
return new PartSpot(new double[]{0, 0, 0}, Vectors.UP.clone(), 0, 0, Double.NaN);
}
PartSpot movedBy(double[] offset) {
return new PartSpot(Vectors.add(origin, offset), heading, parentT, parentLength, outward);
}
boolean hasOutward() {
return !Double.isNaN(outward);
}
}
@@ -0,0 +1,170 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.MaxNumber;
import art.arcane.iris.pack.schema.annotation.MinNumber;
@Description("A line that grows from where the part sits: a trunk, branch, spire, stalk, root or shard. Values given as a curve run over where the stem sits on its parent, except taper, lean curve, bend curve and helix radius, which run from the stem's base (0) to its tip (1).")
public final class PartStem {
@Description("How long the stem grows, in blocks.")
private ProceduralValue length = ProceduralValue.constant(8);
@MinNumber(0)
@Description("If above 0, the stem is this fraction of its parent stem's length instead, for branches that shrink as they split.")
private double lengthScale = 0;
@Description("The radius at the base in blocks. 0.5 is one block wide.")
private ProceduralValue radius = ProceduralValue.constant(0.5);
@Description("A multiplier on the radius from the base (0) to the tip (1), such as [[0, 1], [1, 0]] to taper to a point.")
private ProceduralValue taper;
@Description("The cross-section of the stem.")
private PartSection section = PartSection.ROUND;
@Description("The angle in degrees above the horizon the stem grows toward: 90 is straight up, -90 straight down. Unset, it carries on its parent's direction (up for a root part).")
private ProceduralValue pitch;
@Description("The compass direction in degrees the stem grows toward when pitch is set. Unset, it keeps its parent's direction, or grows toward its facing.")
private ProceduralValue azimuth;
@Description("The compass direction in degrees the stem leans and bends toward. Unset, it leans away from the center of its cluster or branch, or a random way.")
private ProceduralValue facing;
@Description("How far the stem leans, in degrees from its direction, by the time it reaches its tip.")
private ProceduralValue lean = ProceduralValue.constant(0);
@Description("How the lean builds up from base (0) to tip (1), from 0 to 1. Unset, it grows evenly.")
private ProceduralValue leanCurve;
@Description("How far the stem turns, in degrees, by its tip: 90 turns an upright stem sideways, 180 brings it back down like an arch.")
private ProceduralValue bend = ProceduralValue.constant(0);
@Description("How the bend builds up from base (0) to tip (1), from 0 to 1. Unset, it turns evenly.")
private ProceduralValue bendCurve;
@Description("How much the stem sags under its own weight, as a fraction of its length: 0.2 drops the tip a fifth of the length.")
private ProceduralValue droop = ProceduralValue.constant(0);
@Description("How far the stem wanders sideways at random, in blocks.")
private ProceduralValue sway = ProceduralValue.constant(0);
@Description("How far the stem waves from side to side, in blocks.")
private ProceduralValue wave = ProceduralValue.constant(0);
@Description("How many full waves the stem makes over its length.")
private ProceduralValue wavePeriods = ProceduralValue.constant(1);
@Description("The radius in blocks of a corkscrew the stem winds around, from base (0) to tip (1). It starts on the facing side, so copies facing apart wind as a double helix.")
private ProceduralValue helixRadius = ProceduralValue.constant(0);
@Description("How many full turns the corkscrew makes over the stem's length.")
private ProceduralValue helixTurns = ProceduralValue.constant(1);
@MinNumber(0)
@MaxNumber(1)
@Description("How rough the surface is, from 0 (smooth) to 1 (heavily pitted).")
private double roughness = 0;
@MinNumber(0)
@MaxNumber(1)
@Description("How many blocks along the surface are knocked off at random, from 0 to 1.")
private double jitter = 0;
public ProceduralValue length() {
return length == null ? ProceduralValue.constant(8) : length;
}
public double lengthScale() {
return lengthScale;
}
public ProceduralValue radius() {
return radius == null ? ProceduralValue.constant(0.5) : radius;
}
public ProceduralValue taper() {
return taper;
}
public PartSection section() {
return section == null ? PartSection.ROUND : section;
}
public ProceduralValue pitch() {
return pitch;
}
public ProceduralValue azimuth() {
return azimuth;
}
public ProceduralValue facing() {
return facing;
}
public ProceduralValue lean() {
return lean;
}
public ProceduralValue leanCurve() {
return leanCurve;
}
public ProceduralValue bend() {
return bend;
}
public ProceduralValue bendCurve() {
return bendCurve;
}
public ProceduralValue droop() {
return droop;
}
public ProceduralValue sway() {
return sway;
}
public ProceduralValue wave() {
return wave;
}
public ProceduralValue wavePeriods() {
return wavePeriods;
}
public ProceduralValue helixRadius() {
return helixRadius;
}
public ProceduralValue helixTurns() {
return helixTurns;
}
public double roughness() {
return roughness;
}
public double jitter() {
return jitter;
}
}
@@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import java.util.Map;
/**
* Which part placed each block of one baked variant, by the block's position in the variant's object. Decorations
* belong to no part.
*/
public final class PartTrace {
public static final PartTrace EMPTY = new PartTrace(Map.of());
private final Map<Long, Integer> partsByBlock;
PartTrace(Map<Long, Integer> partsByBlock) {
this.partsByBlock = partsByBlock;
}
/** How many blocks a part placed. */
public int blockCount() {
return partsByBlock.size();
}
/** The {@link PartOutline} id of the part that placed the block, or {@link PartOutline#NO_PART}. */
public int partAt(int x, int y, int z) {
return partsByBlock.getOrDefault(PartCanvas.key(x, y, z), PartOutline.NO_PART);
}
}
@@ -0,0 +1,93 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.MaxNumber;
import art.arcane.iris.pack.schema.annotation.MinNumber;
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
import java.util.Collections;
import java.util.List;
@Description("Blocks placed against the finished object, such as vines, moss, fruit or lanterns. Vines and lichen attach to the block they touch.")
public final class ProceduralDecoration {
@RegistryListBlockType
@Description("The block to place. Ignored when palette is set.")
private String block = "minecraft:vine";
@Description("A noise palette to place.")
private IrisMaterialPalette palette;
@Description("The roles to decorate. Empty decorates every block.")
private List<String> on = List.of();
@Description("Where on those blocks to place it.")
private DecorationSpot at = DecorationSpot.SIDE;
@MinNumber(0)
@MaxNumber(1)
@Description("The chance each spot gets one.")
private double chance = 0.3;
@Description("How the chance is spread over the spots.")
private PartPattern pattern = PartPattern.RANDOM;
@MinNumber(1)
@Description("The size of the patches in blocks for the PATCHES pattern.")
private double scale = 3;
@Description("How many blocks long a strand hangs for BELOW and BOTTOM.")
private ProceduralValue length = ProceduralValue.constant(1);
@Description("How far from where the object stands GROUND decorations spread, in blocks.")
private ProceduralValue radius = ProceduralValue.constant(3);
public BlockChoice choice() {
return new BlockChoice(block, palette, 0);
}
public List<String> on() {
return on == null ? List.of() : Collections.unmodifiableList(on);
}
public DecorationSpot at() {
return at == null ? DecorationSpot.SIDE : at;
}
public double chance() {
return chance;
}
public PartPattern pattern() {
return pattern == null ? PartPattern.RANDOM : pattern;
}
public double scale() {
return scale;
}
public ProceduralValue length() {
return length == null ? ProceduralValue.constant(1) : length;
}
public ProceduralValue radius() {
return radius == null ? ProceduralValue.constant(3) : radius;
}
}
@@ -0,0 +1,60 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.MinNumber;
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
import art.arcane.iris.pack.schema.annotation.Required;
import java.util.Collections;
import java.util.List;
@Description("The blocks of one role. Logs are turned along the part they belong to, and leaves get decay distances.")
public final class ProceduralMaterial {
@Required
@Description("The role the parts refer to, such as wood, leaves, rock or cap.")
private String role = "main";
@RegistryListBlockType
@Description("The block. Ignored when palette is set.")
private String block = "minecraft:stone";
@Description("A noise palette mixing several blocks.")
private IrisMaterialPalette palette;
@MinNumber(0)
@Description("If above 0, the palette changes every this many blocks of height, for strata.")
private int bands = 0;
@Description("Swaps for blocks that meet conditions; the first rule that applies wins.")
private List<MaterialRule> rules = List.of();
public String role() {
return role == null ? "main" : role;
}
public BlockChoice choice() {
return new BlockChoice(block, palette, bands);
}
public List<MaterialRule> rules() {
return rules == null ? List.of() : Collections.unmodifiableList(rules);
}
}
@@ -0,0 +1,105 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.MaxNumber;
import art.arcane.iris.pack.schema.annotation.MinNumber;
import art.arcane.iris.pack.loading.IrisRegistrant;
import java.util.Collections;
import java.util.List;
@Description("A procedural object built from parts: stems, blobs, branches and clusters, each placing blocks of a role. Anything from a tree to a rock arch to a crystal-studded boulder. Iris bakes a pool of variants from it once. Place it from any object placement as procedural/<path>, or a single variant as procedural/<path>#<index>.")
public final class ProceduralObject extends IrisRegistrant {
@MinNumber(1)
@MaxNumber(64)
@Description("How many different variants to bake. More means more variety for a little memory.")
private int variants = 6;
@Description("The seed every variant is baked from. The same seed and settings always bake the same variants.")
private long seed = 1337;
@Description("The blocks of each role. A part whose role has no material uses the first one.")
private List<ProceduralMaterial> materials = List.of();
@Description("The parts the object grows from, each starting at the object's base.")
private List<ProceduralPart> parts = List.of();
@Description("Blocks placed against the finished object, such as vines, moss or fruit.")
private List<ProceduralDecoration> decorations = List.of();
@Description("If true leaves get the distances from wood vanilla needs to keep them. Leaves more than 6 blocks from wood are made persistent; the object view in /iris studio map shows them. If false all leaves are persistent.")
private boolean leafDecay = true;
@Description("If true every block that can hold water is waterlogged, so coral stays alive.")
private boolean waterlogged = false;
@MinNumber(0)
@MaxNumber(1)
@Description("Sinks the object into the ground by this fraction of its height.")
private double sink = 0;
@Override
public String getFolderName() {
return "procedural";
}
@Override
public String getTypeName() {
return "Procedural Object";
}
public int variants() {
return variants;
}
public long seed() {
return seed;
}
public List<ProceduralMaterial> materials() {
return materials == null ? List.of() : Collections.unmodifiableList(materials);
}
/** The role of a root part that sets none: the first material's. */
public String defaultRole() {
return materials().isEmpty() ? "main" : materials().getFirst().role();
}
public List<ProceduralPart> parts() {
return parts == null ? List.of() : Collections.unmodifiableList(parts);
}
public List<ProceduralDecoration> decorations() {
return decorations == null ? List.of() : Collections.unmodifiableList(decorations);
}
public boolean leafDecay() {
return leafDecay;
}
public boolean waterlogged() {
return waterlogged;
}
public double sink() {
return sink;
}
}
@@ -0,0 +1,125 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.MaxNumber;
import art.arcane.iris.pack.schema.annotation.MinNumber;
import art.arcane.iris.pack.schema.annotation.Snippet;
import java.util.Collections;
import java.util.List;
@Snippet("procedural-part")
@Description("One piece of a procedural object. Set exactly one of stem, blob, branches or cluster; children grow from this part.")
public final class ProceduralPart {
@Description("The role of the blocks this part places, matching a material's role, such as wood or leaves. Unset, it takes its parent's role.")
private String role;
@Description("Where on its parent this part sits, from the base (0) to the tip (1). Unset, it sits at the tip of a stem or the top of a blob.")
private ProceduralValue at;
@Description("Moves this part from where it sits, in blocks.")
private PartOffset offset;
@Description("How this part's blocks combine with the blocks earlier parts placed.")
private PartMode mode = PartMode.ADD;
@MinNumber(0)
@MaxNumber(1)
@Description("The fraction of this part's blocks that are placed, for sparse leaves or eroded carving.")
private double density = 1;
@Description("How the density is spread over the blocks.")
private PartPattern pattern = PartPattern.RANDOM;
@MinNumber(1)
@Description("The size of the patches in blocks for the PATCHES pattern.")
private double scale = 3;
@MinNumber(0)
@Description("Thins the blocks toward the edge of the shape: 1 thins evenly, 2 keeps a dense core.")
private double falloff = 0;
@Description("A line that grows from here: a trunk, branch, spire, stalk or shard.")
private PartStem stem;
@Description("A rounded volume: a leaf crown, boulder, cap or coral head.")
private PartBlob blob;
@Description("Copies of a part grown out of this part's parent along its length.")
private PartBranches branches;
@Description("Copies of a part placed around this spot.")
private PartCluster cluster;
@Description("The parts that grow from this one.")
private List<ProceduralPart> children = List.of();
public String role() {
return role;
}
public ProceduralValue at() {
return at;
}
public PartOffset offset() {
return offset;
}
public PartMode mode() {
return mode == null ? PartMode.ADD : mode;
}
public double density() {
return density;
}
public PartPattern pattern() {
return pattern == null ? PartPattern.RANDOM : pattern;
}
public double scale() {
return scale;
}
public double falloff() {
return falloff;
}
public PartStem stem() {
return stem;
}
public PartBlob blob() {
return blob;
}
public PartBranches branches() {
return branches;
}
public PartCluster cluster() {
return cluster;
}
public List<ProceduralPart> children() {
return children == null ? List.of() : Collections.unmodifiableList(children);
}
}
@@ -0,0 +1,55 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
import art.arcane.iris.pack.schema.annotation.MaxNumber;
import art.arcane.iris.pack.schema.annotation.MinNumber;
@Description("A stretch between two points from 0 to 1, such as from the base (0) to the tip (1) of a part.")
public final class ProceduralSpan {
@MinNumber(0)
@MaxNumber(1)
@Description("Where the stretch starts.")
private double from = 0;
@MinNumber(0)
@MaxNumber(1)
@Description("Where the stretch ends.")
private double to = 1;
public ProceduralSpan() {
}
public ProceduralSpan(double from, double to) {
this.from = from;
this.to = to;
}
public double from() {
return Math.min(from, to);
}
public double to() {
return Math.max(from, to);
}
public boolean contains(double t) {
return t >= from() - 1e-9 && t <= to() + 1e-9;
}
}
@@ -0,0 +1,322 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.util.documentation.Description;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/**
* A number a pack author may write as a constant ({@code 5}), a random range ({@code [3, 8]} or
* {@code {"min": 3, "max": 8}}), a curve of keyframes ({@code [[0, 1], [0.6, 0.8], [1, 0.2]]}) or a named curve
* ({@code {"shape": "power", "exponent": 3, "from": 0, "to": 1}}). Each field says what a curve runs over.
*/
@Description("A number, a [min, max] range rolled once per use, or a curve: [[t, value], ...] keyframes or {\"shape\": ..., \"from\": ..., \"to\": ...}.")
@JsonAdapter(ProceduralValue.Adapter.class)
public final class ProceduralValue {
private final Object written;
private final Form form;
private ProceduralValue(Object written, Form form) {
this.written = written;
this.form = form;
}
public static ProceduralValue constant(double value) {
return new ProceduralValue(value, new Constant(value));
}
public static ProceduralValue range(double min, double max) {
return new ProceduralValue(List.of(min, max), new Range(min, max));
}
/** This value with any range rolled once, so a curve or constant is all that is left. */
public ProceduralValue fix(RNG rng) {
if (form instanceof Range range) {
return constant(range.roll(rng));
}
return this;
}
/** The value at {@code t}, from 0 to 1; a range gives its middle, so fix it first to roll it. */
public double at(double t) {
return form.at(Math.max(0, Math.min(1, t)));
}
/** The value at {@code t}, with a range rolled with {@code rng}. */
public double sample(RNG rng, double t) {
return fix(rng).at(t);
}
public boolean isCurve() {
return form instanceof Keyframes || form instanceof Shape;
}
/** A short reading of the value for labels: {@code 12}, {@code 4–9} or {@code curve}. */
public String summary() {
return switch (form) {
case Constant constant -> shortNumber(constant.value());
case Range range -> shortNumber(range.min()) + "–" + shortNumber(range.max());
case Keyframes ignored -> "curve";
case Shape ignored -> "curve";
};
}
private static String shortNumber(double value) {
return value == Math.rint(value) ? Long.toString((long) value) : String.format(Locale.ROOT, "%.4g", value).replaceAll("\\.?0+$", "");
}
@Override
public String toString() {
return written.toString();
}
private sealed interface Form permits Constant, Range, Keyframes, Shape {
double at(double t);
}
private record Constant(double value) implements Form {
@Override
public double at(double t) {
return value;
}
}
private record Range(double min, double max) implements Form {
double roll(RNG rng) {
return min == max ? min : rng.d(Math.min(min, max), Math.max(min, max));
}
@Override
public double at(double t) {
return (min + max) / 2;
}
}
private record Keyframes(double[] times, double[] values) implements Form {
@Override
public double at(double t) {
if (t <= times[0]) {
return values[0];
}
for (int i = 1; i < times.length; i++) {
if (t <= times[i]) {
double span = times[i] - times[i - 1];
double blend = span <= 0 ? 1 : (t - times[i - 1]) / span;
return values[i - 1] + (values[i] - values[i - 1]) * blend;
}
}
return values[values.length - 1];
}
}
private record Shape(CurveShape shape, double from, double to, Map<?, ?> parameters) implements Form {
@Override
public double at(double t) {
return from + (to - from) * shape.at(t, parameters);
}
}
/** The named curves, each running from 0 at t = 0 toward 1, stretched between a value's from and to. */
public enum CurveShape {
LINEAR(List.of()) {
@Override
double at(double t, Map<?, ?> p) {
return t;
}
},
SMOOTH(List.of()) {
@Override
double at(double t, Map<?, ?> p) {
return t * t * (3 - 2 * t);
}
},
POWER(List.of(new Parameter("exponent", 2))) {
@Override
double at(double t, Map<?, ?> p) {
return Math.pow(t, parameter(p, "exponent"));
}
},
SIGMOID(List.of(new Parameter("steepness", 10), new Parameter("mid", 0.5))) {
@Override
double at(double t, Map<?, ?> p) {
return 1 / (1 + Math.exp(-parameter(p, "steepness") * (t - parameter(p, "mid"))));
}
},
BELL(List.of(new Parameter("mid", 0.5), new Parameter("width", 0.15))) {
@Override
double at(double t, Map<?, ?> p) {
double spread = Math.max(1e-6, parameter(p, "width"));
return Math.exp(-0.5 * Math.pow((t - parameter(p, "mid")) / spread, 2));
}
},
PERIODIC(List.of(new Parameter("periods", 4), new Parameter("sharpness", 8))) {
@Override
double at(double t, Map<?, ?> p) {
double wave = Math.max(0, Math.sin(2 * Math.PI * t * parameter(p, "periods")));
return Math.pow(wave, parameter(p, "sharpness"));
}
},
SINE(List.of(new Parameter("periods", 1))) {
@Override
double at(double t, Map<?, ?> p) {
return 0.5 + 0.5 * Math.sin(2 * Math.PI * t * parameter(p, "periods"));
}
};
private final List<Parameter> parameters;
CurveShape(List<Parameter> parameters) {
this.parameters = parameters;
}
abstract double at(double t, Map<?, ?> parameters);
/** What shapes this curve beyond its from and to, each with the value it has unless the curve sets it. */
public List<Parameter> parameters() {
return parameters;
}
/** As a value writes it, like {@code power}. */
public String key() {
return name().toLowerCase(Locale.ROOT);
}
final double parameter(Map<?, ?> written, String name) {
if (written.containsKey(name)) {
return Forms.number(written.get(name), name);
}
return parameters.stream().filter(parameter -> parameter.name().equals(name)).findFirst().orElseThrow().fallback();
}
public record Parameter(String name, double fallback) {
}
}
/** Reads the forms a pack writes and writes a value back exactly as it was read. */
static final class Adapter extends TypeAdapter<ProceduralValue> {
private static final Gson PLAIN = new Gson();
@Override
public ProceduralValue read(JsonReader in) {
Object json = PLAIN.fromJson(JsonParser.parseReader(in), Object.class);
try {
return Forms.read(json);
} catch (IllegalArgumentException invalid) {
throw new JsonParseException(invalid.getMessage(), invalid);
}
}
@Override
public void write(JsonWriter out, ProceduralValue value) throws IOException {
JsonElement written = PLAIN.toJsonTree(value.written);
PLAIN.toJson(written, out);
}
}
static final class Forms {
private static final String SHAPE = "shape";
private static final String MIN = "min";
private static final String MAX = "max";
private static final String FROM = "from";
private static final String TO = "to";
private static final double DEFAULT_FROM = 0;
private static final double DEFAULT_TO = 1;
static ProceduralValue read(Object json) {
return new ProceduralValue(json, formOf(json));
}
private static Form formOf(Object json) {
return switch (json) {
case Number number -> new Constant(number.doubleValue());
case List<?> list -> listForm(list);
case Map<?, ?> object when object.containsKey(SHAPE) -> shapeForm(object);
case Map<?, ?> object when object.containsKey(MIN) && object.containsKey(MAX) ->
new Range(number(object.get(MIN), MIN), number(object.get(MAX), MAX));
case Map<?, ?> object -> throw new IllegalArgumentException("A value needs min and max, or a shape: " + object);
default -> throw new IllegalArgumentException("A value is a number, a [min, max] range or a curve, not " + json);
};
}
private static Form listForm(List<?> list) {
if (list.isEmpty()) {
throw new IllegalArgumentException("A value can not be an empty list");
}
if (list.getFirst() instanceof Number) {
if (list.size() != 2) {
throw new IllegalArgumentException("A range is written [min, max]: " + list);
}
return new Range(number(list.get(0), MIN), number(list.get(1), MAX));
}
return keyframes(list);
}
private static Form keyframes(List<?> list) {
List<double[]> keys = new ArrayList<>();
for (Object key : list) {
if (!(key instanceof List<?> pair) || pair.size() != 2) {
throw new IllegalArgumentException("A keyframe is written [t, value]: " + key);
}
keys.add(new double[]{number(pair.get(0), "t"), number(pair.get(1), "value")});
}
keys.sort((a, b) -> Double.compare(a[0], b[0]));
double[] times = new double[keys.size()];
double[] values = new double[keys.size()];
for (int i = 0; i < keys.size(); i++) {
times[i] = keys.get(i)[0];
values[i] = keys.get(i)[1];
}
return new Keyframes(times, values);
}
private static Form shapeForm(Map<?, ?> object) {
String name = String.valueOf(object.get(SHAPE)).toUpperCase(Locale.ROOT);
CurveShape shape;
try {
shape = CurveShape.valueOf(name);
} catch (IllegalArgumentException unknown) {
throw new IllegalArgumentException("Unknown curve shape " + name.toLowerCase(Locale.ROOT));
}
double from = object.containsKey(FROM) ? number(object.get(FROM), FROM) : DEFAULT_FROM;
double to = object.containsKey(TO) ? number(object.get(TO), TO) : DEFAULT_TO;
return new Shape(shape, from, to, object);
}
static double number(Object written, String name) {
if (written instanceof Number number) {
return number.doubleValue();
}
throw new IllegalArgumentException(name + " needs a number, not " + written);
}
}
}
@@ -0,0 +1,73 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.iris.generation.geometry.IrisBlockVector;
import art.arcane.iris.generation.procedural.BakeProfile;
import art.arcane.iris.generation.procedural.ObjectBuilder;
import art.arcane.iris.generation.procedural.ProceduralShape;
import art.arcane.iris.generation.procedural.ProceduralVariants;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.structure.object.IrisObject;
import art.arcane.volmlib.util.math.RNG;
import java.util.HashMap;
import java.util.Map;
/** The variants of a procedural object, baked by {@link ObjectBaker}. */
public final class ResolvedProceduralObject extends ProceduralVariants {
private final ProceduralObject definition;
private final PartOutline outline;
public ResolvedProceduralObject(String path, ProceduralObject definition, IrisData data) {
super(path, definition.seed(), definition.variants(), data);
this.definition = definition;
this.outline = PartOutline.of(definition);
}
@Override
protected ProceduralShape generate(int index, RNG rng, ObjectBuilder blocks, BakeProfile profile) {
return ObjectBaker.bake(definition, outline, rng, blocks, profile);
}
public PartOutline outline() {
return outline;
}
/** The part of each block of {@code variant} that has one, in the positions of its blocks; empty when it is not one of these. */
public Map<IrisBlockVector, Integer> parts(IrisObject variant) {
PartTrace trace = trace(variant);
Map<IrisBlockVector, Integer> partsByBlock = new HashMap<>();
variant.getBlocks().forEach((position, state) -> {
int part = trace.partAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
if (part != PartOutline.NO_PART) {
partsByBlock.put(position, part);
}
});
return partsByBlock;
}
/** Which part placed each block of {@code variant}, baked again to find out; empty when it is not one of these. */
public PartTrace trace(IrisObject variant) {
int index = bakeIndexOf(variant);
if (index < 0) {
return PartTrace.EMPTY;
}
return ObjectBaker.trace(definition, outline, variantRng(index), newBuilder());
}
}
@@ -0,0 +1,32 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.documentation.Description;
@Description("Which open side a block needs for a material rule to apply to it.")
public enum RuleFace {
@Description("Any side open to the air.")
ANY,
@Description("Open above.")
UP,
@Description("Open below.")
DOWN,
@Description("Open on a horizontal side.")
SIDE
}
@@ -0,0 +1,37 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
/** How far a point is from the center of a cross-section, in the section's own measure, so 1 is on its edge at radius 1. */
final class Sections {
private static final double HEX_SLANT = Math.sqrt(3) / 2;
private Sections() {
}
static double norm(PartSection section, double u, double w) {
double au = Math.abs(u);
double aw = Math.abs(w);
return switch (section) {
case ROUND -> Math.sqrt(u * u + w * w);
case SQUARE -> Math.max(au, aw);
case DIAMOND -> au + aw;
case HEX -> Math.max(aw, au * HEX_SLANT + aw * 0.5);
};
}
}
@@ -0,0 +1,243 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
import art.arcane.volmlib.util.math.RNG;
/**
* A stem traced as a path of closely spaced samples, each with a center, a direction and a radius, then swept into
* blocks: one block per sample while it is thin, a slice of its cross-section once it is thicker.
*/
final class StemShape implements PartShape {
static final double LONGEST_BLOCKS = 256;
private static final double SAMPLE_SPACING_BLOCKS = 0.25;
private static final double THIN_RADIUS_BLOCKS = 0.5;
private static final double SWAY_FREQUENCY = 0.35;
private final double length;
private final double[][] centers;
private final double[][] headings;
private final double[] radii;
private final double outward;
private StemShape(double length, double[][] centers, double[][] headings, double[] radii, double outward) {
this.length = length;
this.centers = centers;
this.headings = headings;
this.radii = radii;
this.outward = outward;
}
/** Traces the stem from {@code spot} without placing anything. */
static StemShape trace(PartStem stem, PartSpot spot, RNG rng) {
double length = stemLength(stem, spot, rng);
double baseRadius = Math.max(0, stem.radius().sample(rng, spot.parentT()));
ProceduralValue taper = stem.taper() == null ? null : stem.taper().fix(rng);
double facing = stem.facing() != null ? stem.facing().sample(rng, spot.parentT())
: spot.hasOutward() ? spot.outward() : rng.d(0, 360);
double[] heading = startHeading(stem, spot, facing, rng);
double[] toward = Vectors.across(heading, Vectors.direction(facing, 0));
double[] beside = Vectors.normalize(Vectors.cross(heading, toward), toward);
Bends bends = Bends.of(stem, spot, rng, length);
double pathLength = Math.max(0, length - 1);
int steps = Math.max(2, (int) Math.ceil(pathLength / SAMPLE_SPACING_BLOCKS));
double step = pathLength / steps;
double[][] centers = new double[steps + 1][];
double[] radii = new double[steps + 1];
double[] base = spot.origin().clone();
for (int i = 0; i <= steps; i++) {
double t = i / (double) steps;
if (i > 0) {
double middle = (i - 0.5) / steps;
base = Vectors.addScaled(base, bends.heading(heading, toward, middle), step);
}
centers[i] = Vectors.add(base, bends.offset(toward, beside, t, pathLength));
radii[i] = baseRadius * (taper == null ? 1 : Math.max(0, taper.at(t)));
}
return new StemShape(length, centers, directions(centers, heading), radii, facing);
}
/** Places the stem's blocks and records its tip. */
void draw(PartFill fill, PartSection section, double roughness, double jitter) {
for (int i = 0; i < centers.length; i++) {
double t = i / (double) (centers.length - 1);
PartCanvas.Axis axis = PartCanvas.Axis.along(headings[i]);
if (radii[i] <= THIN_RADIUS_BLOCKS && roughness <= 0) {
fill.place(round(centers[i][0]), round(centers[i][1]), round(centers[i][2]), 0, t, axis);
continue;
}
sweepSlice(fill, i, t, axis, section, roughness, jitter);
}
double[] tip = centers[centers.length - 1];
fill.canvas().addTip(new PartCanvas.Tip(round(tip[0]), round(tip[1]), round(tip[2]), headings[headings.length - 1], fill.role()));
}
private void sweepSlice(PartFill fill, int index, double t, PartCanvas.Axis axis, PartSection section, double roughness, double jitter) {
double[] center = centers[index];
double[] heading = headings[index];
double radius = Math.max(THIN_RADIUS_BLOCKS, radii[index]);
double[] across = Vectors.across(heading, new double[]{1, 0, 0});
double[] beside = Vectors.cross(heading, across);
double slab = SAMPLE_SPACING_BLOCKS * 0.5 + 0.5;
boolean first = index == 0;
boolean last = index == centers.length - 1;
int squareWidth = Math.max(1, (int) Math.round(radius * 2));
double squareShift = section == PartSection.SQUARE && squareWidth % 2 == 0 ? 0.5 : 0;
int reach = (int) Math.ceil(radius * (1 + roughness) + 1.5);
int cx = round(center[0]);
int cy = round(center[1]);
int cz = round(center[2]);
for (int x = cx - reach; x <= cx + reach; x++) {
for (int y = cy - reach; y <= cy + reach; y++) {
for (int z = cz - reach; z <= cz + reach; z++) {
double[] offset = {x - center[0], y - center[1], z - center[2]};
double axial = Vectors.dot(offset, heading);
if (Math.abs(axial) > slab || (first && axial < -0.5) || (last && axial > 0.5)) {
continue;
}
double[] radial = Vectors.addScaled(offset, heading, -axial);
double u = Vectors.dot(radial, across) - squareShift;
double w = Vectors.dot(radial, beside) - squareShift;
double limit = section == PartSection.SQUARE ? squareWidth / 2.0 : radius;
double edge = Sections.norm(section, u, w);
if (roughness > 0) {
limit += (PartNoise.hash(x, y, z, fill.seed() + 9001L) - 0.5) * roughness * (radius + 1);
}
boolean core = x == cx && y == cy && z == cz;
if (!core && edge > limit) {
continue;
}
if (!core && jitter > 0 && edge > limit - 1 && PartNoise.hash(x, y, z, fill.seed() + 77L) < jitter * 0.5) {
continue;
}
fill.place(x, y, z, Math.min(edge, limit) / (limit + 1), t, axis);
}
}
}
}
@Override
public PartSpot spotAt(double t) {
double position = Math.max(0, Math.min(1, t)) * (centers.length - 1);
int index = (int) Math.floor(position);
int next = Math.min(centers.length - 1, index + 1);
double blend = position - index;
double[] center = Vectors.add(Vectors.scale(centers[index], 1 - blend), Vectors.scale(centers[next], blend));
double[] heading = headings[index];
double outwardHere = Vectors.isVertical(heading) ? outward : Vectors.azimuth(heading);
return new PartSpot(center, heading.clone(), t, length, outwardHere);
}
@Override
public double length() {
return length;
}
@Override
public double defaultAt() {
return 1;
}
private static double stemLength(PartStem stem, PartSpot spot, RNG rng) {
double length = stem.lengthScale() > 0 && spot.parentLength() > 0
? spot.parentLength() * stem.lengthScale()
: stem.length().sample(rng, spot.parentT());
return Math.max(1, Math.min(LONGEST_BLOCKS, length));
}
private static double[] startHeading(PartStem stem, PartSpot spot, double facing, RNG rng) {
if (stem.pitch() == null && stem.azimuth() == null) {
return spot.heading().clone();
}
double pitch = stem.pitch() != null ? stem.pitch().sample(rng, spot.parentT()) : Vectors.pitch(spot.heading());
double azimuth = stem.azimuth() != null ? stem.azimuth().sample(rng, spot.parentT())
: Vectors.isVertical(spot.heading()) ? facing : Vectors.azimuth(spot.heading());
return Vectors.direction(azimuth, pitch);
}
/** The direction at each sample, from its neighbors, so offsets such as lean and corkscrew turn the slices too. */
private static double[][] directions(double[][] centers, double[] fallback) {
double[][] headings = new double[centers.length][];
for (int i = 0; i < centers.length; i++) {
double[] before = centers[Math.max(0, i - 1)];
double[] after = centers[Math.min(centers.length - 1, i + 1)];
headings[i] = Vectors.normalize(Vectors.subtract(after, before), i > 0 ? headings[i - 1] : fallback);
}
return headings;
}
private static int round(double value) {
return (int) Math.round(value);
}
/** Everything that pulls a stem off a straight line, rolled once per stem. */
private record Bends(double leanTangent, ProceduralValue leanCurve, double bendRadians, ProceduralValue bendCurve,
double droop, double sway, double wave, double wavePeriods, double wavePhase,
ProceduralValue helixRadius, double helixTurns, long swaySeed) {
static Bends of(PartStem stem, PartSpot spot, RNG rng, double length) {
double t = spot.parentT();
double lean = Math.max(-85, Math.min(85, sample(stem.lean(), rng, t)));
return new Bends(Math.tan(Math.toRadians(lean)), fixed(stem.leanCurve(), rng),
Math.toRadians(sample(stem.bend(), rng, t)), fixed(stem.bendCurve(), rng),
sample(stem.droop(), rng, t), sample(stem.sway(), rng, t),
sample(stem.wave(), rng, t), sample(stem.wavePeriods(), rng, t), rng.d(0, Math.PI * 2),
fixed(stem.helixRadius(), rng), sample(stem.helixTurns(), rng, t), rng.nextLong());
}
double[] heading(double[] start, double[] toward, double t) {
if (bendRadians == 0) {
return start;
}
double angle = bendRadians * progress(bendCurve, t);
return Vectors.add(Vectors.scale(start, Math.cos(angle)), Vectors.scale(toward, Math.sin(angle)));
}
double[] offset(double[] toward, double[] beside, double t, double pathLength) {
double[] offset = Vectors.scale(toward, pathLength * leanTangent * progress(leanCurve, t));
offset[1] -= droop * pathLength * t * t;
double helix = helixRadius == null ? 0 : helixRadius.at(t);
if (helix != 0) {
double angle = Math.PI * 2 * helixTurns * t;
offset = Vectors.addScaled(offset, toward, Math.cos(angle) * helix);
offset = Vectors.addScaled(offset, beside, Math.sin(angle) * helix);
}
if (wave != 0) {
offset = Vectors.addScaled(offset, beside, wave * Math.sin(Math.PI * 2 * wavePeriods * t + wavePhase));
}
if (sway != 0) {
double along = t * pathLength * SWAY_FREQUENCY;
offset = Vectors.addScaled(offset, toward, sway * (PartNoise.line(along, swaySeed) * 2 - 1));
offset = Vectors.addScaled(offset, beside, sway * (PartNoise.line(along, swaySeed + 1) * 2 - 1));
}
return offset;
}
private static double progress(ProceduralValue curve, double t) {
return curve == null ? t : curve.at(t);
}
private static double sample(ProceduralValue value, RNG rng, double t) {
return value == null ? 0 : value.sample(rng, t);
}
private static ProceduralValue fixed(ProceduralValue value, RNG rng) {
return value == null ? null : value.fix(rng);
}
}
}
@@ -0,0 +1,96 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural.part;
/** Small vector maths on {@code double[3]}, with compass azimuths measured from south (+z) toward east (+x). */
final class Vectors {
static final double[] UP = {0, 1, 0};
private Vectors() {
}
/** The unit direction {@code azimuth} degrees around the compass and {@code pitch} degrees above the horizon. */
static double[] direction(double azimuth, double pitch) {
double a = Math.toRadians(azimuth);
double p = Math.toRadians(pitch);
return new double[]{Math.cos(p) * Math.sin(a), Math.sin(p), Math.cos(p) * Math.cos(a)};
}
static double azimuth(double[] direction) {
return Math.toDegrees(Math.atan2(direction[0], direction[2]));
}
static double pitch(double[] direction) {
return Math.toDegrees(Math.asin(Math.max(-1, Math.min(1, direction[1]))));
}
static boolean isVertical(double[] direction) {
return Math.abs(direction[1]) > 0.999;
}
static double[] add(double[] a, double[] b) {
return new double[]{a[0] + b[0], a[1] + b[1], a[2] + b[2]};
}
static double[] subtract(double[] a, double[] b) {
return new double[]{a[0] - b[0], a[1] - b[1], a[2] - b[2]};
}
static double[] scale(double[] a, double factor) {
return new double[]{a[0] * factor, a[1] * factor, a[2] * factor};
}
static double[] addScaled(double[] a, double[] b, double factor) {
return new double[]{a[0] + b[0] * factor, a[1] + b[1] * factor, a[2] + b[2] * factor};
}
static double dot(double[] a, double[] b) {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
static double[] cross(double[] a, double[] b) {
return new double[]{a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]};
}
static double length(double[] a) {
return Math.sqrt(dot(a, a));
}
/** {@code a} scaled to length 1; {@code fallback} when it has no length. */
static double[] normalize(double[] a, double[] fallback) {
double length = length(a);
return length < 1e-9 ? fallback.clone() : scale(a, 1 / length);
}
/** The unit vector across {@code axis} that points most toward {@code toward}; any across one when they line up. */
static double[] across(double[] axis, double[] toward) {
double[] flattened = subtract(toward, scale(axis, dot(toward, axis)));
if (length(flattened) > 1e-6) {
return normalize(flattened, UP);
}
double[] reference = Math.abs(axis[0]) < 0.9 ? new double[]{1, 0, 0} : new double[]{0, 0, 1};
return normalize(subtract(reference, scale(axis, dot(reference, axis))), UP);
}
/** {@code direction} turned {@code degrees} toward {@code azimuth}, for leaning something away from where it points. */
static double[] tilted(double[] direction, double azimuth, double degrees) {
double[] toward = across(direction, direction(azimuth, 0));
double angle = Math.toRadians(degrees);
return normalize(add(scale(direction, Math.cos(angle)), scale(toward, Math.sin(angle))), direction);
}
}
@@ -56,6 +56,7 @@ import art.arcane.iris.world.entity.IrisEntity;
import art.arcane.iris.generation.noise.IrisExpression;
import art.arcane.iris.structure.object.IrisObjectScale;
import art.arcane.iris.generation.noise.IrisGenerator;
import art.arcane.iris.generation.procedural.part.ProceduralObject;
import art.arcane.iris.generation.image.IrisImage;
import art.arcane.iris.generation.image.IrisImageMap;
import art.arcane.iris.structure.jigsaw.IrisJigsawPiece;
@@ -142,6 +143,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
private ResourceLoader<IrisStructure> structureLoader;
private ResourceLoader<IrisJigsawPool> jigsawPoolLoader;
private ResourceLoader<IrisJigsawPiece> jigsawPieceLoader;
private ResourceLoader<ProceduralObject> proceduralObjectLoader;
private KMap<String, KList<String>> possibleSnippets;
private Gson gson;
private Gson snippetLoader;
@@ -486,6 +488,14 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
return (ResourceLoader<T>) loaders.get(type);
}
/** The object {@code key} names; a procedural pool key gives the variant {@code rng} picks. */
public IrisObject loadObject(String key, RNG rng) {
if (objectLoader instanceof ObjectResourceLoader objects) {
return objects.load(key, rng);
}
return objectLoader.load(key);
}
public ResourceLoader<?> getTypedLoaderFor(File f) {
String[] k = f.getPath().split("\\Q" + File.separator + "\\E");
@@ -733,6 +743,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
this.structureLoader = registerLoader(IrisStructure.class, replacement);
this.jigsawPoolLoader = registerLoader(IrisJigsawPool.class, replacement);
this.jigsawPieceLoader = registerLoader(IrisJigsawPiece.class, replacement);
this.proceduralObjectLoader = registerLoader(ProceduralObject.class, replacement);
builder.registerTypeAdapterFactory(KeyedType::createTypeAdapter);
gson = builder.create();
@@ -783,6 +794,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
public synchronized void invalidateStructureResources() {
StructureGraphCatalog.invalidate(this);
invalidateLoader(proceduralObjectLoader);
invalidateLoader(objectLoader);
invalidateLoader(structureLoader);
invalidateLoader(jigsawPoolLoader);
@@ -18,21 +18,27 @@
package art.arcane.iris.pack.loading;
import art.arcane.iris.generation.procedural.ProceduralObjectCatalog;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.configuration.IrisSettings;
import art.arcane.iris.structure.object.IrisObject;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.collection.KSet;
import art.arcane.volmlib.util.data.KCache;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Optional;
public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
private final ProceduralObjectCatalog procedural;
public ObjectResourceLoader(File root, IrisData idm, String folderName, String resourceTypeName, Options options) {
super(root, idm, folderName, resourceTypeName, IrisObject.class, options);
procedural = new ProceduralObjectCatalog(idm);
loadCache = new KCache<>(this::loadRaw, IrisSettings.get().getPerformance().getObjectLoaderCacheSize());
}
@@ -81,10 +87,17 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
for (File i : getFolders()) {
m.addAll(getFiles(i, ".iob", true, visitedDirectories));
}
m.addAll(procedural.definitionKeys());
possibleKeys = m.toArray(new String[0]);
return possibleKeys;
}
@Override
public void clearCache() {
super.clearCache();
procedural.invalidate();
}
private KList<String> getFiles(File dir, String ext, boolean skipDirName, HashSet<String> visitedDirectories) {
KList<String> paths = new KList<>();
if (dir == null || !dir.exists()) {
@@ -151,6 +164,14 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
return file == null ? null : loadFile(file, name);
}
/** The object {@code name} names; a procedural pool key gives the variant {@code rng} picks. */
public IrisObject load(String name, RNG rng) {
if (!ProceduralObjectCatalog.isProceduralKey(name)) {
return load(name);
}
return procedural.object(name, rng).orElseGet(() -> load(name));
}
public IrisObject load(String name, boolean warn) {
if (name == null || name.trim().isEmpty()) {
return null;
@@ -159,6 +180,12 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
IrisLogging.warn("Refusing " + resourceTypeName + " load for literal string \"null\" (called by " + callerHint() + ")");
return null;
}
if (ProceduralObjectCatalog.isProceduralKey(name)) {
Optional<IrisObject> baked = procedural.object(name);
if (baked.isPresent()) {
return baked.get();
}
}
IrisObject result = loadCache.get(name);
if (result == null && warn) {
IrisLogging.warn("Couldn't find " + resourceTypeName + ": " + name + " (called by " + callerHint() + ")");
@@ -382,7 +382,7 @@ public class IrisObjectPlacement {
return null;
}
return data.getObjectLoader().load(pool.get(random.nextInt(pool.size())));
return data.loadObject(pool.get(random.nextInt(pool.size())), random);
}
public IrisObject scaleObject(RNG random, IrisObject object, IrisDimension dimension) {
@@ -0,0 +1,139 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural;
import art.arcane.iris.spi.IrisPlatform;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformRegistries;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.withSettings;
/**
* Registries whose blocks carry properties the way the game's do: a key gets Minecraft's namespace, logs and stems an
* axis, leaves their distance, persistence and waterlogging, and setting a property gives the state with it. A key
* naming {@code minecraft:missing_*} is a block the platform lacks.
*/
public final class GameLikeBlocks {
private static final String NAMESPACE = "minecraft:";
private static final String MISSING = NAMESPACE + "missing_";
private final Map<String, NativeBlockState> states = new ConcurrentHashMap<>();
private final PlatformRegistries registries = mock(PlatformRegistries.class, withSettings().stubOnly());
private final IrisPlatform platform = mock(IrisPlatform.class, withSettings().stubOnly());
public GameLikeBlocks() {
when(registries.block(anyString())).thenAnswer(invocation -> {
NativeBlockState state = orNull(invocation.getArgument(0));
return state == null ? state("minecraft:air") : state;
});
when(registries.blockOrNull(anyString())).thenAnswer(invocation -> orNull(invocation.getArgument(0)));
when(registries.blockOrNull(anyString(), anyBoolean())).thenAnswer(invocation -> orNull(invocation.getArgument(0)));
when(registries.air()).thenAnswer(invocation -> state("minecraft:air"));
when(platform.registries()).thenReturn(registries);
}
public void bind() {
IrisPlatforms.unbind();
IrisPlatforms.bind(platform);
}
private NativeBlockState orNull(String key) {
String canonical = canonical(key);
return canonical.startsWith(MISSING) ? null : state(canonical);
}
private NativeBlockState state(String canonical) {
return states.computeIfAbsent(canonical, this::create);
}
private NativeBlockState create(String key) {
NativeBlockState state = mock(NativeBlockState.class, withSettings().stubOnly());
String material = material(key);
when(state.key()).thenReturn(key);
when(state.materialKey()).thenReturn(material);
when(state.isAir()).thenReturn(material.endsWith("air"));
when(state.withProperty(anyString(), anyString())).thenAnswer(invocation -> {
Map<String, String> properties = properties(key);
properties.put(invocation.getArgument(0), invocation.getArgument(1));
return state(write(material, properties));
});
return state;
}
private static String canonical(String key) {
String lower = key.toLowerCase(Locale.ROOT);
String namespaced = lower.contains(":") ? lower : NAMESPACE + lower;
String material = material(namespaced);
Map<String, String> properties = defaults(material);
properties.putAll(properties(namespaced));
return write(material, properties);
}
private static Map<String, String> defaults(String material) {
Map<String, String> properties = new TreeMap<>();
if (material.endsWith("_leaves")) {
properties.put("distance", "7");
properties.put("persistent", "false");
properties.put("waterlogged", "false");
} else if (material.endsWith("_log") || material.endsWith("_wood") || material.endsWith("_stem")
|| material.endsWith("_hyphae")) {
properties.put("axis", "y");
}
return properties;
}
private static String material(String key) {
int bracket = key.indexOf('[');
return bracket < 0 ? key : key.substring(0, bracket);
}
private static Map<String, String> properties(String key) {
Map<String, String> properties = new TreeMap<>();
int bracket = key.indexOf('[');
if (bracket < 0 || !key.endsWith("]")) {
return properties;
}
for (String property : key.substring(bracket + 1, key.length() - 1).split(",")) {
int equals = property.indexOf('=');
if (equals > 0) {
properties.put(property.substring(0, equals), property.substring(equals + 1));
}
}
return properties;
}
private static String write(String material, Map<String, String> properties) {
if (properties.isEmpty()) {
return material;
}
return material + properties.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue())
.collect(Collectors.joining(",", "[", "]"));
}
}
@@ -0,0 +1,94 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.generation.procedural;
import art.arcane.iris.generation.procedural.part.ProceduralObject;
import art.arcane.iris.generation.procedural.part.ResolvedProceduralObject;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.pack.loading.ResourceLoader;
import art.arcane.iris.spi.IrisPlatforms;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Stream;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.withSettings;
/** The overworld pack's {@code procedural/} folder, read the way a pack is, over registries whose blocks behave like the game's. */
final class ProceduralFixture {
private static final String RESOURCE = "/procedural-parts";
private static final String DEFINITIONS = "procedural";
private final Path pack;
private final IrisData data;
private final Gson gson;
private ProceduralFixture(Path pack, IrisData data, Gson gson) {
this.pack = pack;
this.data = data;
this.gson = gson;
}
static ProceduralFixture bind() throws URISyntaxException {
new GameLikeBlocks().bind();
Path pack = Path.of(ProceduralFixture.class.getResource(RESOURCE).toURI());
IrisData data = mock(IrisData.class, withSettings().stubOnly().defaultAnswer(CALLS_REAL_METHODS));
doReturn(pack.toFile()).when(data).getDataFolder();
doReturn(mock(ResourceLoader.class)).when(data).getBlockLoader();
doReturn(null).when(data).getEngine();
Gson gson = new GsonBuilder().registerTypeAdapterFactory(data).create();
return new ProceduralFixture(pack, data, gson);
}
static void unbind() {
IrisPlatforms.unbind();
}
IrisData data() {
return data;
}
ResolvedProceduralObject resolved(String path) throws IOException {
return new ResolvedProceduralObject(path, definition(path), data);
}
ProceduralObject definition(String path) throws IOException {
String json = Files.readString(pack.resolve(DEFINITIONS).resolve(path + ".json"));
return gson.fromJson(json, ProceduralObject.class);
}
List<String> definitionPaths() throws IOException {
Path folder = pack.resolve(DEFINITIONS);
try (Stream<Path> files = Files.walk(folder)) {
return files.filter(file -> file.toString().endsWith(".json"))
.map(file -> folder.relativize(file).toString().replace('\\', '/'))
.map(file -> file.substring(0, file.length() - ".json".length()))
.sorted()
.toList();
}
}
}
@@ -0,0 +1,109 @@
/*
* 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.generation.procedural;
import art.arcane.iris.generation.procedural.part.ProceduralObject;
import art.arcane.iris.pack.loading.ResourceLoader;
import art.arcane.iris.structure.object.IrisObject;
import art.arcane.volmlib.util.math.RNG;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
public class ProceduralObjectCatalogTest {
private static final String RED_CAP = "fungi/mushroom/red-cap";
private static final String RED_CAP_KEY = ProceduralObjectCatalog.KEY_PREFIX + RED_CAP;
private static final int RED_CAP_VARIANTS = 6;
private ProceduralFixture fixture;
private ResourceLoader<ProceduralObject> definitions;
private ProceduralObjectCatalog catalog;
@Before
@SuppressWarnings("unchecked")
public void bindPackWithRedCap() throws Exception {
fixture = ProceduralFixture.bind();
definitions = mock(ResourceLoader.class);
doReturn(new String[]{RED_CAP}).when(definitions).getPossibleKeys();
doReturn(null).when(definitions).load(anyString(), eq(false));
doReturn(fixture.definition(RED_CAP)).when(definitions).load(RED_CAP, false);
doReturn(definitions).when(fixture.data()).getProceduralObjectLoader();
catalog = new ProceduralObjectCatalog(fixture.data());
}
@After
public void unbindPlatform() {
ProceduralFixture.unbind();
}
@Test
public void listsEveryDefinitionAsAPoolKey() {
assertEquals(List.of(RED_CAP_KEY), catalog.definitionKeys());
}
@Test
public void aPinnedKeyGivesThatVariant() {
Optional<IrisObject> third = catalog.object(RED_CAP_KEY + "#2");
assertTrue(third.isPresent());
assertEquals(RED_CAP_KEY + "#2", third.get().getLoadKey());
}
@Test
public void aPoolKeyPicksTheSameVariantForTheSameSeed() {
IrisObject first = catalog.object(RED_CAP_KEY, new RNG(42)).orElseThrow();
IrisObject again = catalog.object(RED_CAP_KEY, new RNG(42)).orElseThrow();
assertEquals(first.getLoadKey(), again.getLoadKey());
assertEquals(RED_CAP_VARIANTS, catalog.placeable(RED_CAP_KEY).size());
}
@Test
public void aKeyTheOtherPackObjectsUseIsNotProcedural() {
assertFalse(ProceduralObjectCatalog.isProceduralKey("trees/oak"));
assertTrue(ProceduralObjectCatalog.isProceduralKey(RED_CAP_KEY));
}
@Test
public void anUnknownDefinitionGivesNothing() {
assertTrue(catalog.object(ProceduralObjectCatalog.KEY_PREFIX + "fungi/missing").isEmpty());
}
@Test
public void definitionsBakeOnceUntilInvalidated() {
catalog.object(RED_CAP_KEY);
catalog.object(RED_CAP_KEY + "#1");
verify(definitions, times(1)).load(RED_CAP, false);
catalog.invalidate();
catalog.object(RED_CAP_KEY);
verify(definitions, times(2)).load(RED_CAP, false);
}
}
@@ -0,0 +1,196 @@
/*
* 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.generation.procedural;
import art.arcane.iris.generation.geometry.IrisBlockVector;
import art.arcane.iris.structure.object.IrisObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HexFormat;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* Every procedural object of the overworld pack (its {@code procedural/} folder, with the palette snippets it names)
* bakes, and bakes the same variants as when these digests were taken: same names, sizes and blocks, in the order
* they were made. A digest that changes means world generation places different objects.
* <p>
* Shapes match Iris v5 block for block. Palette picks follow v4's noise, which scales zoom over fracture and cellular
* and keeps the style's own power, so objects with a multi-block palette differ from v5's digests by design.
*/
public class ProceduralObjectsGoldenTest {
private static final Map<String, String> GAME_LIKE = Map.ofEntries(
Map.entry("coral/ocean/reef-brain", "b780ee9793980556"),
Map.entry("coral/ocean/reef-branch", "5d9d2881b522ca52"),
Map.entry("coral/ocean/reef-fan", "7aa06119d4a119c2"),
Map.entry("coral/temperate/brain-coral", "7f61fb3597b4f07a"),
Map.entry("coral/temperate/branch-coral", "85866503fe458e27"),
Map.entry("crystals/estranged/amethyst-cluster", "8a1cf4b29c5e2643"),
Map.entry("crystals/estranged/frostspar", "94adf86f507c9775"),
Map.entry("crystals/frozen/glacial-frost-bloom", "269ba23560175716"),
Map.entry("crystals/frozen/glacial-frost-sprigs", "2966bfc03d3ecc49"),
Map.entry("formations/estranged/boulder", "8d8601e794ade5a3"),
Map.entry("formations/estranged/obelisk-spire", "35c0817e7aef80e3"),
Map.entry("formations/estranged/ossuary-spire", "b070c7cdcdcb1893"),
Map.entry("formations/frozen/glacial-arch", "88b208875ba9137c"),
Map.entry("formations/frozen/glacial-arch-2", "eda15bb101c732b2"),
Map.entry("formations/frozen/glacial-cave-arch", "4106698fa11c4fd9"),
Map.entry("formations/frozen/glacial-cave-fissure", "4b66f037cb8dfafc"),
Map.entry("formations/frozen/glacial-cave-hanging-needle", "309896032f06a611"),
Map.entry("formations/frozen/glacial-cave-iceberg", "85c94b00f016e48c"),
Map.entry("formations/frozen/glacial-cave-needle", "958c6a5be931e30d"),
Map.entry("formations/frozen/glacial-cave-overhang", "084251a8b3b73489"),
Map.entry("formations/frozen/glacial-cave-shard-fan", "bdf6728f843298a5"),
Map.entry("formations/frozen/glacial-cave-spiral", "95dec28606d59bd1"),
Map.entry("formations/frozen/glacial-crooked-spire", "2a65f5c2c165519e"),
Map.entry("formations/frozen/glacial-crooked-spire-2", "29db29d789a47ad8"),
Map.entry("formations/frozen/glacial-drift", "d6bf138b5fedf4ec"),
Map.entry("formations/frozen/glacial-fissure", "e6f03adedc95d4b5"),
Map.entry("formations/frozen/glacial-fissure-2", "414b7ca59be86d70"),
Map.entry("formations/frozen/glacial-iceberg", "68204af6fd4e82c9"),
Map.entry("formations/frozen/glacial-iceberg-2", "c94e60ef36416a21"),
Map.entry("formations/frozen/glacial-overhang", "8c833445d4bdee4c"),
Map.entry("formations/frozen/glacial-overhang-2", "33d4344f779ecc12"),
Map.entry("formations/frozen/glacial-overhang-3", "fa68510db7ab437e"),
Map.entry("formations/frozen/glacial-shard-fan", "e01f0e007cb2cdbd"),
Map.entry("formations/frozen/glacial-shard-fan-2", "71559cf0f7aa8192"),
Map.entry("formations/frozen/glacial-spiral", "ee0eba9400f7531b"),
Map.entry("formations/frozen/glacial-spiral-2", "042681969a2f42b8"),
Map.entry("formations/frozen/glacial-spiral-3", "afadec6271ac652b"),
Map.entry("formations/magnetics/glacial-leaning-lance", "bb21fbb337bc4c3c"),
Map.entry("formations/magnetics/glacial-leaning-lance-2", "6050700a6e2cf702"),
Map.entry("formations/magnetics/glacial-needle", "6f96f650f3287013"),
Map.entry("formations/magnetics/glacial-needle-2", "74cf79674ecd59b2"),
Map.entry("formations/magnetics/glacial-shard-fan", "ce0699c25f897800"),
Map.entry("formations/magnetics/glacial-shard-fan-2", "7a92fcd891b58b67"),
Map.entry("fungi/mushroom/brown-table", "43559217abe6f50e"),
Map.entry("fungi/mushroom/red-cap", "d530e0ee8bf2c45a"),
Map.entry("fungi/mushroom/spindle-toadstool", "f9325da029df1a25"),
Map.entry("ruins/estranged/pallid-marker", "ecc17127ff23b82d"),
Map.entry("ruins/estranged/ruined-pillar", "f4ad226fb50365d5"),
Map.entry("ruins/estranged/ruined-wall", "e892dc089247bab2"),
Map.entry("trees/estranged/baobab-giant", "2d2f6ac1d0f3a12e"),
Map.entry("trees/estranged/baobab-young", "040e6f0edbe0454c"),
Map.entry("trees/estranged/birchglass", "18ddbb47c30ecf39"),
Map.entry("trees/estranged/birchglass-wide", "bc76c876729c039b"),
Map.entry("trees/estranged/bloomspire", "c7abe73e9aacc9c7"),
Map.entry("trees/estranged/bonsai-blossom", "b1086398efa3d47d"),
Map.entry("trees/estranged/bonsai-green", "d65fe4f34e9db801"),
Map.entry("trees/estranged/candlewood", "747ac67821c9b669"),
Map.entry("trees/estranged/emberbark", "fcf9b3f2ddafd4e2"),
Map.entry("trees/estranged/emberbark-tall", "d2d9c1b1e5745fb7"),
Map.entry("trees/estranged/lollipop-pink", "a3f8915b37fa0cea"),
Map.entry("trees/estranged/lollipop-teal", "9ccc63d709c941eb"),
Map.entry("trees/estranged/mistveil-spire", "54a98ed949007920"),
Map.entry("trees/estranged/mistveil-young", "5b997ebf801fd7e9"),
Map.entry("trees/estranged/pallid-spindle", "7e61438ae7d9d0b3"),
Map.entry("trees/estranged/pallid-willow", "7671510319a28455"),
Map.entry("trees/estranged/skyreach-pine", "56eeb832a996f9f5"),
Map.entry("trees/estranged/snarlwood", "4949c8fb9b8b3d1b"),
Map.entry("trees/estranged/spindle-golden", "8c59979a5ebeb224"),
Map.entry("trees/estranged/spindle-whorl", "2b91fe5d0c10db6b"),
Map.entry("trees/estranged/stiltroot", "8986e4cae3578abf"),
Map.entry("trees/estranged/taxodium", "5f61ee1495fc3ff5"),
Map.entry("trees/estranged/weeping-willow", "ceda6cba27c98ccf")
);
private ProceduralFixture fixture;
@Before
public void bindGameLikePlatform() throws URISyntaxException {
fixture = ProceduralFixture.bind();
}
@After
public void unbindPlatform() {
ProceduralFixture.unbind();
}
@Test
public void everyProceduralObjectOfTheOverworldPackBakesVariantsWithBlocks() throws IOException {
List<String> empty = new ArrayList<>();
for (String path : fixture.definitionPaths()) {
List<IrisObject> variants = fixture.resolved(path).variants();
if (variants.isEmpty() || variants.stream().anyMatch(variant -> variant.getBlocks().isEmpty())) {
empty.add(path);
}
}
assertEquals(List.of(), empty);
}
@Test
public void everyProceduralObjectOfTheOverworldPackBakesAsWhenTheDigestsWereTaken() throws Exception {
Map<String, String> actual = new TreeMap<>();
for (String path : fixture.definitionPaths()) {
actual.put(path, digest(fixture.resolved(path)));
}
assertEquals(new TreeMap<>(GAME_LIKE), actual);
}
@Test
public void theBakedObjectsHoldTheShapesTheDigestsWereTakenOf() throws Exception {
for (String path : fixture.definitionPaths()) {
ProceduralVariants variants = fixture.resolved(path);
for (IrisObject baked : variants.variants()) {
int index = Integer.parseInt(baked.getLoadKey().substring(baked.getLoadKey().indexOf('#') + 1));
ProceduralShape shape = shapeOf(variants, index);
assertNotNull(path, shape);
assertEquals(path, variants.variantKey(index), baked.getLoadKey());
assertEquals(path, shape.width(), baked.getW());
assertEquals(path, shape.height(), baked.getH());
assertEquals(path, shape.depth(), baked.getD());
assertEquals(path, shape.blocks().size(), baked.getBlocks().size());
for (ProceduralBlock block : shape.blocks()) {
assertEquals(path, block.state(), baked.getBlocks().get(new IrisBlockVector(block.x(), block.y(), block.z())));
}
}
}
}
private static ProceduralShape shapeOf(ProceduralVariants variants, int index) {
return variants.generate(index, variants.variantRng(index), variants.newBuilder(), BakeProfile.NONE);
}
private static String digest(ProceduralVariants variants) throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
for (IrisObject variant : variants.variants()) {
update(digest, variant.getLoadKey() + ' ' + variant.getW() + 'x' + variant.getH() + 'x' + variant.getD() + ':');
variant.getBlocks().forEach((position, state) ->
update(digest, position.getBlockX() + "," + position.getBlockY() + "," + position.getBlockZ() + "=" + state.key() + ";"));
update(digest, "\n");
}
return HexFormat.of().formatHex(digest.digest(), 0, 8);
}
private static void update(MessageDigest digest, String text) {
digest.update(text.getBytes(StandardCharsets.UTF_8));
}
}
@@ -0,0 +1,83 @@
/*
* 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.generation.procedural;
import art.arcane.iris.generation.geometry.IrisBlockVector;
import art.arcane.iris.generation.procedural.part.PartTrace;
import art.arcane.iris.generation.procedural.part.ResolvedProceduralObject;
import art.arcane.iris.structure.object.IrisObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/** The parts the studio picks out of a baked variant are the ones that placed the blocks it shows. */
public class ProceduralPartTraceTest {
private static final String[] OBJECTS = {"trees/estranged/baobab-giant", "trees/estranged/stiltroot", "formations/frozen/glacial-arch"};
private ProceduralFixture fixture;
@Before
public void bindGameLikePlatform() throws URISyntaxException {
fixture = ProceduralFixture.bind();
}
@After
public void unbindPlatform() {
ProceduralFixture.unbind();
}
@Test
public void everyTracedBlockIsABlockOfTheVariantAndItsPartIsInTheOutline() throws IOException {
for (String path : OBJECTS) {
ResolvedProceduralObject object = fixture.resolved(path);
for (IrisObject variant : object.variants()) {
PartTrace trace = object.trace(variant);
Map<IrisBlockVector, Integer> parts = object.parts(variant);
assertFalse(path + " " + variant.getLoadKey() + " has no part blocks", parts.isEmpty());
assertEquals(path + " " + variant.getLoadKey() + " traced blocks that are not shown", trace.blockCount(), parts.size());
assertTrue(parts.values().stream().allMatch(part -> part < object.outline().nodeCount()));
}
}
}
@Test
public void aVariantBakedFromAnotherObjectHasNoParts() throws IOException {
ResolvedProceduralObject object = fixture.resolved(OBJECTS[0]);
IrisObject foreign = fixture.resolved(OBJECTS[1]).variants().get(0);
assertTrue(object.parts(foreign).isEmpty());
}
@Test
public void tracingTwiceFindsTheSameParts() throws IOException {
ResolvedProceduralObject object = fixture.resolved(OBJECTS[0]);
IrisObject variant = object.variants().get(0);
assertEquals(object.parts(variant), object.parts(variant));
}
}
@@ -101,7 +101,8 @@ public class PackTypeBukkitPurityGateTest {
"art.arcane.iris.structure.object.matter.IrisMatterObject",
"art.arcane.iris.structure.placement.IrisStructure",
"art.arcane.iris.structure.jigsaw.IrisJigsawPool",
"art.arcane.iris.structure.jigsaw.IrisJigsawPiece");
"art.arcane.iris.structure.jigsaw.IrisJigsawPiece",
"art.arcane.iris.generation.procedural.part.ProceduralObject");
/**
* Types reachable from a pack that are not roots and carry no {@code @Snippet}, but are
@@ -0,0 +1,39 @@
{
"variants": 5,
"seed": 9412,
"materials": [
{
"role": "coral",
"block": "minecraft:brain_coral_block",
"palette": {
"style": {
"style": "CELLULAR",
"zoom": 0.35
},
"palette": [
{
"block": "minecraft:brain_coral_block",
"weight": 3
},
{
"block": "minecraft:bubble_coral_block",
"weight": 2
}
]
}
}
],
"parts": [
{
"offset": {
"y": 3.0
},
"blob": {
"radius": 4,
"height": 3.0,
"roughness": 0.332
}
}
],
"waterlogged": true
}
@@ -0,0 +1,102 @@
{
"variants": 8,
"seed": 9411,
"materials": [
{
"role": "coral",
"block": "minecraft:fire_coral_block",
"palette": {
"style": {
"style": "CELLULAR",
"zoom": 0.3
},
"palette": [
{
"block": "minecraft:fire_coral_block",
"weight": 3
},
{
"block": "minecraft:tube_coral_block",
"weight": 2
},
{
"block": "minecraft:bubble_coral_block",
"weight": 2
},
{
"block": "minecraft:horn_coral_block",
"weight": 2
},
{
"block": "minecraft:brain_coral_block",
"weight": 2
}
]
}
}
],
"parts": [
{
"stem": {
"length": [
2.0,
4.0
],
"sway": 0.5737
},
"children": [
{
"branches": {
"count": 6,
"along": {
"from": 0.85,
"to": 1
},
"azimuth": "GOLDEN",
"pitch": 40,
"part": {
"stem": {
"length": 5.0,
"sway": 0.5737
},
"children": [
{
"blob": {
"radius": 1
}
},
{
"branches": {
"count": 2,
"along": {
"from": 1,
"to": 1
},
"azimuth": "FAN",
"fan": 35,
"pitch": 50,
"part": {
"stem": {
"lengthScale": 0.6,
"sway": 0.5737
},
"children": []
}
}
}
]
}
}
}
]
}
],
"decorations": [
{
"at": "TOP",
"chance": 0.25,
"block": "minecraft:sea_pickle"
}
],
"waterlogged": true
}
@@ -0,0 +1,81 @@
{
"variants": 5,
"seed": 9413,
"materials": [
{
"role": "coral",
"block": "minecraft:horn_coral_block",
"palette": {
"style": {
"style": "CELLULAR",
"zoom": 0.3
},
"palette": [
{
"block": "minecraft:horn_coral_block",
"weight": 3
},
{
"block": "minecraft:fire_coral_block",
"weight": 2
}
]
}
}
],
"parts": [
{
"offset": {
"y": 1.75
},
"blob": {
"radius": 5,
"height": [
1.0,
2.5
],
"stretchZ": 0.05,
"profile": [
[
0.0,
0.0
],
[
0.125,
0.3827
],
[
0.25,
0.7071
],
[
0.375,
0.9239
],
[
0.5,
1.0
],
[
0.625,
0.9239
],
[
0.75,
0.7071
],
[
0.875,
0.3827
],
[
1.0,
0.0
]
],
"section": "SQUARE"
}
}
],
"waterlogged": true
}
@@ -0,0 +1,39 @@
{
"variants": 5,
"seed": 9402,
"materials": [
{
"role": "coral",
"block": "minecraft:brain_coral_block",
"palette": {
"style": {
"style": "CELLULAR",
"zoom": 0.35
},
"palette": [
{
"block": "minecraft:brain_coral_block",
"weight": 3
},
{
"block": "minecraft:bubble_coral_block",
"weight": 1
}
]
}
}
],
"parts": [
{
"offset": {
"y": 2.5
},
"blob": {
"radius": 3,
"height": 2.5,
"roughness": 0.332
}
}
],
"waterlogged": true
}
@@ -0,0 +1,98 @@
{
"variants": 6,
"seed": 9401,
"materials": [
{
"role": "coral",
"block": "minecraft:tube_coral_block",
"palette": {
"style": {
"style": "CELLULAR",
"zoom": 0.3
},
"palette": [
{
"block": "minecraft:tube_coral_block",
"weight": 3
},
{
"block": "minecraft:brain_coral_block",
"weight": 2
},
{
"block": "minecraft:bubble_coral_block",
"weight": 2
},
{
"block": "minecraft:horn_coral_block",
"weight": 2
}
]
}
}
],
"parts": [
{
"stem": {
"length": [
2.0,
3.0
],
"sway": 0.5
},
"children": [
{
"branches": {
"count": 5,
"along": {
"from": 0.85,
"to": 1
},
"azimuth": "GOLDEN",
"pitch": 35,
"part": {
"stem": {
"length": 4.0,
"sway": 0.5
},
"children": [
{
"blob": {
"radius": 1
}
},
{
"branches": {
"count": 2,
"along": {
"from": 1,
"to": 1
},
"azimuth": "FAN",
"fan": 35,
"pitch": 45,
"part": {
"stem": {
"lengthScale": 0.6,
"sway": 0.5
},
"children": []
}
}
}
]
}
}
}
]
}
],
"decorations": [
{
"at": "TOP",
"chance": 0.2,
"block": "minecraft:sea_pickle"
}
],
"waterlogged": true
}
@@ -0,0 +1,92 @@
{
"variants": 6,
"seed": 9201,
"materials": [
{
"role": "shard",
"block": "minecraft:amethyst_block",
"palette": {
"style": {
"style": "CELLULAR",
"zoom": 0.3
},
"palette": [
{
"block": "minecraft:amethyst_block",
"weight": 5
},
{
"block": "minecraft:calcite",
"weight": 2
}
]
},
"rules": [
{
"block": "minecraft:amethyst_cluster",
"along": {
"from": 0.95,
"to": 1
},
"chance": 0.6
}
]
},
{
"role": "base",
"block": "minecraft:budding_amethyst"
}
],
"parts": [
{
"role": "base",
"blob": {
"radius": 2.5,
"roughness": 0.6667
}
},
{
"role": "shard",
"cluster": {
"count": [
5.0,
9.0
],
"radius": 1.5,
"layout": "GOLDEN",
"tilt": [
[
0,
8.25
],
[
1,
63.25
]
],
"part": {
"stem": {
"length": [
4.0,
7.0
],
"radius": 1.5,
"taper": [
[
0,
1
],
[
1,
0.2
]
]
},
"offset": {
"y": 1.05
}
}
}
}
]
}
@@ -0,0 +1,90 @@
{
"variants": 5,
"seed": 9202,
"materials": [
{
"role": "shard",
"block": "minecraft:quartz_block",
"palette": {
"style": {
"style": "CELLULAR",
"zoom": 0.3
},
"palette": [
{
"block": "minecraft:quartz_block",
"weight": 4
},
{
"block": "minecraft:tinted_glass",
"weight": 2
},
{
"block": "minecraft:packed_ice",
"weight": 1
}
]
},
"rules": [
{
"block": "minecraft:glowstone",
"along": {
"from": 0.95,
"to": 1
},
"chance": 0.6
}
]
},
{
"role": "base",
"block": "minecraft:calcite"
}
],
"parts": [
{
"role": "base",
"blob": {
"radius": 2.0,
"roughness": 0.5
}
},
{
"role": "shard",
"cluster": {
"count": [
4.0,
7.0
],
"radius": 1.2,
"layout": "RANDOM",
"tilt": [
0,
40.0
],
"part": {
"stem": {
"length": [
5.0,
9.0
],
"radius": 1.5,
"taper": [
[
0,
1
],
[
1,
0.15
]
]
},
"offset": {
"y": 0.84
}
}
}
}
]
}
@@ -0,0 +1,77 @@
{
"variants": 24,
"seed": 5055031,
"materials": [
{
"role": "shard",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.95,
"to": 1
},
"chance": 0.65
}
]
},
{
"role": "base",
"block": "minecraft:blue_ice"
}
],
"parts": [
{
"role": "base",
"blob": {
"radius": 1.8,
"roughness": 0.6667
}
},
{
"role": "shard",
"cluster": {
"count": [
3.0,
6.0
],
"radius": 1.08,
"layout": "GOLDEN",
"tilt": [
[
0,
10.2
],
[
1,
79.9
]
],
"part": {
"stem": {
"length": [
3.0,
6.0
],
"radius": 1.1,
"taper": [
[
0,
1
],
[
1,
0.0
]
]
},
"offset": {
"y": 0.756
}
}
}
}
]
}
@@ -0,0 +1,71 @@
{
"variants": 24,
"seed": 5055032,
"materials": [
{
"role": "shard",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.95,
"to": 1
},
"chance": 0.55
}
]
},
{
"role": "base",
"block": "minecraft:blue_ice"
}
],
"parts": [
{
"role": "base",
"blob": {
"radius": 1.2,
"roughness": 0.8333
}
},
{
"role": "shard",
"cluster": {
"count": [
2.0,
5.0
],
"radius": 0.72,
"layout": "RANDOM",
"tilt": [
0,
80.0
],
"part": {
"stem": {
"length": [
2.0,
4.0
],
"radius": 1.0,
"taper": [
[
0,
1
],
[
1,
0.0
]
]
},
"offset": {
"y": 0.504
}
}
}
}
]
}
@@ -0,0 +1,54 @@
{
"variants": 6,
"seed": 9003,
"materials": [
{
"role": "rock",
"block": "minecraft:mossy_cobblestone",
"palette": {
"style": {
"style": "CELLULAR",
"zoom": 0.4
},
"palette": [
{
"block": "minecraft:stone",
"weight": 3
},
{
"block": "minecraft:mossy_cobblestone",
"weight": 2
},
{
"block": "minecraft:andesite",
"weight": 2
},
{
"block": "minecraft:cobblestone",
"weight": 1
}
]
}
}
],
"parts": [
{
"role": "rock",
"offset": {
"y": 2.25
},
"blob": {
"radius": [
3.0,
6.0
],
"height": [
2.0,
3.0
],
"stretchZ": 0.95,
"roughness": 0.3
}
}
]
}
@@ -0,0 +1,79 @@
{
"variants": 4,
"seed": 9001,
"materials": [
{
"role": "rock",
"block": "minecraft:stone",
"palette": {
"style": {
"style": "STATIC"
},
"palette": [
{
"block": "minecraft:calcite"
},
{
"block": "minecraft:tuff"
}
]
},
"bands": 2
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
14.0,
26.0
],
"radius": [
3.0,
5.0
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9678
],
[
0.25,
0.8828
],
[
0.375,
0.7627
],
[
0.5,
0.625
],
[
0.625,
0.4873
],
[
0.75,
0.3672
],
[
0.875,
0.2822
],
[
1.0,
0.25
]
],
"roughness": 0.35,
"jitter": 0.3
}
}
]
}
@@ -0,0 +1,85 @@
{
"variants": 7,
"seed": 9411,
"materials": [
{
"role": "rock",
"block": "minecraft:calcite",
"palette": {
"style": {
"style": "CELLULAR",
"zoom": 0.4
},
"palette": [
{
"block": "minecraft:calcite",
"weight": 5
},
{
"block": "minecraft:diorite",
"weight": 3
},
{
"block": "minecraft:bone_block",
"weight": 1
}
]
}
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
8.0,
19.0
],
"radius": [
2.0,
5.0
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9693
],
[
0.25,
0.8884
],
[
0.375,
0.774
],
[
0.5,
0.6429
],
[
0.625,
0.5117
],
[
0.75,
0.3973
],
[
0.875,
0.3164
],
[
1.0,
0.2857
]
],
"roughness": 0.65,
"jitter": 0.7
}
}
]
}
@@ -0,0 +1,121 @@
{
"variants": 24,
"seed": 5055005,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice"
}
],
"parts": [
{
"role": "rock",
"offset": {
"y": 2.0
},
"stem": {
"length": [
22.4818,
37.1784
],
"radius": 2.0,
"pitch": 82.9003,
"azimuth": 0,
"facing": 0,
"bend": 165.8005,
"bendCurve": [
[
0,
0
],
[
0.0285,
0.0
],
[
0.1567,
0.1027
],
[
0.2318,
0.1494
],
[
0.2928,
0.1916
],
[
0.3449,
0.2373
],
[
0.3904,
0.2906
],
[
0.431,
0.3541
],
[
0.4681,
0.4279
],
[
0.5035,
0.5081
],
[
0.5391,
0.5875
],
[
0.5768,
0.6594
],
[
0.6182,
0.7208
],
[
0.6649,
0.7724
],
[
0.7186,
0.8169
],
[
0.7818,
0.8592
],
[
0.8612,
0.9087
],
[
1,
1
]
],
"roughness": 0.112,
"sway": 0.96,
"jitter": 0.049
},
"children": [
{
"at": 0,
"blob": {
"radius": 2.9
}
},
{
"at": 1,
"blob": {
"radius": 2.9
}
}
]
}
]
}
@@ -0,0 +1,121 @@
{
"variants": 16,
"seed": 5055005,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice"
}
],
"parts": [
{
"role": "rock",
"offset": {
"y": 2.0
},
"stem": {
"length": [
19.4504,
32.4344
],
"radius": 2.0,
"pitch": 82.7539,
"azimuth": 0,
"facing": 0,
"bend": 165.5078,
"bendCurve": [
[
0,
0
],
[
0.0282,
0.0
],
[
0.1557,
0.1047
],
[
0.2305,
0.152
],
[
0.2914,
0.1946
],
[
0.3436,
0.2404
],
[
0.3894,
0.2936
],
[
0.4302,
0.3565
],
[
0.4677,
0.4292
],
[
0.5036,
0.508
],
[
0.5396,
0.586
],
[
0.5776,
0.6569
],
[
0.6194,
0.7178
],
[
0.6662,
0.7693
],
[
0.72,
0.8141
],
[
0.7831,
0.8567
],
[
0.8621,
0.9069
],
[
1,
1
]
],
"roughness": 0.112,
"sway": 0.8,
"jitter": 0.049
},
"children": [
{
"at": 0,
"blob": {
"radius": 2.9
}
},
{
"at": 1,
"blob": {
"radius": 2.9
}
}
]
}
]
}
@@ -0,0 +1,121 @@
{
"variants": 12,
"seed": 5055105,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice"
}
],
"parts": [
{
"role": "rock",
"offset": {
"y": 1.0
},
"stem": {
"length": [
13.2144,
23.622
],
"radius": 1.0,
"pitch": 84.6633,
"azimuth": 0,
"facing": 0,
"bend": 169.3265,
"bendCurve": [
[
0,
0
],
[
0.0312,
0.0
],
[
0.1699,
0.0782
],
[
0.2485,
0.1161
],
[
0.3106,
0.1525
],
[
0.362,
0.1944
],
[
0.4051,
0.2476
],
[
0.4416,
0.3174
],
[
0.4735,
0.4069
],
[
0.5029,
0.5106
],
[
0.5326,
0.6124
],
[
0.5652,
0.6981
],
[
0.603,
0.7642
],
[
0.6476,
0.8147
],
[
0.7009,
0.8551
],
[
0.7656,
0.8911
],
[
0.8491,
0.9308
],
[
1,
1
]
],
"roughness": 0.09,
"sway": 0.384,
"jitter": 0.021
},
"children": [
{
"at": 0,
"blob": {
"radius": 1.27
}
},
{
"at": 1,
"blob": {
"radius": 1.27
}
}
]
}
]
}
@@ -0,0 +1,87 @@
{
"variants": 12,
"seed": 5055102,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.8333,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"cluster": {
"count": 3,
"radius": 4.0,
"layout": "LINE",
"part": {
"stem": {
"length": [
4.96,
16.0
],
"radius": 1.0,
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
23.254
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.2,
"jitter": 0.04
}
}
}
}
]
}
@@ -0,0 +1,75 @@
{
"variants": 16,
"seed": 5055123,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.8667,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
10.0,
20.0
],
"radius": [
1.0,
2.0
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.875
],
[
0.25,
0.75
],
[
0.375,
0.625
],
[
0.5,
0.5
],
[
0.625,
0.375
],
[
0.75,
0.25
],
[
0.875,
0.125
],
[
1.0,
0.0
]
],
"roughness": 0.1,
"jitter": 0.01
}
}
]
}
@@ -0,0 +1,109 @@
{
"variants": 12,
"seed": 5055101,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.7333,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"offset": {
"y": 1.134
},
"blob": {
"radius": [
2.3,
4.5
],
"stretchZ": 0.9,
"height": [
2.1,
4.2
],
"depth": 1.134,
"roughness": 0.135
}
},
{
"role": "rock",
"cluster": {
"count": 3,
"radius": 1.55,
"layout": "RANDOM",
"part": {
"stem": {
"length": [
3.0,
10.0
],
"radius": [
1.0,
1.74
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
10.8464
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.3,
"jitter": 0.08
}
}
}
}
]
}
@@ -0,0 +1,75 @@
{
"variants": 16,
"seed": 5055121,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.8519,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
9.0,
18.0
],
"radius": [
1.0,
2.0
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.875
],
[
0.25,
0.75
],
[
0.375,
0.625
],
[
0.5,
0.5
],
[
0.625,
0.375
],
[
0.75,
0.25
],
[
0.875,
0.125
],
[
1.0,
0.0
]
],
"roughness": 0.1,
"jitter": 0.01
}
}
]
}
@@ -0,0 +1,127 @@
{
"variants": 12,
"seed": 5055104,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.97,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
14.7591,
21.5596
],
"radius": [
1.0,
2.0
],
"taper": [
[
0,
1
],
[
1,
0.36
]
],
"pitch": 89.8141,
"facing": [
80.0,
100.0
],
"bend": 178.8393,
"bendCurve": [
[
0,
0
],
[
0.0047,
0.0
],
[
0.0516,
0.0104
],
[
0.0986,
0.0208
],
[
0.1457,
0.0311
],
[
0.1929,
0.0413
],
[
0.2403,
0.0515
],
[
0.288,
0.0616
],
[
0.336,
0.0715
],
[
0.3843,
0.0813
],
[
0.433,
0.0909
],
[
0.5204,
0.326
],
[
0.6057,
0.3976
],
[
0.6757,
0.5382
],
[
0.739,
0.7258
],
[
0.8124,
0.8667
],
[
0.9042,
0.9517
],
[
1,
1
]
],
"roughness": 0.072,
"jitter": 0.021
}
}
]
}
@@ -0,0 +1,87 @@
{
"variants": 16,
"seed": 5055122,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.84,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"cluster": {
"count": 3,
"radius": 4.0,
"layout": "LINE",
"part": {
"stem": {
"length": [
4.96,
17.0
],
"radius": 1.0,
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
22.3477
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.16,
"jitter": 0.03
}
}
}
}
]
}
@@ -0,0 +1,55 @@
{
"variants": 12,
"seed": 5055103,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.97,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
8.0,
16.0
],
"radius": 1.0,
"taper": [
[
0,
1
],
[
1,
0.52
]
],
"helixRadius": [
[
0,
3.0
],
[
1,
0.84
]
],
"helixTurns": 1.3,
"roughness": 0.07,
"jitter": 0.014
}
}
]
}
@@ -0,0 +1,77 @@
{
"variants": 32,
"seed": 5055021,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.8947,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
14.0,
24.0
],
"radius": [
5.0,
8.0
],
"taper": [
[
0.0,
0.8252
],
[
0.125,
0.6714
],
[
0.25,
0.5492
],
[
0.375,
0.45
],
[
0.5,
0.3652
],
[
0.625,
0.2864
],
[
0.75,
0.2049
],
[
0.875,
0.1123
],
[
1.0,
0.0769
]
],
"lean": 18.0,
"facing": 72.0,
"roughness": 0.32,
"jitter": 0.09
}
}
]
}
@@ -0,0 +1,77 @@
{
"variants": 24,
"seed": 5055021,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.8824,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
12.0,
22.0
],
"radius": [
5.0,
7.0
],
"taper": [
[
0.0,
0.8556
],
[
0.125,
0.6953
],
[
0.25,
0.5672
],
[
0.375,
0.4628
],
[
0.5,
0.3736
],
[
0.625,
0.2912
],
[
0.75,
0.2071
],
[
0.875,
0.1129
],
[
1.0,
0.0833
]
],
"lean": 18.0,
"facing": 72.0,
"roughness": 0.32,
"jitter": 0.09
}
}
]
}
@@ -0,0 +1,31 @@
{
"variants": 24,
"seed": 5055041,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice"
}
],
"parts": [
{
"role": "rock",
"offset": {
"y": 2.0
},
"blob": {
"radius": [
2.0,
4.0
],
"height": [
2.0,
2.5
],
"stretchZ": 0.95,
"roughness": 0.36
}
}
]
}
@@ -0,0 +1,87 @@
{
"variants": 24,
"seed": 5055002,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.8889,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"cluster": {
"count": 3,
"radius": 9.9444,
"layout": "LINE",
"part": {
"stem": {
"length": [
8.06,
23.0
],
"radius": 3.4722,
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
38.5591
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.3,
"jitter": 0.08
}
}
}
}
]
}
@@ -0,0 +1,87 @@
{
"variants": 16,
"seed": 5055002,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.871,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"cluster": {
"count": 3,
"radius": 9.0185,
"layout": "LINE",
"part": {
"stem": {
"length": [
6.82,
20.0
],
"radius": 3.0093,
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
41.0471
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.3,
"jitter": 0.08
}
}
}
}
]
}
@@ -0,0 +1,109 @@
{
"variants": 24,
"seed": 5055001,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.8824,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"offset": {
"y": 2.5704
},
"blob": {
"radius": [
5.75,
12.0
],
"stretchZ": 0.9,
"height": [
5.04,
9.24
],
"depth": 2.5704,
"roughness": 0.189
}
},
{
"role": "rock",
"cluster": {
"count": 4,
"radius": 4.03,
"layout": "RANDOM",
"part": {
"stem": {
"length": [
6.96,
22.0
],
"radius": [
1.4,
4.64
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
12.4298
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.42,
"jitter": 0.14
}
}
}
}
]
}
@@ -0,0 +1,109 @@
{
"variants": 16,
"seed": 5055001,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.8621,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"offset": {
"y": 2.1924
},
"blob": {
"radius": [
5.75,
12.0
],
"stretchZ": 0.9,
"height": [
4.2,
7.98
],
"depth": 2.1924,
"roughness": 0.189
}
},
{
"role": "rock",
"cluster": {
"count": 4,
"radius": 4.03,
"layout": "RANDOM",
"part": {
"stem": {
"length": [
5.8,
19.0
],
"radius": [
1.4,
4.64
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
14.5516
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.42,
"jitter": 0.14
}
}
}
}
]
}
@@ -0,0 +1,127 @@
{
"variants": 24,
"seed": 5055004,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.97,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
27.7662,
35.3456
],
"radius": [
5.0,
8.0
],
"taper": [
[
0,
1
],
[
1,
0.36
]
],
"pitch": 89.7979,
"facing": [
80.0,
100.0
],
"bend": 178.8163,
"bendCurve": [
[
0,
0
],
[
0.0045,
0.0
],
[
0.0494,
0.0113
],
[
0.0944,
0.0226
],
[
0.1395,
0.0338
],
[
0.1847,
0.0449
],
[
0.2302,
0.0559
],
[
0.276,
0.0668
],
[
0.3221,
0.0775
],
[
0.3686,
0.088
],
[
0.4155,
0.0984
],
[
0.5036,
0.3407
],
[
0.5903,
0.4144
],
[
0.6626,
0.5524
],
[
0.7294,
0.7305
],
[
0.8062,
0.8666
],
[
0.9011,
0.9513
],
[
1,
1
]
],
"roughness": 0.156,
"jitter": 0.056
}
}
]
}
@@ -0,0 +1,127 @@
{
"variants": 24,
"seed": 5055004,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.97,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
23.158,
30.7438
],
"radius": [
5.0,
7.0
],
"taper": [
[
0,
1
],
[
1,
0.36
]
],
"pitch": 89.7997,
"facing": [
80.0,
100.0
],
"bend": 178.8149,
"bendCurve": [
[
0,
0
],
[
0.0045,
0.0
],
[
0.0497,
0.0112
],
[
0.0949,
0.0224
],
[
0.1403,
0.0335
],
[
0.1858,
0.0445
],
[
0.2315,
0.0554
],
[
0.2775,
0.0662
],
[
0.3239,
0.0768
],
[
0.3706,
0.0873
],
[
0.4178,
0.0976
],
[
0.5059,
0.339
],
[
0.5926,
0.4122
],
[
0.6647,
0.55
],
[
0.7311,
0.7291
],
[
0.8074,
0.8661
],
[
0.9017,
0.9511
],
[
1,
1
]
],
"roughness": 0.1543,
"jitter": 0.056
}
}
]
}
@@ -0,0 +1,127 @@
{
"variants": 16,
"seed": 5055004,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.97,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
23.158,
30.7438
],
"radius": [
5.0,
7.0
],
"taper": [
[
0,
1
],
[
1,
0.36
]
],
"pitch": 89.7997,
"facing": [
80.0,
100.0
],
"bend": 178.8149,
"bendCurve": [
[
0,
0
],
[
0.0045,
0.0
],
[
0.0497,
0.0112
],
[
0.0949,
0.0224
],
[
0.1403,
0.0335
],
[
0.1858,
0.0445
],
[
0.2315,
0.0554
],
[
0.2775,
0.0662
],
[
0.3239,
0.0768
],
[
0.3706,
0.0873
],
[
0.4178,
0.0976
],
[
0.5059,
0.339
],
[
0.5926,
0.4122
],
[
0.6647,
0.55
],
[
0.7311,
0.7291
],
[
0.8074,
0.8661
],
[
0.9017,
0.9511
],
[
1,
1
]
],
"roughness": 0.1543,
"jitter": 0.056
}
}
]
}
@@ -0,0 +1,87 @@
{
"variants": 24,
"seed": 5055023,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.8788,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"cluster": {
"count": 3,
"radius": 9.9444,
"layout": "LINE",
"part": {
"stem": {
"length": [
7.44,
21.0
],
"radius": 3.4722,
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
41.7731
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.28,
"jitter": 0.08
}
}
}
}
]
}
@@ -0,0 +1,87 @@
{
"variants": 24,
"seed": 5055023,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.871,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"cluster": {
"count": 3,
"radius": 9.4815,
"layout": "LINE",
"part": {
"stem": {
"length": [
6.82,
20.0
],
"radius": 3.2407,
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
42.6397
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.28,
"jitter": 0.08
}
}
}
}
]
}
@@ -0,0 +1,55 @@
{
"variants": 24,
"seed": 5055003,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.97,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
15.0,
24.0
],
"radius": 3,
"taper": [
[
0,
1
],
[
1,
0.52
]
],
"helixRadius": [
[
0,
6.0
],
[
1,
1.68
]
],
"helixTurns": 1.15,
"roughness": 0.108,
"jitter": 0.049
}
}
]
}
@@ -0,0 +1,55 @@
{
"variants": 24,
"seed": 5055003,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.97,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
12.0,
21.0
],
"radius": 3,
"taper": [
[
0,
1
],
[
1,
0.52
]
],
"helixRadius": [
[
0,
5.0
],
[
1,
1.4
]
],
"helixTurns": 1.1,
"roughness": 0.108,
"jitter": 0.049
}
}
]
}
@@ -0,0 +1,55 @@
{
"variants": 16,
"seed": 5055003,
"materials": [
{
"role": "rock",
"block": "minecraft:packed_ice",
"palette": "snippet/palette/frozen/magical-ice",
"rules": [
{
"block": "minecraft:blue_ice",
"along": {
"from": 0.97,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
12.0,
21.0
],
"radius": 3,
"taper": [
[
0,
1
],
[
1,
0.52
]
],
"helixRadius": [
[
0,
5.0
],
[
1,
1.4
]
],
"helixTurns": 1.1,
"roughness": 0.108,
"jitter": 0.049
}
}
]
}
@@ -0,0 +1,77 @@
{
"variants": 16,
"seed": 5055022,
"materials": [
{
"role": "rock",
"block": "minecraft:light_blue_stained_glass",
"palette": "snippet/palette/magnetics/magical-glass",
"rules": [
{
"block": "minecraft:tinted_glass",
"along": {
"from": 0.9459,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
26.0,
48.0
],
"radius": [
1.0,
2.0
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.957
],
[
0.25,
0.8438
],
[
0.375,
0.6836
],
[
0.5,
0.5
],
[
0.625,
0.3164
],
[
0.75,
0.1562
],
[
0.875,
0.043
],
[
1.0,
0.0
]
],
"lean": 10.0,
"facing": 72.0,
"roughness": 0.14,
"jitter": 0.02
}
}
]
}
@@ -0,0 +1,77 @@
{
"variants": 24,
"seed": 5055022,
"materials": [
{
"role": "rock",
"block": "minecraft:light_blue_stained_glass",
"palette": "snippet/palette/magnetics/magical-glass",
"rules": [
{
"block": "minecraft:tinted_glass",
"along": {
"from": 0.9565,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
32.0,
60.0
],
"radius": [
1.0,
2.0
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.957
],
[
0.25,
0.8438
],
[
0.375,
0.6836
],
[
0.5,
0.5
],
[
0.625,
0.3164
],
[
0.75,
0.1562
],
[
0.875,
0.043
],
[
1.0,
0.0
]
],
"lean": 10.0,
"facing": 72.0,
"roughness": 0.14,
"jitter": 0.02
}
}
]
}
@@ -0,0 +1,75 @@
{
"variants": 16,
"seed": 5055021,
"materials": [
{
"role": "rock",
"block": "minecraft:light_blue_stained_glass",
"palette": "snippet/palette/magnetics/magical-glass",
"rules": [
{
"block": "minecraft:tinted_glass",
"along": {
"from": 0.9333,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
20.0,
40.0
],
"radius": [
1.0,
2.0
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.875
],
[
0.25,
0.75
],
[
0.375,
0.625
],
[
0.5,
0.5
],
[
0.625,
0.375
],
[
0.75,
0.25
],
[
0.875,
0.125
],
[
1.0,
0.0
]
],
"roughness": 0.12,
"jitter": 0.02
}
}
]
}
@@ -0,0 +1,75 @@
{
"variants": 24,
"seed": 5055021,
"materials": [
{
"role": "rock",
"block": "minecraft:light_blue_stained_glass",
"palette": "snippet/palette/magnetics/magical-glass",
"rules": [
{
"block": "minecraft:tinted_glass",
"along": {
"from": 0.9487,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"stem": {
"length": [
26.0,
52.0
],
"radius": [
1.0,
2.0
],
"taper": [
[
0.0,
1.0
],
[
0.125,
0.875
],
[
0.25,
0.75
],
[
0.375,
0.625
],
[
0.5,
0.5
],
[
0.625,
0.375
],
[
0.75,
0.25
],
[
0.875,
0.125
],
[
1.0,
0.0
]
],
"roughness": 0.12,
"jitter": 0.02
}
}
]
}
@@ -0,0 +1,87 @@
{
"variants": 16,
"seed": 5055023,
"materials": [
{
"role": "rock",
"block": "minecraft:light_blue_stained_glass",
"palette": "snippet/palette/magnetics/magical-glass",
"rules": [
{
"block": "minecraft:tinted_glass",
"along": {
"from": 0.931,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"cluster": {
"count": 4,
"radius": 7.5,
"layout": "LINE",
"part": {
"stem": {
"length": [
12.4,
38.0
],
"radius": 1.0,
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
15.0359
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.18,
"jitter": 0.04
}
}
}
}
]
}
@@ -0,0 +1,87 @@
{
"variants": 24,
"seed": 5055023,
"materials": [
{
"role": "rock",
"block": "minecraft:light_blue_stained_glass",
"palette": "snippet/palette/magnetics/magical-glass",
"rules": [
{
"block": "minecraft:tinted_glass",
"along": {
"from": 0.9474,
"to": 1
}
}
]
}
],
"parts": [
{
"role": "rock",
"cluster": {
"count": 4,
"radius": 7.5,
"layout": "LINE",
"part": {
"stem": {
"length": [
16.12,
50.0
],
"radius": 1.0,
"taper": [
[
0.0,
1.0
],
[
0.125,
0.9083
],
[
0.25,
0.8129
],
[
0.375,
0.7129
],
[
0.5,
0.6071
],
[
0.625,
0.4935
],
[
0.75,
0.3686
],
[
0.875,
0.2238
],
[
1.0,
0.0
]
],
"lean": [
0,
11.5023
],
"leanCurve": {
"shape": "power",
"exponent": 2
},
"roughness": 0.18,
"jitter": 0.04
}
}
}
}
]
}
@@ -0,0 +1,103 @@
{
"variants": 6,
"seed": 9302,
"materials": [
{
"role": "stem",
"block": "minecraft:mushroom_stem"
},
{
"role": "cap",
"block": "minecraft:brown_mushroom_block",
"rules": [
{
"block": "minecraft:shroomlight",
"face": "DOWN",
"chance": 0.5
}
]
}
],
"parts": [
{
"role": "stem",
"stem": {
"length": [
5.0,
11.0
],
"radius": 1.0,
"section": "SQUARE",
"lean": 4.0,
"leanCurve": {
"shape": "power",
"exponent": 2
},
"facing": 0,
"wave": 0.4,
"wavePeriods": 1
},
"children": [
{
"role": "cap",
"blob": {
"radius": [
7.0,
10.0
],
"height": 1.343,
"depth": 1.0,
"profile": [
[
0.0,
0.98
],
[
0.1,
0.96
],
[
0.2,
0.935
],
[
0.3,
0.905
],
[
0.4,
0.875
],
[
0.5,
0.835
],
[
0.6,
0.79
],
[
0.7,
0.735
],
[
0.8,
0.665
],
[
0.9,
0.545
],
[
1.0,
0.0
]
],
"shell": 1,
"open": true
}
}
]
}
]
}
@@ -0,0 +1,103 @@
{
"variants": 6,
"seed": 9301,
"materials": [
{
"role": "stem",
"block": "minecraft:mushroom_stem"
},
{
"role": "cap",
"block": "minecraft:red_mushroom_block",
"rules": [
{
"block": "minecraft:mushroom_stem",
"face": "DOWN",
"chance": 0.7
}
]
}
],
"parts": [
{
"role": "stem",
"stem": {
"length": [
4.0,
9.0
],
"radius": 1.0,
"section": "SQUARE",
"lean": 6.0,
"leanCurve": {
"shape": "power",
"exponent": 2
},
"facing": 0,
"wave": 0.4,
"wavePeriods": 1.5
},
"children": [
{
"role": "cap",
"blob": {
"radius": [
5.0,
7.0
],
"height": 2.958,
"depth": 1.9495,
"profile": [
[
0.0,
1.0
],
[
0.1,
0.985
],
[
0.2,
0.96
],
[
0.3,
0.925
],
[
0.4,
0.885
],
[
0.5,
0.83
],
[
0.6,
0.77
],
[
0.7,
0.69
],
[
0.8,
0.59
],
[
0.9,
0.445
],
[
1.0,
0.0
]
],
"shell": 2,
"open": true
}
}
]
}
]
}
@@ -0,0 +1,126 @@
{
"variants": 6,
"seed": 9303,
"materials": [
{
"role": "stem",
"block": "minecraft:mushroom_stem",
"palette": {
"style": {
"style": "SIMPLEX",
"zoom": 0.6
},
"palette": [
{
"block": "minecraft:mushroom_stem",
"weight": 5
},
{
"block": "minecraft:pale_oak_wood",
"weight": 1
}
]
}
},
{
"role": "cap",
"block": "minecraft:red_mushroom_block",
"rules": [
{
"block": "minecraft:shroomlight",
"face": "DOWN",
"chance": 0.6
},
{
"block": "minecraft:brown_mushroom_block",
"face": "UP",
"chance": 0.25,
"pattern": "PATCHES",
"scale": 2
}
]
}
],
"parts": [
{
"role": "stem",
"stem": {
"length": [
6.0,
12.0
],
"radius": 0.5,
"section": "SQUARE",
"lean": 10.0,
"leanCurve": {
"shape": "power",
"exponent": 2
},
"facing": 0,
"wave": 0.6,
"wavePeriods": 2
},
"children": [
{
"role": "cap",
"blob": {
"radius": [
3.0,
5.0
],
"height": 2.576,
"depth": 1.6161,
"profile": [
[
0.0,
1.0
],
[
0.1,
0.94
],
[
0.2,
0.875
],
[
0.3,
0.805
],
[
0.4,
0.73
],
[
0.5,
0.645
],
[
0.6,
0.545
],
[
0.7,
0.435
],
[
0.8,
0.305
],
[
0.9,
0.16
],
[
1.0,
0.0
]
],
"shell": 2,
"open": true
}
}
]
}
]
}
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff. Show more