mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Merge IrisModule into module/ with its history
git-subtree-dir: module git-subtree-mainline:925c942764git-subtree-split:27b0036450
This commit is contained in:
commit
68ae3c8d3a
391 files changed
+43895
No files matched your search
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
/**
|
||||
* The purposes Iris's built-in modules ask {@link PackWorld#seed(ResourceId)} for, one per feature.
|
||||
*/
|
||||
public final class IrisSeedPurposes {
|
||||
public static final ResourceId BIOME = purpose("biome");
|
||||
public static final ResourceId CARVE = purpose("carve");
|
||||
public static final ResourceId COMPLEX = purpose("complex");
|
||||
public static final ResourceId COMPONENT = purpose("component");
|
||||
public static final ResourceId DECORATOR = purpose("decorator");
|
||||
public static final ResourceId DEPOSIT = purpose("deposit");
|
||||
public static final ResourceId ENTITY = purpose("entity");
|
||||
public static final ResourceId LOOT = purpose("loot");
|
||||
public static final ResourceId MANTLE = purpose("mantle");
|
||||
/** The random each chunk's objects are placed with, before the chunk's coordinates are mixed in. */
|
||||
public static final ResourceId OBJECT_CHUNK = purpose("object-chunk");
|
||||
/** The noise that picks the count of a placement with a density style. */
|
||||
public static final ResourceId OBJECT_DENSITY = purpose("object-density");
|
||||
/** The noise that warps the columns of object placements with a surface warp. */
|
||||
public static final ResourceId OBJECT_WARP = purpose("object-warp");
|
||||
/** The candidate spots, ranks and chance noise of separated object placements. */
|
||||
public static final ResourceId OBJECT_SEPARATION = purpose("object-separation");
|
||||
public static final ResourceId POST = purpose("post");
|
||||
public static final ResourceId TERRAIN = purpose("terrain");
|
||||
|
||||
private static final String NAMESPACE = "iris";
|
||||
private static final String PATH_PREFIX = "seed/";
|
||||
|
||||
private IrisSeedPurposes() {
|
||||
}
|
||||
|
||||
private static ResourceId purpose(String name) {
|
||||
return new ResourceId(NAMESPACE, PATH_PREFIX + name);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
import com.volmit.stage.ChunkStage;
|
||||
import com.volmit.stage.MantleStage;
|
||||
import com.volmit.stage.Stage;
|
||||
|
||||
/**
|
||||
* The mantle and chunk stages of Iris's built-in modules, one nested class per module, in the order their pipelines
|
||||
* run them: mantle, then chunk. The stage graph decides the actual order. The object placement stages are the
|
||||
* placement modules' own.
|
||||
*/
|
||||
public final class IrisStages {
|
||||
private IrisStages() {
|
||||
}
|
||||
|
||||
/** Module {@code iris:carve}: caves, planned in the mantle and cut into each chunk's terrain. */
|
||||
public static final class Carve {
|
||||
/** Plans the caves of the dimension's cave profiles into the mantle, one block into each neighbor. */
|
||||
public static final MantleStage CAVES = Stage.mantle("iris:carve/caves");
|
||||
/** Cuts the planned caves out of the chunk's terrain and decorates their floors and ceilings. */
|
||||
public static final ChunkStage<Void> APPLY = Stage.chunk("iris:carve/apply");
|
||||
|
||||
private Carve() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:objects}: the objects the dimension's regions and biomes place. */
|
||||
public static final class Objects {
|
||||
/** Places surface, cave and upper-dimension objects into the mantle, after the caves they anchor in. */
|
||||
public static final MantleStage PLACE = Stage.mantle("iris:objects/place");
|
||||
|
||||
private Objects() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:floating}: the floating islands of floating child biomes. */
|
||||
public static final class Floating {
|
||||
/** Places the objects on and under the islands into the mantle, after the dimension's other objects. */
|
||||
public static final MantleStage OBJECTS = Stage.mantle("iris:floating/objects");
|
||||
/** Writes the islands' solid blocks. */
|
||||
public static final ChunkStage<Void> SOLIDS = Stage.chunk("iris:floating/solids");
|
||||
/** Decorates the islands' tops and bottoms once the chunk's own decoration is done. */
|
||||
public static final ChunkStage<Void> DECORATE = Stage.chunk("iris:floating/decorate");
|
||||
|
||||
private Floating() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:structure}: Iris structures, assembled from pieces. */
|
||||
public static final class Structure {
|
||||
/** Places the structures of the dimension, its regions and biomes into the mantle, after objects and floating objects. */
|
||||
public static final MantleStage PLACE = Stage.mantle("iris:structure/place");
|
||||
|
||||
private Structure() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:terrain}: the solid ground, fluids and biome layers of a chunk. */
|
||||
public static final class Terrain {
|
||||
/** Fills each column from bedrock up to its height and the fluid height, with its biome's layers. */
|
||||
public static final ChunkStage<Void> SHAPE = Stage.chunk("iris:terrain/shape");
|
||||
|
||||
private Terrain() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:post}: smoothing a chunk's surface after carving. */
|
||||
public static final class Post {
|
||||
/** Fills single-block holes, places slabs and walls on steps and settles snow. */
|
||||
public static final ChunkStage<Void> SMOOTH = Stage.chunk("iris:post/smooth");
|
||||
|
||||
private Post() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:deposit}: ores and other deposits. */
|
||||
public static final class Deposit {
|
||||
/**
|
||||
* Places the deposits every level declares at the chunk's centre column, the dimension's, the region's and
|
||||
* the biome's, each with its own clumps. Active where any column of the chunk has deposits.
|
||||
*/
|
||||
public static final ChunkStage<Void> ORES = Stage.chunk("iris:deposit/ores");
|
||||
|
||||
private Deposit() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:matter}: the blocks the mantle planned for a chunk, such as objects and structures. */
|
||||
public static final class Matter {
|
||||
/** Copies the chunk's planned mantle blocks into it. */
|
||||
public static final ChunkStage<Void> INSERT = Stage.chunk("iris:matter/insert");
|
||||
|
||||
private Matter() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:decorant}: the decorators of biomes, such as grass, flowers and cave ceilings. */
|
||||
public static final class Decorant {
|
||||
/** Places every column's surface, sea, shore and cave decorators. */
|
||||
public static final ChunkStage<Void> DECORATE = Stage.chunk("iris:decorant/decorate");
|
||||
|
||||
private Decorant() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:perfection}: the last touches on an overworld chunk's blocks. */
|
||||
public static final class Perfection {
|
||||
/** Hides ores when the dimension asks, then removes decorations that nothing holds up. */
|
||||
public static final ChunkStage<Void> SURFACE = Stage.chunk("iris:perfection/surface");
|
||||
|
||||
private Perfection() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* How the settings of Iris's built-ins name families of the platform's registry keys, such as structures and placed
|
||||
* features: a pattern matches the keys equal to it and the keys it starts at a namespace, slash or underscore boundary,
|
||||
* ignoring case and surrounding space. So {@code minecraft:village} matches {@code minecraft:village_plains},
|
||||
* {@code minecraft:ore} every vanilla ore, and {@code nova_structures:} a whole namespace.
|
||||
*/
|
||||
public final class RegistryKeyFamily {
|
||||
private RegistryKeyFamily() {
|
||||
}
|
||||
|
||||
/** Whether the family pattern {@code pattern} matches the registry key {@code key}. */
|
||||
public static boolean matches(String pattern, String key) {
|
||||
if (pattern == null || key == null) {
|
||||
return false;
|
||||
}
|
||||
String normalizedPattern = normalize(pattern);
|
||||
String normalizedKey = normalize(key);
|
||||
if (normalizedPattern.isEmpty() || !normalizedKey.startsWith(normalizedPattern)) {
|
||||
return false;
|
||||
}
|
||||
if (normalizedKey.length() == normalizedPattern.length()) {
|
||||
return true;
|
||||
}
|
||||
char patternEnd = normalizedPattern.charAt(normalizedPattern.length() - 1);
|
||||
if (patternEnd == ':' || patternEnd == '/' || patternEnd == '_') {
|
||||
return true;
|
||||
}
|
||||
char boundary = normalizedKey.charAt(normalizedPattern.length());
|
||||
return boundary == '/' || boundary == '_';
|
||||
}
|
||||
|
||||
private static String normalize(String key) {
|
||||
return key.trim().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.anchor;
|
||||
|
||||
/** The height an object's anchor is placed at. */
|
||||
public record AnchorHeight(int y) {
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.anchor;
|
||||
|
||||
/** How a placement mode finds the height of an object placed without a requested height. */
|
||||
public enum AnchorSampling {
|
||||
/** The surface at the object's center, or the floor of the cave it is placed in. */
|
||||
CENTER,
|
||||
/** The highest surface under any column of the object. */
|
||||
HIGHEST,
|
||||
/** The highest surface under the object's four corners. */
|
||||
HIGHEST_CORNER,
|
||||
/** The lowest surface under any column of the object. */
|
||||
LOWEST,
|
||||
/** The lowest surface under the object's four corners. */
|
||||
LOWEST_CORNER,
|
||||
/** The surface at the object's center, ignoring caves; each block then follows its own column. */
|
||||
SURFACE,
|
||||
/** The translation alone, in open air. */
|
||||
TRANSLATION,
|
||||
/** The requested height, even when negative. */
|
||||
REQUESTED
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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.builtin.anchor;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
|
||||
@Desc("Object Place modes are useful for positioning objects just right. The default value is CENTER_HEIGHT.")
|
||||
public enum ObjectPlaceMode {
|
||||
@Desc("The default place mode. This mode picks a center point (where the center of the object will be) and takes the height. That height is used for the whole object.")
|
||||
|
||||
CENTER_HEIGHT(PlaceMode.of(AnchorSampling.CENTER, StiltShape.NONE)),
|
||||
|
||||
@Desc("Samples a lot of points where the object will cover (horizontally) and picks the highest height, that height is then used to place the object. This mode is useful for preventing any part of your object from being buried though it will float off of cliffs.")
|
||||
|
||||
MAX_HEIGHT(PlaceMode.of(AnchorSampling.HIGHEST, StiltShape.NONE)),
|
||||
|
||||
@Desc("Samples only 4 points where the object will cover (horizontally) and picks the highest height, that height is then used to place the object. This mode is useful for preventing any part of your object from being buried though it will float off of cliffs.\"")
|
||||
|
||||
FAST_MAX_HEIGHT(PlaceMode.of(AnchorSampling.HIGHEST_CORNER, StiltShape.NONE)),
|
||||
|
||||
@Desc("Samples a lot of points where the object will cover (horizontally) and picks the lowest height, that height is then used to place the object. This mode is useful for preventing any part of your object from overhanging a cliff though it gets buried a lot")
|
||||
MIN_HEIGHT(PlaceMode.of(AnchorSampling.LOWEST, StiltShape.NONE)),
|
||||
|
||||
@Desc("Samples only 4 points where the object will cover (horizontally) and picks the lowest height, that height is then used to place the object. This mode is useful for preventing any part of your object from overhanging a cliff though it gets buried a lot")
|
||||
|
||||
FAST_MIN_HEIGHT(PlaceMode.of(AnchorSampling.LOWEST_CORNER, StiltShape.NONE)),
|
||||
|
||||
@Desc("Stilting is MAX_HEIGHT but it repeats the bottom most block of your object until it hits the surface. This is expensive because it has to first sample every height value for each x,z position of your object. Avoid using this unless its structures for performance reasons.")
|
||||
|
||||
STILT(PlaceMode.of(AnchorSampling.HIGHEST, StiltShape.STRAIGHT)),
|
||||
|
||||
@Desc("Just like stilting but very inaccurate. Useful for stilting a lot of objects without too much care on accuracy (you can use the over-stilt value to force stilts under ground further)")
|
||||
|
||||
FAST_STILT(PlaceMode.of(AnchorSampling.HIGHEST_CORNER, StiltShape.STRAIGHT)),
|
||||
|
||||
@Desc("Stilting is MIN_HEIGHT but it repeats the bottom most block of your object until it hits the surface. This is expensive because it has to first sample every height value for each x,z position of your object. Avoid using this unless its structures for performance reasons.")
|
||||
|
||||
MIN_STILT(PlaceMode.of(AnchorSampling.LOWEST, StiltShape.STRAIGHT)),
|
||||
|
||||
@Desc("Just like MIN_STILT but very inaccurate. Useful for stilting a lot of objects without too much care on accuracy (you can use the over-stilt value to force stilts under ground further)")
|
||||
|
||||
FAST_MIN_STILT(PlaceMode.of(AnchorSampling.LOWEST_CORNER, StiltShape.STRAIGHT)),
|
||||
|
||||
@Desc("Stilting is CENTER_HEIGHT but it repeats the bottom most block of your object until it hits the surface. This is expensive because it has to first sample every height value for each x,z position of your object. Avoid using this unless its structures for performance reasons.")
|
||||
|
||||
CENTER_STILT(PlaceMode.of(AnchorSampling.CENTER, StiltShape.STRAIGHT)),
|
||||
|
||||
@Desc("Erode stilting tapers columns downward like an ice cream cone. Blocks near the center extend deepest while edge blocks drop off first. Blocks are randomly skipped in the lower portion for a rough organic eroded texture.")
|
||||
|
||||
ERODE_STILT(PlaceMode.of(AnchorSampling.HIGHEST, StiltShape.ERODE)),
|
||||
|
||||
@Desc("Organic stilting scans straight down from the bottom of the object to the first solid block (the cave floor, or terrain) and fills the gap with the object's own bottom block. Each column stops at a slightly different, noise-varied depth and the lower portion is randomly broken up, so the underside reads as rough organic roots rather than a flat disc. Designed for objects placed inside caves so they connect to the floor instead of floating. Tune with stilt-settings (organicMaxScan, organicJitter, organicScratch).")
|
||||
|
||||
ORGANIC_STILT(PlaceMode.of(AnchorSampling.CENTER, StiltShape.ORGANIC, PlaceTrait.CAVE_ANCHORED)),
|
||||
|
||||
@Desc("Hangs the object upside-down from a cave ceiling. The object is flipped vertically (its tip points down like a stalactite) and its top is anchored to the ceiling, while an organic, noise-varied stilt grows up into the ceiling so it never floats below the roof. Use inside caves; tune with stilt-settings (organicMaxScan, organicJitter, organicScratch).")
|
||||
|
||||
CEILING_HANG(PlaceMode.of(AnchorSampling.CENTER, StiltShape.CEILING, PlaceTrait.UPSIDE_DOWN, PlaceTrait.CAVE_ANCHORED)),
|
||||
|
||||
@Desc("Anchors the object at the terrain surface (plus translate.y) like CENTER_HEIGHT, then bends the surrounding terrain to be flush with the object's base. Columns inside the object footprint are raised (or lowered) to meet the base, and the deformation falls off parabolically out to a radius so the terrain smoothly blends back to its natural height. Use this to seat a floating/translated object on the ground without a flat stilt disc, e.g. a cube translated up 10 on a mountain pulls the terrain up to meet it. Tune with vacuum-settings (radius, falloff).")
|
||||
|
||||
VACUUM(PlaceMode.vacuum(VacuumProfile.STANDARD)),
|
||||
|
||||
@Desc("VACUUM with a larger radius and finer per-column sampling for the smoothest terrain blend. More expensive.")
|
||||
|
||||
VACUUM_HIGH(PlaceMode.vacuum(VacuumProfile.HIGH)),
|
||||
|
||||
@Desc("VACUUM with a smaller radius and coarser sampling for performance. Use when seating many objects.")
|
||||
|
||||
VACUUM_FAST(PlaceMode.vacuum(VacuumProfile.FAST)),
|
||||
|
||||
@Desc("VACUUM whose falloff radius is perturbed by noise per column, so the terrain meets the object with an irregular organic edge rather than a clean parabolic bowl.")
|
||||
|
||||
VACUUM_ORGANIC(PlaceMode.vacuum(VacuumProfile.ORGANIC)),
|
||||
|
||||
@Desc("VACUUM whose terrain bend is bent by smooth coherent simplex noise so the surface meets the object with a gently rolling, wavy slope instead of the ragged white-noise edge of VACUUM_ORGANIC or a clean parabolic bowl. The object itself still seats flush; the waves fade to zero under the object and at the outer rim, peaking across the mid-slope. Tune with vacuum-settings (waveAmplitude, waveScale).")
|
||||
|
||||
VACUUM_WAVY(PlaceMode.vacuum(VacuumProfile.WAVY)),
|
||||
|
||||
@Desc("Samples the height of the terrain at every x,z position of your object and pushes it down to the surface. It's pretty much like a melt function over the terrain.")
|
||||
|
||||
PAINT(PlaceMode.of(AnchorSampling.SURFACE, StiltShape.NONE)),
|
||||
|
||||
@Desc("Places the object in pure air at an absolute Y driven entirely by translate.y (plus optional translate.yRandom). Terrain height, underwater, and carving anchor checks are skipped. Use this for floating islands, sky structures, clouds, or blimps where the object must not be translated to the ground.")
|
||||
|
||||
FLOATING(PlaceMode.of(AnchorSampling.TRANSLATION, StiltShape.NONE, PlaceTrait.FREE_HEIGHT)),
|
||||
|
||||
@Desc("Raw stamp at the caller-supplied (x, y, z). No terrain sampling, no stilting, no Y recomputation, no underwater or carving anchor guards. Used internally to route native Minecraft structure pieces (villages etc.) through the Iris object placer.")
|
||||
|
||||
STRUCTURE_PIECE(PlaceMode.of(AnchorSampling.REQUESTED, StiltShape.NONE, PlaceTrait.RAW_STAMP, PlaceTrait.FREE_HEIGHT));
|
||||
|
||||
private final PlaceMode placeMode;
|
||||
|
||||
ObjectPlaceMode(PlaceMode placeMode) {
|
||||
this.placeMode = placeMode;
|
||||
}
|
||||
|
||||
/** What the mode does, for the placement stages to ask. */
|
||||
public PlaceMode placeMode() {
|
||||
return placeMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mode an object takes on a floating island, which has no ground below to grow stilts to or to stamp into: a
|
||||
* stilt down to the ground becomes the same height sampling without the stilt, a raw stamp the default mode.
|
||||
*/
|
||||
public ObjectPlaceMode onFloatingIsland() {
|
||||
if (placeMode.has(PlaceTrait.RAW_STAMP)) {
|
||||
return CENTER_HEIGHT;
|
||||
}
|
||||
if (placeMode.stilt() != StiltShape.STRAIGHT && placeMode.stilt() != StiltShape.ERODE) {
|
||||
return this;
|
||||
}
|
||||
for (ObjectPlaceMode mode : values()) {
|
||||
if (mode.placeMode.equals(PlaceMode.of(placeMode.anchor(), StiltShape.NONE))) {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No place mode samples " + placeMode.anchor() + " without a stilt");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.anchor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* What an object place mode does, as data the placement stages ask instead of comparing modes: how it finds its
|
||||
* height, the stilt it grows, how it bends the terrain around the object, and its traits.
|
||||
*/
|
||||
public record PlaceMode(AnchorSampling anchor, StiltShape stilt, VacuumProfile vacuum, Set<PlaceTrait> traits) {
|
||||
public PlaceMode {
|
||||
traits = Set.copyOf(traits);
|
||||
}
|
||||
|
||||
public static PlaceMode of(AnchorSampling anchor, StiltShape stilt, PlaceTrait... traits) {
|
||||
return new PlaceMode(anchor, stilt, VacuumProfile.NONE, Set.of(traits));
|
||||
}
|
||||
|
||||
public static PlaceMode vacuum(VacuumProfile vacuum) {
|
||||
return new PlaceMode(AnchorSampling.CENTER, StiltShape.NONE, vacuum, Set.of());
|
||||
}
|
||||
|
||||
public boolean has(PlaceTrait trait) {
|
||||
return traits.contains(trait);
|
||||
}
|
||||
|
||||
/** Whether the mode bends the terrain to meet the object's base. */
|
||||
public boolean bendsTerrain() {
|
||||
return vacuum != VacuumProfile.NONE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.anchor;
|
||||
|
||||
/** A trait of an object place mode that changes what the placement stages do. */
|
||||
public enum PlaceTrait {
|
||||
/** Stamps the object at the requested position as it is: no terrain sampling, no height recomputation. */
|
||||
RAW_STAMP,
|
||||
/** Takes its height from the placement alone, so the terrain, water and carving guards do not apply. */
|
||||
FREE_HEIGHT,
|
||||
/** Flips the object upside down and anchors its top. */
|
||||
UPSIDE_DOWN,
|
||||
/** Anchors to a cave's floor or ceiling, so it keeps its own mode underground. */
|
||||
CAVE_ANCHORED
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.anchor;
|
||||
|
||||
/** What a placement mode grows between the object and the ground or ceiling. */
|
||||
public enum StiltShape {
|
||||
NONE,
|
||||
/** Repeats the bottom layer straight down to the surface. */
|
||||
STRAIGHT,
|
||||
/** Like {@link #STRAIGHT}, tapering toward the edges and broken up at depth. */
|
||||
ERODE,
|
||||
/** Repeats the bottom layer down to the first solid block, each column a little different. */
|
||||
ORGANIC,
|
||||
/** Hangs the flipped object from a ceiling and grows its top layer up into it. */
|
||||
CEILING
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.anchor;
|
||||
|
||||
/** How a place mode bends the terrain around the object to meet its base; NONE leaves the terrain alone. */
|
||||
public enum VacuumProfile {
|
||||
NONE(0, 1, Edge.PARABOLIC),
|
||||
STANDARD(12, 1, Edge.PARABOLIC),
|
||||
HIGH(20, 1, Edge.PARABOLIC),
|
||||
FAST(8, 2, Edge.PARABOLIC),
|
||||
ORGANIC(12, 1, Edge.JITTERED),
|
||||
WAVY(12, 1, Edge.WAVY);
|
||||
|
||||
/** The shape of the bend's outer edge. */
|
||||
public enum Edge {
|
||||
PARABOLIC,
|
||||
/** The radius perturbed per column. */
|
||||
JITTERED,
|
||||
/** The bend rolled by smooth noise. */
|
||||
WAVY
|
||||
}
|
||||
|
||||
private final int defaultRadiusBlocks;
|
||||
private final int columnStepBlocks;
|
||||
private final Edge edge;
|
||||
|
||||
VacuumProfile(int defaultRadiusBlocks, int columnStepBlocks, Edge edge) {
|
||||
this.defaultRadiusBlocks = defaultRadiusBlocks;
|
||||
this.columnStepBlocks = columnStepBlocks;
|
||||
this.edge = edge;
|
||||
}
|
||||
|
||||
/** How far the bend reaches when the vacuum settings leave the radius open. */
|
||||
public int defaultRadiusBlocks() {
|
||||
return defaultRadiusBlocks;
|
||||
}
|
||||
|
||||
/** Every how many columns the bend samples the terrain. */
|
||||
public int columnStepBlocks() {
|
||||
return columnStepBlocks;
|
||||
}
|
||||
|
||||
public Edge edge() {
|
||||
return edge;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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.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("iris/blocks/object-block-replacer")
|
||||
@Desc("Find and replace object materials")
|
||||
public final class ObjectReplace {
|
||||
@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,61 @@
|
||||
/*
|
||||
* 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.BlockState;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* The object's own blocks a placement wrote, in world positions, in the order they were written. Positions and states
|
||||
* are kept side by side, so recording a block allocates nothing beyond the position the placement already has.
|
||||
*/
|
||||
public final class WrittenBlocks {
|
||||
private final List<BlockPosition> positions = new ArrayList<>();
|
||||
private final List<BlockState> states = new ArrayList<>();
|
||||
|
||||
public void add(BlockPosition position, BlockState state) {
|
||||
positions.add(position);
|
||||
states.add(state);
|
||||
}
|
||||
|
||||
public List<BlockPosition> positions() {
|
||||
return Collections.unmodifiableList(positions);
|
||||
}
|
||||
|
||||
/** The written states, each at the index of its position in {@link #positions()}. */
|
||||
public List<BlockState> states() {
|
||||
return Collections.unmodifiableList(states);
|
||||
}
|
||||
|
||||
/** Each written block's position and state, in the order they were written. */
|
||||
public void forEach(BiConsumer<BlockPosition, BlockState> action) {
|
||||
for (int index = 0; index < positions.size(); index++) {
|
||||
action.accept(positions.get(index), states.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return positions.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.builtin.carve;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Defines if an object is allowed to place in carvings, surfaces or both.")
|
||||
public enum CarvingMode {
|
||||
@Desc("Only place this object on surfaces (NOT under carvings)")
|
||||
SURFACE_ONLY,
|
||||
|
||||
@Desc("Only place this object under carvings (NOT on the surface)")
|
||||
CARVING_ONLY,
|
||||
|
||||
@Desc("This object can place anywhere")
|
||||
ANYWHERE;
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean supportsCarving() {
|
||||
return this.equals(ANYWHERE) || this.equals(CARVING_ONLY);
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean supportsSurface() {
|
||||
return this.equals(ANYWHERE) || this.equals(SURFACE_ONLY);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package art.arcane.iris.builtin.carve;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Defines which carved-space anchor to target for cave object placement.")
|
||||
public enum CaveAnchorMode {
|
||||
@Desc("Use the active cave profile default anchor mode.")
|
||||
PROFILE_DEFAULT,
|
||||
|
||||
@Desc("Target cave floor anchors where carved space has solid support below.")
|
||||
FLOOR,
|
||||
|
||||
@Desc("Target cave ceiling anchors where carved space has solid support above.")
|
||||
CEILING,
|
||||
|
||||
@Desc("Target carved positions with no immediate solid support above or below.")
|
||||
CENTER,
|
||||
|
||||
@Desc("Target any carved-space anchor.")
|
||||
ANY
|
||||
}
|
||||
@@ -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.carve;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Range;
|
||||
import com.volmit.noise.NoiseStyle;
|
||||
|
||||
/** One more layer of noise a cave profile blends into its density, an entry of the profile's {@code modules}. */
|
||||
@Desc("Represents a modular cave-density layer.")
|
||||
public final class CaveFieldModule {
|
||||
@Desc("Density style used by this module.")
|
||||
private NoiseStyle style = NoiseStyle.of("CELLULAR_IRIS_DOUBLE");
|
||||
@MinNumber(0)
|
||||
@Desc("Layer contribution multiplier.")
|
||||
private double weight = 1;
|
||||
@MinNumber(-1)
|
||||
@MaxNumber(1)
|
||||
@Desc("Threshold offset applied to this layer before blending.")
|
||||
private double threshold = 0;
|
||||
@Desc("Vertical bounds where this module can contribute, in engine-local Y where 0 is the bottom of the dimension, not world Y.")
|
||||
private Range verticalRange = Range.of(0, 384);
|
||||
@Desc("Invert this module before weighting.")
|
||||
private boolean invert = false;
|
||||
|
||||
public CaveFieldModule() {
|
||||
}
|
||||
|
||||
public NoiseStyle style() {
|
||||
return style;
|
||||
}
|
||||
|
||||
public double weight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public double threshold() {
|
||||
return threshold;
|
||||
}
|
||||
|
||||
public Range verticalRange() {
|
||||
return verticalRange;
|
||||
}
|
||||
|
||||
public boolean invert() {
|
||||
return invert;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.carve;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
|
||||
/** A dimension's {@code caveLavaHeight}, written as the bare number. */
|
||||
@Desc("The subterranean fluid (cave lava) layer height, in engine-local Y where 0 is the bottom of the dimension, not world Y. With the default -64..320 height, 8 means world Y -56.")
|
||||
@Feature(id = "iris:carve/lava-height", name = "Cave lava height", key = "caveLavaHeight", root = "height", targets = Level.DIMENSION)
|
||||
public final class CaveLavaHeightSettings implements IrisFeature {
|
||||
public static final int DEFAULT_HEIGHT = 8;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(318)
|
||||
@Desc("The subterranean fluid (cave lava) layer height, in engine-local Y where 0 is the bottom of the dimension, not world Y. With the default -64..320 height, 8 means world Y -56.")
|
||||
private int height = DEFAULT_HEIGHT;
|
||||
|
||||
public CaveLavaHeightSettings() {
|
||||
}
|
||||
|
||||
public CaveLavaHeightSettings(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int height() {
|
||||
return height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.decorant;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The decorators one biome declares, written as {@code "decorators": [...]}, the list of decorators. IrisApi types only, like
|
||||
* {@link Decorator}.
|
||||
*/
|
||||
@Desc("Decorators are used for things like tall grass, bisected flowers, and even kelp or cactus (random heights)")
|
||||
@Feature(id = "iris:decorant", name = "Decorators", key = "decorators", root = "decorators", targets = Level.BIOME)
|
||||
public final class DecorantSettings implements IrisFeature {
|
||||
@Desc("Decorators are used for things like tall grass, bisected flowers, and even kelp or cactus (random heights)")
|
||||
private List<Decorator> decorators = List.of();
|
||||
|
||||
public DecorantSettings() {
|
||||
}
|
||||
|
||||
public DecorantSettings(List<Decorator> decorators) {
|
||||
this.decorators = List.copyOf(decorators);
|
||||
}
|
||||
|
||||
public List<Decorator> decorators() {
|
||||
return decorators == null ? List.of() : Collections.unmodifiableList(decorators);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.decorant;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Represents a location where decorations should go")
|
||||
public enum DecorationPart {
|
||||
@Desc("The default, decorate anywhere")
|
||||
NONE,
|
||||
|
||||
@Desc("Targets shore lines (typically for sugar cane)")
|
||||
SHORE_LINE,
|
||||
|
||||
@Desc("Target sea surfaces (typically for lilypads)")
|
||||
SEA_SURFACE,
|
||||
|
||||
@Desc("Targets the sea floor (entire placement must be bellow sea level)")
|
||||
SEA_FLOOR,
|
||||
|
||||
@Desc("Decorates on cave & carving ceilings or underside of overhangs")
|
||||
CEILING,
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* 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.decorant;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import com.volmit.block.BlockSpec;
|
||||
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 com.volmit.noise.NoiseStyle;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* One decorator of a biome, as packs write it in the {@code "decorators"} list or under
|
||||
* {@code snippet/iris/decorant/decorator/}: which blocks it places, where, how often and how tall. A value of IrisApi types only; the
|
||||
* decorant module resolves the blocks and builds the noise.
|
||||
*/
|
||||
@Snippet("iris/decorant/decorator")
|
||||
@Desc("A biome decorator is used for placing flowers, grass, cacti and so on")
|
||||
public final class Decorator {
|
||||
private static final String STATIC_NOISE = "STATIC";
|
||||
private static final String DEFAULT_BLOCK = "grass";
|
||||
|
||||
@Desc("The varience dispersion is used when multiple blocks are put in the palette. Scatter scrambles them, Wispy shows streak-looking varience")
|
||||
private NoiseStyle variance = NoiseStyle.of(STATIC_NOISE);
|
||||
|
||||
@Desc("Forcefully place this decorant anywhere it is supposed to go even if it should not go on a specific surface block. For example, you could force tallgrass to place on top of stone by using this.")
|
||||
private boolean forcePlace = false;
|
||||
|
||||
@Desc("Forced the surface block of this decorant to be the specified block. Assumes forcePlace.")
|
||||
private BlockSpec forceBlock;
|
||||
|
||||
@Desc("When set, the decorator can only place onto any of these blocks.")
|
||||
private List<BlockSpec> whitelist;
|
||||
|
||||
@Desc("When set, the decorator will never place onto any of these blocks.")
|
||||
private List<BlockSpec> blacklist;
|
||||
|
||||
@Desc("The slope at which this decorator can be placed. Range from 0 to 10 by default. Calculated from a 3-block radius from the center of the decorator placement.")
|
||||
private SlopeClip slopeCondition = new SlopeClip();
|
||||
|
||||
@Desc("If stackMax is set to true, use this to limit its max height for large caverns")
|
||||
private int absoluteMaxStack = 30;
|
||||
|
||||
@Desc("Dispersion is used to pick places to spawn. Scatter randomly places them (vanilla) or Wispy for a streak like patch system.")
|
||||
private NoiseStyle style = NoiseStyle.of(STATIC_NOISE);
|
||||
|
||||
@Desc("If this decorator has a height more than 1 this changes how it picks the height between your maxes. Scatter = random, Wispy = wavy heights")
|
||||
private NoiseStyle heightVariance = NoiseStyle.of(STATIC_NOISE);
|
||||
|
||||
@Desc("Tells iris where this decoration is a part of. I.e. SHORE_LINE or SEA_SURFACE")
|
||||
private DecorationPart partOf = DecorationPart.NONE;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(2032)
|
||||
@Desc("The minimum repeat stack height (setting to 3 would stack 3 of <block> on top of each other")
|
||||
private int stackMin = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(2032)
|
||||
@Desc("The maximum repeat stack height")
|
||||
private int stackMax = 1;
|
||||
|
||||
@Desc("""
|
||||
Changes stackMin and stackMin from being absolute block heights and instead uses them as a percentage to scale the stack based on the cave height
|
||||
|
||||
Within a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height""")
|
||||
private boolean scaleStack = false;
|
||||
|
||||
@Required
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance for this decorator to decorate at a given X,Y coordinate. This is hit 256 times per chunk (per surface block)")
|
||||
private double chance = 0.1;
|
||||
|
||||
@Required
|
||||
@MinItems(1)
|
||||
@Desc("The palette of blocks to pick from when this decorator needs to place.")
|
||||
private List<BlockSpec> palette = List.of(BlockSpec.of(DEFAULT_BLOCK));
|
||||
|
||||
@Desc("The palette of blocks used at the very top of a 'stackMax' of higher than 1. For example, bamboo tops.")
|
||||
private List<BlockSpec> topPalette = List.of();
|
||||
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(1.0)
|
||||
@Desc("When the stack passes the top threshold, the top palette will start being used instead of the normal palette.")
|
||||
private double topThreshold = 1.0;
|
||||
|
||||
/** A decorator with every option at its default, as packs get it from {@code {}}. */
|
||||
public Decorator() {
|
||||
}
|
||||
|
||||
public NoiseStyle variance() {
|
||||
return variance == null ? NoiseStyle.of(STATIC_NOISE) : variance;
|
||||
}
|
||||
|
||||
public boolean forcePlace() {
|
||||
return forcePlace;
|
||||
}
|
||||
|
||||
public Optional<BlockSpec> forceBlock() {
|
||||
return Optional.ofNullable(forceBlock);
|
||||
}
|
||||
|
||||
/** The blocks it may only be placed onto; empty when unset, which {@link #hasWhitelist()} tells apart from an explicitly empty list that blocks all placement. */
|
||||
public List<BlockSpec> whitelist() {
|
||||
return listOrEmpty(whitelist);
|
||||
}
|
||||
|
||||
public boolean hasWhitelist() {
|
||||
return whitelist != null;
|
||||
}
|
||||
|
||||
public List<BlockSpec> blacklist() {
|
||||
return listOrEmpty(blacklist);
|
||||
}
|
||||
|
||||
public boolean hasBlacklist() {
|
||||
return blacklist != null;
|
||||
}
|
||||
|
||||
public SlopeClip slopeCondition() {
|
||||
return slopeCondition == null ? new SlopeClip() : slopeCondition;
|
||||
}
|
||||
|
||||
public int absoluteMaxStack() {
|
||||
return absoluteMaxStack;
|
||||
}
|
||||
|
||||
public NoiseStyle style() {
|
||||
return style == null ? NoiseStyle.of(STATIC_NOISE) : style;
|
||||
}
|
||||
|
||||
public NoiseStyle heightVariance() {
|
||||
return heightVariance == null ? NoiseStyle.of(STATIC_NOISE) : heightVariance;
|
||||
}
|
||||
|
||||
public DecorationPart partOf() {
|
||||
return partOf == null ? DecorationPart.NONE : partOf;
|
||||
}
|
||||
|
||||
public int stackMin() {
|
||||
return stackMin;
|
||||
}
|
||||
|
||||
public int stackMax() {
|
||||
return stackMax;
|
||||
}
|
||||
|
||||
public boolean scaleStack() {
|
||||
return scaleStack;
|
||||
}
|
||||
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public List<BlockSpec> palette() {
|
||||
return listOrEmpty(palette);
|
||||
}
|
||||
|
||||
public List<BlockSpec> topPalette() {
|
||||
return listOrEmpty(topPalette);
|
||||
}
|
||||
|
||||
public double topThreshold() {
|
||||
return topThreshold;
|
||||
}
|
||||
|
||||
/** Whether it places more than one block per column. */
|
||||
public boolean isStacking() {
|
||||
return stackMax > 1;
|
||||
}
|
||||
|
||||
private static <T> List<T> listOrEmpty(List<T> list) {
|
||||
return list == null ? List.of() : Collections.unmodifiableList(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
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;
|
||||
|
||||
@Snippet("iris/loot/attribute-modifier")
|
||||
@Desc("Represents an attribute modifier for an item or an entity. This allows you to create modifications to basic game attributes such as MAX_HEALTH or ARMOR_VALUE.")
|
||||
public final class ItemAttributeModifier {
|
||||
@Required
|
||||
@Desc("The Attribute type key such as max_health or minecraft:armor. This type is pulled from the game attributes. Zombie & Horse attributes will not work on non-zombie/horse entities.\nUsing an attribute on an item will have affects when held, or worn. There is no way to specify further granularity as the game picks this depending on the item type.")
|
||||
private String attribute = null;
|
||||
|
||||
@Required
|
||||
@Desc("The Attribute Name is used internally only for the game. This value should be unique to all other attributes applied to this item/entity. It is not shown in game.")
|
||||
private String name = "";
|
||||
|
||||
@Desc("The application operation: ADD_NUMBER (default), ADD_SCALAR or MULTIPLY_SCALAR_1. Add Number adds to the default value. \nAdd scalar_1 will multiply by 1 for example if the health is 20 and you multiply_scalar_1 by 0.5, the health will result in 30, not 10. Use negative values to achieve that.")
|
||||
private String operation = "ADD_NUMBER";
|
||||
|
||||
@Desc("Minimum amount for this modifier. Iris randomly chooses an amount, this is the minimum it can choose randomly for this attribute.")
|
||||
private double minAmount = 1;
|
||||
|
||||
@Desc("Maximum amount for this modifier Iris randomly chooses an amount, this is the maximum it can choose randomly for this attribute.")
|
||||
private double maxAmount = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance that this attribute is applied (0 to 1). If the chance is 0.5 (50%), then Iris will only apply this attribute 50% of the time.")
|
||||
private double chance = 1;
|
||||
|
||||
public ItemAttributeModifier() {
|
||||
}
|
||||
|
||||
public String attribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String operation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public double minAmount() {
|
||||
return minAmount;
|
||||
}
|
||||
|
||||
public double maxAmount() {
|
||||
return maxAmount;
|
||||
}
|
||||
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
@Snippet("iris/loot/enchantment")
|
||||
@Desc("Represents an enchantment & level")
|
||||
public final class LootEnchantment {
|
||||
@Required
|
||||
@Ref(Reference.ENCHANTMENT)
|
||||
@Desc("The enchantment")
|
||||
private String enchantment;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum amount of this loot")
|
||||
private int minLevel = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum amount of this loot")
|
||||
private int maxLevel = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance that this enchantment is applied (0 to 1)")
|
||||
private double chance = 1;
|
||||
|
||||
public LootEnchantment() {
|
||||
}
|
||||
|
||||
public String enchantment() {
|
||||
return enchantment;
|
||||
}
|
||||
|
||||
public int minLevel() {
|
||||
return minLevel;
|
||||
}
|
||||
|
||||
public int maxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Snippet("iris/loot/loot")
|
||||
@Desc("Represents a loot entry")
|
||||
public final class LootEntry {
|
||||
public static final int MAX_AMOUNT = 64;
|
||||
|
||||
@Desc("The target inventory slot types to fill this loot with. World generation only ever fills STORAGE; the other values are inert during worldgen.")
|
||||
private LootSlot slotTypes = LootSlot.STORAGE;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The sub rarity of this loot. Calculated after this loot table has been picked.")
|
||||
private int rarity = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(MAX_AMOUNT)
|
||||
@Desc("Minimum amount of this loot, from 1 to 64")
|
||||
private int minAmount = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(MAX_AMOUNT)
|
||||
@Desc("Maximum amount of this loot, from 1 to 64")
|
||||
private int maxAmount = 1;
|
||||
|
||||
@Desc("The display name of this item")
|
||||
private String displayName = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Minimum durability percent")
|
||||
private double minDurability = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Maximum durability percent")
|
||||
private double maxDurability = 1;
|
||||
|
||||
@Desc("Define a custom model identifier 1.14+ only")
|
||||
private Integer customModel = null;
|
||||
|
||||
@Desc("Set this to true to prevent it from being broken")
|
||||
private boolean unbreakable = false;
|
||||
|
||||
@Desc("The item flags to add")
|
||||
private List<String> itemFlags = List.of();
|
||||
|
||||
@Desc("Apply enchantments to this item")
|
||||
private List<LootEnchantment> enchantments = List.of();
|
||||
|
||||
@Desc("Apply attribute modifiers to this item")
|
||||
private List<ItemAttributeModifier> attributes = List.of();
|
||||
|
||||
@Desc("Add lore to this item")
|
||||
private List<String> lore = List.of();
|
||||
|
||||
@Ref(Reference.ITEM)
|
||||
@Required
|
||||
@Desc("This is the item or block type. Does not accept minecraft:*, only materials such as DIAMOND_SWORD or DIRT. The exception are modded materials, as they require a namespace.")
|
||||
private String type = "";
|
||||
|
||||
@Desc("The dye color")
|
||||
private String dyeColor = null;
|
||||
|
||||
@Desc("The leather armor color")
|
||||
private String leatherColor = null;
|
||||
|
||||
@Desc("Defines a custom NBT Tag for the item.")
|
||||
private Map<String, Object> customNbt;
|
||||
|
||||
public LootEntry() {
|
||||
}
|
||||
|
||||
public LootSlot slotTypes() {
|
||||
return slotTypes == null ? LootSlot.STORAGE : slotTypes;
|
||||
}
|
||||
|
||||
public int rarity() {
|
||||
return rarity;
|
||||
}
|
||||
|
||||
public int minAmount() {
|
||||
return minAmount;
|
||||
}
|
||||
|
||||
public int maxAmount() {
|
||||
return maxAmount;
|
||||
}
|
||||
|
||||
public String displayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public double minDurability() {
|
||||
return minDurability;
|
||||
}
|
||||
|
||||
public double maxDurability() {
|
||||
return maxDurability;
|
||||
}
|
||||
|
||||
public Integer customModel() {
|
||||
return customModel;
|
||||
}
|
||||
|
||||
public boolean unbreakable() {
|
||||
return unbreakable;
|
||||
}
|
||||
|
||||
public List<String> itemFlags() {
|
||||
return listOrEmpty(itemFlags);
|
||||
}
|
||||
|
||||
public List<LootEnchantment> enchantments() {
|
||||
return listOrEmpty(enchantments);
|
||||
}
|
||||
|
||||
public List<ItemAttributeModifier> attributes() {
|
||||
return listOrEmpty(attributes);
|
||||
}
|
||||
|
||||
public List<String> lore() {
|
||||
return listOrEmpty(lore);
|
||||
}
|
||||
|
||||
/** The authored item key, exactly as written in the pack. Each platform resolves it against its own item registry. */
|
||||
public String type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String dyeColor() {
|
||||
return dyeColor;
|
||||
}
|
||||
|
||||
public String leatherColor() {
|
||||
return leatherColor;
|
||||
}
|
||||
|
||||
/** The custom data of the item; empty when unset. */
|
||||
public Map<String, Object> customNbt() {
|
||||
return customNbt == null ? Map.of() : Collections.unmodifiableMap(customNbt);
|
||||
}
|
||||
|
||||
private static <T> List<T> listOrEmpty(List<T> list) {
|
||||
return list == null ? List.of() : Collections.unmodifiableList(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("A loot mode is used to describe what to do with the existing loot layers before adding this loot. ADD appends to the building list of tables (dimension tables, then region tables, then biome tables). REPLACE swaps the parent tables for this reference's tables. CLEAR suppresses loot entirely at this point.")
|
||||
public enum LootMode {
|
||||
@Desc("Add to the existing parent loot tables")
|
||||
ADD,
|
||||
@Desc("Clear all parent loot tables and contribute nothing at this level. Any tables listed here are ignored.")
|
||||
CLEAR,
|
||||
@Desc("Replace all parent loot tables with this reference's tables")
|
||||
REPLACE,
|
||||
@Desc("Only use when there was no loot table defined by an object")
|
||||
FALLBACK
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit 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.loot;
|
||||
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.ToIntFunction;
|
||||
|
||||
/**
|
||||
* The random streams loot is drawn from and the picks made on them, shared by the loot module and the hosts that fill
|
||||
* containers, so a container always holds the same loot. Changing a seed, a salt or a draw changes the loot of existing worlds.
|
||||
*/
|
||||
public final class LootResolver {
|
||||
private static final int MAX_SCALED_SOURCE_COUNT = 256;
|
||||
private static final long CONTAINER_SALT = 0x632BE59BD9B4E019L;
|
||||
private static final long TABLE_SALT = 0x94D049BB133111EBL;
|
||||
private static final long ENTRY_SALT = 0x9E3779B97F4A7C15L;
|
||||
|
||||
private LootResolver() {
|
||||
}
|
||||
|
||||
public static RNG containerRng(long lootSeed, int x, int y, int z) {
|
||||
return new RNG(containerSeed(lootSeed, x, y, z));
|
||||
}
|
||||
|
||||
public static long containerSeed(long lootSeed, int x, int y, int z) {
|
||||
long seed = mix(lootSeed ^ CONTAINER_SALT);
|
||||
seed = mix(seed ^ ((long) x * 0xD6E8FEB86659FD93L));
|
||||
seed = mix(seed ^ ((long) y * 0xA5A3564E27F886A7L));
|
||||
return mix(seed ^ ((long) z * 0x8CB92BA72F3D8DD7L));
|
||||
}
|
||||
|
||||
/** The random stream of one loot table at one position; {@code tableIdentity} names the table (its key, else its name). */
|
||||
public static RNG tableRng(long lootSeed, String tableIdentity, int x, int y, int z) {
|
||||
return new RNG(tableSeed(lootSeed, tableIdentity, x, y, z));
|
||||
}
|
||||
|
||||
public static long tableSeed(long lootSeed, String tableIdentity, int x, int y, int z) {
|
||||
return mix(containerSeed(lootSeed, x, y, z) ^ stableHash(tableIdentity) ^ TABLE_SALT);
|
||||
}
|
||||
|
||||
public static boolean spatialOneIn(
|
||||
long lootSeed,
|
||||
String tableIdentity,
|
||||
int entryIndex,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
long rarity
|
||||
) {
|
||||
if (rarity <= 1L) {
|
||||
return true;
|
||||
}
|
||||
long roll = mix(tableSeed(lootSeed, tableIdentity, x, y, z) ^ ((long) entryIndex * ENTRY_SALT));
|
||||
return new RNG(roll).nextLong(rarity) == 0L;
|
||||
}
|
||||
|
||||
public static long combinedRarity(int tableRarity, int entryRarity) {
|
||||
long table = Math.max(1, tableRarity);
|
||||
long entry = Math.max(1, entryRarity);
|
||||
if (table > Long.MAX_VALUE / entry) {
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
return table * entry;
|
||||
}
|
||||
|
||||
public static boolean oneIn(RNG rng, int rarity) {
|
||||
int bound = Math.max(1, rarity);
|
||||
return bound == 1 || rng.nextInt(bound) == 0;
|
||||
}
|
||||
|
||||
public static int inclusive(RNG rng, int first, int second) {
|
||||
int lower = Math.min(first, second);
|
||||
int upper = Math.max(first, second);
|
||||
if (lower == upper) {
|
||||
return lower;
|
||||
}
|
||||
long span = (long) upper - lower + 1L;
|
||||
return (int) (lower + rng.nextLong(span));
|
||||
}
|
||||
|
||||
public static <T> T pickWeighted(List<T> choices, ToIntFunction<T> weight, RNG rng) {
|
||||
long total = 0L;
|
||||
for (T choice : choices) {
|
||||
int value = Math.max(0, weight.applyAsInt(choice));
|
||||
total = Long.MAX_VALUE - total < value ? Long.MAX_VALUE : total + value;
|
||||
}
|
||||
if (total <= 0L) {
|
||||
return null;
|
||||
}
|
||||
long pull = rng.nextLong(total);
|
||||
for (T choice : choices) {
|
||||
pull -= Math.max(0, weight.applyAsInt(choice));
|
||||
if (pull < 0L) {
|
||||
return choice;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> void scaleSources(List<T> sources, double multiplier, RNG rng) {
|
||||
if (!Double.isFinite(multiplier) || multiplier < 0D) {
|
||||
throw new IllegalArgumentException("Effective loot source multiplier must be finite and non-negative, got "
|
||||
+ multiplier + ".");
|
||||
}
|
||||
if (sources.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (sources.size() > MAX_SCALED_SOURCE_COUNT) {
|
||||
throw new IllegalArgumentException("Loot source scaling starts above the maximum of "
|
||||
+ MAX_SCALED_SOURCE_COUNT + " sources: " + sources.size() + ".");
|
||||
}
|
||||
double scaledSize = sources.size() * multiplier;
|
||||
if (!Double.isFinite(scaledSize) || scaledSize > MAX_SCALED_SOURCE_COUNT) {
|
||||
throw new IllegalArgumentException("Loot source scaling exceeds the maximum of "
|
||||
+ MAX_SCALED_SOURCE_COUNT + " sources: " + sources.size() + " * " + multiplier + ".");
|
||||
}
|
||||
int target = (int) Math.round(scaledSize);
|
||||
if (target == sources.size()) {
|
||||
return;
|
||||
}
|
||||
List<T> original = new ArrayList<>(sources);
|
||||
int[] order = new int[original.size()];
|
||||
if (target < original.size()) {
|
||||
shrinkSources(sources, original, order, target, rng);
|
||||
return;
|
||||
}
|
||||
expandSources(sources, original, order, target, rng);
|
||||
}
|
||||
|
||||
private static <T> void shrinkSources(List<T> sources, List<T> original, int[] order, int target, RNG rng) {
|
||||
shuffleOrder(order, rng);
|
||||
boolean[] selected = new boolean[original.size()];
|
||||
for (int index = 0; index < target; index++) {
|
||||
selected[order[index]] = true;
|
||||
}
|
||||
sources.clear();
|
||||
for (int index = 0; index < original.size(); index++) {
|
||||
if (selected[index]) {
|
||||
sources.add(original.get(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> void expandSources(List<T> sources, List<T> original, int[] order, int target, RNG rng) {
|
||||
while (sources.size() < target) {
|
||||
shuffleOrder(order, rng);
|
||||
int additions = Math.min(target - sources.size(), original.size());
|
||||
for (int index = 0; index < additions; index++) {
|
||||
sources.add(original.get(order[index]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void shuffleOrder(int[] order, RNG rng) {
|
||||
for (int index = 0; index < order.length; index++) {
|
||||
order[index] = index;
|
||||
}
|
||||
for (int index = 0; index < order.length - 1; index++) {
|
||||
int selected = index + rng.nextInt(order.length - index);
|
||||
int previous = order[index];
|
||||
order[index] = order[selected];
|
||||
order[selected] = previous;
|
||||
}
|
||||
}
|
||||
|
||||
private static long stableHash(String value) {
|
||||
long hash = 0xCBF29CE484222325L;
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
hash ^= value.charAt(i);
|
||||
hash *= 0x100000001B3L;
|
||||
}
|
||||
return mix(hash);
|
||||
}
|
||||
|
||||
private static long mix(long value) {
|
||||
long mixed = value;
|
||||
mixed = (mixed ^ (mixed >>> 30)) * 0xBF58476D1CE4E5B9L;
|
||||
mixed = (mixed ^ (mixed >>> 27)) * 0x94D049BB133111EBL;
|
||||
return mixed ^ (mixed >>> 31);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.ResourceRef;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The loot tables one dimension, region or biome adds to the containers it covers, written as
|
||||
* {@code "loot": {"mode": "ADD", "tables": [...], "multiplier": 1}}. Levels stack, dimension first, then region and
|
||||
* biome; {@link LootMode} says what each does with the tables before it. An entity's {@code loot} has the same shape.
|
||||
*/
|
||||
@Snippet("iris/loot/loot-registry")
|
||||
@Desc("Reference loot tables in this area")
|
||||
@Feature(id = "iris:loot", name = "Loot", key = "loot", targets = {Level.DIMENSION, Level.REGION, Level.BIOME})
|
||||
public final class LootSettings implements IrisFeature {
|
||||
public static final double MAX_MULTIPLIER = 16D;
|
||||
|
||||
@Desc("ADD = add on top of parent tables. REPLACE = clear parent tables, then add these. CLEAR = clear parent tables and add nothing, even if tables are listed. FALLBACK = only used when nothing else defined a table.")
|
||||
private LootMode mode = LootMode.ADD;
|
||||
|
||||
@ResourceRef(LootTable.class)
|
||||
@Desc("Add loot table registries here")
|
||||
private List<String> tables = List.of();
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(MAX_MULTIPLIER)
|
||||
@Desc("Scale loot sources in this area from 0 to 16 times their normal count")
|
||||
private double multiplier = 1D;
|
||||
|
||||
/** Nothing added, nothing scaled: what a level without loot settings means. */
|
||||
public LootSettings() {
|
||||
}
|
||||
|
||||
public LootMode mode() {
|
||||
return mode == null ? LootMode.ADD : mode;
|
||||
}
|
||||
|
||||
/** The keys of the loot tables, in order. */
|
||||
public List<String> tables() {
|
||||
return tables == null ? List.of() : Collections.unmodifiableList(tables);
|
||||
}
|
||||
|
||||
public double multiplier() {
|
||||
return multiplier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("An inventory slot type is used to represent a type of slot for items to fit into in any given inventory.")
|
||||
public enum LootSlot {
|
||||
@Desc("Typically the one you want to go with. Storage represnents most slots in inventories.")
|
||||
STORAGE,
|
||||
|
||||
@Desc("Used for the fuel slot in Furnaces, Blast furnaces, smokers etc.")
|
||||
FUEL,
|
||||
|
||||
@Desc("Used for the cook slot in furnaces")
|
||||
FURNACE,
|
||||
@Desc("Used for the cook slot in blast furnaces")
|
||||
BLAST_FURNACE,
|
||||
|
||||
@Desc("Used for the cook slot in smokers")
|
||||
SMOKER,
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Required;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** A loot table of the pack, one file of {@code loot/}. */
|
||||
@Desc("Represents a loot table. Biomes, Regions & Objects can add or replace the virtual table with these loot tables")
|
||||
public final class LootTable {
|
||||
public static final int MAX_PICKED = 64;
|
||||
public static final int MAX_TRIES = 256;
|
||||
|
||||
@Required
|
||||
@Desc("The name of this loot table")
|
||||
private String name = "";
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The rarity as in 1 in X chance")
|
||||
private int rarity = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(MAX_PICKED)
|
||||
@Desc("The maximum amount of loot that can be picked in this table at a time, from 1 to 64")
|
||||
private int maxPicked = 5;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(MAX_PICKED)
|
||||
@Desc("The minimum amount of loot that can be picked in this table at a time, from 0 to 64")
|
||||
private int minPicked = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(MAX_TRIES)
|
||||
@Desc("The maximum amount of tries to generate loot, from 1 to 256")
|
||||
private int maxTries = 10;
|
||||
|
||||
@Desc("The loot in this table")
|
||||
private List<LootEntry> loot = List.of();
|
||||
|
||||
public LootTable() {
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name == null ? "" : name;
|
||||
}
|
||||
|
||||
public int rarity() {
|
||||
return rarity;
|
||||
}
|
||||
|
||||
public int maxPicked() {
|
||||
return maxPicked;
|
||||
}
|
||||
|
||||
public int minPicked() {
|
||||
return minPicked;
|
||||
}
|
||||
|
||||
public int maxTries() {
|
||||
return maxTries;
|
||||
}
|
||||
|
||||
public List<LootEntry> loot() {
|
||||
return loot == null ? List.of() : Collections.unmodifiableList(loot);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.loot;
|
||||
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.ResourceRef;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Snippet("iris/loot/object-loot")
|
||||
@Desc("Represents loot within this object")
|
||||
public final class ObjectLoot implements ObjectLootEntry {
|
||||
@Desc("The list of blocks this loot table should apply to")
|
||||
private List<BlockSpec> filter = List.of();
|
||||
@Desc("Exactly match the block data or not")
|
||||
private boolean exact = false;
|
||||
@Desc("The loot table name")
|
||||
@Required
|
||||
@ResourceRef(LootTable.class)
|
||||
private String name;
|
||||
@Desc("The weight of this loot table being chosen")
|
||||
@MinNumber(1)
|
||||
private int weight = 1;
|
||||
|
||||
public ObjectLoot() {
|
||||
}
|
||||
|
||||
/** A table for every container of the placement. */
|
||||
public ObjectLoot(String name, int weight) {
|
||||
this.name = name;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int weight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exact() {
|
||||
return exact;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockSpec> filter() {
|
||||
return filter == null ? List.of() : Collections.unmodifiableList(filter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import com.volmit.block.BlockSpec;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* One loot table an object placement gives its containers: which table, how often it is picked among the placement's
|
||||
* tables, and which of the object's containers it is for.
|
||||
*/
|
||||
public interface ObjectLootEntry {
|
||||
/** The table: a key of the pack's loot tables, or a key of the platform's. */
|
||||
String name();
|
||||
|
||||
/** How often the table is picked among equals; a table with no weight is never picked. */
|
||||
int weight();
|
||||
|
||||
/** Whether the table applies to the exact state of the blocks in {@link #filter}, not to every state of their kind of block. */
|
||||
boolean exact();
|
||||
|
||||
/** The blocks the table is for; none means every container the placement holds. */
|
||||
List<BlockSpec> filter();
|
||||
}
|
||||
@@ -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.loot;
|
||||
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Snippet("iris/loot/object-vanilla-loot")
|
||||
@Desc("Represents vanilla loot within this object")
|
||||
public final class ObjectVanillaLoot implements ObjectLootEntry {
|
||||
@Desc("The list of blocks this loot table should apply to")
|
||||
private List<BlockSpec> filter = List.of();
|
||||
@Desc("Exactly match the block data or not")
|
||||
private boolean exact = false;
|
||||
@Desc("The vanilla loot table key")
|
||||
@Required
|
||||
@Ref(Reference.LOOT_TABLE)
|
||||
private String name;
|
||||
@Desc("The weight of this loot table being chosen")
|
||||
@MinNumber(1)
|
||||
private int weight = 1;
|
||||
|
||||
public ObjectVanillaLoot() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int weight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exact() {
|
||||
return exact;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockSpec> filter() {
|
||||
return filter == null ? List.of() : Collections.unmodifiableList(filter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
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 com.volmit.noise.NoiseStyle;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** The virtual heightmap an object placement may sit on instead of the terrain, written as the placement's {@code heightmap}. */
|
||||
@Snippet("iris/objects/generator")
|
||||
@Desc("A noise generator")
|
||||
public final class HeightmapNoise {
|
||||
@MinNumber(0.0001)
|
||||
@Desc("The coordinate input zoom")
|
||||
private double zoom = 1;
|
||||
@Desc("Reverse the output. So that noise = -noise + opacity")
|
||||
private boolean negative = false;
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The output multiplier")
|
||||
private double opacity = 1;
|
||||
@Desc("Coordinate offset x")
|
||||
private double offsetX = 0;
|
||||
@Desc("Height output offset y. Avoid using with terrain generation.")
|
||||
private double offsetY = 0;
|
||||
@Desc("Coordinate offset z")
|
||||
private double offsetZ = 0;
|
||||
@Required
|
||||
@Desc("The seed")
|
||||
private long seed = 0;
|
||||
@Desc("Apply a parametric curve on the output")
|
||||
private boolean parametric = false;
|
||||
@Desc("Apply a bezier curve on the output")
|
||||
private boolean bezier = false;
|
||||
@Desc("Apply a sin-center curve on the output (0, and 1 = 0 and 0.5 = 1.0 using a sinoid shape.)")
|
||||
private boolean sinCentered = false;
|
||||
@Desc("The exponent noise^EXPONENT")
|
||||
private double exponent = 1;
|
||||
@Desc("Enable / disable. Outputs offsetY if disabled")
|
||||
private boolean enabled = true;
|
||||
@Required
|
||||
@Desc("The Noise Style")
|
||||
private NoiseStyle style = NoiseStyle.of("IRIS");
|
||||
@MinNumber(1)
|
||||
@Desc("Multiple octaves for multple generators of changing zooms added together")
|
||||
private int octaves = 1;
|
||||
@Desc("Apply a child noise generator to fracture the input coordinates of this generator")
|
||||
private List<HeightmapNoise> fracture = List.of();
|
||||
|
||||
public HeightmapNoise() {
|
||||
}
|
||||
|
||||
public double zoom() {
|
||||
return zoom;
|
||||
}
|
||||
|
||||
public boolean negative() {
|
||||
return negative;
|
||||
}
|
||||
|
||||
public double opacity() {
|
||||
return opacity;
|
||||
}
|
||||
|
||||
public double offsetX() {
|
||||
return offsetX;
|
||||
}
|
||||
|
||||
public double offsetY() {
|
||||
return offsetY;
|
||||
}
|
||||
|
||||
public double offsetZ() {
|
||||
return offsetZ;
|
||||
}
|
||||
|
||||
public long seed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
public boolean parametric() {
|
||||
return parametric;
|
||||
}
|
||||
|
||||
public boolean bezier() {
|
||||
return bezier;
|
||||
}
|
||||
|
||||
public boolean sinCentered() {
|
||||
return sinCentered;
|
||||
}
|
||||
|
||||
public double exponent() {
|
||||
return exponent;
|
||||
}
|
||||
|
||||
public boolean enabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public NoiseStyle style() {
|
||||
return style;
|
||||
}
|
||||
|
||||
public int octaves() {
|
||||
return octaves;
|
||||
}
|
||||
|
||||
public List<HeightmapNoise> fracture() {
|
||||
return fracture == null ? List.of() : Collections.unmodifiableList(fracture);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,717 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.carve.CaveAnchorMode;
|
||||
import art.arcane.iris.builtin.loot.ObjectLoot;
|
||||
import art.arcane.iris.builtin.loot.ObjectVanillaLoot;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.spawn.PlacementMarker;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.ResourceRef;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.noise.NoiseStyle;
|
||||
import com.volmit.noise.StyledRange;
|
||||
import com.volmit.object.GeneratedObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* One object placement of a biome or region, an entry of its {@code objects}: which objects, how often, and how they sit
|
||||
* in the world. {@code iris:objects} decides from the options it owns (what to place, chance, density, carving and
|
||||
* surface support); Iris's placement stages read the rest from the placement itself, so this keeps the JSON the placement
|
||||
* was written as ({@link #json()}) for Iris to read it again the way it reads placements everywhere else.
|
||||
*/
|
||||
@Snippet("iris/objects/object-placer")
|
||||
@Desc("Represents an iris object placer. It places objects.")
|
||||
@JsonAdapter(ObjectPlacement.KeepingItsJson.class)
|
||||
public final class ObjectPlacement {
|
||||
private static final int DEFAULT_SURFACE_SUPPORT_BUFFER = 2;
|
||||
private static final int DEFAULT_SURFACE_SUPPORT_DEPTH = 2;
|
||||
|
||||
@Required
|
||||
@ResourceRef(GeneratedObject.class)
|
||||
@Desc("List of objects to place")
|
||||
private List<String> place = List.of();
|
||||
@Desc("Rotate this objects placement")
|
||||
private ObjectRotation rotation = new ObjectRotation();
|
||||
@Desc("Limit the max height or min height of placement.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The maximum layer level of a snow filter overtop of this placement. Set to 0 to disable. Max of 1.")
|
||||
private double snow = 0;
|
||||
@Desc("Whether or not this object can be targeted by a dolphin.")
|
||||
private boolean isDolphinTarget = false;
|
||||
@Desc("The slope at which this object can be placed. Range from 0 to 10 by default. Calculated from a 3-block radius from the center of the object placement.")
|
||||
private SlopeClip slopeCondition = new SlopeClip();
|
||||
@Desc("Set to true to add the rotation of the direction of the slope of the terrain (wherever the slope is going down) to the y-axis rotation of the object." +
|
||||
"Rounded to 90 degrees. Adds the *min* rotation of the y axis as well (to still allow you to rotate objects nicely). Discards *max* and *interval* on *yaxis*")
|
||||
private boolean rotateTowardsSlope = false;
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance for this to place in a chunk. If you need multiple per chunk, set this to 1 and use density.")
|
||||
private double chance = 1;
|
||||
@Desc("If set, chance is multiplied by this noise (0 to 1) at the chunk, so objects gather in some areas and thin out in others.")
|
||||
private NoiseStyle chanceStyle = null;
|
||||
@MinNumber(0)
|
||||
@Desc("Keeps objects of this placement at least this many blocks apart, also across chunks and biomes that place the same objects. Each chunk then places at most one. 0 turns it off. Surface placements only.")
|
||||
private int separation = 0;
|
||||
@MinNumber(1)
|
||||
@Desc("If the chance check passes, place this many in a single chunk. Ignored when separation is set.")
|
||||
private int density = 1;
|
||||
@Desc("If the chance check passes, and you specify this, it picks a number in the range based on noise, and 'density' is ignored.")
|
||||
private StyledRange densityStyle = null;
|
||||
@Desc("When stilting is enabled, this object will define various properties related to it.")
|
||||
private StiltSettings stiltSettings;
|
||||
@Desc("When a VACUUM place mode is used, this defines the deformation radius and falloff.")
|
||||
private VacuumSettings vacuumSettings;
|
||||
@MaxNumber(64)
|
||||
@MinNumber(0)
|
||||
@Desc("When bore is enabled, expand max-y of the cuboid it removes")
|
||||
private int boreExtendMaxY = 0;
|
||||
@Desc("Add markers to blocks in this object")
|
||||
private List<PlacementMarker> markers = List.of();
|
||||
@MaxNumber(64)
|
||||
@MinNumber(-1)
|
||||
@Desc("When bore is enabled, lower min-y of the cuboid it removes")
|
||||
private int boreExtendMinY = 0;
|
||||
@Desc("If set to true, objects will place on the terrain height, ignoring the water surface.")
|
||||
private boolean underwater = false;
|
||||
@Desc("If set to true, objects will place in carvings (such as underground) or under an overhang.")
|
||||
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@Desc("Extra buffer, in blocks, around this object's base footprint that must also be solid, un-carved ground. 0 checks only the footprint itself.")
|
||||
private int surfaceSupportBuffer = DEFAULT_SURFACE_SUPPORT_BUFFER;
|
||||
@MinNumber(1)
|
||||
@MaxNumber(16)
|
||||
@Desc("Minimum thickness, in blocks, of un-carved ground required under every column of this object's base footprint.")
|
||||
private int surfaceSupportDepth = DEFAULT_SURFACE_SUPPORT_DEPTH;
|
||||
@Desc("Set to false to let this placement sit over carved surface openings such as cave entrances.")
|
||||
private boolean requireSurfaceSupport = true;
|
||||
@Desc("When carving placement is enabled, select which carved-space anchor this placement targets.")
|
||||
private CaveAnchorMode caveAnchorMode = CaveAnchorMode.PROFILE_DEFAULT;
|
||||
@Desc("If this is defined, this object wont place on the terrain heightmap, but instead on this virtual heightmap")
|
||||
private HeightmapNoise heightmap;
|
||||
@Desc("If set to true, Iris will try to fill the insides of 'rooms' and 'pockets' where air should fit based off of raytrace checks. This prevents a village house placing in an area where a tree already exists, and instead replaces the parts of the tree where the interior of the structure is. \n\nThis operation does not affect warmed-up generation speed however it does slow down loading objects.")
|
||||
private boolean smartBore = false;
|
||||
@Desc("If set to true, Blocks placed underwater that could be waterlogged are waterlogged.")
|
||||
private boolean waterloggable = false;
|
||||
@Desc("If set to true, objects will place on the fluid height level Such as boats.")
|
||||
private boolean onwater = false;
|
||||
@Desc("If set to true, this object will only place parts of itself where blocks already exist. Warning: Melding is very performance intensive!")
|
||||
private boolean meld = false;
|
||||
@Desc("If set to true, this object will get placed from the bottom of the world up")
|
||||
private boolean fromBottom;
|
||||
@Desc("If set to true, this object will place from the ground up instead of height checks when not y locked to the surface. This is not compatable with X and Z axis rotations (it may look off)")
|
||||
private boolean bottom = false;
|
||||
@Desc("If set to true, air will be placed before the schematic places.")
|
||||
private boolean bore = false;
|
||||
@Desc("Use a generator to warp the field of coordinates. Using simplex for example would make a square placement warp like a flag")
|
||||
private NoiseStyle warp = NoiseStyle.of(NoiseStyle.FLAT);
|
||||
@Desc("The placement mode")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
@Desc("Find and replace blocks")
|
||||
private List<ObjectReplace> edit = List.of();
|
||||
@Desc("Translate this object's placement")
|
||||
private ObjectTranslate translate = new ObjectTranslate();
|
||||
@Desc("Scale Objects")
|
||||
private ObjectScale scale = new ObjectScale();
|
||||
@Desc("The loot tables to apply to these objects")
|
||||
private List<ObjectLoot> loot = List.of();
|
||||
@Desc("The vanilla loot tables to apply to these objects")
|
||||
private List<ObjectVanillaLoot> vanillaLoot = List.of();
|
||||
@Desc("Whether the given loot tables override any and all other loot tables available in the dimension, region or biome.")
|
||||
private boolean overrideGlobalLoot = false;
|
||||
@Desc("This object / these objects override the following trees when they grow...")
|
||||
private List<TreeOverride> trees = List.of();
|
||||
@ResourceRef(GeneratedObject.class)
|
||||
@Desc("List of objects to this object is allowed to collied with")
|
||||
private List<String> allowedCollisions = List.of();
|
||||
@ResourceRef(GeneratedObject.class)
|
||||
@Desc("List of objects to this object is forbidden to collied with")
|
||||
private List<String> forbiddenCollisions = List.of();
|
||||
@Desc("Ignore any placement restrictions for this object")
|
||||
@SerializedName(value = "forcePlace", alternate = {"force"})
|
||||
private boolean forcePlace = false;
|
||||
|
||||
private transient volatile String json;
|
||||
|
||||
public ObjectPlacement() {
|
||||
}
|
||||
|
||||
private ObjectPlacement(ObjectPlacement source) {
|
||||
place = source.place;
|
||||
rotation = source.rotation;
|
||||
clamp = source.clamp;
|
||||
snow = source.snow;
|
||||
isDolphinTarget = source.isDolphinTarget;
|
||||
slopeCondition = source.slopeCondition;
|
||||
rotateTowardsSlope = source.rotateTowardsSlope;
|
||||
chance = source.chance;
|
||||
chanceStyle = source.chanceStyle;
|
||||
separation = source.separation;
|
||||
density = source.density;
|
||||
densityStyle = source.densityStyle;
|
||||
stiltSettings = source.stiltSettings;
|
||||
vacuumSettings = source.vacuumSettings;
|
||||
boreExtendMaxY = source.boreExtendMaxY;
|
||||
markers = source.markers;
|
||||
boreExtendMinY = source.boreExtendMinY;
|
||||
underwater = source.underwater;
|
||||
carvingSupport = source.carvingSupport;
|
||||
surfaceSupportBuffer = source.surfaceSupportBuffer;
|
||||
surfaceSupportDepth = source.surfaceSupportDepth;
|
||||
requireSurfaceSupport = source.requireSurfaceSupport;
|
||||
caveAnchorMode = source.caveAnchorMode;
|
||||
heightmap = source.heightmap;
|
||||
smartBore = source.smartBore;
|
||||
waterloggable = source.waterloggable;
|
||||
onwater = source.onwater;
|
||||
meld = source.meld;
|
||||
fromBottom = source.fromBottom;
|
||||
bottom = source.bottom;
|
||||
bore = source.bore;
|
||||
warp = source.warp;
|
||||
mode = source.mode;
|
||||
edit = source.edit;
|
||||
translate = source.translate;
|
||||
scale = source.scale;
|
||||
loot = source.loot;
|
||||
vanillaLoot = source.vanillaLoot;
|
||||
overrideGlobalLoot = source.overrideGlobalLoot;
|
||||
trees = source.trees;
|
||||
allowedCollisions = source.allowedCollisions;
|
||||
forbiddenCollisions = source.forbiddenCollisions;
|
||||
forcePlace = source.forcePlace;
|
||||
json = source.json;
|
||||
}
|
||||
|
||||
/** A builder of a placement made in code, starting from the defaults a pack's placement starts from. */
|
||||
public static Builder builder() {
|
||||
return new Builder(new ObjectPlacement());
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder of a copy of this placement with some options changed. The copy keeps the JSON this placement was
|
||||
* read from, so the module settings it declares, and what Iris made of it, unless a noise option changes.
|
||||
*/
|
||||
public Builder toBuilder() {
|
||||
return new Builder(new ObjectPlacement(this));
|
||||
}
|
||||
|
||||
/** The objects to pick from, by the keys of the pack's objects. */
|
||||
public List<String> place() {
|
||||
return listOf(place);
|
||||
}
|
||||
|
||||
public ObjectRotation rotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public ObjectLimit clamp() {
|
||||
return clamp;
|
||||
}
|
||||
|
||||
public double snow() {
|
||||
return snow;
|
||||
}
|
||||
|
||||
public boolean isDolphinTarget() {
|
||||
return isDolphinTarget;
|
||||
}
|
||||
|
||||
public SlopeClip slopeCondition() {
|
||||
return slopeCondition;
|
||||
}
|
||||
|
||||
public boolean rotateTowardsSlope() {
|
||||
return rotateTowardsSlope;
|
||||
}
|
||||
|
||||
public double chance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
/** The noise, from 0 to 1, that {@link #chance()} is multiplied by at each chunk; empty when the chance is the same everywhere. */
|
||||
public Optional<NoiseStyle> chanceStyle() {
|
||||
return Optional.ofNullable(chanceStyle);
|
||||
}
|
||||
|
||||
/** The least distance in blocks between two objects of placements with the same objects; 0 when they are not kept apart. */
|
||||
public int separation() {
|
||||
return separation;
|
||||
}
|
||||
|
||||
public boolean isSeparated() {
|
||||
return separation > 0;
|
||||
}
|
||||
|
||||
/** The count of placements when the chance check passes, unless {@link #densityStyle()} picks it. */
|
||||
public int density() {
|
||||
return density;
|
||||
}
|
||||
|
||||
public Optional<StyledRange> densityStyle() {
|
||||
return Optional.ofNullable(densityStyle);
|
||||
}
|
||||
|
||||
/** The fixed density, or, when a style picks the count, the middle of its range. */
|
||||
public int middleDensity() {
|
||||
if (densityStyle == null) {
|
||||
return density;
|
||||
}
|
||||
return (int) ((densityStyle.max() + densityStyle.min()) / 2);
|
||||
}
|
||||
|
||||
public Optional<StiltSettings> stiltSettings() {
|
||||
return Optional.ofNullable(stiltSettings);
|
||||
}
|
||||
|
||||
public Optional<VacuumSettings> vacuumSettings() {
|
||||
return Optional.ofNullable(vacuumSettings);
|
||||
}
|
||||
|
||||
public int boreExtendMaxY() {
|
||||
return boreExtendMaxY;
|
||||
}
|
||||
|
||||
public List<PlacementMarker> markers() {
|
||||
return listOf(markers);
|
||||
}
|
||||
|
||||
public int boreExtendMinY() {
|
||||
return boreExtendMinY;
|
||||
}
|
||||
|
||||
public boolean underwater() {
|
||||
return underwater;
|
||||
}
|
||||
|
||||
public CarvingMode carvingSupport() {
|
||||
return carvingSupport;
|
||||
}
|
||||
|
||||
public int surfaceSupportBuffer() {
|
||||
return surfaceSupportBuffer;
|
||||
}
|
||||
|
||||
public int surfaceSupportDepth() {
|
||||
return surfaceSupportDepth;
|
||||
}
|
||||
|
||||
public boolean requireSurfaceSupport() {
|
||||
return requireSurfaceSupport;
|
||||
}
|
||||
|
||||
public CaveAnchorMode caveAnchorMode() {
|
||||
return caveAnchorMode;
|
||||
}
|
||||
|
||||
/** The virtual heightmap the objects place on instead of the terrain, if one is set. */
|
||||
public Optional<HeightmapNoise> heightmap() {
|
||||
return Optional.ofNullable(heightmap);
|
||||
}
|
||||
|
||||
public boolean smartBore() {
|
||||
return smartBore;
|
||||
}
|
||||
|
||||
public boolean waterloggable() {
|
||||
return waterloggable;
|
||||
}
|
||||
|
||||
public boolean onwater() {
|
||||
return onwater;
|
||||
}
|
||||
|
||||
public boolean meld() {
|
||||
return meld;
|
||||
}
|
||||
|
||||
public boolean fromBottom() {
|
||||
return fromBottom;
|
||||
}
|
||||
|
||||
public boolean bottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
public boolean bore() {
|
||||
return bore;
|
||||
}
|
||||
|
||||
public NoiseStyle warp() {
|
||||
return warp;
|
||||
}
|
||||
|
||||
public ObjectPlaceMode mode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public List<ObjectReplace> edit() {
|
||||
return listOf(edit);
|
||||
}
|
||||
|
||||
public ObjectTranslate translate() {
|
||||
return translate;
|
||||
}
|
||||
|
||||
public ObjectScale scale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public List<ObjectLoot> loot() {
|
||||
return listOf(loot);
|
||||
}
|
||||
|
||||
public List<ObjectVanillaLoot> vanillaLoot() {
|
||||
return listOf(vanillaLoot);
|
||||
}
|
||||
|
||||
public boolean overrideGlobalLoot() {
|
||||
return overrideGlobalLoot;
|
||||
}
|
||||
|
||||
public List<TreeOverride> trees() {
|
||||
return listOf(trees);
|
||||
}
|
||||
|
||||
/** Whether one of the trees this placement overrides is the species {@code species} grown on a sapling area of {@code width} by {@code depth}. */
|
||||
public boolean overridesTree(int width, int depth, String species) {
|
||||
return trees().stream().anyMatch(tree -> tree.matches(width, depth, species));
|
||||
}
|
||||
|
||||
public List<String> allowedCollisions() {
|
||||
return listOf(allowedCollisions);
|
||||
}
|
||||
|
||||
public List<String> forbiddenCollisions() {
|
||||
return listOf(forbiddenCollisions);
|
||||
}
|
||||
|
||||
public boolean forcePlace() {
|
||||
return forcePlace;
|
||||
}
|
||||
|
||||
/** The JSON this placement was read from, which declares its module settings; null for one made in code. */
|
||||
public String json() {
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* The names a placement's own options are written under: every field Gson reads, under its {@code @SerializedName} and
|
||||
* alternates. Settings other modules declare on a placement may not take these keys
|
||||
* ({@link com.volmit.FeatureRegistry#registerPlacementType}).
|
||||
*/
|
||||
public static Set<String> jsonFields() {
|
||||
Set<String> names = new TreeSet<>();
|
||||
for (Field field : ObjectPlacement.class.getDeclaredFields()) {
|
||||
int modifiers = field.getModifiers();
|
||||
if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers) || field.isSynthetic()) {
|
||||
continue;
|
||||
}
|
||||
SerializedName serialized = field.getAnnotation(SerializedName.class);
|
||||
if (serialized == null) {
|
||||
names.add(field.getName());
|
||||
continue;
|
||||
}
|
||||
names.add(serialized.value());
|
||||
names.addAll(Arrays.asList(serialized.alternate()));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
private static <T> List<T> listOf(List<T> values) {
|
||||
return values == null ? List.of() : Collections.unmodifiableList(values);
|
||||
}
|
||||
|
||||
/** Sets the options of a placement made in code; each setter returns the builder. */
|
||||
public static final class Builder {
|
||||
private final ObjectPlacement placement;
|
||||
|
||||
private Builder(ObjectPlacement placement) {
|
||||
this.placement = placement;
|
||||
}
|
||||
|
||||
public Builder place(List<String> keys) {
|
||||
placement.place = List.copyOf(keys);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder rotation(ObjectRotation rotation) {
|
||||
placement.rotation = rotation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder clamp(ObjectLimit clamp) {
|
||||
placement.clamp = clamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder snow(double snow) {
|
||||
placement.snow = snow;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder slopeCondition(SlopeClip slopeCondition) {
|
||||
placement.slopeCondition = slopeCondition;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder rotateTowardsSlope(boolean rotateTowardsSlope) {
|
||||
placement.rotateTowardsSlope = rotateTowardsSlope;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder chance(double chance) {
|
||||
placement.chance = chance;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder density(int density) {
|
||||
placement.density = density;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder densityStyle(StyledRange densityStyle) {
|
||||
placement.densityStyle = densityStyle;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder stiltSettings(StiltSettings stiltSettings) {
|
||||
placement.stiltSettings = stiltSettings;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder vacuumSettings(VacuumSettings vacuumSettings) {
|
||||
placement.vacuumSettings = vacuumSettings;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder boreExtendMaxY(int blocks) {
|
||||
placement.boreExtendMaxY = blocks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder markers(List<PlacementMarker> markers) {
|
||||
placement.markers = List.copyOf(markers);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder boreExtendMinY(int blocks) {
|
||||
placement.boreExtendMinY = blocks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder underwater(boolean underwater) {
|
||||
placement.underwater = underwater;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder carvingSupport(CarvingMode carvingSupport) {
|
||||
placement.carvingSupport = carvingSupport;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder surfaceSupportBuffer(int blocks) {
|
||||
placement.surfaceSupportBuffer = blocks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder surfaceSupportDepth(int blocks) {
|
||||
placement.surfaceSupportDepth = blocks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder requireSurfaceSupport(boolean require) {
|
||||
placement.requireSurfaceSupport = require;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder caveAnchorMode(CaveAnchorMode caveAnchorMode) {
|
||||
placement.caveAnchorMode = caveAnchorMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder heightmap(HeightmapNoise heightmap) {
|
||||
placement.heightmap = heightmap;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder smartBore(boolean smartBore) {
|
||||
placement.smartBore = smartBore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder waterloggable(boolean waterloggable) {
|
||||
placement.waterloggable = waterloggable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder onwater(boolean onwater) {
|
||||
placement.onwater = onwater;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder meld(boolean meld) {
|
||||
placement.meld = meld;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder fromBottom(boolean fromBottom) {
|
||||
placement.fromBottom = fromBottom;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder bottom(boolean bottom) {
|
||||
placement.bottom = bottom;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder bore(boolean bore) {
|
||||
placement.bore = bore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder warp(NoiseStyle warp) {
|
||||
placement.warp = warp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder mode(ObjectPlaceMode mode) {
|
||||
placement.mode = mode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder edit(List<ObjectReplace> edit) {
|
||||
placement.edit = List.copyOf(edit);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder translate(ObjectTranslate translate) {
|
||||
placement.translate = translate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder scale(ObjectScale scale) {
|
||||
placement.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder loot(List<ObjectLoot> loot) {
|
||||
placement.loot = List.copyOf(loot);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder vanillaLoot(List<ObjectVanillaLoot> vanillaLoot) {
|
||||
placement.vanillaLoot = List.copyOf(vanillaLoot);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder overrideGlobalLoot(boolean override) {
|
||||
placement.overrideGlobalLoot = override;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder trees(List<TreeOverride> trees) {
|
||||
placement.trees = List.copyOf(trees);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder allowedCollisions(List<String> keys) {
|
||||
placement.allowedCollisions = List.copyOf(keys);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder forbiddenCollisions(List<String> keys) {
|
||||
placement.forbiddenCollisions = List.copyOf(keys);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder forcePlace(boolean forcePlace) {
|
||||
placement.forcePlace = forcePlace;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** The placement; the builder must not be used after. */
|
||||
/** The placement as set so far; later changes to the builder do not reach it. */
|
||||
public ObjectPlacement build() {
|
||||
return new ObjectPlacement(placement);
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads a placement like any settings and keeps the JSON it was read from. */
|
||||
public static final class KeepingItsJson implements TypeAdapterFactory {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked") // The type is checked to be ObjectPlacement.
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (type.getRawType() != ObjectPlacement.class) {
|
||||
return null;
|
||||
}
|
||||
TypeAdapter<ObjectPlacement> placements = gson.getDelegateAdapter(this, TypeToken.get(ObjectPlacement.class));
|
||||
TypeAdapter<JsonElement> elements = gson.getAdapter(JsonElement.class);
|
||||
return (TypeAdapter<T>) new TypeAdapter<ObjectPlacement>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, ObjectPlacement placement) throws IOException {
|
||||
placements.write(out, placement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPlacement read(JsonReader in) throws IOException {
|
||||
JsonElement written = elements.read(in);
|
||||
ObjectPlacement placement = placements.fromJsonTree(written);
|
||||
if (placement != null) {
|
||||
placement.json = written.toString();
|
||||
}
|
||||
return placement;
|
||||
}
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.noise.NoiseStyle;
|
||||
import com.volmit.object.PackObjects;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.placement.PlacementOutcome;
|
||||
import com.volmit.placement.PlacementRequest;
|
||||
import com.volmit.placement.PlacementRun;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
/**
|
||||
* One object placed through the pack's placement stages with an object placement's settings: the input Iris's built-in
|
||||
* placement stages read ({@link PlacementRun#input}), and what they report back, the height the object was anchored at
|
||||
* and which of the written blocks are the object's own. Made for one placement; not thread-safe.
|
||||
*/
|
||||
public final class ObjectRun {
|
||||
private static final int NOT_ANCHORED = Integer.MIN_VALUE;
|
||||
private static final int NEIGHBOR_READ_BLOCKS = 1;
|
||||
private static final long X_MULTIPLIER = 0x9E3779B97F4A7C15L;
|
||||
private static final long Z_MULTIPLIER = 0xC2B2AE3D27D4EB4FL;
|
||||
private static final long Y_MULTIPLIER = 0x165667B19E3779F9L;
|
||||
private static final long FNV_OFFSET_BASIS = 0xCBF29CE484222325L;
|
||||
private static final long FNV_PRIME = 0x100000001B3L;
|
||||
|
||||
private PlaceableObject object;
|
||||
private final ObjectPlacement settings;
|
||||
private final int x;
|
||||
private final int requestedY;
|
||||
private final int z;
|
||||
private final Cave cave;
|
||||
private final List<BlockPosition> objectBlocks = new ArrayList<>();
|
||||
private int anchorY = NOT_ANCHORED;
|
||||
|
||||
private ObjectRun(PlaceableObject object, ObjectPlacement settings, int x, int requestedY, int z, Cave cave) {
|
||||
this.object = Objects.requireNonNull(object, "object");
|
||||
this.settings = Objects.requireNonNull(settings, "settings");
|
||||
this.x = x;
|
||||
this.requestedY = requestedY;
|
||||
this.z = z;
|
||||
this.cave = cave;
|
||||
}
|
||||
|
||||
/** @param requestedY the height to place at, or a negative value for the stages to sample it */
|
||||
public static ObjectRun of(PlaceableObject object, ObjectPlacement settings, int x, int requestedY, int z) {
|
||||
return new ObjectRun(object, settings, x, requestedY, z, null);
|
||||
}
|
||||
|
||||
/** A placement inside {@code cave}, which the stages anchor in and keep the object's height within. */
|
||||
public static ObjectRun inCave(PlaceableObject object, ObjectPlacement settings, int x, int requestedY, int z, Cave cave) {
|
||||
return new ObjectRun(object, settings, x, requestedY, z, Objects.requireNonNull(cave, "cave"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The cave an object is placed in.
|
||||
*
|
||||
* @param surface the height of its floor
|
||||
* @param height how many blocks high it is
|
||||
*/
|
||||
public record Cave(int surface, int height) {
|
||||
}
|
||||
|
||||
/** Places the object into {@code terrain} through the pack's placement stages of {@code world} ({@link #toRun}). */
|
||||
public PlacementOutcome placeIn(PackWorld world, PlacementTerrain terrain) {
|
||||
return world.placements().place(toRun(terrain, world));
|
||||
}
|
||||
|
||||
/**
|
||||
* The run of this placement in {@code terrain}. Its seed comes from the world's seed and the placement's identity, the
|
||||
* object's name and requested position, so the same placement draws the same in every run. Its area is every column
|
||||
* the object reaches in any rotation around its anchor, moved by its translation and surface warp, and one block more
|
||||
* for neighbor reads. A placement that smart bores bores its object first, so the stages see the bored air.
|
||||
*/
|
||||
public PlacementRun toRun(PlacementTerrain terrain, PackWorld world) {
|
||||
return toRun(terrain, world.seed(), world.resources().objects());
|
||||
}
|
||||
|
||||
/** As {@link #toRun(PlacementTerrain, PackWorld)}, for a world of seed {@code worldSeed} whose pack's objects are {@code objects}. */
|
||||
public PlacementRun toRun(PlacementTerrain terrain, long worldSeed, PackObjects objects) {
|
||||
if (settings.smartBore()) {
|
||||
object = objects.smartBored(object);
|
||||
}
|
||||
PlacementRequest request = new PlacementRequest(object.geometry(), new BlockPosition(x, requestedY, z));
|
||||
return new PlacementRun(request, object.name(), Optional.ofNullable(settings.json()), area(), terrain, this,
|
||||
placementSeed(worldSeed));
|
||||
}
|
||||
|
||||
public PlaceableObject object() {
|
||||
return object;
|
||||
}
|
||||
|
||||
/** The settings as the caller passed them; the stages derive what they change, such as the rotation, themselves. */
|
||||
public ObjectPlacement settings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/** The height the caller asked for, negative when the stages sample it. */
|
||||
public int requestedY() {
|
||||
return requestedY;
|
||||
}
|
||||
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
/** The cave the object is placed in; empty outside caves. */
|
||||
public Optional<Cave> cave() {
|
||||
return Optional.ofNullable(cave);
|
||||
}
|
||||
|
||||
/** Reports the height the object was anchored at. */
|
||||
public void anchoredAt(int y) {
|
||||
anchorY = y;
|
||||
}
|
||||
|
||||
/** The height the object was anchored at; empty until a stage anchors it. */
|
||||
public OptionalInt anchorY() {
|
||||
return anchorY == NOT_ANCHORED ? OptionalInt.empty() : OptionalInt.of(anchorY);
|
||||
}
|
||||
|
||||
/** Reports a written block as one of the object's own, as opposed to boring, stilts, snow or a terrain bend. */
|
||||
public void objectBlockWritten(BlockPosition position) {
|
||||
objectBlocks.add(position);
|
||||
}
|
||||
|
||||
/** The object's own blocks the stages wrote, in the order they wrote them; they reach the world only if it is placed. */
|
||||
public List<BlockPosition> objectBlocks() {
|
||||
return Collections.unmodifiableList(objectBlocks);
|
||||
}
|
||||
|
||||
private BlockBox area() {
|
||||
int objectRadius = Math.max(rotationRadius(object.geometry().bounds()), rotationRadius(declaredBox()));
|
||||
int reach = objectRadius + translationLength(settings.translate()) + warpMargin(settings.warp()) + NEIGHBOR_READ_BLOCKS;
|
||||
return new BlockBox(x - reach, Integer.MIN_VALUE, z - reach, x + reach + 1, Integer.MAX_VALUE, z + reach + 1);
|
||||
}
|
||||
|
||||
/** The object's declared size around its center, which its block offsets count from. */
|
||||
private BlockBox declaredBox() {
|
||||
BlockPosition center = object.center();
|
||||
return new BlockBox(-center.x(), -center.y(), -center.z(), Math.max(1, object.width()) - center.x(),
|
||||
Math.max(1, object.height()) - center.y(), Math.max(1, object.depth()) - center.z());
|
||||
}
|
||||
|
||||
/** The farthest any block of {@code bounds} lies from the origin, which rotations turn around. */
|
||||
private static int rotationRadius(BlockBox bounds) {
|
||||
long farthestX = farthest(bounds.minX(), bounds.maxX());
|
||||
long farthestY = farthest(bounds.minY(), bounds.maxY());
|
||||
long farthestZ = farthest(bounds.minZ(), bounds.maxZ());
|
||||
return (int) Math.ceil(Math.sqrt(farthestX * farthestX + farthestY * farthestY + farthestZ * farthestZ));
|
||||
}
|
||||
|
||||
private static long farthest(int min, int maxExclusive) {
|
||||
return Math.max(Math.abs((long) min), Math.abs((long) maxExclusive - 1));
|
||||
}
|
||||
|
||||
private static int translationLength(ObjectTranslate translate) {
|
||||
long translateX = translate.x();
|
||||
long translateY = translate.y();
|
||||
long translateZ = translate.z();
|
||||
return (int) Math.ceil(Math.sqrt(translateX * translateX + translateY * translateY + translateZ * translateZ));
|
||||
}
|
||||
|
||||
private static int warpMargin(NoiseStyle warp) {
|
||||
return warps(warp) ? (int) Math.ceil(Math.abs(warp.multiplier()) / 2D) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether {@code warp} moves the placement's columns: any base style but {@link NoiseStyle#FLAT}. Unlike
|
||||
* {@link NoiseStyle#isFlat()}, a flat style with an expression still does not warp, as Iris always read it.
|
||||
*/
|
||||
public static boolean warps(NoiseStyle warp) {
|
||||
return !NoiseStyle.FLAT.equals(warp.style());
|
||||
}
|
||||
|
||||
private long placementSeed(long worldSeed) {
|
||||
return worldSeed ^ fnv1a(object.name()) ^ (x * X_MULTIPLIER) ^ (requestedY * Y_MULTIPLIER) ^ (z * Z_MULTIPLIER);
|
||||
}
|
||||
|
||||
private static long fnv1a(String text) {
|
||||
long hash = FNV_OFFSET_BASIS;
|
||||
for (byte value : text.getBytes(StandardCharsets.UTF_8)) {
|
||||
hash = (hash ^ (value & 0xFF)) * FNV_PRIME;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
/** How an object placement scales its objects, written as the placement's {@code scale}. */
|
||||
@Snippet("iris/objects/object-scale")
|
||||
@Desc("Scale Objects")
|
||||
public final class ObjectScale {
|
||||
private static final double NO_SCALE = 1;
|
||||
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(50)
|
||||
@Desc("Fixed scale multiplier for this object. 0.5 shrinks to half size, 2.0 doubles the size. When set to anything other than 1, this overrides minimumScale and maximumScale. Leave at 1 to use the minimumScale/maximumScale range.")
|
||||
private double size = NO_SCALE;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(32)
|
||||
@Desc("Iris Objects are scaled and cached to speed up placements. Because of this extra memory is used, so we evenly distribute variations across the defined scale range, then pick one randomly. If the differences is small, use a lower number. For more possibilities on the scale spectrum, increase this at the cost of memory.")
|
||||
private int variations = 7;
|
||||
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(50)
|
||||
@Desc("The minimum scale. Used when size is 1 to pick a random scale per placement.")
|
||||
private double minimumScale = NO_SCALE;
|
||||
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(50)
|
||||
@Desc("The maximum scale. Used when size is 1 to pick a random scale per placement.")
|
||||
private double maximumScale = NO_SCALE;
|
||||
|
||||
@Desc("If this object is scaled up beyond its origin size, specify a 3D interpolator. NONE keeps blocky scaled output, TRILINEAR (LERP) smooths with linear interpolation, TRICUBIC and TRIHERMITE produce smoother but slower output.")
|
||||
private ScaleInterpolation interpolation = ScaleInterpolation.NONE;
|
||||
|
||||
public ObjectScale() {
|
||||
}
|
||||
|
||||
public double size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public int variations() {
|
||||
return variations;
|
||||
}
|
||||
|
||||
public double minimumScale() {
|
||||
return minimumScale;
|
||||
}
|
||||
|
||||
public double maximumScale() {
|
||||
return maximumScale;
|
||||
}
|
||||
|
||||
public ScaleInterpolation interpolation() {
|
||||
return interpolation == null ? ScaleInterpolation.NONE : interpolation;
|
||||
}
|
||||
|
||||
/** The largest factor this scale makes an object, which a placement's reach has to cover. */
|
||||
public double maxScale() {
|
||||
if (size != NO_SCALE) {
|
||||
return size;
|
||||
}
|
||||
return Math.max(minimumScale, maximumScale);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The object placements a region or biome declares, written as {@code "objects": [...]}, the list of placements. A chunk
|
||||
* places those of its centre column's region and of that column's biome, and of the cave biome where it places in caves.
|
||||
*/
|
||||
@Desc("Objects define what schematics (iob files) iris will place here")
|
||||
@Feature(id = "iris:objects", name = "Objects", key = "objects", root = "objects", targets = {Level.REGION, Level.BIOME})
|
||||
public final class ObjectSettings implements IrisFeature {
|
||||
@Desc("Objects define what schematics (iob files) iris will place here")
|
||||
private List<ObjectPlacement> objects = List.of();
|
||||
|
||||
public ObjectSettings() {
|
||||
}
|
||||
|
||||
public List<ObjectPlacement> objects() {
|
||||
return objects == null ? List.of() : Collections.unmodifiableList(objects);
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
/** Whether a dimension refuses surface objects over carved openings, written as {@code "requireObjectSurfaceSupport": true}. */
|
||||
@Desc("Refuse to place surface objects and trees over carved surface openings.")
|
||||
@Feature(id = "iris:objects/surface-support", name = "Require surface support", key = "requireObjectSurfaceSupport", root = "require", targets = Level.DIMENSION)
|
||||
public final class RequireSurfaceSupportSettings implements IrisFeature {
|
||||
private static final boolean DEFAULT_REQUIRED = true;
|
||||
|
||||
@Desc("Refuse to place surface objects and trees over carved surface openings.")
|
||||
private boolean require = DEFAULT_REQUIRED;
|
||||
|
||||
public RequireSurfaceSupportSettings() {
|
||||
}
|
||||
|
||||
public boolean require() {
|
||||
return require;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Use 3D Interpolation on scaled objects if they are larger than the origin.")
|
||||
public enum ScaleInterpolation {
|
||||
@Desc("Don't interpolate, big cubes")
|
||||
NONE,
|
||||
@Desc("Uses linear interpolation in 3 dimensions, generally pretty good, but slow")
|
||||
TRILINEAR,
|
||||
@Desc("Uses cubic spline interpolation in 3 dimensions, even better, but extreme slowdowns")
|
||||
TRICUBIC,
|
||||
@Desc("Uses hermite spline interpolation in 3 dimensions, even better, but extreme slowdowns")
|
||||
TRIHERMITE
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
|
||||
/** The least surface-support buffer a dimension gives its surface objects, written as {@code "objectSurfaceSupportBuffer": 2}. */
|
||||
@Desc("Minimum surface-support buffer, in blocks, applied to every surface object placement in this dimension. A placement may ask for more but never less.")
|
||||
@Feature(id = "iris:objects/surface-support-buffer", name = "Surface support buffer", key = "objectSurfaceSupportBuffer", root = "buffer", targets = Level.DIMENSION)
|
||||
public final class SurfaceSupportBufferSettings implements IrisFeature {
|
||||
private static final int DEFAULT_BUFFER_BLOCKS = 2;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@Desc("Minimum surface-support buffer, in blocks, applied to every surface object placement in this dimension. A placement may ask for more but never less.")
|
||||
private int buffer = DEFAULT_BUFFER_BLOCKS;
|
||||
|
||||
public SurfaceSupportBufferSettings() {
|
||||
}
|
||||
|
||||
public int buffer() {
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
@@ -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.objects;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** The trees an object placement overrides when their saplings grow, an entry of the placement's {@code trees}. */
|
||||
@Snippet("iris/objects/tree")
|
||||
@Desc("Tree replace options for this object placer")
|
||||
public final class TreeOverride {
|
||||
@Required
|
||||
@Desc("The types of trees overwritten by this object")
|
||||
private List<String> treeTypes = List.of();
|
||||
|
||||
@Required
|
||||
@Desc("The size of the square of saplings this applies to (2 means a 2 * 2 sapling area)")
|
||||
private List<TreeSize> sizes = List.of();
|
||||
|
||||
public TreeOverride() {
|
||||
}
|
||||
|
||||
public List<String> treeTypes() {
|
||||
return treeTypes == null ? List.of() : Collections.unmodifiableList(treeTypes);
|
||||
}
|
||||
|
||||
public List<TreeSize> sizes() {
|
||||
return sizes == null ? List.of() : Collections.unmodifiableList(sizes);
|
||||
}
|
||||
|
||||
/** Whether this override is for a sapling area of {@code width} by {@code depth} growing the species {@code species}. */
|
||||
public boolean matches(int width, int depth, String species) {
|
||||
return matchesSize(width, depth) && matchesSpecies(species);
|
||||
}
|
||||
|
||||
private boolean matchesSize(int width, int depth) {
|
||||
for (TreeSize size : sizes()) {
|
||||
if (size.matches(width, depth)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean matchesSpecies(String species) {
|
||||
for (String type : treeTypes()) {
|
||||
if (type != null && type.equalsIgnoreCase(species)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
/** The size of a sapling area, in saplings, that a tree override applies to. */
|
||||
@Snippet("iris/objects/tree-size")
|
||||
@Desc("Sapling override object picking options")
|
||||
public final class TreeSize {
|
||||
@Required
|
||||
@Desc("The width of the sapling area")
|
||||
private int width = 1;
|
||||
|
||||
@Required
|
||||
@Desc("The depth of the sapling area")
|
||||
private int depth = 1;
|
||||
|
||||
public TreeSize() {
|
||||
}
|
||||
|
||||
public TreeSize(int width, int depth) {
|
||||
this.width = width;
|
||||
this.depth = depth;
|
||||
}
|
||||
|
||||
public int width() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int depth() {
|
||||
return depth;
|
||||
}
|
||||
|
||||
/** Whether an area of {@code otherWidth} by {@code otherDepth} saplings is this size, turned either way. */
|
||||
public boolean matches(int otherWidth, int otherDepth) {
|
||||
return (width == otherWidth && depth == otherDepth) || (depth == otherWidth && width == otherDepth);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
/** Whether the objects placed in the terrain stacked above ignore placement restrictions, written as {@code "upperObjectsForcePlace": true}. */
|
||||
@Desc("When true, upper-dimension objects force-place regardless of placement restrictions (slope, underwater, clamp, collisions, carving). Normal dimension objects always place first; upper objects place second and may clip or occlude lower-dimension placements when this is enabled.")
|
||||
@Feature(id = "iris:objects/upper-force", name = "Force upper dimension objects", key = "upperObjectsForcePlace", root = "force", targets = Level.DIMENSION)
|
||||
public final class UpperObjectsForceSettings implements IrisFeature {
|
||||
@Desc("When true, upper-dimension objects force-place regardless of placement restrictions (slope, underwater, clamp, collisions, carving). Normal dimension objects always place first; upper objects place second and may clip or occlude lower-dimension placements when this is enabled.")
|
||||
private boolean force = false;
|
||||
|
||||
public UpperObjectsForceSettings() {
|
||||
}
|
||||
|
||||
public boolean force() {
|
||||
return force;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.objects;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
/** Whether the objects of a dimension are also placed in the terrain stacked above it, written as {@code "upperDimensionObjects": true}. */
|
||||
@Desc("When true, objects from the mantle (structures, trees, etc.) can be placed in the upper dimension terrain zone. When false, the upper terrain is protected from object placement.")
|
||||
@Feature(id = "iris:objects/upper", name = "Upper dimension objects", key = "upperDimensionObjects", root = "enabled", targets = Level.DIMENSION)
|
||||
public final class UpperObjectsSettings implements IrisFeature {
|
||||
@Desc("When true, objects from the mantle (structures, trees, etc.) can be placed in the upper dimension terrain zone. When false, the upper terrain is protected from object placement.")
|
||||
private boolean enabled = false;
|
||||
|
||||
public UpperObjectsSettings() {
|
||||
}
|
||||
|
||||
public boolean enabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The public face of Iris's built-in modules: every stage constant, in {@link art.arcane.iris.builtin.IrisStages},
|
||||
* and the settings and output types of those stages. {@link art.arcane.iris.core.modules.IrisModuleHost} exposes this package, with its
|
||||
* subpackages, to pack modules, so a pack jar can {@code requires(...)} a built-in stage and read its
|
||||
* output. Everything here is part of what packs compile against.
|
||||
* <p>
|
||||
* Keep implementation out of it: stage bodies and anything that uses Iris internals live in the
|
||||
* built-in module classes outside this package, which packs cannot see. Settings and output types go in one
|
||||
* subpackage per built-in module, named after the module path, such as {@code art.arcane.iris.builtin.spawn}
|
||||
* for {@code iris:spawn}. A type only the built-ins jar uses, which Iris itself never reads, lives in
|
||||
* {@code art.arcane.iris.modules} instead, which Iris does not expose.
|
||||
* <p>
|
||||
* Besides those, it holds what Iris and the built-ins jar must share, since each sees its own copy
|
||||
* of every other class: narrow facades only Iris's own built-ins use, interfaces Iris's worlds implement
|
||||
* ({@link art.arcane.iris.builtin.structure.StructureHost}), and the seed purposes of the built-in features
|
||||
* ({@link art.arcane.iris.builtin.IrisSeedPurposes}). Keep them few: each is a promise.
|
||||
* <p>
|
||||
* The placement stages ({@code iris:prepare} to {@code iris:snow}) run in the pack's placement graph, which
|
||||
* {@code PackWorld.placements()} runs. They read the object and its settings from the run's input,
|
||||
* {@link art.arcane.iris.builtin.objects.ObjectRun}, which Iris also builds when it places an object itself.
|
||||
*/
|
||||
package art.arcane.iris.builtin;
|
||||
@@ -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("iris/prepare/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,279 @@
|
||||
/*
|
||||
* 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 art.arcane.iris.engine.object.value.IrisDirection;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* How an object is turned around each axis, written as a placement's {@code rotation}. Positions turn around X, then Z,
|
||||
* then Y; an axis locked to a multiple of a quarter turn swaps coordinates exactly instead of turning by an angle.
|
||||
*/
|
||||
@Snippet("iris/prepare/object-rotator")
|
||||
@Desc("Configures rotation for iris")
|
||||
public final class ObjectRotation {
|
||||
private static final double QUARTER_TURN_DEGREES = 90;
|
||||
private static final double HALF_TURN_DEGREES = 180;
|
||||
private static final double THREE_QUARTER_TURN_DEGREES = 270;
|
||||
private static final double FULL_TURN_DEGREES = 360;
|
||||
|
||||
@Desc("If this rotator is enabled or not")
|
||||
private boolean enabled = true;
|
||||
|
||||
@Desc("The x axis rotation")
|
||||
private AxisRotationClamp xAxis = new AxisRotationClamp();
|
||||
|
||||
@Desc("The y axis rotation")
|
||||
private AxisRotationClamp yAxis = AxisRotationClamp.of(true, false, 0, 0, QUARTER_TURN_DEGREES);
|
||||
|
||||
@Desc("The z axis rotation")
|
||||
private AxisRotationClamp zAxis = new AxisRotationClamp();
|
||||
|
||||
public ObjectRotation() {
|
||||
}
|
||||
|
||||
/** A rotation with the given axes. */
|
||||
public static ObjectRotation of(boolean enabled, AxisRotationClamp xAxis, AxisRotationClamp yAxis, AxisRotationClamp zAxis) {
|
||||
ObjectRotation rotation = new ObjectRotation();
|
||||
rotation.enabled = enabled;
|
||||
rotation.xAxis = xAxis;
|
||||
rotation.yAxis = yAxis;
|
||||
rotation.zAxis = zAxis;
|
||||
return rotation;
|
||||
}
|
||||
|
||||
/** A rotation locked to the given angles, in degrees; enabled only when one of them is not 0. */
|
||||
public static ObjectRotation of(double x, double y, double z) {
|
||||
return of(x != 0 || y != 0 || z != 0,
|
||||
AxisRotationClamp.locked(x != 0, x, QUARTER_TURN_DEGREES),
|
||||
AxisRotationClamp.locked(y != 0, y, QUARTER_TURN_DEGREES),
|
||||
AxisRotationClamp.locked(z != 0, z, QUARTER_TURN_DEGREES));
|
||||
}
|
||||
|
||||
/** Upside down: half a turn around X and no turn around Y or Z. */
|
||||
public static ObjectRotation xFlip180() {
|
||||
return of(true, AxisRotationClamp.locked(true, HALF_TURN_DEGREES, 0), new AxisRotationClamp(), new AxisRotationClamp());
|
||||
}
|
||||
|
||||
/** Upside down, then a random quarter turn around Y. */
|
||||
public static ObjectRotation xFlip180RandomY() {
|
||||
return xFlip180().withYAxis(AxisRotationClamp.of(true, false, 0, 0, QUARTER_TURN_DEGREES));
|
||||
}
|
||||
|
||||
/** Upside down, then {@code y} degrees around Y. */
|
||||
public static ObjectRotation xFlip180WithY(double y) {
|
||||
return xFlip180().withYAxis(AxisRotationClamp.locked(true, y, QUARTER_TURN_DEGREES));
|
||||
}
|
||||
|
||||
/** This rotation with {@code axis} around Y. */
|
||||
public ObjectRotation withYAxis(AxisRotationClamp axis) {
|
||||
return of(enabled, xAxis, axis, zAxis);
|
||||
}
|
||||
|
||||
public boolean enabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public AxisRotationClamp xAxis() {
|
||||
return xAxis;
|
||||
}
|
||||
|
||||
public AxisRotationClamp yAxis() {
|
||||
return yAxis;
|
||||
}
|
||||
|
||||
public AxisRotationClamp zAxis() {
|
||||
return zAxis;
|
||||
}
|
||||
|
||||
public boolean canRotateX() {
|
||||
return enabled && xAxis.enabled();
|
||||
}
|
||||
|
||||
public boolean canRotateY() {
|
||||
return enabled && yAxis.enabled();
|
||||
}
|
||||
|
||||
public boolean canRotateZ() {
|
||||
return enabled && zAxis.enabled();
|
||||
}
|
||||
|
||||
public boolean canRotate() {
|
||||
return canRotateX() || canRotateY() || canRotateZ();
|
||||
}
|
||||
|
||||
/** The angle, in radians, the object turns around {@code axis} for the random {@code spin}; 0 when the rotation or the axis is off. */
|
||||
public double radians(AxisRotationClamp axis, int spin) {
|
||||
if (!enabled || !axis.enabled()) {
|
||||
return 0;
|
||||
}
|
||||
return axis.getRadians(spin);
|
||||
}
|
||||
|
||||
public double xRadians(int spin) {
|
||||
return radians(xAxis, spin);
|
||||
}
|
||||
|
||||
public double yRadians(int spin) {
|
||||
return radians(yAxis, spin);
|
||||
}
|
||||
|
||||
public double zRadians(int spin) {
|
||||
return radians(zAxis, spin);
|
||||
}
|
||||
|
||||
public IrisBlockVector rotate(IrisBlockVector position) {
|
||||
return rotate(position, 0, 0, 0);
|
||||
}
|
||||
|
||||
public IrisPosition rotate(IrisPosition position) {
|
||||
return rotate(position, 0, 0, 0);
|
||||
}
|
||||
|
||||
public IrisPosition rotate(IrisPosition position, int spinX, int spinY, int spinZ) {
|
||||
IrisBlockVector turned = rotate(new IrisBlockVector(position.getX(), position.getY(), position.getZ()), spinX, spinY, spinZ);
|
||||
return new IrisPosition(turned.getBlockX(), turned.getBlockY(), turned.getBlockZ());
|
||||
}
|
||||
|
||||
/** The direction closest to {@code direction} turned by this rotation. */
|
||||
public IrisDirection rotate(IrisDirection direction) {
|
||||
IrisBlockVector turned = rotate(new IrisBlockVector(direction.x(), direction.y(), direction.z()));
|
||||
double closestDistance = Double.MAX_VALUE;
|
||||
IrisDirection closest = null;
|
||||
for (IrisDirection candidate : IrisDirection.values()) {
|
||||
double distance = new IrisBlockVector(candidate.x(), candidate.y(), candidate.z()).distance(turned);
|
||||
if (distance < closestDistance) {
|
||||
closestDistance = distance;
|
||||
closest = candidate;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
/** {@code position} turned around X, then Z, then Y, each by the angle {@code spin} picks for it; a copy unless nothing turns. */
|
||||
public IrisBlockVector rotate(IrisBlockVector position, int spinX, int spinY, int spinZ) {
|
||||
if (!canRotate()) {
|
||||
return position;
|
||||
}
|
||||
IrisBlockVector turned = position.clone();
|
||||
if (canRotateX()) {
|
||||
turnAroundX(turned, spinX);
|
||||
}
|
||||
if (canRotateZ()) {
|
||||
turnAroundZ(turned, spinZ);
|
||||
}
|
||||
if (canRotateY()) {
|
||||
turnAroundY(turned, spinY);
|
||||
}
|
||||
return turned;
|
||||
}
|
||||
|
||||
private void turnAroundX(IrisBlockVector v, int spin) {
|
||||
if (!xAxis.isLocked()) {
|
||||
v.rotateAroundX(xRadians(spin));
|
||||
return;
|
||||
}
|
||||
double angle = xAxis.max();
|
||||
if (Math.abs(angle) % FULL_TURN_DEGREES == HALF_TURN_DEGREES) {
|
||||
v.setZ(-v.getZ());
|
||||
v.setY(-v.getY());
|
||||
} else if (isQuarterTurn(angle)) {
|
||||
double z = v.getZ();
|
||||
v.setZ(v.getY());
|
||||
v.setY(-z);
|
||||
} else if (isThreeQuarterTurn(angle)) {
|
||||
double z = v.getZ();
|
||||
v.setZ(-v.getY());
|
||||
v.setY(z);
|
||||
} else {
|
||||
v.rotateAroundX(xRadians(spin));
|
||||
}
|
||||
}
|
||||
|
||||
private void turnAroundZ(IrisBlockVector v, int spin) {
|
||||
if (!zAxis.isLocked()) {
|
||||
v.rotateAroundZ(zRadians(spin));
|
||||
return;
|
||||
}
|
||||
double angle = zAxis.max();
|
||||
if (Math.abs(angle) % FULL_TURN_DEGREES == HALF_TURN_DEGREES) {
|
||||
v.setY(-v.getY());
|
||||
v.setX(-v.getX());
|
||||
} else if (isQuarterTurn(angle)) {
|
||||
double y = v.getY();
|
||||
v.setY(v.getX());
|
||||
v.setX(-y);
|
||||
} else if (isThreeQuarterTurn(angle)) {
|
||||
double y = v.getY();
|
||||
v.setY(-v.getX());
|
||||
v.setX(y);
|
||||
} else {
|
||||
v.rotateAroundZ(zRadians(spin));
|
||||
}
|
||||
}
|
||||
|
||||
private void turnAroundY(IrisBlockVector v, int spin) {
|
||||
if (!yAxis.isLocked()) {
|
||||
v.rotateAroundY(yRadians(spin));
|
||||
return;
|
||||
}
|
||||
double angle = yAxis.max();
|
||||
if (Math.abs(angle) % FULL_TURN_DEGREES == HALF_TURN_DEGREES) {
|
||||
v.setX(-v.getX());
|
||||
v.setZ(-v.getZ());
|
||||
} else if (isQuarterTurn(angle)) {
|
||||
double x = v.getX();
|
||||
v.setX(v.getZ());
|
||||
v.setZ(-x);
|
||||
} else if (isThreeQuarterTurn(angle)) {
|
||||
double x = v.getX();
|
||||
v.setX(-v.getZ());
|
||||
v.setZ(x);
|
||||
} else {
|
||||
v.rotateAroundY(yRadians(spin));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isQuarterTurn(double angle) {
|
||||
return angle % FULL_TURN_DEGREES == QUARTER_TURN_DEGREES || angle % FULL_TURN_DEGREES == -THREE_QUARTER_TURN_DEGREES;
|
||||
}
|
||||
|
||||
private static boolean isThreeQuarterTurn(double angle) {
|
||||
return angle == -QUARTER_TURN_DEGREES || angle % FULL_TURN_DEGREES == THREE_QUARTER_TURN_DEGREES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof ObjectRotation rotation
|
||||
&& enabled == rotation.enabled
|
||||
&& Objects.equals(xAxis, rotation.xAxis)
|
||||
&& Objects.equals(yAxis, rotation.yAxis)
|
||||
&& Objects.equals(zAxis, rotation.zAxis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(enabled, xAxis, yAxis, zAxis);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package art.arcane.iris.builtin.prepare;
|
||||
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
|
||||
/**
|
||||
* Precomputed vector rotation for a single placement.
|
||||
* <p>
|
||||
* Turns vectors branch for branch as Iris's object rotation does, with two differences: it mutates the vector
|
||||
* handed to it instead of cloning, and the per-axis angle plus its cosine and sine are resolved once instead of once
|
||||
* per block. The angle is a pure function of the axis clamp and the spin, both fixed for the placement, and
|
||||
* Math.cos/Math.sin are pure, so every produced double is identical to the value the per-call form would have produced.
|
||||
*/
|
||||
public final class ObjectSpinKernel {
|
||||
private static final int MODE_NONE = 0;
|
||||
private static final int MODE_FLIP = 1;
|
||||
private static final int MODE_QUARTER = 2;
|
||||
private static final int MODE_THREE_QUARTER = 3;
|
||||
private static final int MODE_ANGLE = 4;
|
||||
|
||||
private final ObjectRotation rotation;
|
||||
|
||||
private final int xMode;
|
||||
private final int yMode;
|
||||
private final int zMode;
|
||||
private final double xCos;
|
||||
private final double xSin;
|
||||
private final double yCos;
|
||||
private final double ySin;
|
||||
private final double zCos;
|
||||
private final double zSin;
|
||||
|
||||
public ObjectSpinKernel(ObjectRotation rotation, int spinX, int spinY, int spinZ) {
|
||||
this.rotation = rotation;
|
||||
xMode = rotation.canRotateX() ? modeOf(rotation.xAxis()) : MODE_NONE;
|
||||
zMode = rotation.canRotateZ() ? modeOf(rotation.zAxis()) : MODE_NONE;
|
||||
yMode = rotation.canRotateY() ? modeOf(rotation.yAxis()) : MODE_NONE;
|
||||
double xAngle = xMode == MODE_ANGLE ? rotation.radians(rotation.xAxis(), spinX) : 0;
|
||||
double zAngle = zMode == MODE_ANGLE ? rotation.radians(rotation.zAxis(), spinZ) : 0;
|
||||
double yAngle = yMode == MODE_ANGLE ? rotation.radians(rotation.yAxis(), spinY) : 0;
|
||||
xCos = Math.cos(xAngle);
|
||||
xSin = Math.sin(xAngle);
|
||||
zCos = Math.cos(zAngle);
|
||||
zSin = Math.sin(zAngle);
|
||||
yCos = Math.cos(yAngle);
|
||||
ySin = Math.sin(yAngle);
|
||||
}
|
||||
|
||||
private static int modeOf(AxisRotationClamp clamp) {
|
||||
if (!clamp.isLocked()) {
|
||||
return MODE_ANGLE;
|
||||
}
|
||||
|
||||
if (Math.abs(clamp.max()) % 360D == 180D) {
|
||||
return MODE_FLIP;
|
||||
}
|
||||
|
||||
if (clamp.max() % 360D == 90D || clamp.max() % 360D == -270D) {
|
||||
return MODE_QUARTER;
|
||||
}
|
||||
|
||||
if (clamp.max() == -90D || clamp.max() % 360D == 270D) {
|
||||
return MODE_THREE_QUARTER;
|
||||
}
|
||||
|
||||
return MODE_ANGLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates in place. Axis order (X, then Z, then Y) is load bearing.
|
||||
*/
|
||||
public void rotate(IrisBlockVector v) {
|
||||
if (!rotation.canRotate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (xMode) {
|
||||
case MODE_FLIP -> {
|
||||
v.setZ(-v.getZ());
|
||||
v.setY(-v.getY());
|
||||
}
|
||||
case MODE_QUARTER -> {
|
||||
double z = v.getZ();
|
||||
v.setZ(v.getY());
|
||||
v.setY(-z);
|
||||
}
|
||||
case MODE_THREE_QUARTER -> {
|
||||
double z = v.getZ();
|
||||
v.setZ(-v.getY());
|
||||
v.setY(z);
|
||||
}
|
||||
case MODE_ANGLE -> {
|
||||
double y = xCos * v.getY() - xSin * v.getZ();
|
||||
double z = xSin * v.getY() + xCos * v.getZ();
|
||||
v.setY(y);
|
||||
v.setZ(z);
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
|
||||
switch (zMode) {
|
||||
case MODE_FLIP -> {
|
||||
v.setY(-v.getY());
|
||||
v.setX(-v.getX());
|
||||
}
|
||||
case MODE_QUARTER -> {
|
||||
double y = v.getY();
|
||||
v.setY(v.getX());
|
||||
v.setX(-y);
|
||||
}
|
||||
case MODE_THREE_QUARTER -> {
|
||||
double y = v.getY();
|
||||
v.setY(-v.getX());
|
||||
v.setX(y);
|
||||
}
|
||||
case MODE_ANGLE -> {
|
||||
double x = zCos * v.getX() - zSin * v.getY();
|
||||
double y = zSin * v.getX() + zCos * v.getY();
|
||||
v.setX(x);
|
||||
v.setY(y);
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
|
||||
switch (yMode) {
|
||||
case MODE_FLIP -> {
|
||||
v.setX(-v.getX());
|
||||
v.setZ(-v.getZ());
|
||||
}
|
||||
case MODE_QUARTER -> {
|
||||
double x = v.getX();
|
||||
v.setX(v.getZ());
|
||||
v.setZ(-x);
|
||||
}
|
||||
case MODE_THREE_QUARTER -> {
|
||||
double x = v.getX();
|
||||
v.setX(-v.getZ());
|
||||
v.setZ(x);
|
||||
}
|
||||
case MODE_ANGLE -> {
|
||||
double x = yCos * v.getX() + ySin * v.getZ();
|
||||
double z = -ySin * v.getX() + yCos * v.getZ();
|
||||
v.setX(x);
|
||||
v.setZ(z);
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.prepare;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
/** How far an object is shifted from where it would be placed, written as a placement's {@code translate}. */
|
||||
@Snippet("iris/prepare/object-translator")
|
||||
@Desc("Translate objects")
|
||||
public final class ObjectTranslate {
|
||||
@MinNumber(-128)
|
||||
@MaxNumber(128)
|
||||
@Desc("The x shift in blocks")
|
||||
private int x = 0;
|
||||
|
||||
@Required
|
||||
@MinNumber(-128)
|
||||
@MaxNumber(128)
|
||||
@Desc("The y shift in blocks")
|
||||
private int y = 0;
|
||||
|
||||
@MinNumber(-128)
|
||||
@MaxNumber(128)
|
||||
@Desc("Adds an additional amount of height randomly (translateY + rand(0 - yRandom))")
|
||||
private int yRandom = 0;
|
||||
|
||||
@MinNumber(-128)
|
||||
@MaxNumber(128)
|
||||
@Desc("The z shift in blocks")
|
||||
private int z = 0;
|
||||
|
||||
public ObjectTranslate() {
|
||||
}
|
||||
|
||||
/** A shift of the given size, as Iris's own translate model hands it to the placement stages. */
|
||||
public static ObjectTranslate of(int x, int y, int yRandom, int z) {
|
||||
ObjectTranslate translate = new ObjectTranslate();
|
||||
translate.x = x;
|
||||
translate.y = y;
|
||||
translate.yRandom = yRandom;
|
||||
translate.z = z;
|
||||
return translate;
|
||||
}
|
||||
|
||||
public boolean canTranslate() {
|
||||
return x != 0 || y != 0 || z != 0;
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int yRandom() {
|
||||
return yRandom;
|
||||
}
|
||||
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
@@ -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 an object placement, a decorator or a terrain layer may sit on, written as its {@code slopeCondition}. */
|
||||
@Snippet("iris/prepare/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,23 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/** The bounds of a transformed object around its anchor, inclusive, widened by the surface warp along X and Z. */
|
||||
public record TransformedBounds(int minX, int maxX, int minY, int maxY, int minZ, int maxZ) {
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
/**
|
||||
* A sound, particles, potion effect or commands that play now and then around the players in an area. The same
|
||||
* settings make the effect an entity shows when it appears ({@link EntityDefinition#spawnEffect()}).
|
||||
*/
|
||||
@Snippet("iris/spawn/effect")
|
||||
@Desc("An iris effect")
|
||||
public final class AmbientEffect {
|
||||
@Ref(Reference.POTION_EFFECT)
|
||||
@Desc("The potion effect to apply in this area")
|
||||
private String potionEffect = "";
|
||||
|
||||
@Desc("The particle effect to apply in the area")
|
||||
private String particleEffect = null;
|
||||
|
||||
@MinNumber(-32)
|
||||
@MaxNumber(32)
|
||||
@Desc("Randomly offset from the surface to this surface+value")
|
||||
private int particleOffset = 0;
|
||||
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt x, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double particleAltX = 0;
|
||||
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt y, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double particleAltY = 0;
|
||||
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt z, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double particleAltZ = 0;
|
||||
|
||||
@Desc("Randomize the altX by -altX to altX")
|
||||
private boolean randomAltX = true;
|
||||
|
||||
@Desc("Randomize the altY by -altY to altY")
|
||||
private boolean randomAltY = false;
|
||||
|
||||
@Desc("Randomize the altZ by -altZ to altZ")
|
||||
private boolean randomAltZ = true;
|
||||
|
||||
@Desc("The sound to play")
|
||||
private String sound = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(512)
|
||||
@Desc("The max distance from the player the sound will play")
|
||||
private int soundDistance = 12;
|
||||
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(1.99)
|
||||
@Desc("The minimum sound pitch")
|
||||
private double minPitch = 0.5D;
|
||||
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(1.99)
|
||||
@Desc("The max sound pitch")
|
||||
private double maxPitch = 1.5D;
|
||||
|
||||
@MinNumber(0.001)
|
||||
@MaxNumber(512)
|
||||
@Desc("The sound volume.")
|
||||
private double volume = 1.5D;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(512)
|
||||
@Desc("The particle count. Try setting to zero for using the alt xyz to a motion value instead of an offset")
|
||||
private int particleCount = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(64)
|
||||
@Desc("How far away from the player particles can play")
|
||||
private int particleDistance = 20;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(128)
|
||||
@Desc("How wide the particles can play (player's view left and right) RADIUS")
|
||||
private int particleDistanceWidth = 24;
|
||||
|
||||
@Desc("An extra value for some particles... Which bukkit doesn't even document.")
|
||||
private double extra = 0;
|
||||
|
||||
@MinNumber(-1)
|
||||
@MaxNumber(1024)
|
||||
@Desc("The Potion Strength or -1 to disable")
|
||||
private int potionStrength = -1;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The max time the potion will last for")
|
||||
private int potionTicksMax = 155;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The min time the potion will last for")
|
||||
private int potionTicksMin = 75;
|
||||
|
||||
@Required
|
||||
@MinNumber(0)
|
||||
@Desc("The effect interval in milliseconds")
|
||||
private int interval = 150;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@Desc("The effect distance start away")
|
||||
private int particleAway = 5;
|
||||
|
||||
@Required
|
||||
@MinNumber(1)
|
||||
@Desc("The chance is 1 in CHANCE per interval")
|
||||
private int chance = 50;
|
||||
|
||||
@Desc("Run commands, with configurable location parameters")
|
||||
private EffectCommands commandRegistry = null;
|
||||
|
||||
public AmbientEffect() {
|
||||
}
|
||||
|
||||
public String potionEffect() {
|
||||
return potionEffect;
|
||||
}
|
||||
|
||||
public String particleEffect() {
|
||||
return particleEffect;
|
||||
}
|
||||
|
||||
public int particleOffset() {
|
||||
return particleOffset;
|
||||
}
|
||||
|
||||
public double particleAltX() {
|
||||
return particleAltX;
|
||||
}
|
||||
|
||||
public double particleAltY() {
|
||||
return particleAltY;
|
||||
}
|
||||
|
||||
public double particleAltZ() {
|
||||
return particleAltZ;
|
||||
}
|
||||
|
||||
public boolean randomAltX() {
|
||||
return randomAltX;
|
||||
}
|
||||
|
||||
public boolean randomAltY() {
|
||||
return randomAltY;
|
||||
}
|
||||
|
||||
public boolean randomAltZ() {
|
||||
return randomAltZ;
|
||||
}
|
||||
|
||||
public String sound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
public int soundDistance() {
|
||||
return soundDistance;
|
||||
}
|
||||
|
||||
public double minPitch() {
|
||||
return minPitch;
|
||||
}
|
||||
|
||||
public double maxPitch() {
|
||||
return maxPitch;
|
||||
}
|
||||
|
||||
public double volume() {
|
||||
return volume;
|
||||
}
|
||||
|
||||
public int particleCount() {
|
||||
return particleCount;
|
||||
}
|
||||
|
||||
public int particleDistance() {
|
||||
return particleDistance;
|
||||
}
|
||||
|
||||
public int particleDistanceWidth() {
|
||||
return particleDistanceWidth;
|
||||
}
|
||||
|
||||
public double extra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public int potionStrength() {
|
||||
return potionStrength;
|
||||
}
|
||||
|
||||
public int potionTicksMax() {
|
||||
return potionTicksMax;
|
||||
}
|
||||
|
||||
public int potionTicksMin() {
|
||||
return potionTicksMin;
|
||||
}
|
||||
|
||||
public int interval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
public int particleAway() {
|
||||
return particleAway;
|
||||
}
|
||||
|
||||
public int chance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
/** The commands the effect runs; null for none. */
|
||||
public EffectCommands commandRegistry() {
|
||||
return commandRegistry;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
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.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Snippet("iris/spawn/command-registry")
|
||||
@Desc("Represents a casting location for a command")
|
||||
public final class EffectCommands {
|
||||
@Required
|
||||
@Desc("Run commands, at the exact location of the player")
|
||||
private List<SpawnCommand> rawCommands = List.of();
|
||||
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt x, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double commandOffsetX = 0;
|
||||
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt y, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double commandOffsetY = 0;
|
||||
|
||||
@MinNumber(-8)
|
||||
@MaxNumber(8)
|
||||
@Desc("The alt z, usually represents motion if the particle count is zero. Otherwise an offset.")
|
||||
private double commandOffsetZ = 0;
|
||||
|
||||
@Desc("Randomize the altX from -altX to altX")
|
||||
private boolean commandRandomAltX = true;
|
||||
|
||||
@Desc("Randomize the altY from -altY to altY")
|
||||
private boolean commandRandomAltY = false;
|
||||
|
||||
@Desc("Randomize the altZ from -altZ to altZ")
|
||||
private boolean commandRandomAltZ = true;
|
||||
|
||||
@Desc("Randomize location for all separate commands (true), or run all on the same location (false)")
|
||||
private boolean commandAllRandomLocations = true;
|
||||
|
||||
public EffectCommands() {
|
||||
}
|
||||
|
||||
public List<SpawnCommand> rawCommands() {
|
||||
return rawCommands == null ? List.of() : Collections.unmodifiableList(rawCommands);
|
||||
}
|
||||
|
||||
public double commandOffsetX() {
|
||||
return commandOffsetX;
|
||||
}
|
||||
|
||||
public double commandOffsetY() {
|
||||
return commandOffsetY;
|
||||
}
|
||||
|
||||
public double commandOffsetZ() {
|
||||
return commandOffsetZ;
|
||||
}
|
||||
|
||||
public boolean commandRandomAltX() {
|
||||
return commandRandomAltX;
|
||||
}
|
||||
|
||||
public boolean commandRandomAltY() {
|
||||
return commandRandomAltY;
|
||||
}
|
||||
|
||||
public boolean commandRandomAltZ() {
|
||||
return commandRandomAltZ;
|
||||
}
|
||||
|
||||
public boolean commandAllRandomLocations() {
|
||||
return commandAllRandomLocations;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.loot.ItemAttributeModifier;
|
||||
import art.arcane.iris.builtin.loot.LootEntry;
|
||||
import art.arcane.iris.builtin.loot.LootSettings;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** An entity of the pack, one file of {@code entities/}: what spawners and markers spawn, with its equipment, attributes, passengers and loot. */
|
||||
@Desc("Represents an iris entity.")
|
||||
public final class EntityDefinition {
|
||||
@Required
|
||||
@Ref(Reference.ENTITY)
|
||||
@Desc("The namespaced key of the entity type to spawn, such as minecraft:zombie or alexsmobs:grizzly_bear. To spawn a mob from another plugin or provider, set this type to unknown and define the special type.")
|
||||
private String type = null;
|
||||
|
||||
@Desc("The SpawnReason name to spawn the entity with, such as NATURAL or COMMAND.")
|
||||
private String reason = null;
|
||||
|
||||
@Desc("The custom name of this entity")
|
||||
private String customName = "";
|
||||
|
||||
@Desc("Should the name on this entity be visible even if you arent looking at it.")
|
||||
private boolean customNameVisible = false;
|
||||
|
||||
@Desc("If this entity type is a mob, should it be aware of it's surroundings & interact with the world.")
|
||||
private boolean aware = true;
|
||||
|
||||
@Desc("If this entity type is a creature, should it have ai goals.")
|
||||
private boolean ai = true;
|
||||
|
||||
@Desc("Should this entity be glowing")
|
||||
private boolean glowing = false;
|
||||
|
||||
@Desc("Should gravity apply to this entity")
|
||||
private boolean gravity = true;
|
||||
|
||||
@Desc("When an entity is invulnerable it can only be damaged by players increative mode.")
|
||||
private boolean invulnerable = false;
|
||||
|
||||
@Desc("When an entity is silent it will not produce any sound.")
|
||||
private boolean silent = false;
|
||||
|
||||
@Desc("Should this entity be allowed to pickup items")
|
||||
private boolean pickupItems = false;
|
||||
|
||||
@Desc("Should this entity be removed when far away")
|
||||
private boolean removable = false;
|
||||
|
||||
@Desc("Entity helmet equipment")
|
||||
private LootEntry helmet = null;
|
||||
|
||||
@Desc("Entity chestplate equipment")
|
||||
private LootEntry chestplate = null;
|
||||
|
||||
@Desc("Entity boots equipment")
|
||||
private LootEntry boots = null;
|
||||
|
||||
@Desc("Entity leggings equipment")
|
||||
private LootEntry leggings = null;
|
||||
|
||||
@Desc("Entity main hand equipment")
|
||||
private LootEntry mainHand = null;
|
||||
|
||||
@Desc("Entity off hand equipment")
|
||||
private LootEntry offHand = null;
|
||||
|
||||
@Desc("Make other entities ride this entity")
|
||||
private List<EntityDefinition> passengers = List.of();
|
||||
|
||||
@Desc("Attribute modifiers for this entity")
|
||||
private List<ItemAttributeModifier> attributes = List.of();
|
||||
|
||||
@Desc("Loot tables for drops. Only the tables list is honored for entities; mode and multiplier are ignored, and the tables replace vanilla drops entirely.")
|
||||
private LootSettings loot = new LootSettings();
|
||||
|
||||
@Desc("If specified, this entity will be leashed by this entity. I.e. THIS ENTITY Leashed by SPECIFIED. This has no effect on EnderDragons, Withers, Players, or Bats.Non-living entities excluding leashes will not persist as leashholders.")
|
||||
private EntityDefinition leashHolder = null;
|
||||
|
||||
@Desc("If specified, this entity will spawn with an effect")
|
||||
private AmbientEffect spawnEffect = null;
|
||||
|
||||
@Desc("Simply moves the entity from below the surface slowly out of the ground as a spawn-in effect")
|
||||
private boolean spawnEffectRiseOutOfGround = false;
|
||||
|
||||
@Desc("The main gene for a panda if the entity type is a panda. One of NORMAL, LAZY, WORRIED, PLAYFUL, BROWN, WEAK or AGGRESSIVE.")
|
||||
private String pandaMainGene = null;
|
||||
|
||||
@Desc("The hidden gene for a panda if the entity type is a panda. One of NORMAL, LAZY, WORRIED, PLAYFUL, BROWN, WEAK or AGGRESSIVE.")
|
||||
private String pandaHiddenGene = null;
|
||||
|
||||
@Desc("The this entity is ageable, set it's baby status")
|
||||
private boolean baby = false;
|
||||
|
||||
@Desc("If the entity should never be culled.")
|
||||
private boolean keepEntity = false;
|
||||
|
||||
@Desc("The surface type to spawn this mob on")
|
||||
private SpawnSurface surface = SpawnSurface.LAND;
|
||||
|
||||
@Ref(Reference.SPECIAL_ENTITY)
|
||||
@Desc("Create a mob from another plugin, such as Mythic Mobs. Should be in the format of a namespace of PluginName:MobName")
|
||||
private String specialType = "";
|
||||
|
||||
@Desc("Set to true if you want to apply all of the settings here to the mob, even though an external plugin has already done so.")
|
||||
private boolean applySettingsToCustomMobAnyways = false;
|
||||
|
||||
@Desc("Run raw commands when this entity is spawned. Use {x}, {y}, and {z} for location. /summon pig {x} {y} {z}")
|
||||
private List<SpawnCommand> rawCommands = List.of();
|
||||
|
||||
public EntityDefinition() {
|
||||
}
|
||||
|
||||
public String type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String reason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public String customName() {
|
||||
return customName;
|
||||
}
|
||||
|
||||
public boolean customNameVisible() {
|
||||
return customNameVisible;
|
||||
}
|
||||
|
||||
public boolean aware() {
|
||||
return aware;
|
||||
}
|
||||
|
||||
public boolean ai() {
|
||||
return ai;
|
||||
}
|
||||
|
||||
public boolean glowing() {
|
||||
return glowing;
|
||||
}
|
||||
|
||||
public boolean gravity() {
|
||||
return gravity;
|
||||
}
|
||||
|
||||
public boolean invulnerable() {
|
||||
return invulnerable;
|
||||
}
|
||||
|
||||
public boolean silent() {
|
||||
return silent;
|
||||
}
|
||||
|
||||
public boolean pickupItems() {
|
||||
return pickupItems;
|
||||
}
|
||||
|
||||
public boolean removable() {
|
||||
return removable;
|
||||
}
|
||||
|
||||
public LootEntry helmet() {
|
||||
return helmet;
|
||||
}
|
||||
|
||||
public LootEntry chestplate() {
|
||||
return chestplate;
|
||||
}
|
||||
|
||||
public LootEntry boots() {
|
||||
return boots;
|
||||
}
|
||||
|
||||
public LootEntry leggings() {
|
||||
return leggings;
|
||||
}
|
||||
|
||||
public LootEntry mainHand() {
|
||||
return mainHand;
|
||||
}
|
||||
|
||||
public LootEntry offHand() {
|
||||
return offHand;
|
||||
}
|
||||
|
||||
public List<EntityDefinition> passengers() {
|
||||
return passengers == null ? List.of() : Collections.unmodifiableList(passengers);
|
||||
}
|
||||
|
||||
public List<ItemAttributeModifier> attributes() {
|
||||
return attributes == null ? List.of() : Collections.unmodifiableList(attributes);
|
||||
}
|
||||
|
||||
/** The loot the entity drops when it dies; only its tables count. */
|
||||
public LootSettings loot() {
|
||||
return loot == null ? new LootSettings() : loot;
|
||||
}
|
||||
|
||||
public EntityDefinition leashHolder() {
|
||||
return leashHolder;
|
||||
}
|
||||
|
||||
public AmbientEffect spawnEffect() {
|
||||
return spawnEffect;
|
||||
}
|
||||
|
||||
public boolean spawnEffectRiseOutOfGround() {
|
||||
return spawnEffectRiseOutOfGround;
|
||||
}
|
||||
|
||||
public String pandaMainGene() {
|
||||
return pandaMainGene;
|
||||
}
|
||||
|
||||
public String pandaHiddenGene() {
|
||||
return pandaHiddenGene;
|
||||
}
|
||||
|
||||
public boolean baby() {
|
||||
return baby;
|
||||
}
|
||||
|
||||
public boolean keepEntity() {
|
||||
return keepEntity;
|
||||
}
|
||||
|
||||
public SpawnSurface surface() {
|
||||
return surface == null ? SpawnSurface.LAND : surface;
|
||||
}
|
||||
|
||||
public String specialType() {
|
||||
return specialType;
|
||||
}
|
||||
|
||||
/** Whether the entity is a mob of another plugin. */
|
||||
public boolean isSpecialType() {
|
||||
return specialType != null && !specialType.isEmpty();
|
||||
}
|
||||
|
||||
public boolean applySettingsToCustomMobAnyways() {
|
||||
return applySettingsToCustomMobAnyways;
|
||||
}
|
||||
|
||||
public List<SpawnCommand> rawCommands() {
|
||||
return rawCommands == null ? List.of() : Collections.unmodifiableList(rawCommands);
|
||||
}
|
||||
}
|
||||
@@ -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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.ResourceRef;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
@Snippet("iris/spawn/entity-spawn")
|
||||
@Desc("Represents an entity spawn during initial chunk generation")
|
||||
public final class EntitySpawn {
|
||||
@ResourceRef(EntityDefinition.class)
|
||||
@Required
|
||||
@Desc("The entity")
|
||||
private String entity = "";
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The 1 in RARITY chance for this entity to spawn")
|
||||
private int rarity = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The minumum of this entity to spawn")
|
||||
private int minSpawns = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The max of this entity to spawn")
|
||||
private int maxSpawns = 1;
|
||||
|
||||
public EntitySpawn() {
|
||||
}
|
||||
|
||||
/** The key of the entity of the pack. */
|
||||
public String entity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public int rarity() {
|
||||
return rarity;
|
||||
}
|
||||
|
||||
public int minSpawns() {
|
||||
return minSpawns;
|
||||
}
|
||||
|
||||
public int maxSpawns() {
|
||||
return maxSpawns;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.spawn;
|
||||
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.ResourceRef;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** Blocks of an object placement that get a {@link SpawnMarker}, an entry of the placement's {@code markers}. */
|
||||
@Snippet("iris/spawn/object-marker")
|
||||
@Desc("Find blocks to mark")
|
||||
public final class PlacementMarker {
|
||||
@Required
|
||||
@Desc("Find block types to mark")
|
||||
private List<BlockSpec> mark = List.of();
|
||||
@MinNumber(1)
|
||||
@MaxNumber(16)
|
||||
@Desc("The maximum amount of markers to place. Use these sparingly!")
|
||||
private int maximumMarkers = 8;
|
||||
@Desc("If true, markers will only be placed if the block matches the mark list perfectly.")
|
||||
private boolean exact = false;
|
||||
@Required
|
||||
@ResourceRef(SpawnMarker.class)
|
||||
@Desc("The marker to add")
|
||||
private String marker;
|
||||
|
||||
public PlacementMarker() {
|
||||
}
|
||||
|
||||
/** The blocks that get a marker. */
|
||||
public List<BlockSpec> mark() {
|
||||
return mark == null ? List.of() : Collections.unmodifiableList(mark);
|
||||
}
|
||||
|
||||
public int maximumMarkers() {
|
||||
return maximumMarkers;
|
||||
}
|
||||
|
||||
public boolean exact() {
|
||||
return exact;
|
||||
}
|
||||
|
||||
/** The key of the {@link SpawnMarker} to place. */
|
||||
public String marker() {
|
||||
return marker;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Snippet("iris/spawn/command")
|
||||
@Desc("Represents a set of Iris commands")
|
||||
public final class SpawnCommand {
|
||||
@Required
|
||||
@Desc("List of commands. Iris replaces {x} {y} and {z} with the location of the entity spawn")
|
||||
private List<String> commands = List.of();
|
||||
|
||||
@Desc("The delay for running the command. Instant by default")
|
||||
private long delay = 0;
|
||||
|
||||
@Desc("If this should be repeated (indefinitely, cannot be cancelled). This does not persist with server-restarts, so it only repeats when the chunk is generated.")
|
||||
private boolean repeat = false;
|
||||
|
||||
@Desc("The delay between repeats, in server ticks (by default 100, so 5 seconds)")
|
||||
private long repeatDelay = 100;
|
||||
|
||||
@Desc("The block of 24 hour time in which the command should execute.")
|
||||
private SpawnTimeBlock timeBlock = new SpawnTimeBlock();
|
||||
|
||||
@Desc("The weather that is required for the command to execute.")
|
||||
private SpawnWeather weather = SpawnWeather.ANY;
|
||||
|
||||
public SpawnCommand() {
|
||||
}
|
||||
|
||||
public List<String> commands() {
|
||||
return commands == null ? List.of() : Collections.unmodifiableList(commands);
|
||||
}
|
||||
|
||||
public long delay() {
|
||||
return delay;
|
||||
}
|
||||
|
||||
public boolean repeat() {
|
||||
return repeat;
|
||||
}
|
||||
|
||||
public long repeatDelay() {
|
||||
return repeatDelay;
|
||||
}
|
||||
|
||||
public SpawnTimeBlock timeBlock() {
|
||||
return timeBlock == null ? new SpawnTimeBlock() : timeBlock;
|
||||
}
|
||||
|
||||
public SpawnWeather weather() {
|
||||
return weather == null ? SpawnWeather.ANY : weather;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Snippet("iris/spawn/duration")
|
||||
@Desc("Represents a combined duration. Fill each property to add time into a single duration")
|
||||
public final class SpawnDuration {
|
||||
private static final long MILLISECONDS_PER_MINECRAFT_TICK = 50L;
|
||||
private static final long MILLISECONDS_PER_MINECRAFT_HOUR = 50_000L;
|
||||
private static final long MILLISECONDS_PER_MINECRAFT_DAY = 1_200_000L;
|
||||
private static final long MILLISECONDS_PER_MINECRAFT_WEEK = 8_400_000L;
|
||||
private static final long MILLISECONDS_PER_MINECRAFT_LUNAR_CYCLE = 9_600_000L;
|
||||
|
||||
@Desc("Milliseconds (1000ms = 1 second)")
|
||||
private int milliseconds = 0;
|
||||
|
||||
@Desc("Minecraft Ticks (20 minecraft ticks = 1 second)")
|
||||
private int minecraftTicks = 0;
|
||||
|
||||
@Desc("Seconds (60 seconds = 1 minute)")
|
||||
private int seconds = 0;
|
||||
|
||||
@Desc("Minutes (60 minutes = 1 hour)")
|
||||
private int minutes = 0;
|
||||
|
||||
@Desc("Minecraft Hours (about 50 real seconds)")
|
||||
private int minecraftHours = 0;
|
||||
|
||||
@Desc("Hours (24 hours = 1 day)")
|
||||
private int hours = 0;
|
||||
|
||||
@Desc("Minecraft Days (1 minecraft day = 20 real minutes)")
|
||||
private int minecraftDays = 0;
|
||||
|
||||
@Desc("Minecraft Weeks (7 minecraft days = 2 real hours and 20 real minutes)")
|
||||
private int minecraftWeeks = 0;
|
||||
|
||||
@Desc("Minecraft Lunar Cycles (8 minecraft days = 2 real hours and 40 real minutes)")
|
||||
private int minecraftLunarCycles = 0;
|
||||
|
||||
@Desc("REAL (not minecraft) Days")
|
||||
private int days = 0;
|
||||
|
||||
public SpawnDuration() {
|
||||
}
|
||||
|
||||
public long toMilliseconds() {
|
||||
return milliseconds
|
||||
+ TimeUnit.SECONDS.toMillis(seconds)
|
||||
+ TimeUnit.MINUTES.toMillis(minutes)
|
||||
+ TimeUnit.HOURS.toMillis(hours)
|
||||
+ TimeUnit.DAYS.toMillis(days)
|
||||
+ (minecraftTicks * MILLISECONDS_PER_MINECRAFT_TICK)
|
||||
+ (minecraftHours * MILLISECONDS_PER_MINECRAFT_HOUR)
|
||||
+ (minecraftDays * MILLISECONDS_PER_MINECRAFT_DAY)
|
||||
+ (minecraftWeeks * MILLISECONDS_PER_MINECRAFT_WEEK)
|
||||
+ (minecraftLunarCycles * MILLISECONDS_PER_MINECRAFT_LUNAR_CYCLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Terrain modes are used to decide the generator type currently used")
|
||||
public enum SpawnGroup {
|
||||
@Desc("Spawns on the terrain surface")
|
||||
NORMAL,
|
||||
|
||||
@Desc("Spawns in cave-air and low light level areas")
|
||||
CAVE,
|
||||
|
||||
@Desc("Spawns underwater")
|
||||
UNDERWATER,
|
||||
|
||||
@Desc("Spawns in beaches")
|
||||
BEACH
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.ResourceRef;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** A marker of the pack, one file of {@code markers/}: object placements put markers in the world and a marker names the spawners that fire there. */
|
||||
@Desc("Represents a marker")
|
||||
public final class SpawnMarker {
|
||||
@Desc("A list of spawners to add to anywhere this marker is.")
|
||||
@ResourceRef(Spawner.class)
|
||||
private List<String> spawners = List.of();
|
||||
|
||||
@Desc("Remove this marker when the block it's assigned to is changed.")
|
||||
private boolean removeOnChange = true;
|
||||
|
||||
@Desc("If true, markers will only be placed here if there is 2 air blocks above it.")
|
||||
private boolean emptyAbove = true;
|
||||
|
||||
@Desc("If this marker is used, what is the chance it removes itself. For example 25% (0.25) would mean that on average 4 uses will remove a specific marker. Set this below 0 (-1) to never exhaust & set this to 1 or higher to always exhaust on first use.")
|
||||
private double exhaustionChance = 0;
|
||||
|
||||
public SpawnMarker() {
|
||||
}
|
||||
|
||||
/** The keys of the spawners that fire at the marker. */
|
||||
public List<String> spawners() {
|
||||
return spawners == null ? List.of() : Collections.unmodifiableList(spawners);
|
||||
}
|
||||
|
||||
public boolean removeOnChange() {
|
||||
return removeOnChange;
|
||||
}
|
||||
|
||||
public boolean emptyAbove() {
|
||||
return emptyAbove;
|
||||
}
|
||||
|
||||
public double exhaustionChance() {
|
||||
return exhaustionChance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
@Snippet("iris/spawn/rate")
|
||||
@Desc("Represents a count of something per time duration")
|
||||
public final class SpawnRate {
|
||||
@Desc("The amount of things. Leave 0 for infinite (meaning always spawn whenever)")
|
||||
private int amount = 0;
|
||||
|
||||
@Desc("The time interval. Leave blank for infinite 0 (meaning always spawn all the time)")
|
||||
private SpawnDuration per = new SpawnDuration();
|
||||
|
||||
public SpawnRate() {
|
||||
}
|
||||
|
||||
/** The milliseconds between two things: the interval divided by the amount, at least 1. */
|
||||
public long interval() {
|
||||
long t = duration().toMilliseconds() / (amount == 0 ? 1 : amount);
|
||||
return Math.abs(t <= 0 ? 1 : t);
|
||||
}
|
||||
|
||||
/** Whether there is no limit: no interval was given. */
|
||||
public boolean isInfinite() {
|
||||
return duration().toMilliseconds() == 0;
|
||||
}
|
||||
|
||||
private SpawnDuration duration() {
|
||||
return per == null ? new SpawnDuration() : per;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("The type of surface entities should spawn on")
|
||||
public enum SpawnSurface {
|
||||
|
||||
@Desc("Land surfaces")
|
||||
LAND,
|
||||
|
||||
@Desc("Any surfaces animals can spawn on, such as dirt, grass and podzol")
|
||||
ANIMAL,
|
||||
|
||||
@Desc("Within the water")
|
||||
WATER,
|
||||
|
||||
@Desc("On land or on water")
|
||||
OVERWORLD,
|
||||
|
||||
@Desc("Within lava")
|
||||
LAVA
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Snippet;
|
||||
|
||||
@Snippet("iris/spawn/time-block")
|
||||
@Desc("Represents a time of day (24h time, not 12h am/pm). Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||
public final class SpawnTimeBlock {
|
||||
private static final double NEVER = -1;
|
||||
|
||||
@Desc("The beginning hour. Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||
private double startHour = 0;
|
||||
|
||||
@Desc("The ending hour. Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||
private double endHour = 0;
|
||||
|
||||
public SpawnTimeBlock() {
|
||||
}
|
||||
|
||||
/** Whether {@code hour}, a time of day from 0 to 24, lies in the block; a block that wraps past midnight includes both ends. */
|
||||
public boolean contains(double hour) {
|
||||
if (startHour == endHour) {
|
||||
return endHour != NEVER;
|
||||
}
|
||||
|
||||
if (startHour > endHour) {
|
||||
return hour >= startHour || hour <= endHour;
|
||||
}
|
||||
|
||||
return hour >= startHour && hour <= endHour;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Represents a weather type")
|
||||
public enum SpawnWeather {
|
||||
@Desc("Represents when weather is not causing downfall")
|
||||
NONE,
|
||||
|
||||
@Desc("Represents rain or snow")
|
||||
DOWNFALL,
|
||||
|
||||
@Desc("Represents rain or snow with thunder")
|
||||
DOWNFALL_WITH_THUNDER,
|
||||
|
||||
@Desc("Any weather")
|
||||
ANY;
|
||||
|
||||
/** Whether the weather of a world, which is {@code storming} and {@code thundering} or neither, is this one. */
|
||||
public boolean matches(boolean storming, boolean thundering) {
|
||||
return switch (this) {
|
||||
case NONE -> !storming && !thundering;
|
||||
case DOWNFALL -> storming;
|
||||
case DOWNFALL_WITH_THUNDER -> storming && thundering;
|
||||
case ANY -> true;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.spawn;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Range;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** A spawner of the pack, one file of {@code spawners/}: which entities appear where, when and how often. */
|
||||
@Desc("Represents an entity spawn during initial chunk generation")
|
||||
public final class Spawner {
|
||||
@Desc("The entity spawns to add")
|
||||
private List<EntitySpawn> spawns = List.of();
|
||||
|
||||
@Desc("The entity spawns to add initially. EXECUTES PER CHUNK!")
|
||||
private List<EntitySpawn> initialSpawns = List.of();
|
||||
|
||||
@Desc("This spawner will not spawn in a given chunk if that chunk has more than the defined amount of living entities.")
|
||||
private int maxEntitiesPerChunk = 1;
|
||||
|
||||
@Desc("The block of 24 hour time to contain this spawn in.")
|
||||
private SpawnTimeBlock timeBlock = new SpawnTimeBlock();
|
||||
|
||||
@Desc("The weather condition required for this spawner to fire.")
|
||||
private SpawnWeather weather = SpawnWeather.ANY;
|
||||
|
||||
@Desc("The maximum rate this spawner can fire")
|
||||
private SpawnRate maximumRate = new SpawnRate();
|
||||
|
||||
@Desc("The maximum rate this spawner can fire on a specific chunk")
|
||||
private SpawnRate maximumRatePerChunk = new SpawnRate();
|
||||
|
||||
@Desc("The light levels this spawn is allowed to run in (0-15 inclusive)")
|
||||
private Range allowedLightLevels = Range.of(0, 15);
|
||||
|
||||
@Desc("Where should these spawns be placed")
|
||||
private SpawnGroup group = SpawnGroup.NORMAL;
|
||||
|
||||
public Spawner() {
|
||||
}
|
||||
|
||||
public List<EntitySpawn> spawns() {
|
||||
return spawns == null ? List.of() : Collections.unmodifiableList(spawns);
|
||||
}
|
||||
|
||||
public List<EntitySpawn> initialSpawns() {
|
||||
return initialSpawns == null ? List.of() : Collections.unmodifiableList(initialSpawns);
|
||||
}
|
||||
|
||||
public int maxEntitiesPerChunk() {
|
||||
return maxEntitiesPerChunk;
|
||||
}
|
||||
|
||||
public SpawnTimeBlock timeBlock() {
|
||||
return timeBlock == null ? new SpawnTimeBlock() : timeBlock;
|
||||
}
|
||||
|
||||
public SpawnWeather weather() {
|
||||
return weather == null ? SpawnWeather.ANY : weather;
|
||||
}
|
||||
|
||||
public SpawnRate maximumRate() {
|
||||
return maximumRate == null ? new SpawnRate() : maximumRate;
|
||||
}
|
||||
|
||||
public SpawnRate maximumRatePerChunk() {
|
||||
return maximumRatePerChunk == null ? new SpawnRate() : maximumRatePerChunk;
|
||||
}
|
||||
|
||||
public Range allowedLightLevels() {
|
||||
return allowedLightLevels == null ? Range.of(0, 15) : allowedLightLevels;
|
||||
}
|
||||
|
||||
public SpawnGroup group() {
|
||||
return group == null ? SpawnGroup.NORMAL : group;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.stilt;
|
||||
|
||||
import com.volmit.object.ObjectBlock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The bottom and top layers of the blocks a stilt can repeat, with their positions already transformed
|
||||
* around the anchor. Each layer keeps the blocks at its lowest or highest height seen so far.
|
||||
*/
|
||||
public final class StiltLayers {
|
||||
private final List<ObjectBlock> bottom = new ArrayList<>();
|
||||
private final List<ObjectBlock> top = new ArrayList<>();
|
||||
private int bottomY = Integer.MAX_VALUE;
|
||||
private int topY = Integer.MIN_VALUE;
|
||||
|
||||
public void include(ObjectBlock transformed) {
|
||||
int y = transformed.position().y();
|
||||
if (y < bottomY) {
|
||||
bottomY = y;
|
||||
bottom.clear();
|
||||
}
|
||||
if (y == bottomY) {
|
||||
bottom.add(transformed);
|
||||
}
|
||||
if (y > topY) {
|
||||
topY = y;
|
||||
top.clear();
|
||||
}
|
||||
if (y == topY) {
|
||||
top.add(transformed);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return bottom.isEmpty();
|
||||
}
|
||||
|
||||
public List<ObjectBlock> bottom() {
|
||||
return Collections.unmodifiableList(bottom);
|
||||
}
|
||||
|
||||
public List<ObjectBlock> top() {
|
||||
return Collections.unmodifiableList(top);
|
||||
}
|
||||
|
||||
public int bottomY() {
|
||||
return bottomY;
|
||||
}
|
||||
|
||||
public int topY() {
|
||||
return topY;
|
||||
}
|
||||
}
|
||||
@@ -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("iris/stilt/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,34 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Iris extension: says that a text option names structures of Iris's structure model by key, which Iris completes in
|
||||
* studio and carries along when it exports the pack. The structure model is Iris's own resource kind, whose class a
|
||||
* module cannot see, so {@code @ResourceRef} cannot name it; to another host the option is plain text.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface IrisStructureRef {
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Required;
|
||||
import com.volmit.vanilla.JigsawOverrides;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* One platform structure a structure placement starts itself, written as
|
||||
* {@code {"structure": "minecraft:ancient_city", "weight": 2, "jigsaw": {...}}}. IrisApi types only.
|
||||
*/
|
||||
@Desc("A live vanilla, datapack, or modded structure generated by Minecraft at an Iris-controlled placement.")
|
||||
public final class NativeStructureSource {
|
||||
@Required
|
||||
@Ref(Reference.STRUCTURE)
|
||||
@Desc("Registered structure key. The source retains its native generator, pieces, templates, processors, entities, markers, and data.")
|
||||
private String structure = "";
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Relative selection weight when a placement offers multiple native structure sources.")
|
||||
private int weight = 1;
|
||||
|
||||
@Desc("Optional jigsaw-only assembly overrides. Null preserves the complete registered structure definition.")
|
||||
private JigsawOverrides jigsaw = null;
|
||||
|
||||
public NativeStructureSource() {
|
||||
}
|
||||
|
||||
/** The registry key of the platform structure, as the pack wrote it. */
|
||||
public String structure() {
|
||||
return structure;
|
||||
}
|
||||
|
||||
public int weight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
/** The overrides of the platform's jigsaw assembly; empty to keep its own. */
|
||||
public Optional<JigsawOverrides> jigsaw() {
|
||||
return Optional.ofNullable(jigsaw);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
/** Whether a structure placement replaces the platform structure its structures stand in for. */
|
||||
@Desc("Controls whether an Iris structure placement suppresses its imported native source.")
|
||||
public enum NativeStructureSuppression {
|
||||
@Desc("Leaves native generation enabled alongside this Iris structure placement.")
|
||||
NONE,
|
||||
|
||||
@Desc("Suppresses the structure's vanillaSource when used by a validated dimension-level replacement placement.")
|
||||
REPLACE_SOURCE
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** One entry of {@link StructureSettings#adjustments()}: how the platform's own starts of the structures it matches are moved and fitted. */
|
||||
@Desc("A per-structure adjustment applied to vanilla, mod, and datapack structures that still generate natively (those NOT suppressed by an Iris 'structures' placement). Vertical shifts move the structure start, pieces, bounds, and jigsaw metadata together before references and placement. Intersecting trees are cleared automatically inside structure piece envelopes; optional postprocessing can build palette-driven foundation columns.")
|
||||
public final class StructureAdjustment {
|
||||
@Ref(Reference.STRUCTURE_PREFIX)
|
||||
@Desc("Structure keys this adjustment applies to, e.g. 'minecraft:stronghold'. A namespace:path prefix also matches, so 'minecraft:village' adjusts every village variant and 'minecraft:ruined_portal' adjusts every ruined portal. Empty matches nothing.")
|
||||
private List<String> match = List.of();
|
||||
|
||||
@MinNumber(-512)
|
||||
@MaxNumber(512)
|
||||
@Desc("Vertical block offset. Negative pushes the structure down, positive lifts it. The resolved shift is clamped so the structure remains inside the world's vertical build bounds.")
|
||||
private int yShift = 0;
|
||||
|
||||
@Desc("Optional absolute world Y band. The structure is relocated so its vertical midpoint lands inside the band, deterministically from its start chunk and clamped to the world's build bounds. Precedence: preserveSourceY wins over yBand, and yBand wins over both yShift and Iris burial repositioning. Structures with a fixed vanilla alignment (ocean monument sea level, desert and jungle pyramid surface fit) ignore it.")
|
||||
private StructureYBand yBand = null;
|
||||
|
||||
@Desc("When true, skip Iris burial repositioning so the structure keeps the Y its own vanilla placement chose. Underground structures are otherwise pushed below the lowest solid column across their whole footprint, which hides terrain-aware structures such as mineshafts that intentionally breach cliffs and surfaces. Vertical shifts still apply on top of the preserved Y: this dimension's undergroundYShift plus every matching adjustment's yShift.")
|
||||
private boolean preserveSourceY = false;
|
||||
|
||||
@Desc("Optional foundation columns placed beneath the native structure piece bases after placement.")
|
||||
private StructureStilts stilt = null;
|
||||
|
||||
@Desc("Optional terrain integration override. VACUUM raises surface terrain from processed solid rigid-template foundations at or below each authored ground plane with a 12-block falloff without lowering existing ground. BORE and FORCE_CARVE clear every intersecting chunk before native pieces are placed, while ENCASE fills it with solid blocks instead. Left unset, SOURCE replays the registered structure's authored terrain adaptation, including surface fitting, burial, and encapsulation.")
|
||||
private StructureTerrain terrain = null;
|
||||
|
||||
public StructureAdjustment() {
|
||||
}
|
||||
|
||||
public StructureAdjustment(List<String> match, int yShift, StructureYBand yBand, boolean preserveSourceY, StructureStilts stilt,
|
||||
StructureTerrain terrain) {
|
||||
this.match = List.copyOf(match);
|
||||
this.yShift = yShift;
|
||||
this.yBand = yBand;
|
||||
this.preserveSourceY = preserveSourceY;
|
||||
this.stilt = stilt;
|
||||
this.terrain = terrain;
|
||||
}
|
||||
|
||||
/** Family patterns of the structures this adjustment applies to. */
|
||||
public List<String> match() {
|
||||
return StructureSettings.listOrEmpty(match);
|
||||
}
|
||||
|
||||
public int yShift() {
|
||||
return yShift;
|
||||
}
|
||||
|
||||
public Optional<StructureYBand> yBand() {
|
||||
return Optional.ofNullable(yBand);
|
||||
}
|
||||
|
||||
public boolean preserveSourceY() {
|
||||
return preserveSourceY;
|
||||
}
|
||||
|
||||
public Optional<StructureStilts> stilt() {
|
||||
return Optional.ofNullable(stilt);
|
||||
}
|
||||
|
||||
public Optional<StructureTerrain> terrain() {
|
||||
return Optional.ofNullable(terrain);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.structure;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
/** How a structure placement picks the height it anchors a structure at. The placement identity hashes the order. */
|
||||
@Desc("Selects the vertical environment used to anchor an Iris structure placement.")
|
||||
public enum StructureAnchorMode {
|
||||
@Desc("Preserve the historical underground boolean behavior.")
|
||||
LEGACY,
|
||||
|
||||
@Desc("Anchor to the terrain surface and use minHeight/maxHeight as a surface gate.")
|
||||
SURFACE,
|
||||
|
||||
@Desc("Choose a deterministic Y inside the minHeight/maxHeight band.")
|
||||
HEIGHT_BAND,
|
||||
|
||||
@Desc("Anchor in carved space with solid support below.")
|
||||
CAVE_FLOOR,
|
||||
|
||||
@Desc("Anchor in carved space with solid support above.")
|
||||
CAVE_CEILING,
|
||||
|
||||
@Desc("Anchor in carved space without nearby floor or ceiling support.")
|
||||
CAVE_CENTER,
|
||||
|
||||
@Desc("Anchor at any carved-space position.")
|
||||
CAVE_ANY;
|
||||
|
||||
/** Whether the anchor looks for carved space. */
|
||||
public boolean isCave() {
|
||||
return switch (this) {
|
||||
case CAVE_FLOOR, CAVE_CEILING, CAVE_CENTER, CAVE_ANY -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Controls the shape of the expanded terrain carve around an overbored structure.")
|
||||
public enum StructureCarveShape {
|
||||
@Desc("Carves the full expanded rectangular volume with straight walls, ceiling, and floor.")
|
||||
BOX,
|
||||
|
||||
@Desc("Carves a smooth rounded volume around the structure without erosion noise.")
|
||||
ROUNDED,
|
||||
|
||||
@Desc("Carves a rounded volume whose outer boundary is eroded by deterministic noise.")
|
||||
ERODED;
|
||||
|
||||
private static final double ERODED_CEILING_GROWTH = 0.8D;
|
||||
|
||||
public double maximumCeilingScale() {
|
||||
return maximumCeilingScale(1D);
|
||||
}
|
||||
|
||||
/** How far above its configured head room a carve of this shape may reach, as a multiple of it. */
|
||||
public double maximumCeilingScale(double erosionStrength) {
|
||||
double strength = Double.isFinite(erosionStrength)
|
||||
? Math.max(0D, Math.min(1D, erosionStrength)) : 1D;
|
||||
return switch (this) {
|
||||
case BOX, ROUNDED -> 1D;
|
||||
case ERODED -> 1D + ERODED_CEILING_GROWTH * strength;
|
||||
};
|
||||
}
|
||||
|
||||
public int maximumCeilingExtension(int configuredHeight) {
|
||||
return maximumCeilingExtension(configuredHeight, 1D);
|
||||
}
|
||||
|
||||
public int maximumCeilingExtension(int configuredHeight, double erosionStrength) {
|
||||
return (int) Math.ceil(Math.max(0, configuredHeight) * maximumCeilingScale(erosionStrength));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
/** How a structure placement scatters its starts. The placement identity hashes the order. */
|
||||
@Desc("Controls how structure start positions are scattered across the world.")
|
||||
public enum StructureDistribution {
|
||||
@Desc("Vanilla-style spacing/separation grid. One placement attempt per grid cell, randomly offset within it by the separation. Use spacing, separation and salt.")
|
||||
RANDOM_SPREAD,
|
||||
|
||||
@Desc("A per-chunk probability roll, like object density. Use density (0-1).")
|
||||
DENSITY,
|
||||
|
||||
@Desc("Concentric rings around the world origin, like vanilla strongholds. Use rings.")
|
||||
CONCENTRIC_RINGS
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.generation.InvocationContext;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* What {@code iris:structure} asks of Iris: Iris places its jigsaw structures itself. The structure model (structures,
|
||||
* pools, pieces), the assembler that builds a structure from them and the locator that spreads them over the world are
|
||||
* Iris's, shared with the jigsaw studio and the structure importers and exporters. Iris offers it as an extension of its
|
||||
* worlds and of the settings of the pack it loads: {@code world.extension(StructureHost.class)}.
|
||||
*/
|
||||
public interface StructureHost {
|
||||
/** Places the structures that start in the chunk whose mantle the mantle invocation {@code context} generates. */
|
||||
void placeChunk(InvocationContext context);
|
||||
|
||||
/** How far, in blocks along X and Z, a structure may write beyond the chunk it starts in. */
|
||||
int reach();
|
||||
|
||||
/** The loot tables the structure gives its pieces' containers; empty when the pack has no such structure. */
|
||||
Optional<List<String>> lootTables(ResourceId structure);
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.ResourceRef;
|
||||
import com.volmit.world.PackBiome;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Where and how often the structures of a dimension, region or biome start, written as one entry of its
|
||||
* {@code "structures": [...]}: the pack's own structures to assemble or the platform's to start natively, the
|
||||
* distribution of the starts, the height they anchor at, and how they meet the terrain. IrisApi types only.
|
||||
*/
|
||||
@Desc("Attaches structures to a biome, region or dimension and controls where and how often they generate. This is independent of a structure's own native generation, so you can add custom placements in tandem with native generation or instead of it.")
|
||||
public final class StructurePlacement {
|
||||
@IrisStructureRef
|
||||
@Desc("Editable Iris assembly resources offered by this placement. Leave empty when nativeStructures supplies the source.")
|
||||
private List<String> structures = List.of();
|
||||
|
||||
@Desc("Live registered vanilla, datapack, and modded structures offered by this placement. Minecraft runs their native generator directly, independent of normal biome or dimension eligibility.")
|
||||
private List<NativeStructureSource> nativeStructures = List.of();
|
||||
|
||||
@Desc("Stable authored identity for this placement. Set this when multiple placements use the same structure and settings. When empty, Iris derives identity from the placement content so list reordering does not move generated structures.")
|
||||
private String placementId = "";
|
||||
|
||||
@Desc("Controls native replacement for this placement. REPLACE_SOURCE suppresses each selected Iris structure's vanillaSource or registered native source, and is honored only for dimension-level placements. NONE leaves native generation untouched.")
|
||||
private NativeStructureSuppression nativeSuppression = NativeStructureSuppression.NONE;
|
||||
|
||||
@Desc("How start positions are scattered.")
|
||||
private StructureDistribution distribution = StructureDistribution.RANDOM_SPREAD;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(4096)
|
||||
@Desc("RANDOM_SPREAD only: the grid cell size in chunks. One placement attempt per cell. Larger = rarer.")
|
||||
private int spacing = 32;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("RANDOM_SPREAD only: the minimum chunk separation between placements within the grid. Must be smaller than spacing.")
|
||||
private int separation = 8;
|
||||
|
||||
@Desc("RANDOM_SPREAD only: a salt mixed into the placement RNG so different structures using the same spacing do not stack.")
|
||||
private int salt = 165745296;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("DENSITY only: the per-chunk probability (0-1) of a placement starting in a chunk.")
|
||||
private double density = 0.02;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("CONCENTRIC_RINGS only: the number of placements distributed across the rings.")
|
||||
private int ringCount = 128;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("CONCENTRIC_RINGS only: the ring spacing in chunks.")
|
||||
private int ringDistance = 32;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("CONCENTRIC_RINGS only: how many placements share each ring before moving outward.")
|
||||
private int ringSpread = 3;
|
||||
|
||||
@Desc("Minimum world Y. SURFACE uses it as a terrain-height gate; HEIGHT_BAND and cave anchors use it as the lower candidate bound. LEGACY follows underground.")
|
||||
private int minHeight = -2032;
|
||||
|
||||
@Desc("Maximum world Y. SURFACE uses it as a terrain-height gate; HEIGHT_BAND and cave anchors use it as the upper candidate bound. LEGACY follows underground.")
|
||||
private int maxHeight = 2032;
|
||||
|
||||
@Desc("LEGACY anchor only: if true, choose a deterministic world Y inside [minHeight, maxHeight]; otherwise gate the terrain surface. Explicit anchor modes override this field.")
|
||||
private boolean underground = false;
|
||||
|
||||
@Desc("Vertical anchor policy. LEGACY preserves the underground boolean. Cave modes search existing carved-space data and implicitly behave as underground placements.")
|
||||
private StructureAnchorMode anchor = StructureAnchorMode.LEGACY;
|
||||
|
||||
@ResourceRef(PackBiome.class)
|
||||
@Desc("Optional cave-biome allowlist for cave anchor modes. Empty accepts the cave biome resolved at the selected anchor. Entries match by load key, including prefix matches.")
|
||||
private List<String> caveBiomes = List.of();
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Desc("Cave anchor modes only: deterministic X/Z columns tested inside the start chunk before the placement is skipped.")
|
||||
private int caveAnchorAttempts = 8;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(16)
|
||||
@Desc("Cave anchor modes only: vertical scan step in blocks. One is exact; larger values trade precision for speed.")
|
||||
private int caveAnchorScanStep = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Desc("Cave anchor modes only: minimum contiguous carved-space height required at the selected anchor.")
|
||||
private int caveMinimumClearance = 3;
|
||||
|
||||
@Desc("Terrain integration for this placement. The editable structures backend supports SOURCE, PRESERVE, BORE, and FORCE_CARVE. The nativeStructures backend supports every terrain mode.")
|
||||
private StructureTerrain terrain = new StructureTerrain();
|
||||
|
||||
@Desc("Optional foundation columns placed beneath the assembled structure's occupied bottom cells. Columns pass through air and fluids until they reach solid ground, up to maxDepth.")
|
||||
private StructureStilts stilt = null;
|
||||
|
||||
@Desc("If false, the placement is skipped when its selected surface or cave column is submerged.")
|
||||
private boolean underwater = false;
|
||||
|
||||
public StructurePlacement() {
|
||||
}
|
||||
|
||||
/** Keys of the pack's structures the placement assembles, one picked per start. */
|
||||
public List<String> structures() {
|
||||
return listOrEmpty(structures);
|
||||
}
|
||||
|
||||
/** The platform structures the placement starts natively, one picked per start by weight. */
|
||||
public List<NativeStructureSource> nativeStructures() {
|
||||
return listOrEmpty(nativeStructures);
|
||||
}
|
||||
|
||||
public String placementId() {
|
||||
return placementId;
|
||||
}
|
||||
|
||||
public NativeStructureSuppression nativeSuppression() {
|
||||
return nativeSuppression == null ? NativeStructureSuppression.NONE : nativeSuppression;
|
||||
}
|
||||
|
||||
public StructureDistribution distribution() {
|
||||
return distribution == null ? StructureDistribution.RANDOM_SPREAD : distribution;
|
||||
}
|
||||
|
||||
public int spacing() {
|
||||
return spacing;
|
||||
}
|
||||
|
||||
public int separation() {
|
||||
return separation;
|
||||
}
|
||||
|
||||
public int salt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
public double density() {
|
||||
return density;
|
||||
}
|
||||
|
||||
public int ringCount() {
|
||||
return ringCount;
|
||||
}
|
||||
|
||||
public int ringDistance() {
|
||||
return ringDistance;
|
||||
}
|
||||
|
||||
public int ringSpread() {
|
||||
return ringSpread;
|
||||
}
|
||||
|
||||
public int minHeight() {
|
||||
return minHeight;
|
||||
}
|
||||
|
||||
public int maxHeight() {
|
||||
return maxHeight;
|
||||
}
|
||||
|
||||
public boolean underground() {
|
||||
return underground;
|
||||
}
|
||||
|
||||
/** The anchor as written; {@link #resolvedAnchor} says what {@code LEGACY} means for this placement. */
|
||||
public StructureAnchorMode anchor() {
|
||||
return anchor == null ? StructureAnchorMode.LEGACY : anchor;
|
||||
}
|
||||
|
||||
/** Cave biome keys or key prefixes a cave anchor accepts; empty for any. */
|
||||
public List<String> caveBiomes() {
|
||||
return listOrEmpty(caveBiomes);
|
||||
}
|
||||
|
||||
public int caveAnchorAttempts() {
|
||||
return caveAnchorAttempts;
|
||||
}
|
||||
|
||||
public int caveAnchorScanStep() {
|
||||
return caveAnchorScanStep;
|
||||
}
|
||||
|
||||
public int caveMinimumClearance() {
|
||||
return caveMinimumClearance;
|
||||
}
|
||||
|
||||
/** How the placement's structures meet the terrain; the defaults when the pack wrote none. */
|
||||
public StructureTerrain resolvedTerrain() {
|
||||
return terrain == null ? new StructureTerrain() : terrain;
|
||||
}
|
||||
|
||||
/** The foundation columns under the structures; empty for none. */
|
||||
public Optional<StructureStilts> stilt() {
|
||||
return Optional.ofNullable(stilt);
|
||||
}
|
||||
|
||||
public boolean underwater() {
|
||||
return underwater;
|
||||
}
|
||||
|
||||
public boolean hasIrisStructures() {
|
||||
return !structures().isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasNativeStructures() {
|
||||
return !nativeStructures().isEmpty();
|
||||
}
|
||||
|
||||
/** The anchor this placement uses: {@code LEGACY} is the band when {@link #underground}, else the surface. */
|
||||
public StructureAnchorMode resolvedAnchor() {
|
||||
if (anchor() == StructureAnchorMode.LEGACY) {
|
||||
return underground ? StructureAnchorMode.HEIGHT_BAND : StructureAnchorMode.SURFACE;
|
||||
}
|
||||
return anchor();
|
||||
}
|
||||
|
||||
public boolean isAnchoredUnderground() {
|
||||
StructureAnchorMode activeAnchor = resolvedAnchor();
|
||||
return activeAnchor == StructureAnchorMode.HEIGHT_BAND || activeAnchor.isCave();
|
||||
}
|
||||
|
||||
private static <T> List<T> listOrEmpty(List<T> list) {
|
||||
return list == null ? List.of() : Collections.unmodifiableList(list);
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The structure placements of a dimension, region or biome, written as {@code "structures": [...]}: one
|
||||
* {@link StructurePlacement} per entry. IrisApi types only.
|
||||
*/
|
||||
@Desc("Iris structure placements of this dimension, region or biome: where and how often its structures start.")
|
||||
@Feature(id = "iris:structure/placements", name = "Structure placements", key = "structures", root = "placements",
|
||||
targets = {Level.DIMENSION, Level.REGION, Level.BIOME})
|
||||
public final class StructurePlacementSettings implements IrisFeature {
|
||||
@Desc("Iris structure placements, each independent of the others.")
|
||||
private List<StructurePlacement> placements = List.of();
|
||||
|
||||
public StructurePlacementSettings() {
|
||||
}
|
||||
|
||||
public List<StructurePlacement> placements() {
|
||||
return placements == null ? List.of() : Collections.unmodifiableList(placements);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.structure;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
|
||||
/** One entry of {@link StructureSettings#frequencyOverrides()}: how often the structures of one platform structure set start. */
|
||||
@Desc("An exact registered structure-set frequency multiplier. Iris retains the set's structures, weights, biome eligibility, placement algorithm, salt, exclusion zone, starts, processors, mobs, loot, and locate behavior while scaling only its native placement density.")
|
||||
public final class StructureSetFrequency {
|
||||
@Ref(Reference.STRUCTURE_SET)
|
||||
@Desc("Exact registered structure-set key, for example 'minecraft:nether_complexes'. Structure keys such as 'minecraft:fortress' are not valid here.")
|
||||
private String structureSet = "";
|
||||
|
||||
@MinNumber(0.01)
|
||||
@MaxNumber(16)
|
||||
@Desc("Requested placement-density multiplier. Random-spread sets scale their placement frequency first and then their integer chunk spacing; integer spacing and separation constraints can make the realized increase slightly lower or higher. The default 1 leaves the registered placement unchanged.")
|
||||
private double multiplier = 1D;
|
||||
|
||||
public StructureSetFrequency() {
|
||||
}
|
||||
|
||||
public StructureSetFrequency(String structureSet, double multiplier) {
|
||||
this.structureSet = structureSet;
|
||||
this.multiplier = multiplier;
|
||||
}
|
||||
|
||||
public String structureSet() {
|
||||
return structureSet == null ? "" : structureSet;
|
||||
}
|
||||
|
||||
public double multiplier() {
|
||||
return multiplier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* How a dimension treats the platform's own structures (vanilla, data pack and mod structures), written as
|
||||
* {@code "importedStructures": {"disabled": [...], "adjustments": [...]}}: which ones it disables, how the ones that still
|
||||
* generate are moved and fitted, how often structure sets start, and whether installed data packs may replace the
|
||||
* platform's own definitions. IrisApi types only.
|
||||
*/
|
||||
@Desc("Controls native vanilla, mod, and ingested datapack structure generation for this dimension. Every registered structure generates through its native placement unless its key matches 'disabled', equals a key in 'disabledExact', or a viable dimension-level Iris placement explicitly replaces its source. Family matching uses namespace, slash, or underscore boundaries, while exact matching compares normalized complete keys only. Run '/iris module structure list' to dump every valid key. Only affects newly generated chunks and is separate from Iris structure placements.")
|
||||
@Feature(id = "iris:structure", name = "Structures", key = "importedStructures", targets = Level.DIMENSION)
|
||||
public final class StructureSettings implements IrisFeature {
|
||||
@Ref(Reference.STRUCTURE_PREFIX)
|
||||
@Desc("Structure keys to deny explicitly, e.g. 'minecraft:stronghold'. A namespace:path prefix also matches, so 'minecraft:village' disables every village variant and 'minecraft:ruined_portal' disables every ruined portal. Every key not matched here remains enabled.")
|
||||
private List<String> disabled = List.of();
|
||||
|
||||
@Ref(Reference.STRUCTURE)
|
||||
@Desc("Exact structure keys to deny after trimming and case normalization. Unlike 'disabled', entries never match key families, so 'minecraft:ruined_portal' does not disable 'minecraft:ruined_portal_nether'.")
|
||||
private List<String> disabledExact = List.of();
|
||||
|
||||
@MinNumber(-512)
|
||||
@MaxNumber(512)
|
||||
@Desc("Vertical block offset applied only to UNDERGROUND vanilla structures (the UNDERGROUND_STRUCTURES, UNDERGROUND_DECORATION, and STRONGHOLDS generation steps: strongholds, trial chambers, mineshafts, ancient cities, etc.). Surface structures (villages, outposts, etc.) are never shifted. Use a negative value to push deep structures lower when your dimension's sea/terrain level differs from vanilla's (e.g. -64 if you lowered the fluid height to 0). 0 = no shift.")
|
||||
private int undergroundYShift = 0;
|
||||
|
||||
@Desc("Controls whether ingested datapacks may replace minecraft-namespaced structure definitions, sets, pools, and templates. When false, those overrides are stripped from installed datapack copies so vanilla definitions stay intact. Non-minecraft structures from datapacks and mods remain governed by disabled because namespace alone cannot identify their origin. Resolved globally across loaded packs: if any dimension sets this false, minecraft-namespaced overrides are stripped from every installed datapack copy.")
|
||||
private boolean datapackOverrides = true;
|
||||
|
||||
@Desc("Exact registered structure-set frequency overrides for native generation. The last entry for a normalized structure-set key wins. These do not convert native structures into Iris placements and affect only newly generated chunks.")
|
||||
private List<StructureSetFrequency> frequencyOverrides = List.of();
|
||||
|
||||
@Desc("Per-structure adjustments applied to vanilla, mod, and datapack structures that still generate natively. Vertical shifts from every matching entry stack. A matching preserveSourceY option disables Iris burial repositioning for that structure. The last matching entry with stilt settings controls foundation columns, and likewise for terrain and yBand settings. A structure suppressed by an Iris placement is unaffected.")
|
||||
private List<StructureAdjustment> adjustments = List.of();
|
||||
|
||||
public StructureSettings() {
|
||||
}
|
||||
|
||||
public StructureSettings(List<String> disabled, List<String> disabledExact, int undergroundYShift, boolean datapackOverrides,
|
||||
List<StructureSetFrequency> frequencyOverrides, List<StructureAdjustment> adjustments) {
|
||||
this.disabled = List.copyOf(disabled);
|
||||
this.disabledExact = List.copyOf(disabledExact);
|
||||
this.undergroundYShift = undergroundYShift;
|
||||
this.datapackOverrides = datapackOverrides;
|
||||
this.frequencyOverrides = List.copyOf(frequencyOverrides);
|
||||
this.adjustments = List.copyOf(adjustments);
|
||||
}
|
||||
|
||||
/** Family patterns of the structures the dimension disables. */
|
||||
public List<String> disabled() {
|
||||
return listOrEmpty(disabled);
|
||||
}
|
||||
|
||||
/** Complete keys of the structures the dimension disables. */
|
||||
public List<String> disabledExact() {
|
||||
return listOrEmpty(disabledExact);
|
||||
}
|
||||
|
||||
public int undergroundYShift() {
|
||||
return undergroundYShift;
|
||||
}
|
||||
|
||||
public boolean datapackOverrides() {
|
||||
return datapackOverrides;
|
||||
}
|
||||
|
||||
public List<StructureSetFrequency> frequencyOverrides() {
|
||||
return listOrEmpty(frequencyOverrides);
|
||||
}
|
||||
|
||||
public List<StructureAdjustment> adjustments() {
|
||||
return listOrEmpty(adjustments);
|
||||
}
|
||||
|
||||
static <T> List<T> listOrEmpty(List<T> list) {
|
||||
return list == null ? List.of() : Collections.unmodifiableList(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.structure;
|
||||
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Foundation columns built beneath a structure's pieces after they are placed, as packs write it:
|
||||
* {"maxDepth": 32, "palette": {"palette": [{"block": "stone_bricks"}]}, "spacing": 2}. Held by structure placements and
|
||||
* by the {@code importedStructures} adjustments; ownership records keep its JSON for the starts they track.
|
||||
*/
|
||||
@Desc("Defines foundation columns placed beneath a structure.")
|
||||
public final class StructureStilts {
|
||||
private static final String DEFAULT_BLOCK = "minecraft:cobblestone";
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(4064)
|
||||
@Desc("Maximum number of blocks each foundation column may descend while searching for solid ground.")
|
||||
private int maxDepth = 64;
|
||||
|
||||
@Desc("Block palette used for foundation columns.")
|
||||
private PaletteSpec palette = PaletteSpec.of(List.of(BlockSpec.of(DEFAULT_BLOCK)));
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Desc("Horizontal spacing between support columns. One fills every eligible foundation column; larger values create sparse stilts.")
|
||||
private int spacing = 1;
|
||||
|
||||
@Desc("For Iris-authored structures, whether solid partial blocks such as slabs, stairs, and walls may seed foundation columns instead of requiring a fully occluding base block.")
|
||||
private boolean supportNonOccluding = false;
|
||||
|
||||
public StructureStilts() {
|
||||
}
|
||||
|
||||
public int maxDepth() {
|
||||
return maxDepth;
|
||||
}
|
||||
|
||||
/** The blocks of the columns; empty when the pack wrote {@code "palette": null}. */
|
||||
public Optional<PaletteSpec> palette() {
|
||||
return Optional.ofNullable(palette);
|
||||
}
|
||||
|
||||
public int spacing() {
|
||||
return spacing;
|
||||
}
|
||||
|
||||
public boolean supportNonOccluding() {
|
||||
return supportNonOccluding;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* How a structure meets the terrain, as packs write it: {"mode": "FORCE_CARVE", "horizontalPadding": 4, "shape": "ERODED"}.
|
||||
* Held by structure placements and by the {@code importedStructures} adjustments; ownership records keep its JSON for
|
||||
* the starts they track, so its field names and defaults are the persisted format.
|
||||
*/
|
||||
@Desc("Terrain integration applied after a structure graph is assembled and before its pieces are placed.")
|
||||
public final class StructureTerrain {
|
||||
private static final double AUTO_LOBE_FREQUENCY_RATIO = 0.3D;
|
||||
private static final double DEFAULT_EROSION_STRENGTH = 0.8D;
|
||||
private static final double DEFAULT_EROSION_FREQUENCY = 0.07D;
|
||||
private static final double DEFAULT_LOBE_STRENGTH = 0.85D;
|
||||
private static final double MIN_EROSION_FREQUENCY = 0.001D;
|
||||
private static final double MAX_EROSION_FREQUENCY = 1D;
|
||||
private static final double MAX_LOBE_FREQUENCY = 1D;
|
||||
|
||||
@Desc("Terrain operation. SOURCE applies the registered native structure's authored terrain adaptation and is a no-op for editable Iris structures. PRESERVE disables terrain integration. VACUUM raises terrain from processed rigid-template foundations at or below each authored ground plane with a 12-block falloff without lowering existing ground. BORE and FORCE_CARVE clear the requested envelope, while ENCASE fills it before placement so native shells are not lost to pre-carved air.")
|
||||
private StructureTerrainMode mode = StructureTerrainMode.SOURCE;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(128)
|
||||
@Desc("Horizontal clearance around the assembled pieces for BORE, FORCE_CARVE, and ENCASE. VACUUM uses its fixed 12-block terrain falloff.")
|
||||
private int horizontalPadding = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(128)
|
||||
@Desc("Air clearance above the assembled pieces.")
|
||||
private int ceilingPadding = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(64)
|
||||
@Desc("Terrain cleared below the assembled pieces. Zero preserves their supporting floor.")
|
||||
private int floorPadding = 0;
|
||||
|
||||
@Desc("Shape used by FORCE_CARVE.")
|
||||
private StructureCarveShape shape = StructureCarveShape.BOX;
|
||||
|
||||
@Desc("Block palette used by ENCASE. When unset, the Overworld uses stone or deepslate, the Nether uses netherrack, and the End uses end stone.")
|
||||
private PaletteSpec encasePalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Boundary erosion strength for ERODED force carving.")
|
||||
private double erosionStrength = DEFAULT_EROSION_STRENGTH;
|
||||
|
||||
@MinNumber(MIN_EROSION_FREQUENCY)
|
||||
@MaxNumber(MAX_EROSION_FREQUENCY)
|
||||
@Desc("Boundary noise frequency for ERODED force carving.")
|
||||
private double erosionFrequency = DEFAULT_EROSION_FREQUENCY;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Low frequency lobe wavelength for ERODED force carving. Zero derives it from the erosion frequency.")
|
||||
private double lobeFrequency = 0D;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Fraction of the horizontal padding the lobes may remove for ERODED force carving. Zero keeps a uniform boundary.")
|
||||
private double lobeStrength = DEFAULT_LOBE_STRENGTH;
|
||||
|
||||
public StructureTerrain() {
|
||||
}
|
||||
|
||||
/** The terrain operation; SOURCE where the pack wrote none or one Iris does not know. */
|
||||
public StructureTerrainMode resolvedMode() {
|
||||
return mode == null ? StructureTerrainMode.SOURCE : mode;
|
||||
}
|
||||
|
||||
public int horizontalPadding() {
|
||||
return horizontalPadding;
|
||||
}
|
||||
|
||||
public int ceilingPadding() {
|
||||
return ceilingPadding;
|
||||
}
|
||||
|
||||
public int floorPadding() {
|
||||
return floorPadding;
|
||||
}
|
||||
|
||||
/** The carve shape; BOX where the pack wrote none or one Iris does not know. */
|
||||
public StructureCarveShape resolvedShape() {
|
||||
return shape == null ? StructureCarveShape.BOX : shape;
|
||||
}
|
||||
|
||||
/** The blocks ENCASE fills with; empty for the dimension's own stone. */
|
||||
public Optional<PaletteSpec> encasePalette() {
|
||||
return Optional.ofNullable(encasePalette);
|
||||
}
|
||||
|
||||
public double resolvedErosionStrength() {
|
||||
if (!Double.isFinite(erosionStrength)) {
|
||||
return DEFAULT_EROSION_STRENGTH;
|
||||
}
|
||||
return Math.max(0D, Math.min(1D, erosionStrength));
|
||||
}
|
||||
|
||||
public double resolvedErosionFrequency() {
|
||||
if (!Double.isFinite(erosionFrequency)) {
|
||||
return DEFAULT_EROSION_FREQUENCY;
|
||||
}
|
||||
return Math.max(MIN_EROSION_FREQUENCY, Math.min(MAX_EROSION_FREQUENCY, erosionFrequency));
|
||||
}
|
||||
|
||||
public double resolvedLobeFrequency() {
|
||||
if (!Double.isFinite(lobeFrequency) || lobeFrequency <= 0D) {
|
||||
return resolvedErosionFrequency() * AUTO_LOBE_FREQUENCY_RATIO;
|
||||
}
|
||||
return Math.min(MAX_LOBE_FREQUENCY, lobeFrequency);
|
||||
}
|
||||
|
||||
public double resolvedLobeStrength() {
|
||||
if (!Double.isFinite(lobeStrength)) {
|
||||
return DEFAULT_LOBE_STRENGTH;
|
||||
}
|
||||
return Math.max(0D, Math.min(1D, lobeStrength));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.structure;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
@Desc("Controls how terrain is integrated with a structure.")
|
||||
public enum StructureTerrainMode {
|
||||
@Desc("Replays the registered native structure's own authored terrain adaptation (beard surface fitting, BURY/ENCAPSULATE fill, legacy template-air clearing). Does nothing for editable Iris structures, which have no source adaptation to replay.")
|
||||
SOURCE,
|
||||
|
||||
@Desc("Disables all terrain integration. Pieces are placed into completely unmodified terrain and may end up embedded in solid rock or floating over dips.")
|
||||
PRESERVE,
|
||||
|
||||
@Desc("Clears one straight axis-aligned box around the assembled pieces, expanded by horizontalPadding, ceilingPadding, and floorPadding. Ignores the carve shape and erosion settings.")
|
||||
BORE,
|
||||
|
||||
@Desc("Clears the padded envelope using the configured carve shape (BOX, ROUNDED, or noise-eroded ERODED) so the cavity hugs the assembled pieces instead of a straight box.")
|
||||
FORCE_CARVE,
|
||||
|
||||
@Desc("Raises surface terrain from processed solid rigid-template foundations at or below each authored ground plane with a 12-block falloff, even when the registered structure has no terrain adaptation. Existing higher terrain and authored air remain untouched.")
|
||||
VACUUM,
|
||||
|
||||
@Desc("Fills the padded piece volume with solid blocks before any piece is placed so shells, walls, and floors land in solid ground instead of pre-carved air. Only air and liquid cells are filled; existing terrain and structures are never overwritten. Native pieces then carve their own interiors.")
|
||||
ENCASE
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.structure;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
|
||||
/**
|
||||
* A band of absolute world heights a platform structure is moved into, as packs write it: {"min": -120, "max": -20}.
|
||||
* Unlike the API's heights these are world Y, as the platform's own structure definitions use them. Reversed bounds
|
||||
* mean the same band.
|
||||
*/
|
||||
@Desc("An absolute world Y band a native structure is relocated into. Reversed bounds are normalized.")
|
||||
public final class StructureYBand {
|
||||
@MinNumber(-4064)
|
||||
@MaxNumber(4064)
|
||||
@Desc("Lowest absolute world Y of the band.")
|
||||
private int min = 0;
|
||||
|
||||
@MinNumber(-4064)
|
||||
@MaxNumber(4064)
|
||||
@Desc("Highest absolute world Y of the band.")
|
||||
private int max = 0;
|
||||
|
||||
public StructureYBand() {
|
||||
}
|
||||
|
||||
public int resolvedMin() {
|
||||
return Math.min(min, max);
|
||||
}
|
||||
|
||||
public int resolvedMax() {
|
||||
return Math.max(min, max);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.terrain;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
/** Whether a dimension has a layer of bedrock at its bottom, written as {@code "bedrock": false}. A dimension without the key has it. */
|
||||
@Desc("Should bedrock be generated or not.")
|
||||
@Feature(id = "iris:terrain/bedrock", name = "Bedrock", key = "bedrock", root = "bedrock", targets = Level.DIMENSION)
|
||||
public final class BedrockSettings implements IrisFeature {
|
||||
@Desc("Should bedrock be generated or not.")
|
||||
private boolean bedrock = true;
|
||||
|
||||
public BedrockSettings() {
|
||||
}
|
||||
|
||||
public boolean bedrock() {
|
||||
return bedrock;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.terrain;
|
||||
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The layers of material a biome is made of below its surface, written as {@code "layers": [...]}, the list of layers. A biome
|
||||
* that declares none gets one layer of grass, so the settings class default is what a biome without the key has.
|
||||
*/
|
||||
@Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.")
|
||||
@Feature(id = "iris:terrain/layers", name = "Layers", key = "layers", root = "layers", targets = Level.BIOME)
|
||||
public final class LayersSettings implements IrisFeature {
|
||||
@Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.")
|
||||
private List<PaletteLayer> layers = List.of(new PaletteLayer());
|
||||
|
||||
public LayersSettings() {
|
||||
}
|
||||
|
||||
public List<PaletteLayer> layers() {
|
||||
return layers == null ? List.of() : layers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import com.volmit.block.BlockSpec;
|
||||
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 com.volmit.noise.NoiseStyle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* One layer of surface or subsurface material of a biome, as packs write it in the biome's layers, sea layers, cave
|
||||
* ceiling layers, slab and wall, in a floating island's bottom palette or under {@code snippet/iris/terrain/biome-palette/}. A value of
|
||||
* IrisApi types only; the terrain module resolves the blocks and builds the noise.
|
||||
*/
|
||||
@Snippet("iris/terrain/biome-palette")
|
||||
@Desc("A layer of surface / subsurface material in biomes")
|
||||
public final class PaletteLayer {
|
||||
private static final String STATIC_NOISE = "STATIC";
|
||||
private static final String DEFAULT_BLOCK = "grass_block";
|
||||
|
||||
@Desc("The style of noise")
|
||||
private NoiseStyle style = NoiseStyle.of(STATIC_NOISE);
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(2032)
|
||||
@Desc("The min thickness of this layer")
|
||||
private int minHeight = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(2032)
|
||||
@Desc("The max thickness of this layer")
|
||||
private int maxHeight = 1;
|
||||
|
||||
@Desc("If set, this layer only shows where the terrain slope is within these bounds; outside them the layer is skipped entirely. Thickness is not scaled by slope.")
|
||||
private SlopeClip slopeCondition = new SlopeClip();
|
||||
|
||||
@MinNumber(0.0001)
|
||||
@Desc("The terrain zoom mostly for zooming in on a wispy palette")
|
||||
private double zoom = 5;
|
||||
|
||||
@Required
|
||||
@MinItems(1)
|
||||
@Desc("The palette of blocks to be used in this layer")
|
||||
private List<BlockSpec> palette = List.of(BlockSpec.of(DEFAULT_BLOCK));
|
||||
|
||||
/** A layer with every option at its default, as packs get it from {@code {}}. */
|
||||
public PaletteLayer() {
|
||||
}
|
||||
|
||||
/** A layer with the default options and no block to place, which is what a biome without a slab or wall has. */
|
||||
public static PaletteLayer withoutBlocks() {
|
||||
PaletteLayer layer = new PaletteLayer();
|
||||
layer.palette = List.of();
|
||||
return layer;
|
||||
}
|
||||
|
||||
public NoiseStyle style() {
|
||||
return style == null ? NoiseStyle.of(STATIC_NOISE) : style;
|
||||
}
|
||||
|
||||
public int minHeight() {
|
||||
return minHeight;
|
||||
}
|
||||
|
||||
public int maxHeight() {
|
||||
return maxHeight;
|
||||
}
|
||||
|
||||
public SlopeClip slopeCondition() {
|
||||
return slopeCondition == null ? new SlopeClip() : slopeCondition;
|
||||
}
|
||||
|
||||
public double zoom() {
|
||||
return zoom;
|
||||
}
|
||||
|
||||
public List<BlockSpec> palette() {
|
||||
return palette == null ? List.of() : palette;
|
||||
}
|
||||
}
|
||||
@@ -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("iris/vacuum/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("iris/validate/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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.modules.decorant.DecorateSettings;
|
||||
import art.arcane.iris.engine.decorator.BiomeDecorators;
|
||||
import art.arcane.iris.engine.decorator.DecoratedBiome;
|
||||
import art.arcane.iris.engine.decorator.DecorationScene;
|
||||
import art.arcane.iris.engine.decorator.IrisSeaFloorDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSeaSurfaceDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisShoreLineDecorator;
|
||||
import art.arcane.iris.engine.decorator.IrisSurfaceDecorator;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleLifecycle;
|
||||
import com.volmit.ModuleSetup;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
/**
|
||||
* Module {@code iris:decorant}: the biomes' decorators ({@link DecorantSettings}), placed on the surface the mantle's
|
||||
* blocks left: the surface itself, the sea surface and floor, and the shore line. A dimension turns decorating off with
|
||||
* {@link DecorateSettings}. The decorators' noise is built ahead of generation, in {@link #warmUp}.
|
||||
*/
|
||||
public final class DecorantModule implements IrisModule, ModuleLifecycle {
|
||||
private static final String VERSION = "built-in";
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("iris:decorant", "Decorators", VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
// Ordering only: iris:matter ships in the built-ins jar, which a pack may not have.
|
||||
setup.stages().define(IrisStages.Decorant.DECORATE).softAfter(IrisStages.Matter.INSERT).run(DecorantModule::decorate);
|
||||
var registry = setup.registry();
|
||||
registry.registerSettings(DecorantSettings.class);
|
||||
registry.registerSettings(DecorateSettings.class);
|
||||
registry.registerLifecycle(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warmUp(PackWorld world) {
|
||||
BiomeDecorators.of(world).warm();
|
||||
}
|
||||
|
||||
private static void decorate(ChunkStageContext context) {
|
||||
if (!decorates(context)) {
|
||||
return;
|
||||
}
|
||||
decorate(DecorationScene.of(context), context.settings(), context.originX(), context.originZ());
|
||||
}
|
||||
|
||||
/** A dimension decorates unless it says {@code decorate: false}. */
|
||||
private static boolean decorates(ChunkStageContext context) {
|
||||
return context.settings().at(DecorateSettings.class, context.centreX(), context.centreZ()).dimension()
|
||||
.map(DecorateSettings::decorate).orElse(true);
|
||||
}
|
||||
|
||||
/** Decorates the 16 x 16 columns of the chunk whose first block is {@code x}, {@code z}, a biome's decorators on the surface its blocks left. */
|
||||
static void decorate(DecorationScene scene, FeatureSettings settings, int x, int z) {
|
||||
Hunk<BlockState> output = scene.blocks();
|
||||
TerrainSampler terrain = scene.terrain();
|
||||
BiomeDecorators decorators = scene.decorators();
|
||||
IrisSurfaceDecorator surfaceDecorator = new IrisSurfaceDecorator(scene);
|
||||
IrisSeaSurfaceDecorator seaSurfaceDecorator = new IrisSeaSurfaceDecorator(scene);
|
||||
IrisSeaFloorDecorator seaFloorDecorator = new IrisSeaFloorDecorator(scene);
|
||||
IrisShoreLineDecorator shoreLineDecorator = new IrisShoreLineDecorator(scene);
|
||||
int fluidHeight = scene.fluidHeight();
|
||||
int worldHeight = scene.worldHeight();
|
||||
|
||||
for (int i = 0; i < output.width(); i++) {
|
||||
int realX = Math.round(x + i);
|
||||
for (int j = 0; j < output.depth(); j++) {
|
||||
int realZ = Math.round(z + j);
|
||||
DecoratedBiome biome = BiomeDecorators.biomeOf(settings, realX, realZ, terrain.surfaceKind(realX, realZ));
|
||||
if (!decorators.hasDecorators(biome)) {
|
||||
continue;
|
||||
}
|
||||
int height = terrain.surfaceHeight(realX, realZ);
|
||||
|
||||
if (height >= 0 && height < fluidHeight && scene.isSolid(output.get(i, height, j))
|
||||
&& height + 1 < output.height() && scene.isWater(output.get(i, height + 1, j))) {
|
||||
seaSurfaceDecorator.decorate(i, j,
|
||||
realX, Math.round(i + 1), Math.round(x + i - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
biome, fluidHeight, worldHeight);
|
||||
seaFloorDecorator.decorate(i, j,
|
||||
realX, realZ, biome, height + 1,
|
||||
fluidHeight + 1);
|
||||
}
|
||||
|
||||
if (height == fluidHeight) {
|
||||
shoreLineDecorator.decorate(i, j,
|
||||
realX, Math.round(x + i + 1), Math.round(x + i - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
biome, height, worldHeight);
|
||||
}
|
||||
|
||||
if (height >= 0 && height < output.height()) {
|
||||
surfaceDecorator.decorate(i, j, realX, realZ, biome, height, worldHeight - height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.modules.terrain.OreSettings;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
/**
|
||||
* Builds the noise of every ore generator the world's biomes, regions and dimension declare before generation needs it.
|
||||
* A generator keeps the noise of the first seed it is given, so each one is warmed with the seed of its place in
|
||||
* this order: the biomes by key, the regions by key, then the dimension. The order is part of what a world generates.
|
||||
*/
|
||||
final class OreWarmUp {
|
||||
private static final long ROOT_SEED_SALT = 7777L;
|
||||
|
||||
private final PackWorld world;
|
||||
private final TerrainOres ores;
|
||||
private final RNG root;
|
||||
private int warmed;
|
||||
|
||||
OreWarmUp(PackWorld world) {
|
||||
this(world, TerrainOres.of(world));
|
||||
}
|
||||
|
||||
OreWarmUp(PackWorld world, TerrainOres ores) {
|
||||
this.world = world;
|
||||
this.ores = ores;
|
||||
this.root = new RNG(world.seed(IrisSeedPurposes.COMPONENT) + ROOT_SEED_SALT);
|
||||
}
|
||||
|
||||
void warm() {
|
||||
LongSupplier seeds = () -> root.nextParallelRNG(warmed++).getSeed();
|
||||
|
||||
SettingsStack<OreSettings> declared = world.settings().declared(OreSettings.class);
|
||||
warmLevel(declared, Level.BIOME, seeds);
|
||||
warmLevel(declared, Level.REGION, seeds);
|
||||
warmLevel(declared, Level.DIMENSION, seeds);
|
||||
}
|
||||
|
||||
/** The ores of every owner at {@code level}, ordered by the key of the biome, region or dimension that declares them. */
|
||||
private void warmLevel(SettingsStack<OreSettings> declared, Level level, LongSupplier seeds) {
|
||||
declared.entries().stream()
|
||||
.filter(entry -> entry.level() == level)
|
||||
.sorted(Comparator.comparing((Entry<OreSettings> entry) -> key(entry.source())))
|
||||
.forEach(entry -> ores.of(entry.value()).warm(seeds));
|
||||
}
|
||||
|
||||
private static String key(ResourceId source) {
|
||||
String path = source.path();
|
||||
return path.substring(path.indexOf('/') + 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.modules.terrain.OreGenerator;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockSpec;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.PaletteSampler;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* One {@link OreGenerator} made ready for one world: its palette resolved to blocks and the noise that
|
||||
* decides where it places ore, built from the seed it is warmed with or, when nothing warmed it, from the terrain seed
|
||||
* of its first use. The palette picks with the terrain seed. What the generator describes stays in the settings;
|
||||
* everything that needs the platform, the pack or the world seed is here.
|
||||
*/
|
||||
final class ResolvedOre {
|
||||
private final OreGenerator settings;
|
||||
private final NoiseFactory noise;
|
||||
private final BlockRegistry blockRegistry;
|
||||
private final long terrainSeed;
|
||||
private final List<BlockState> blocks;
|
||||
private final AtomicCache<NoiseSampler> chance = new AtomicCache<>();
|
||||
private final AtomicCache<PaletteSampler> palette = new AtomicCache<>();
|
||||
|
||||
/**
|
||||
* @param terrainSeed the seed the palette picks with, and the noise is built from when nothing warmed it first
|
||||
* @param blocks the palette as the platform's blocks, each repeated by its weight
|
||||
*/
|
||||
ResolvedOre(OreGenerator settings, NoiseFactory noise, BlockRegistry blockRegistry, long terrainSeed, List<BlockState> blocks) {
|
||||
this.settings = settings;
|
||||
this.noise = noise;
|
||||
this.blockRegistry = blockRegistry;
|
||||
this.terrainSeed = terrainSeed;
|
||||
this.blocks = List.copyOf(blocks);
|
||||
}
|
||||
|
||||
/** {@code settings} ready for a world with {@code resources}: its blocks resolved through the pack, its picks seeded with the terrain seed. */
|
||||
static ResolvedOre of(OreGenerator settings, PackResources resources, long terrainSeed) {
|
||||
BlockRegistry registry = resources.blocks();
|
||||
return new ResolvedOre(settings, resources.noise(), registry, terrainSeed, weighted(registry, settings.palette().palette()));
|
||||
}
|
||||
|
||||
private static List<BlockState> weighted(BlockRegistry registry, List<BlockSpec> specs) {
|
||||
List<BlockState> weighted = new ArrayList<>();
|
||||
for (BlockSpec spec : specs) {
|
||||
BlockState state = registry.resolve(spec);
|
||||
for (int n = 0; n < spec.weight(); n++) {
|
||||
weighted.add(state);
|
||||
}
|
||||
}
|
||||
return weighted;
|
||||
}
|
||||
|
||||
boolean generatesSurface() {
|
||||
return settings.generateSurface();
|
||||
}
|
||||
|
||||
double minY() {
|
||||
return settings.range().min();
|
||||
}
|
||||
|
||||
double maxY() {
|
||||
return settings.range().max();
|
||||
}
|
||||
|
||||
/** Builds the chance noise from {@code seed}, unless it is built already: the first seed it is given is the one it keeps. */
|
||||
void warm(long seed) {
|
||||
chance.aquire(() -> noise.sampler(settings.chanceStyle(), seed));
|
||||
}
|
||||
|
||||
/** The ore block at the position, or null when the position is out of the band, the chance noise is above the threshold or the palette has no block. */
|
||||
BlockState generate(int x, int y, int z) {
|
||||
if (!settings.range().contains(y)) {
|
||||
return null;
|
||||
}
|
||||
if (settings.palette().palette().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (chanceNoise().sample(x, y, z) > settings.threshold()) {
|
||||
return null;
|
||||
}
|
||||
return pick(x, y, z);
|
||||
}
|
||||
|
||||
/** The chance noise, which this runs per block of the terrain, so a built one is read without creating a supplier. */
|
||||
private NoiseSampler chanceNoise() {
|
||||
NoiseSampler built = chance.getIfPresent();
|
||||
if (built != null) {
|
||||
return built;
|
||||
}
|
||||
return chance.aquire(() -> noise.sampler(settings.chanceStyle(), terrainSeed));
|
||||
}
|
||||
|
||||
private BlockState pick(int x, int y, int z) {
|
||||
if (blocks.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (blocks.size() == 1) {
|
||||
return blocks.getFirst();
|
||||
}
|
||||
PaletteSampler sampler = palette.aquire(() -> blockRegistry.palette(settings.palette(), terrainSeed));
|
||||
return sampler.at(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.modules.terrain.OreGenerator;
|
||||
import art.arcane.iris.modules.terrain.OreSettings;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
/**
|
||||
* The ore generators of one dimension, region or biome made ready ({@link ResolvedOre}), in the order its settings list them
|
||||
* and split into the ones that also replace surface blocks and the ones that only replace rock. A level without ores is
|
||||
* {@link #NONE}.
|
||||
*/
|
||||
final class ResolvedOres {
|
||||
static final ResolvedOres NONE = new ResolvedOres(List.of());
|
||||
|
||||
private final List<ResolvedOre> all;
|
||||
private final List<ResolvedOre> surface;
|
||||
private final List<ResolvedOre> underground;
|
||||
private final YBand surfaceBand;
|
||||
private final YBand undergroundBand;
|
||||
|
||||
ResolvedOres(List<ResolvedOre> all) {
|
||||
this.all = List.copyOf(all);
|
||||
this.surface = this.all.stream().filter(ResolvedOre::generatesSurface).toList();
|
||||
this.underground = this.all.stream().filter(ore -> !ore.generatesSurface()).toList();
|
||||
this.surfaceBand = YBand.of(surface);
|
||||
this.undergroundBand = YBand.of(underground);
|
||||
}
|
||||
|
||||
/** {@code settings} ready for a world with {@code resources}; generators the pack wrote as {@code null} are left out. */
|
||||
static ResolvedOres of(OreSettings settings, PackResources resources, long terrainSeed) {
|
||||
List<ResolvedOre> ores = new ArrayList<>();
|
||||
for (OreGenerator generator : settings.generators()) {
|
||||
if (generator != null) {
|
||||
ores.add(ResolvedOre.of(generator, resources, terrainSeed));
|
||||
}
|
||||
}
|
||||
return ores.isEmpty() ? NONE : new ResolvedOres(ores);
|
||||
}
|
||||
|
||||
/** The heights where any surface ore can generate. */
|
||||
YBand surfaceBand() {
|
||||
return surfaceBand;
|
||||
}
|
||||
|
||||
/** The heights where any rock-only ore can generate. */
|
||||
YBand undergroundBand() {
|
||||
return undergroundBand;
|
||||
}
|
||||
|
||||
/** Warms every ore in the order the settings list them, each with the next seed. */
|
||||
void warm(LongSupplier seeds) {
|
||||
for (ResolvedOre ore : all) {
|
||||
ore.warm(seeds.getAsLong());
|
||||
}
|
||||
}
|
||||
|
||||
BlockState generateSurface(int x, int y, int z) {
|
||||
return firstOre(surface, x, y, z);
|
||||
}
|
||||
|
||||
BlockState generateUnderground(int x, int y, int z) {
|
||||
return firstOre(underground, x, y, z);
|
||||
}
|
||||
|
||||
private static BlockState firstOre(List<ResolvedOre> ores, int x, int y, int z) {
|
||||
for (int index = 0; index < ores.size(); index++) {
|
||||
BlockState ore = ores.get(index).generate(x, y, z);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The lowest and highest height any of a set of ores reaches; empty when there are none. */
|
||||
record YBand(boolean hasOres, double min, double max) {
|
||||
static final YBand EMPTY = new YBand(false, 0, 0);
|
||||
|
||||
static YBand of(List<ResolvedOre> ores) {
|
||||
if (ores.isEmpty()) {
|
||||
return EMPTY;
|
||||
}
|
||||
double min = Double.POSITIVE_INFINITY;
|
||||
double max = Double.NEGATIVE_INFINITY;
|
||||
for (ResolvedOre ore : ores) {
|
||||
min = Math.min(min, ore.minY());
|
||||
max = Math.max(max, ore.maxY());
|
||||
}
|
||||
return new YBand(true, min, max);
|
||||
}
|
||||
|
||||
boolean contains(int y) {
|
||||
return hasOres && y >= min && y <= max;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.terrain.BedrockSettings;
|
||||
import art.arcane.iris.modules.terrain.BiomePalettes;
|
||||
import art.arcane.iris.modules.terrain.CaveCeilingLayersSettings;
|
||||
import art.arcane.iris.modules.terrain.ExplodeBiomePaletteSizeSettings;
|
||||
import art.arcane.iris.modules.terrain.ExplodeBiomePalettesSettings;
|
||||
import art.arcane.iris.modules.terrain.FluidPaletteSettings;
|
||||
import art.arcane.iris.modules.terrain.HideOresSettings;
|
||||
import art.arcane.iris.builtin.terrain.LayersSettings;
|
||||
import art.arcane.iris.modules.terrain.LockLayersMaxSettings;
|
||||
import art.arcane.iris.modules.terrain.LockLayersSettings;
|
||||
import art.arcane.iris.modules.terrain.OreSettings;
|
||||
import art.arcane.iris.modules.terrain.RockPaletteSettings;
|
||||
import art.arcane.iris.modules.terrain.SeaLayersSettings;
|
||||
import art.arcane.iris.modules.terrain.SlabSettings;
|
||||
import art.arcane.iris.modules.terrain.WallSettings;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleLifecycle;
|
||||
import com.volmit.ModuleSetup;
|
||||
import com.volmit.service.ProtectedFloor;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import art.arcane.iris.modules.terrain.TerrainPalettes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Module {@code iris:terrain}: the chunk's ground, fluids and biome layers. Each column is filled from bedrock up
|
||||
* to its height and the fluid height with its biome's layers, with ore generators of the dimension, region and
|
||||
* biome replacing blocks on the way and the upper dimension's ground filled in from the top. The ore generators' noise
|
||||
* and the rock and fluid palettes' noise are built ahead of generation, in {@link #warmUp}.
|
||||
*/
|
||||
public final class TerrainModule implements IrisModule, ModuleLifecycle {
|
||||
private static final String VERSION = "built-in";
|
||||
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("iris:terrain", "Terrain", VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(IrisStages.Terrain.SHAPE).run(TerrainModule::shape);
|
||||
var registry = setup.registry();
|
||||
List.of(LayersSettings.class, SeaLayersSettings.class, CaveCeilingLayersSettings.class, SlabSettings.class,
|
||||
WallSettings.class, LockLayersSettings.class, LockLayersMaxSettings.class, RockPaletteSettings.class, FluidPaletteSettings.class,
|
||||
OreSettings.class, HideOresSettings.class, BedrockSettings.class, ExplodeBiomePalettesSettings.class,
|
||||
ExplodeBiomePaletteSizeSettings.class).forEach(registry::registerSettings);
|
||||
registry.registerService(ProtectedFloor.class, TerrainModule::protectsFloor);
|
||||
registry.registerLifecycle(this);
|
||||
setup.tooling().registerView(new BiomePalettes());
|
||||
}
|
||||
|
||||
/** The bedrock row belongs to the terrain while the dimension has bedrock, as it does unless the pack says otherwise. */
|
||||
private static boolean protectsFloor(PackWorld world) {
|
||||
return world.settings().declared(BedrockSettings.class).dimension().map(BedrockSettings::bedrock).orElse(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warmUp(PackWorld world) {
|
||||
TerrainPalettes.of(world).warm();
|
||||
new OreWarmUp(world).warm();
|
||||
}
|
||||
|
||||
private static void shape(ChunkStageContext context) {
|
||||
TerrainShaper.of(context.world()).shape(context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.modules.terrain.OreSettings;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* What the terrain module keeps for one world: the ore generators of its dimension, regions and biomes made ready
|
||||
* ({@link ResolvedOres}), built from their {@link OreSettings} when first asked for or ahead of generation by {@link OreWarmUp}.
|
||||
*/
|
||||
final class TerrainOres {
|
||||
private final PackResources resources;
|
||||
private final long terrainSeed;
|
||||
private final Map<OreSettings, ResolvedOres> resolved = new ConcurrentHashMap<>();
|
||||
|
||||
TerrainOres(PackWorld world) {
|
||||
this.resources = world.resources();
|
||||
this.terrainSeed = world.seed(IrisSeedPurposes.TERRAIN);
|
||||
}
|
||||
|
||||
/** The ores of {@code world}. */
|
||||
static TerrainOres of(PackWorld world) {
|
||||
return world.state(TerrainOres.class, TerrainOres::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ore generators {@code settings}, those a dimension, region or biome declares, make ready; {@link ResolvedOres#NONE} when it
|
||||
* declares none. The terrain asks this for two owners per column, so a resolved set is read without taking the map's lock.
|
||||
*/
|
||||
ResolvedOres of(OreSettings settings) {
|
||||
if (settings == null) {
|
||||
return ResolvedOres.NONE;
|
||||
}
|
||||
ResolvedOres existing = resolved.get(settings);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
}
|
||||
return resolved.computeIfAbsent(settings, declared -> ResolvedOres.of(declared, resources, terrainSeed));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.actuator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.terrain.BedrockSettings;
|
||||
import art.arcane.iris.modules.terrain.HideOresSettings;
|
||||
import art.arcane.iris.modules.terrain.OreSettings;
|
||||
import art.arcane.iris.engine.actuator.ResolvedOres.YBand;
|
||||
import art.arcane.iris.modules.terrain.BiomeLayers;
|
||||
import art.arcane.iris.modules.terrain.ColumnSlope;
|
||||
import art.arcane.iris.modules.terrain.LayeredBiome;
|
||||
import art.arcane.iris.modules.terrain.PaletteExplosion;
|
||||
import art.arcane.iris.modules.terrain.TerrainPalettes;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import com.volmit.world.UpperDimension;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
/** What shaping terrain keeps for one world: the terrain stream's random and the palettes, layers and ores the columns are filled from. */
|
||||
final class TerrainShaper {
|
||||
private static final BlockState BEDROCK = new BlockState("minecraft:bedrock");
|
||||
|
||||
private final TerrainPalettes palettes;
|
||||
private final BiomeLayers layers;
|
||||
private final TerrainOres ores;
|
||||
private final RNG rng;
|
||||
private final boolean levelsBelowTheDimensionDeclareOres;
|
||||
|
||||
static TerrainShaper of(PackWorld world) {
|
||||
return world.state(TerrainShaper.class, TerrainShaper::new);
|
||||
}
|
||||
|
||||
TerrainShaper(PackWorld world) {
|
||||
this(world, TerrainPalettes.of(world), BiomeLayers.of(world), TerrainOres.of(world));
|
||||
}
|
||||
|
||||
TerrainShaper(PackWorld world, TerrainPalettes palettes, BiomeLayers layers, TerrainOres ores) {
|
||||
this.palettes = palettes;
|
||||
this.layers = layers;
|
||||
this.ores = ores;
|
||||
this.rng = new RNG(world.seed(IrisSeedPurposes.TERRAIN));
|
||||
this.levelsBelowTheDimensionDeclareOres = world.settings().declared(OreSettings.class).entries().stream()
|
||||
.anyMatch(entry -> entry.level() != Level.DIMENSION);
|
||||
}
|
||||
|
||||
/** Fills the 16 x 16 columns of the chunk, one slice along x at a time. */
|
||||
void shape(ChunkStageContext context) {
|
||||
Chunk chunk = new Chunk(context);
|
||||
for (int sliceX = 0; sliceX < chunk.blocks.width(); sliceX++) {
|
||||
shapeSliver(chunk, sliceX);
|
||||
}
|
||||
}
|
||||
|
||||
/** One plane from the sky to bedrock, one block thick along x. */
|
||||
private void shapeSliver(Chunk chunk, int xf) {
|
||||
Hunk<BlockState> h = chunk.blocks;
|
||||
int chunkHeight = h.height();
|
||||
int chunkDepth = h.depth();
|
||||
int realX = xf + chunk.originX;
|
||||
|
||||
for (int zf = 0; zf < chunkDepth; zf++) {
|
||||
int realZ = zf + chunk.originZ;
|
||||
int he = Math.min(chunkHeight, chunk.terrain.surfaceHeight(realX, realZ));
|
||||
int hf = Math.max(chunk.clampedFluidHeight, he);
|
||||
if (hf < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int topY = Math.min(hf, chunkHeight - 1);
|
||||
BlockState fluid = palettes.fluidAt(realX, realZ);
|
||||
BlockState rock = palettes.rockAt(realX, realZ);
|
||||
BlockState mappedSurfaceBlock = chunk.terrain.surfaceBlock(realX, realZ).orElse(null);
|
||||
LayeredBiome biome = layers.biome(chunk.terrain.surfaceBiome(realX, realZ), chunk.settings);
|
||||
ColumnOres columnOres = chunk.oresAt(realX, realZ);
|
||||
ResolvedOres biomeOres = columnOres.biome;
|
||||
ResolvedOres regionOres = columnOres.region;
|
||||
YBand biomeSurfaceBand = biomeOres.surfaceBand();
|
||||
YBand regionSurfaceBand = regionOres.surfaceBand();
|
||||
YBand biomeUndergroundBand = biomeOres.undergroundBand();
|
||||
YBand regionUndergroundBand = regionOres.undergroundBand();
|
||||
ResolvedOres dimensionOres = chunk.dimensionOres;
|
||||
YBand dimensionSurfaceBand = dimensionOres.surfaceBand();
|
||||
YBand dimensionUndergroundBand = dimensionOres.undergroundBand();
|
||||
boolean hasSurfaceOres = biomeSurfaceBand.hasOres() || regionSurfaceBand.hasOres() || dimensionSurfaceBand.hasOres();
|
||||
boolean hasUndergroundOres = biomeUndergroundBand.hasOres() || regionUndergroundBand.hasOres() || dimensionUndergroundBand.hasOres();
|
||||
KList<BlockState> blocks = null;
|
||||
KList<BlockState> fblocks = null;
|
||||
|
||||
for (int i = topY; i >= 0; i--) {
|
||||
if (i == 0 && chunk.bedrockEnabled) {
|
||||
place(h, xf, i, zf, BEDROCK);
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockState ore = null;
|
||||
if (hasSurfaceOres) {
|
||||
if (biomeSurfaceBand.contains(i)) {
|
||||
ore = biomeOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && regionSurfaceBand.contains(i)) {
|
||||
ore = regionOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && dimensionSurfaceBand.contains(i)) {
|
||||
ore = dimensionOres.generateSurface(realX, i, realZ);
|
||||
}
|
||||
}
|
||||
if (ore != null) {
|
||||
place(h, xf, i, zf, ore);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i > he && i <= hf) {
|
||||
int fdepth = hf - i;
|
||||
if (fblocks == null) {
|
||||
fblocks = layers.generateSeaLayers(biome, realX, realZ, rng, hf - he);
|
||||
}
|
||||
|
||||
if (fblocks.hasIndex(fdepth)) {
|
||||
place(h, xf, i, zf, fblocks.get(fdepth));
|
||||
} else {
|
||||
place(h, xf, i, zf, fluid);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i <= he) {
|
||||
int depth = he - i;
|
||||
if (depth == 0 && mappedSurfaceBlock != null) {
|
||||
place(h, xf, i, zf, mappedSurfaceBlock);
|
||||
continue;
|
||||
}
|
||||
if (blocks == null) {
|
||||
blocks = layers.generateLayers(biome, chunk.explosion, realX, realZ, rng, he, he, chunk.slope);
|
||||
}
|
||||
|
||||
if (blocks.hasIndex(depth)) {
|
||||
place(h, xf, i, zf, blocks.get(depth));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasUndergroundOres) {
|
||||
if (biomeUndergroundBand.contains(i)) {
|
||||
ore = biomeOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && regionUndergroundBand.contains(i)) {
|
||||
ore = regionOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
if (ore == null && dimensionUndergroundBand.contains(i)) {
|
||||
ore = dimensionOres.generateUnderground(realX, i, realZ);
|
||||
}
|
||||
}
|
||||
|
||||
place(h, xf, i, zf, ore != null ? ore : rock);
|
||||
}
|
||||
}
|
||||
|
||||
if (chunk.upper.isPresent()) {
|
||||
fillUpperDimension(chunk, chunk.upper.get(), xf, zf, realX, realZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The upper dimension's ground, filled in from the top of the column down to where it ends. */
|
||||
private void fillUpperDimension(Chunk chunk, UpperDimension upper, int xf, int zf, int realX, int realZ) {
|
||||
Hunk<BlockState> h = chunk.blocks;
|
||||
int chunkHeight = h.height();
|
||||
OptionalInt upperY = chunk.terrain.upperDimensionY(realX, realZ);
|
||||
if (upperY.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int upperSurfaceY = upperY.getAsInt();
|
||||
if (upperSurfaceY >= chunkHeight - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
FeatureSettings upperSettings = upper.settings();
|
||||
BlockState upperRock = palettes.upperRockAt(upper, realX, realZ);
|
||||
BlockState upperMappedSurface = upper.surfaceBlock(realX, realZ).orElse(null);
|
||||
int upperThickness = chunkHeight - 1 - upperSurfaceY;
|
||||
LayeredBiome upperBiome = upperBiome(upperSettings, realX, realZ);
|
||||
KList<BlockState> upperBlocks = layers.generateLayers(upperBiome, chunk.upperExplosion(upperSettings, realX, realZ),
|
||||
realX, realZ, rng, upperThickness, upperThickness, chunk.slope);
|
||||
|
||||
for (int y = chunkHeight - 1; y >= upperSurfaceY; y--) {
|
||||
if (y == chunkHeight - 1 && chunk.bedrockEnabled) {
|
||||
place(h, xf, y, zf, BEDROCK);
|
||||
continue;
|
||||
}
|
||||
if (y == upperSurfaceY && upperMappedSurface != null) {
|
||||
place(h, xf, y, zf, upperMappedSurface);
|
||||
continue;
|
||||
}
|
||||
int depthFromFace = y - upperSurfaceY;
|
||||
if (upperBlocks.hasIndex(depthFromFace)) {
|
||||
place(h, xf, y, zf, upperBlocks.get(depthFromFace));
|
||||
} else {
|
||||
place(h, xf, y, zf, upperRock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** What the biome of the upper dimension at the column declares about its layers. */
|
||||
private LayeredBiome upperBiome(FeatureSettings upperSettings, int worldX, int worldZ) {
|
||||
return new LayeredBiome(biomeLevel(upperSettings, art.arcane.iris.builtin.terrain.LayersSettings.class, worldX, worldZ), null, null,
|
||||
biomeLevel(upperSettings, art.arcane.iris.modules.terrain.LockLayersSettings.class, worldX, worldZ),
|
||||
biomeLevel(upperSettings, art.arcane.iris.modules.terrain.LockLayersMaxSettings.class, worldX, worldZ), null);
|
||||
}
|
||||
|
||||
private static <S extends IrisFeature> S biomeLevel(FeatureSettings settings, Class<S> type, int worldX, int worldZ) {
|
||||
return settings.at(type, worldX, worldZ).level(Level.BIOME).orElse(null);
|
||||
}
|
||||
|
||||
/** A block the palette has none of leaves the column as it is. */
|
||||
private static void place(Hunk<BlockState> blocks, int x, int y, int z, BlockState block) {
|
||||
if (block != null) {
|
||||
blocks.set(x, y, z, block);
|
||||
}
|
||||
}
|
||||
|
||||
/** The ores of a column's region and biome. */
|
||||
private record ColumnOres(ResolvedOres region, ResolvedOres biome) {
|
||||
static final ColumnOres NONE = new ColumnOres(ResolvedOres.NONE, ResolvedOres.NONE);
|
||||
}
|
||||
|
||||
/** What one chunk's columns share: its views, its dimension's switches and ores. */
|
||||
private final class Chunk {
|
||||
final Hunk<BlockState> blocks;
|
||||
final TerrainSampler terrain;
|
||||
final FeatureSettings settings;
|
||||
final int originX;
|
||||
final int originZ;
|
||||
final int clampedFluidHeight;
|
||||
final boolean bedrockEnabled;
|
||||
final PaletteExplosion explosion;
|
||||
final ColumnSlope slope;
|
||||
final Optional<UpperDimension> upper;
|
||||
final ResolvedOres dimensionOres;
|
||||
private final boolean hideOres;
|
||||
private PaletteExplosion upperExplosion;
|
||||
|
||||
Chunk(ChunkStageContext context) {
|
||||
this.blocks = context.blocks();
|
||||
this.terrain = context.terrain();
|
||||
this.settings = context.settings();
|
||||
this.originX = context.originX();
|
||||
this.originZ = context.originZ();
|
||||
this.clampedFluidHeight = Math.min(blocks.height(), terrain.fluidHeight());
|
||||
int centreX = context.centreX();
|
||||
int centreZ = context.centreZ();
|
||||
this.bedrockEnabled = settings.at(BedrockSettings.class, centreX, centreZ).dimension().map(BedrockSettings::bedrock).orElse(true);
|
||||
this.hideOres = settings.at(HideOresSettings.class, centreX, centreZ).dimension().map(HideOresSettings::hide).orElse(false);
|
||||
this.explosion = PaletteExplosion.of(settings, centreX, centreZ);
|
||||
this.slope = (x, z) -> terrain.column((int) x, (int) z).slope();
|
||||
this.upper = terrain.upperDimension();
|
||||
// Dimension-level ore lookups are chunk-invariant; resolving them per column paid the settings lookup times 256 per chunk for a constant.
|
||||
this.dimensionOres = hideOres ? ResolvedOres.NONE : ores.of(settings.at(OreSettings.class, centreX, centreZ).dimension().orElse(null));
|
||||
}
|
||||
|
||||
/** What the upper dimension declares about exploded palettes: a setting of the dimension, so the same for every column of the chunk. */
|
||||
PaletteExplosion upperExplosion(FeatureSettings upperSettings, int worldX, int worldZ) {
|
||||
if (upperExplosion == null) {
|
||||
upperExplosion = PaletteExplosion.of(upperSettings, worldX, worldZ);
|
||||
}
|
||||
return upperExplosion;
|
||||
}
|
||||
|
||||
/** The ores of the column's region and biome; none where the levels below the dimension declare none, or the dimension hides ores. */
|
||||
ColumnOres oresAt(int worldX, int worldZ) {
|
||||
if (hideOres || !levelsBelowTheDimensionDeclareOres) {
|
||||
return ColumnOres.NONE;
|
||||
}
|
||||
SettingsStack<OreSettings> declared = settings.at(OreSettings.class, worldX, worldZ);
|
||||
return new ColumnOres(ores.of(declared.level(Level.REGION).orElse(null)), ores.of(declared.level(Level.BIOME).orElse(null)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.builtin.decorant.Decorator;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* What the decorant module keeps for one world: the decorators of its biomes made ready ({@link ResolvedDecorator}), sorted into
|
||||
* the places they decorate. Built from the biomes' {@link DecorantSettings} when first asked for, or ahead of generation by
|
||||
* {@link #warm()}.
|
||||
*
|
||||
* <p>A decorator's noise seed is a function of the world's decorator seed, its biome's key and its place in the biome's
|
||||
* list, so it does not depend on which column or which warm-up reached it first.
|
||||
*/
|
||||
public final class BiomeDecorators {
|
||||
private static final ResolvedDecorator[] NO_DECORATORS = new ResolvedDecorator[0];
|
||||
private static final String BIOME_PATH_PREFIX = "biome/";
|
||||
private static final long KEY_SEED_FACTOR = 0x9E3779B97F4A7C15L;
|
||||
private static final long INDEX_SEED_FACTOR = 0xC2B2AE3D27D4EB4FL;
|
||||
|
||||
private final PackWorld world;
|
||||
private final PackResources resources;
|
||||
private final ModuleLog log;
|
||||
private final long decoratorSeed;
|
||||
private final Map<DecorantSettings, Map<DecorationPart, ResolvedDecorator[]>> decorators = new ConcurrentHashMap<>();
|
||||
|
||||
BiomeDecorators(PackWorld world) {
|
||||
this.world = world;
|
||||
this.resources = world.resources();
|
||||
this.log = world.log();
|
||||
this.decoratorSeed = world.seed(IrisSeedPurposes.DECORATOR);
|
||||
}
|
||||
|
||||
/** The world's decorators, kept in its state store. */
|
||||
public static BiomeDecorators of(PackWorld world) {
|
||||
return world.state(BiomeDecorators.class, BiomeDecorators::new);
|
||||
}
|
||||
|
||||
/** The key of the biome a settings entry was declared by, such as {@code desert/dunes} for {@code overworld:biome/desert/dunes}. */
|
||||
public static String biomeKey(ResourceId source) {
|
||||
String path = source.path();
|
||||
return path.startsWith(BIOME_PATH_PREFIX) ? path.substring(BIOME_PATH_PREFIX.length()) : path;
|
||||
}
|
||||
|
||||
/** The biome of the entry a column's settings gave, which is the column's surface biome; null when the biome declares nothing. */
|
||||
public static DecoratedBiome biomeOf(FeatureSettings settings, int worldX, int worldZ, com.volmit.world.BiomeKind kind) {
|
||||
List<Entry<DecorantSettings>> entries = settings.at(DecorantSettings.class, worldX, worldZ).entries();
|
||||
if (entries.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Entry<DecorantSettings> entry = entries.getLast();
|
||||
return new DecoratedBiome(biomeKey(entry.source()), entry.value(), kind);
|
||||
}
|
||||
|
||||
/** The log of the module that decorates, which the decorators write to. */
|
||||
ModuleLog log() {
|
||||
return log;
|
||||
}
|
||||
|
||||
/** Whether the biome declares any decorator. */
|
||||
public boolean hasDecorators(DecoratedBiome biome) {
|
||||
return biome != null && biome.settings() != null && !biome.settings().decorators().isEmpty();
|
||||
}
|
||||
|
||||
/** The biome's decorators for {@code part}, in the order the biome lists them. */
|
||||
ResolvedDecorator[] decorators(DecoratedBiome biome, DecorationPart part) {
|
||||
if (biome == null || biome.settings() == null) {
|
||||
return NO_DECORATORS;
|
||||
}
|
||||
return decorators.computeIfAbsent(biome.settings(), declared -> resolve(biome.key(), declared)).getOrDefault(part, NO_DECORATORS);
|
||||
}
|
||||
|
||||
/** Whether the biome has a decorator for {@code part}. */
|
||||
public boolean hasDecorators(DecoratedBiome biome, DecorationPart part) {
|
||||
return decorators(biome, part).length > 0;
|
||||
}
|
||||
|
||||
/** Resolves every decorator of every biome the dimension reaches and builds its noise, so that generation finds them ready. */
|
||||
public void warm() {
|
||||
List<Entry<DecorantSettings>> declared = new ArrayList<>(world.settings().declared(DecorantSettings.class).entries());
|
||||
declared.sort(Comparator.comparing(entry -> biomeKey(entry.source())));
|
||||
for (Entry<DecorantSettings> entry : declared) {
|
||||
DecoratedBiome biome = new DecoratedBiome(biomeKey(entry.source()), entry.value(), null);
|
||||
for (DecorationPart part : DecorationPart.values()) {
|
||||
for (ResolvedDecorator decorator : decorators(biome, part)) {
|
||||
decorator.warm();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<DecorationPart, ResolvedDecorator[]> resolve(String biomeKey, DecorantSettings settings) {
|
||||
Map<DecorationPart, List<ResolvedDecorator>> staging = new EnumMap<>(DecorationPart.class);
|
||||
List<Decorator> declared = settings.decorators();
|
||||
for (int index = 0; index < declared.size(); index++) {
|
||||
Decorator decorator = declared.get(index);
|
||||
if (decorator == null) {
|
||||
continue;
|
||||
}
|
||||
ResolvedDecorator resolved = ResolvedDecorator.of(decorator, resources, seedOf(biomeKey, index), log, biomeKey);
|
||||
staging.computeIfAbsent(decorator.partOf(), part -> new ArrayList<>()).add(resolved);
|
||||
}
|
||||
|
||||
Map<DecorationPart, ResolvedDecorator[]> buckets = new EnumMap<>(DecorationPart.class);
|
||||
staging.forEach((part, list) -> buckets.put(part, list.toArray(NO_DECORATORS)));
|
||||
return buckets;
|
||||
}
|
||||
|
||||
private long seedOf(String biomeKey, int index) {
|
||||
return decoratorSeed + (biomeKey.hashCode() * KEY_SEED_FACTOR) + (index * INDEX_SEED_FACTOR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import com.volmit.world.BiomeKind;
|
||||
|
||||
/**
|
||||
* A biome as the decorators see it: the key the pack names it by, which seeds its decorators' noise, the decorators it declares
|
||||
* (none when it declares no {@link DecorantSettings}) and what it was generated as.
|
||||
*/
|
||||
public record DecoratedBiome(String key, DecorantSettings settings, BiomeKind kind) {
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.mantle.MantleLayer;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Everything the decorators of one chunk look at: its blocks, the blocks the mantle planned around it, the terrain, the pack's
|
||||
* block rules and the biomes' decorators. A decorator places into {@link #blocks()} only. What it asks of a block is asked
|
||||
* once for each distinct block instance, since a chunk holds few.
|
||||
*/
|
||||
public final class DecorationScene {
|
||||
private final Hunk<BlockState> blocks;
|
||||
private final BlockRegistry registry;
|
||||
private final TerrainSampler terrain;
|
||||
private final MantleLayer<BlockState> planned;
|
||||
private final BiomeDecorators decorators;
|
||||
private final long seed;
|
||||
private final ModuleLog log;
|
||||
private final Map<BlockTrait, Map<BlockState, Boolean>> traits = new EnumMap<>(BlockTrait.class);
|
||||
private final Map<BlockState, Map<BlockState, Boolean>> supports = new IdentityHashMap<>();
|
||||
|
||||
/** The chunk of {@code context}, decorated with the world's decorators. */
|
||||
public static DecorationScene of(ChunkStageContext context) {
|
||||
Mantle mantle = context.mantle();
|
||||
return new DecorationScene(context.blocks(),context.world().resources().blocks(), context.terrain(),
|
||||
mantle == null ? null : mantle.blocks(), BiomeDecorators.of(context.world()), context.world().seed(IrisSeedPurposes.COMPONENT),
|
||||
context.log());
|
||||
}
|
||||
|
||||
public DecorationScene(Hunk<BlockState> blocks, BlockRegistry registry, TerrainSampler terrain, MantleLayer<BlockState> planned,
|
||||
BiomeDecorators decorators, long seed, ModuleLog log) {
|
||||
this.blocks = blocks;
|
||||
this.registry = registry;
|
||||
this.terrain = terrain;
|
||||
this.planned = planned;
|
||||
this.decorators = decorators;
|
||||
this.seed = seed;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
public Hunk<BlockState> blocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public BlockRegistry registry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
public TerrainSampler terrain() {
|
||||
return terrain;
|
||||
}
|
||||
|
||||
public BiomeDecorators decorators() {
|
||||
return decorators;
|
||||
}
|
||||
|
||||
/** The seed the decorators of every place draw from, each shifted by its own part. */
|
||||
long seed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
ModuleLog log() {
|
||||
return log;
|
||||
}
|
||||
|
||||
/** The height of the chunk's volume. */
|
||||
public int worldHeight() {
|
||||
return blocks.height();
|
||||
}
|
||||
|
||||
public int fluidHeight() {
|
||||
return terrain.fluidHeight();
|
||||
}
|
||||
|
||||
/** The slope of the terrain at the column. */
|
||||
double slopeAt(int worldX, int worldZ) {
|
||||
return terrain.column(worldX, worldZ).slope();
|
||||
}
|
||||
|
||||
/** The height of the terrain at the column, rounded. */
|
||||
long roundedHeightAt(int worldX, int worldZ) {
|
||||
return terrain.surfaceHeight(worldX, worldZ);
|
||||
}
|
||||
|
||||
/** The block a placement planned at the position, or air; positions the mantle does not cover read as air. */
|
||||
BlockState plannedAt(int worldX, int y, int worldZ) {
|
||||
if (planned == null || y < 0 || y >= worldHeight()) {
|
||||
return null;
|
||||
}
|
||||
return planned.get(worldX, y, worldZ);
|
||||
}
|
||||
|
||||
boolean has(BlockTrait trait, BlockState block) {
|
||||
return traits.computeIfAbsent(trait, ignored -> new IdentityHashMap<>())
|
||||
.computeIfAbsent(block, known -> registry.hasTrait(known, trait));
|
||||
}
|
||||
|
||||
public boolean isAir(BlockState block) {
|
||||
return has(BlockTrait.AIR, block);
|
||||
}
|
||||
|
||||
public boolean isFluid(BlockState block) {
|
||||
return has(BlockTrait.FLUID, block);
|
||||
}
|
||||
|
||||
public boolean isSolid(BlockState block) {
|
||||
return has(BlockTrait.SOLID, block);
|
||||
}
|
||||
|
||||
public boolean isWater(BlockState block) {
|
||||
return has(BlockTrait.WATER, block);
|
||||
}
|
||||
|
||||
/** Whether {@code decoration} may stand on {@code surface}: its kind of block on that kind of block, and the surface carries a block on its top face. */
|
||||
boolean canGoOn(BlockState decoration, BlockState surface) {
|
||||
return supports.computeIfAbsent(decoration, ignored -> new IdentityHashMap<>())
|
||||
.computeIfAbsent(surface, known -> registry.canPlaceOn(decoration, known)
|
||||
&& registry.canAttach(decoration, known, com.volmit.geometry.BlockFace.UP));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,490 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.geometry.BlockFace;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
final class DecoratorCore {
|
||||
|
||||
private static final long SEED_OFFSET = 29356788L;
|
||||
private static final long PART_FACTOR = 10439677L;
|
||||
private static final String HALF = "half";
|
||||
private static final ResourceId WEEPING_VINES = ResourceId.parse("minecraft:weeping_vines");
|
||||
private static final ResourceId WEEPING_VINES_PLANT = ResourceId.parse("minecraft:weeping_vines_plant");
|
||||
private static final ResourceId TWISTING_VINES = ResourceId.parse("minecraft:twisting_vines");
|
||||
private static final ResourceId TWISTING_VINES_PLANT = ResourceId.parse("minecraft:twisting_vines_plant");
|
||||
private static final ResourceId POINTED_DRIPSTONE = ResourceId.parse("minecraft:pointed_dripstone");
|
||||
private static final String[] DRIPSTONE_THICKNESS = {"tip", "frustum", "base"};
|
||||
private static final BlockState[] DRIPSTONE_UP = dripstones("up");
|
||||
private static final BlockState[] DRIPSTONE_DOWN = dripstones("down");
|
||||
private static final BlockState AIR = new BlockState("minecraft:air");
|
||||
/** The faces a vine can grow on, in the order Iris looks at them, with the neighbour each faces. */
|
||||
private static final List<Face> FACES = List.of(new Face(BlockFace.NORTH, "north", 0, 0, -1), new Face(BlockFace.EAST, "east", 1, 0, 0),
|
||||
new Face(BlockFace.SOUTH, "south", 0, 0, 1), new Face(BlockFace.WEST, "west", -1, 0, 0), new Face(BlockFace.UP, "up", 0, 1, 0),
|
||||
new Face(BlockFace.DOWN, "down", 0, -1, 0));
|
||||
private static final Map<BlockFace, BlockFace> OPPOSITES = Map.of(BlockFace.NORTH, BlockFace.SOUTH, BlockFace.SOUTH, BlockFace.NORTH,
|
||||
BlockFace.EAST, BlockFace.WEST, BlockFace.WEST, BlockFace.EAST, BlockFace.UP, BlockFace.DOWN, BlockFace.DOWN, BlockFace.UP);
|
||||
private static final int CHUNK_LAST = 15;
|
||||
|
||||
static final ThreadLocal<PlaceOpts> SCRATCH_OPTS = ThreadLocal.withInitial(PlaceOpts::new);
|
||||
|
||||
static final class PlaceOpts {
|
||||
boolean caveSkipFluid;
|
||||
boolean underwater;
|
||||
int fluidHeight;
|
||||
|
||||
void reset() {
|
||||
caveSkipFluid = false;
|
||||
underwater = false;
|
||||
fluidHeight = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private record Face(BlockFace face, String property, int dx, int dy, int dz) {
|
||||
}
|
||||
|
||||
static long partSeed(long baseSeed, int partOrdinal) {
|
||||
return baseSeed + SEED_OFFSET - (partOrdinal * PART_FACTOR);
|
||||
}
|
||||
|
||||
static long partSeed(long baseSeed, DecorationPart part) {
|
||||
return partSeed(baseSeed, part.ordinal());
|
||||
}
|
||||
|
||||
/** The decorator of {@code bucket} that decorates the column, drawing from {@code colRng} to choose between those whose chance noise passes. */
|
||||
static ResolvedDecorator pickDecorator(ResolvedDecorator[] bucket, RNG colRng, double realX, double realZ, ModuleLog log) {
|
||||
ResolvedDecorator picked = null;
|
||||
int count = 0;
|
||||
|
||||
for (ResolvedDecorator d : bucket) {
|
||||
try {
|
||||
if (d.passesChanceGate(realX, realZ)) {
|
||||
count++;
|
||||
if (count == 1 || colRng.nextInt(count) == 0) {
|
||||
picked = d;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("A decorator failed to pick for the column", e);
|
||||
}
|
||||
}
|
||||
|
||||
return picked;
|
||||
}
|
||||
|
||||
private static String topHalfValue(String half) {
|
||||
return half.equals("upper") || half.equals("lower") ? "upper" : "top";
|
||||
}
|
||||
|
||||
private static String bottomHalfValue(String half) {
|
||||
return half.equals("upper") || half.equals("lower") ? "lower" : "bottom";
|
||||
}
|
||||
|
||||
static void placeSurfaceSingle(ResolvedDecorator decorator, DecorationScene scene,
|
||||
int x, int z, int realX, int height, int realZ,
|
||||
boolean underwater, boolean caveSkipFluid) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (height < 0 || height >= data.height()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState bdx = data.get(x, height, z);
|
||||
BlockState bd = decorator.pickBlock(realX, realZ);
|
||||
|
||||
if (!underwater && !canGoOn(scene, bd, bdx)
|
||||
&& !decorator.isForcePlace() && decorator.forceBlock() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (decorator.forceBlock() != null) {
|
||||
if (caveSkipFluid && scene.isFluid(bdx)) {
|
||||
return;
|
||||
}
|
||||
data.set(x, height, z, fixFacesForHunk(scene, decorator.forceBlock(), x, z, realX, height, realZ));
|
||||
}
|
||||
|
||||
if (!decorator.isForcePlace() && decorator.rejectsSurface(bdx)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String half = bd == null ? null : bd.properties().get(HALF);
|
||||
if (half != null) {
|
||||
int lowerY = height + 1;
|
||||
int upperY = height + 2;
|
||||
if (!canPlaceTwoBlockPlant(scene, x, z, lowerY, upperY, caveSkipFluid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
BlockState upper = bd.withProperty(HALF, topHalfValue(half));
|
||||
BlockState lower = fixFacesForHunk(scene,
|
||||
bd.withProperty(HALF, bottomHalfValue(half)),
|
||||
x, z, realX, lowerY, realZ);
|
||||
data.set(x, lowerY, z, lower);
|
||||
data.set(x, upperY, z, upper);
|
||||
} catch (Throwable e) {
|
||||
scene.log().error("Failed to place a two-block plant", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int targetY = height + 1;
|
||||
if (bd != null && targetY < data.height() && scene.isAir(data.get(x, targetY, z))) {
|
||||
data.set(x, targetY, z, fixFacesForHunk(scene, bd, x, z, realX, targetY, realZ));
|
||||
}
|
||||
}
|
||||
|
||||
static void placeSingleAt(ResolvedDecorator decorator, DecorationScene scene, int x, int z,
|
||||
int realX, int height, int realZ, boolean applyFixFaces) {
|
||||
BlockState bd = decorator.pickBlock(realX, realZ);
|
||||
if (bd == null) {
|
||||
return;
|
||||
}
|
||||
if (applyFixFaces) {
|
||||
bd = fixFacesForHunk(scene, bd, x, z, realX, height, realZ);
|
||||
}
|
||||
scene.blocks().set(x, height, z, bd);
|
||||
}
|
||||
|
||||
static void placeStackUp(ResolvedDecorator decorator, DecorationScene scene, int x, int z, int realX, int realZ,
|
||||
int height, int max, PlaceOpts opts) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (height < 0 || height >= data.height()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int effectiveMax = max;
|
||||
if (opts.underwater && height < opts.fluidHeight) {
|
||||
effectiveMax = opts.fluidHeight;
|
||||
}
|
||||
|
||||
int stack = computeStack(decorator, realX, realZ, effectiveMax);
|
||||
|
||||
if (stack == 1) {
|
||||
int targetY = height + 1;
|
||||
if (targetY >= data.height()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState existing = data.get(x, targetY, z);
|
||||
if (!canReplaceStackTarget(scene, existing, opts.underwater)
|
||||
|| (opts.caveSkipFluid && scene.isFluid(existing))) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState block = decorator.pickTopBlock(realX, realZ);
|
||||
if (block == null || (!opts.underwater && !canGoOn(scene, block, data.get(x, height, z)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
block = stackedVineBlock(block, stack, 0);
|
||||
data.set(x, targetY, z, block);
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState bdx = data.get(x, height, z);
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
BlockState bd = threshold >= decorator.topThreshold()
|
||||
? decorator.pickTopBlock(realX, realZ)
|
||||
: decorator.pickBlock(realX, realZ);
|
||||
|
||||
if (bd == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 0 && !opts.underwater && !canGoOn(scene, bd, bdx)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (opts.underwater && height + 1 + i > opts.fluidHeight) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (height + 1 + i >= data.height()) {
|
||||
break;
|
||||
}
|
||||
|
||||
BlockState existing = data.get(x, height + 1 + i, z);
|
||||
if (!canReplaceStackTarget(scene, existing, opts.underwater)
|
||||
|| (opts.caveSkipFluid && scene.isFluid(existing))) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (bd.material().equals(POINTED_DRIPSTONE)) {
|
||||
bd = dripstoneBlock(stack, i, DRIPSTONE_UP);
|
||||
}
|
||||
|
||||
bd = stackedVineBlock(bd, stack, i);
|
||||
data.set(x, height + 1 + i, z, bd);
|
||||
}
|
||||
}
|
||||
|
||||
static void placeStackDown(ResolvedDecorator decorator, DecorationScene scene, int x, int z, int realX, int realZ,
|
||||
int height, int minHeight, int max, PlaceOpts opts) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (height < 0 || height >= data.height()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int stack = computeStack(decorator, realX, realZ, max);
|
||||
|
||||
if (stack == 1) {
|
||||
if (opts.caveSkipFluid && scene.isFluid(data.get(x, height, z))) {
|
||||
return;
|
||||
}
|
||||
BlockState block = decorator.pickTopBlock(realX, realZ);
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
block = stackedVineBlock(block, stack, 0);
|
||||
data.set(x, height, z, fixFacesForHunk(scene, block, x, z, realX, height, realZ));
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height - i;
|
||||
if (h < 0 || h < minHeight) {
|
||||
break;
|
||||
}
|
||||
|
||||
double threshold = ((double) i) / (double) (stack - 1);
|
||||
BlockState bd = threshold >= decorator.topThreshold()
|
||||
? decorator.pickTopBlock(realX, realZ)
|
||||
: decorator.pickBlock(realX, realZ);
|
||||
|
||||
if (bd == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (bd.material().equals(POINTED_DRIPSTONE)) {
|
||||
bd = dripstoneBlock(stack, i, DRIPSTONE_DOWN);
|
||||
}
|
||||
|
||||
bd = stackedVineBlock(bd, stack, i);
|
||||
if (opts.caveSkipFluid && scene.isFluid(data.get(x, h, z))) {
|
||||
break;
|
||||
}
|
||||
data.set(x, h, z, fixFacesForHunk(scene, bd, x, z, realX, h, realZ));
|
||||
}
|
||||
}
|
||||
|
||||
static void placeFloatingSimple(ResolvedDecorator decorator, DecorationScene scene,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
BlockState bd = decorator.pickBlock(realX, realZ);
|
||||
if (bd == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String half = bd.properties().get(HALF);
|
||||
if (half != null) {
|
||||
int lowerY = height + 1;
|
||||
int upperY = height + 2;
|
||||
if (max <= 2 || !canPlaceTwoBlockPlant(scene, xf, zf, lowerY, upperY, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
BlockState upper = bd.withProperty(HALF, topHalfValue(half));
|
||||
BlockState lower = bd.withProperty(HALF, bottomHalfValue(half));
|
||||
data.set(xf, lowerY, zf, lower);
|
||||
data.set(xf, upperY, zf, upper);
|
||||
} catch (Throwable e) {
|
||||
scene.log().error("Failed to place a two-block plant", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (max > 1 && height + 1 < data.height()) {
|
||||
data.set(xf, height + 1, zf, bd);
|
||||
}
|
||||
}
|
||||
|
||||
static int placeFloatingStacked(ResolvedDecorator decorator, DecorationScene scene,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
int stack = decorator.stackHeight(realX, realZ);
|
||||
if (decorator.isScaleStack()) {
|
||||
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.absoluteMaxStack());
|
||||
} else {
|
||||
stack = Math.min(max, stack);
|
||||
}
|
||||
|
||||
int placed = 0;
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + 1 + i;
|
||||
if (h >= height + max || h >= data.height()) {
|
||||
break;
|
||||
}
|
||||
double threshold = stack == 1 ? 0.0 : ((double) i) / (stack - 1);
|
||||
BlockState bd = threshold >= decorator.topThreshold()
|
||||
? decorator.pickTopBlock(realX, realZ)
|
||||
: decorator.pickBlock(realX, realZ);
|
||||
if (bd == null) {
|
||||
break;
|
||||
}
|
||||
bd = stackedVineBlock(bd, stack, i);
|
||||
data.set(xf, h, zf, bd);
|
||||
placed++;
|
||||
}
|
||||
return placed;
|
||||
}
|
||||
|
||||
/**
|
||||
* A vine placed at {@code x}, {@code y}, {@code z} (the chunk's local column {@code rX}, {@code rZ}) faces the neighbours that
|
||||
* can hold it: the blocks the mantle planned there, else the chunk's own blocks. A vine with no such neighbour faces down,
|
||||
* or up when it cannot face down. Any other block is returned as it is.
|
||||
*/
|
||||
static BlockState fixFacesForHunk(DecorationScene scene, BlockState b, int rX, int rZ, int x, int y, int z) {
|
||||
if (b == null || !scene.has(BlockTrait.VINE, b)) {
|
||||
return b;
|
||||
}
|
||||
Hunk<BlockState> hunk = scene.blocks();
|
||||
BlockState fixed = b;
|
||||
for (Face face : FACES) {
|
||||
if (b.properties().containsKey(face.property())) {
|
||||
fixed = fixed.withProperty(face.property(), "false");
|
||||
}
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
for (Face face : FACES) {
|
||||
int yy = y + face.dy();
|
||||
BlockFace opposite = OPPOSITES.get(face.face());
|
||||
|
||||
BlockState planned = scene.plannedAt(x + face.dx(), yy, z + face.dz());
|
||||
BlockState support = planned == null ? AIR : planned;
|
||||
if (scene.registry().canAttach(b, support, opposite)) {
|
||||
if (b.properties().containsKey(face.property())) {
|
||||
found = true;
|
||||
fixed = fixed.withProperty(face.property(), "true");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
int xx = rX + face.dx();
|
||||
int zz = rZ + face.dz();
|
||||
if (xx < 0 || xx > CHUNK_LAST || zz < 0 || zz > CHUNK_LAST || yy < 0 || yy >= hunk.height()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (scene.registry().canAttach(b, hunk.get(xx, yy, zz), opposite)) {
|
||||
if (b.properties().containsKey(face.property())) {
|
||||
found = true;
|
||||
fixed = fixed.withProperty(face.property(), "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
String fallback = b.properties().containsKey("down") ? "down" : "up";
|
||||
if (b.properties().containsKey(fallback)) {
|
||||
fixed = fixed.withProperty(fallback, "true");
|
||||
}
|
||||
}
|
||||
return fixed;
|
||||
}
|
||||
|
||||
static boolean canGoOn(DecorationScene scene, BlockState decorator, BlockState surface) {
|
||||
return decorator != null && surface != null && scene.canGoOn(decorator, surface);
|
||||
}
|
||||
|
||||
static boolean isValidShorelineSupport(DecorationScene scene, ResolvedDecorator decorator, BlockState decorant, BlockState surface) {
|
||||
return surface != null
|
||||
&& scene.isSolid(surface)
|
||||
&& (decorator.isForcePlace() || canGoOn(scene, decorant, surface));
|
||||
}
|
||||
|
||||
static boolean canReplaceStackTarget(DecorationScene scene, BlockState state, boolean allowFluid) {
|
||||
return scene.isAir(state) || allowFluid && scene.isFluid(state);
|
||||
}
|
||||
|
||||
private static boolean canPlaceTwoBlockPlant(DecorationScene scene, int x, int z,
|
||||
int lowerY, int upperY, boolean caveSkipFluid) {
|
||||
Hunk<BlockState> data = scene.blocks();
|
||||
if (lowerY < 0 || upperY >= data.height()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockState lower = data.get(x, lowerY, z);
|
||||
BlockState upper = data.get(x, upperY, z);
|
||||
return scene.isAir(lower) && scene.isAir(upper)
|
||||
&& (!caveSkipFluid || !scene.isFluid(lower) && !scene.isFluid(upper));
|
||||
}
|
||||
|
||||
private static int computeStack(ResolvedDecorator decorator, double realX, double realZ, int max) {
|
||||
int stack = decorator.stackHeight(realX, realZ);
|
||||
if (decorator.isScaleStack()) {
|
||||
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.absoluteMaxStack());
|
||||
} else {
|
||||
stack = Math.min(max, stack);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static BlockState[] dripstones(String direction) {
|
||||
BlockState[] arr = new BlockState[DRIPSTONE_THICKNESS.length];
|
||||
for (int k = 0; k < arr.length; k++) {
|
||||
arr[k] = BlockState.parse("minecraft:pointed_dripstone[thickness=" + DRIPSTONE_THICKNESS[k] + ",vertical_direction=" + direction + "]");
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
private static BlockState dripstoneBlock(int stack, int i, BlockState[] byThickness) {
|
||||
int thIdx;
|
||||
if (i == stack - 1) {
|
||||
thIdx = 0;
|
||||
} else if (i == stack - 2) {
|
||||
thIdx = 1;
|
||||
} else {
|
||||
thIdx = 2;
|
||||
}
|
||||
return byThickness[thIdx];
|
||||
}
|
||||
|
||||
/** The key of the vine block that fills a stack of vines at {@code index}: the tip at the end, the plant before it; null for other blocks. */
|
||||
static ResourceId stackedVineMaterial(BlockState state, int stack, int index) {
|
||||
ResourceId material = state.material();
|
||||
boolean tip = index == stack - 1;
|
||||
if (material.equals(WEEPING_VINES) || material.equals(WEEPING_VINES_PLANT)) {
|
||||
return tip ? WEEPING_VINES : WEEPING_VINES_PLANT;
|
||||
}
|
||||
if (material.equals(TWISTING_VINES) || material.equals(TWISTING_VINES_PLANT)) {
|
||||
return tip ? TWISTING_VINES : TWISTING_VINES_PLANT;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BlockState stackedVineBlock(BlockState state, int stack, int index) {
|
||||
ResourceId material = stackedVineMaterial(state, stack, index);
|
||||
return material == null ? state : new BlockState(material.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/*
|
||||
* Floating island decoration path. Bypasses all canGoOn, slope, whitelist, and blacklist
|
||||
* gating from IrisSurfaceDecorator: the island top IS the biome's designated surface by
|
||||
* construction, so those material-compatibility checks are never meaningful here.
|
||||
*/
|
||||
public class FloatingDecorator {
|
||||
|
||||
public static int decorateColumn(DecorationScene scene, DecoratedBiome target, DecorationPart part,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, RNG rng,
|
||||
Runnable candidatesNullCallback) {
|
||||
BiomeDecorators decorators = scene.decorators();
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(target, part), rng, realX, realZ, decorators.log());
|
||||
|
||||
if (decorator == null) {
|
||||
candidatesNullCallback.run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!decorator.isStacking()) {
|
||||
DecoratorCore.placeFloatingSimple(decorator, scene, xf, zf, realX, realZ, height, max);
|
||||
return max > 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
return DecoratorCore.placeFloatingStacked(decorator, scene, xf, zf, realX, realZ, height, max);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
public IrisCeilingDecorator(DecorationScene scene) {
|
||||
super(scene, DecorationPart.CEILING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
DecoratedBiome biome, int height, int max) {
|
||||
boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(biome.kind());
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
|
||||
|
||||
if (decorator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decorator.isStacking()) {
|
||||
if (caveSkipFluid && scene.isFluid(scene.blocks().get(x, height, z))) {
|
||||
return;
|
||||
}
|
||||
DecoratorCore.placeSingleAt(decorator, scene, x, z, realX, height, realZ, true);
|
||||
return;
|
||||
}
|
||||
|
||||
DecoratorCore.PlaceOpts opts = DecoratorCore.SCRATCH_OPTS.get();
|
||||
opts.reset();
|
||||
opts.caveSkipFluid = caveSkipFluid;
|
||||
DecoratorCore.placeStackDown(decorator, scene, x, z, realX, realZ, height, 0, max, opts);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A decorator of one kind of place, placing into the blocks of a {@link DecorationScene}. */
|
||||
public abstract class IrisEngineDecorator {
|
||||
private static final long COLUMN_X_FACTOR = 29356788L;
|
||||
private static final long COLUMN_Z_FACTOR = 10439677L;
|
||||
private static final int X_PART_OFFSET = 6;
|
||||
private static final int Z_PART_OFFSET = 1;
|
||||
|
||||
private final DecorationPart part;
|
||||
protected final DecorationScene scene;
|
||||
protected final BiomeDecorators decorators;
|
||||
|
||||
protected IrisEngineDecorator(DecorationScene scene, DecorationPart part) {
|
||||
this.scene = scene;
|
||||
this.part = part;
|
||||
this.decorators = scene.decorators();
|
||||
}
|
||||
|
||||
public DecorationPart getPart() {
|
||||
return part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorates one column. {@code x} and {@code z} are the column in the chunk, {@code realX} and {@code realZ} in the world,
|
||||
* with the world columns next to it on either side; {@code height} is the Y to decorate from and {@code max} how much room
|
||||
* there is.
|
||||
*/
|
||||
public abstract void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
|
||||
DecoratedBiome biome, int height, int max);
|
||||
|
||||
/** {@link #decorate} for a decorator that looks at no neighbouring column. */
|
||||
public void decorate(int x, int z, int realX, int realZ, DecoratedBiome biome, int height, int max) {
|
||||
decorate(x, z, realX, realX, realX, realZ, realZ, realZ, biome, height, max);
|
||||
}
|
||||
|
||||
protected RNG getRNG(int x, int z) {
|
||||
long seed = DecoratorCore.partSeed(scene.seed(), part);
|
||||
long modX = COLUMN_X_FACTOR ^ (part.ordinal() + X_PART_OFFSET);
|
||||
long modZ = COLUMN_Z_FACTOR ^ (part.ordinal() + Z_PART_OFFSET);
|
||||
return new RNG(x * modX + z * modZ + seed);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 391 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user