Placement settings as module-owned IrisApi types: object limit, slope clip, stilt, vacuum, block replace, axis rotation clamp

This commit is contained in:
piexel committed 2026-10-09 22:01:32 +02:00
1 parent c1f23830a2
commit 9401e8aa78
34 files changed
+654 -362

No files matched your search

@@ -0,0 +1,69 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.blocks;
import com.volmit.block.BlockSpec;
import com.volmit.block.PaletteSpec;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinItems;
import com.volmit.config.MinNumber;
import com.volmit.config.Required;
import com.volmit.config.Snippet;
import java.util.Collections;
import java.util.List;
/** One find-and-replace of an object placement's blocks, an entry of the placement's {@code edit}. */
@Snippet("object-block-replacer")
@Desc("Find and replace object materials")
public final class ObjectReplace {
@MinItems(1)
@Required
@Desc("Find this block")
private List<BlockSpec> find = List.of();
@Required
@Desc("Replace it with this block palette")
private PaletteSpec replace = PaletteSpec.of(List.of(BlockSpec.of("stone")));
@Desc("Exactly match the block data or not")
private boolean exact = false;
@MinNumber(0)
@MaxNumber(1)
@Desc("Modifies the chance the block is replaced")
private float chance = 1;
public ObjectReplace() {
}
public List<BlockSpec> find() {
return find == null ? List.of() : Collections.unmodifiableList(find);
}
public PaletteSpec replace() {
return replace == null ? PaletteSpec.of(List.of(BlockSpec.of("stone"))) : replace;
}
public boolean exact() {
return exact;
}
public float chance() {
return chance;
}
}
@@ -0,0 +1,132 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.prepare;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinNumber;
import com.volmit.config.Required;
import com.volmit.config.Snippet;
import java.util.Objects;
/** One axis of an object rotation, with the angles it may turn by and the steps between them. */
@Snippet("axis-rotation")
@Desc("Represents a rotation axis with intervals and maxes. The x and z axis values are defaulted to disabled. The Y axis defaults to on, rotating by 90 degree increments.")
public final class AxisRotationClamp {
private static final double FULL_TURN_DEGREES = 360D;
@Desc("Should this axis be rotated at all?")
private boolean enabled = false;
private transient boolean forceLock = false;
@Required
@MinNumber(-360)
@MaxNumber(360)
@Desc("The minimum angle (from) or set this and max to zero for any angle degrees. Set both to the same non-zero value to force it to that angle only")
private double min = 0;
@Required
@MinNumber(-360)
@MaxNumber(360)
@Desc("The maximum angle (to) or set this and min to zero for any angle degrees. Set both to the same non-zero value to force it to that angle only")
private double max = 0;
@Required
@MinNumber(0)
@MaxNumber(360)
@Desc("Iris spins the axis but not freely. For example an interval of 90 would mean 4 possible angles (right angles) degrees. \nSetting this to 0 means totally free rotation.\n\nNote that a lot of structures can have issues with non 90 degree intervals because the minecraft block resolution is so low.")
private double interval = 0;
public AxisRotationClamp() {
}
/** An axis turned as {@code enabled} says, by angles from {@code min} to {@code max} in steps of {@code interval}. */
public static AxisRotationClamp of(boolean enabled, boolean forceLock, double min, double max, double interval) {
AxisRotationClamp clamp = new AxisRotationClamp();
clamp.enabled = enabled;
clamp.forceLock = forceLock;
clamp.min = min;
clamp.max = max;
clamp.interval = interval;
return clamp;
}
/** An axis that turns to exactly {@code angle}, in steps of {@code interval}, whatever its min and max say. */
public static AxisRotationClamp locked(boolean enabled, double angle, double interval) {
return of(enabled, true, angle, angle, interval);
}
public boolean enabled() {
return enabled;
}
public double min() {
return min;
}
public double max() {
return max;
}
public double interval() {
return interval;
}
public boolean isUnlimited() {
return min == max && min == 0;
}
public boolean isLocked() {
return min == max && !isUnlimited();
}
public double getRadians(int rng) {
if (forceLock) {
return Math.toRadians(Math.ceil(Math.abs((max % FULL_TURN_DEGREES))));
}
if (isUnlimited()) {
double resolvedInterval = interval < 1 ? 1 : interval;
return Math.toRadians((resolvedInterval * (Math.ceil(Math.abs((rng % FULL_TURN_DEGREES) / resolvedInterval)))) % FULL_TURN_DEGREES);
}
if (min == max && min != 0) {
return Math.toRadians(max);
}
double angle = (interval * (Math.ceil(Math.abs((rng % FULL_TURN_DEGREES) / interval)))) % FULL_TURN_DEGREES;
return Math.toRadians(Math.min(Math.max(min, max), Math.max(Math.min(min, max), angle)));
}
@Override
public boolean equals(Object other) {
return other instanceof AxisRotationClamp clamp
&& enabled == clamp.enabled
&& Double.compare(min, clamp.min) == 0
&& Double.compare(max, clamp.max) == 0
&& Double.compare(interval, clamp.interval) == 0;
}
@Override
public int hashCode() {
return Objects.hash(enabled, min, max, interval);
}
}
@@ -0,0 +1,66 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.prepare;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinNumber;
import com.volmit.config.Snippet;
/** The terrain slopes a placement or decorator may sit on, written as its {@code slopeCondition}. */
@Snippet("slope-clip")
@Desc("Limits placement to a minimum and maximum terrain slope")
public final class SlopeClip {
private static final double DEFAULT_MINIMUM_SLOPE = 0;
private static final double DEFAULT_MAXIMUM_SLOPE = 10;
@MinNumber(0)
@MaxNumber(1024)
@Desc("The minimum slope for placement")
private double minimumSlope = DEFAULT_MINIMUM_SLOPE;
@MinNumber(0)
@MaxNumber(1024)
@Desc("The maximum slope for placement")
private double maximumSlope = DEFAULT_MAXIMUM_SLOPE;
public SlopeClip() {
}
public double minimumSlope() {
return minimumSlope;
}
public double maximumSlope() {
return maximumSlope;
}
/** Whether every slope passes. */
public boolean isDefault() {
return minimumSlope <= 0 && maximumSlope >= DEFAULT_MAXIMUM_SLOPE;
}
public boolean isValid(double slope) {
if (isDefault()) {
return true;
}
return !(minimumSlope > slope) && !(maximumSlope < slope);
}
}
@@ -0,0 +1,90 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.stilt;
import com.volmit.block.PaletteSpec;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinNumber;
import com.volmit.config.Snippet;
import java.util.Optional;
/** How far and with which blocks an object stilts into the ground, written as the placement's {@code stiltSettings}. */
@Snippet("stilt-settings")
@Desc("Defines stilting behaviour.")
public final class StiltSettings {
@MinNumber(0)
@MaxNumber(64)
@Desc("Defines the maximum amount of blocks the object stilts verticially before overstilting and randomRange.")
private int yMax;
@MinNumber(0)
@MaxNumber(64)
@Desc("Defines the upper boundary for additional blocks after overstilting and/or maxStiltRange.")
private int yRand;
@MaxNumber(64)
@MinNumber(0)
@Desc("If the place mode is set to stilt, you can over-stilt it even further into the ground. Especially useful when using fast stilt due to inaccuracies.")
private int overStilt;
@Desc("If defined, stilting will be done using this block palette rather than the last layer of the object.")
private PaletteSpec palette;
@MinNumber(1)
@MaxNumber(256)
@Desc("For ORGANIC_STILT / CEILING_HANG: the maximum number of blocks to scan toward the cave floor (or ceiling) looking for solid ground before giving up.")
private int organicMaxScan = 48;
@MinNumber(0)
@MaxNumber(32)
@Desc("For ORGANIC_STILT / CEILING_HANG: the maximum number of blocks each column's stilt is randomly shortened by, giving the underside a ragged organic edge instead of a flat disc.")
private int organicJitter = 3;
@MinNumber(0)
@MaxNumber(1)
@Desc("For ORGANIC_STILT / CEILING_HANG: in the deepest fraction of each stilt column, blocks are randomly skipped to break the tip up. Higher = more broken and scratchy. 0 disables.")
private double organicScratch = 0.55;
public StiltSettings() {
}
public int yMax() {
return yMax;
}
public int yRand() {
return yRand;
}
public int overStilt() {
return overStilt;
}
public Optional<PaletteSpec> palette() {
return Optional.ofNullable(palette);
}
public int organicMaxScan() {
return organicMaxScan;
}
public int organicJitter() {
return organicJitter;
}
public double organicScratch() {
return organicScratch;
}
}
@@ -0,0 +1,73 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.vacuum;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinNumber;
import com.volmit.config.Snippet;
/** How a VACUUM place mode bends terrain to meet an object's base, written as the placement's {@code vacuumSettings}. */
@Snippet("vacuum-settings")
@Desc("Defines how a VACUUM place mode bends terrain to meet an object's base.")
public final class VacuumSettings {
@MinNumber(0)
@MaxNumber(128)
@Desc("The horizontal radius (in blocks) the terrain deformation extends beyond the object footprint before it blends back to the natural surface. 0 = derive automatically from the place mode (VACUUM, VACUUM_HIGH larger, VACUUM_FAST smaller).")
private int radius = 0;
@MinNumber(0.25)
@MaxNumber(8)
@Desc("The falloff exponent controlling how the deformation eases out across the radius. 1 = linear (cone), 2 = parabolic (default, gentle bowl), higher = flatter near the object with a sharper drop at the edge.")
private double falloff = 2.0;
@MinNumber(0)
@MaxNumber(64)
@Desc("For VACUUM_ORGANIC: the maximum number of blocks the effective radius is randomly perturbed per column, giving the meeting edge an irregular organic outline instead of a clean circle.")
private int organicJitter = 4;
@MinNumber(0)
@MaxNumber(64)
@Desc("For VACUUM_WAVY: the vertical amplitude (in blocks) of the rolling simplex wave applied across the terrain bend. The wave fades to zero under the object (so it stays flush) and at the outer radius (so it blends back to the surface), peaking across the mid-slope. 0 disables the wave.")
private int waveAmplitude = 3;
@MinNumber(0.1)
@MaxNumber(64)
@Desc("For VACUUM_WAVY: the frequency of the simplex wave. Higher values make tighter, choppier ripples; lower values make broad, gentle swells. The wavelength in blocks is roughly 100 / waveScale.")
private double waveScale = 5.0;
public VacuumSettings() {
}
public int radius() {
return radius;
}
public double falloff() {
return falloff;
}
public int organicJitter() {
return organicJitter;
}
public int waveAmplitude() {
return waveAmplitude;
}
public double waveScale() {
return waveScale;
}
}
@@ -0,0 +1,55 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.validate;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinNumber;
import com.volmit.config.Snippet;
/** The heights an object placement may sit between, written as the placement's {@code clamp}. */
@Snippet("object-limit")
@Desc("Limits object placement by minimum and maximum world height")
public final class ObjectLimit {
@MinNumber(-2048)
@MaxNumber(2048)
@Desc("The minimum height for placement (bottom of object)")
private int minimumHeight = -2048;
@MinNumber(-2048)
@MaxNumber(2048)
@Desc("The maximum height for placement (top of object)")
private int maximumHeight = 2048;
public ObjectLimit() {
}
public int minimumHeight() {
return minimumHeight;
}
public int maximumHeight() {
return maximumHeight;
}
/** Whether an object whose top is at {@code highest} and bottom at {@code lowest} fits between the limits. */
public boolean canPlace(int highest, int lowest) {
return highest <= maximumHeight && lowest >= minimumHeight;
}
}