Object place modes are data the placement stages ask

Each ObjectPlaceMode carries a PlaceMode: its height sampling, its stilt, its VacuumProfile (default radius, column
step, edge) and its traits (RAW_STAMP, FREE_HEIGHT, UPSIDE_DOWN, CAVE_ANCHORED). The stages, the structure placer,
the locator and the replacement validation ask the data instead of comparing modes; a floating island derives its
stilt-free mode from the data. The JSON names are unchanged.

Core and the adapters no longer read ObjectPlaceMode: the jigsaw export asks the structure whether it stamps its
pieces where assembled, and the structure commands take IrisObjectPlacement.stampingStructurePieces().
This commit is contained in:
piexel committed 2026-10-10 03:54:40 +02:00
1 parent 3d7b82c2cb
commit 95817f6d17
19 files changed
+241 -111

No files matched your search

@@ -25,106 +25,114 @@ import com.volmit.config.Desc;
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(AnchorSampling.CENTER, StiltShape.NONE),
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(AnchorSampling.HIGHEST, StiltShape.NONE),
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(AnchorSampling.HIGHEST_CORNER, StiltShape.NONE),
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(AnchorSampling.LOWEST, StiltShape.NONE),
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(AnchorSampling.LOWEST_CORNER, StiltShape.NONE),
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(AnchorSampling.HIGHEST, StiltShape.STRAIGHT),
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(AnchorSampling.HIGHEST_CORNER, StiltShape.STRAIGHT),
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(AnchorSampling.LOWEST, StiltShape.STRAIGHT),
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(AnchorSampling.LOWEST_CORNER, StiltShape.STRAIGHT),
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(AnchorSampling.CENTER, StiltShape.STRAIGHT),
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(AnchorSampling.HIGHEST, StiltShape.ERODE),
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(AnchorSampling.CENTER, StiltShape.ORGANIC),
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(AnchorSampling.CENTER, StiltShape.CEILING),
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(AnchorSampling.CENTER, StiltShape.NONE),
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(AnchorSampling.CENTER, StiltShape.NONE),
VACUUM_HIGH(PlaceMode.vacuum(VacuumProfile.HIGH)),
@Desc("VACUUM with a smaller radius and coarser sampling for performance. Use when seating many objects.")
VACUUM_FAST(AnchorSampling.CENTER, StiltShape.NONE),
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(AnchorSampling.CENTER, StiltShape.NONE),
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(AnchorSampling.CENTER, StiltShape.NONE),
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(AnchorSampling.SURFACE, StiltShape.NONE),
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(AnchorSampling.TRANSLATION, StiltShape.NONE),
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(AnchorSampling.REQUESTED, StiltShape.NONE);
STRUCTURE_PIECE(PlaceMode.of(AnchorSampling.REQUESTED, StiltShape.NONE, PlaceTrait.RAW_STAMP, PlaceTrait.FREE_HEIGHT));
private final AnchorSampling anchor;
private final StiltShape stilt;
private final PlaceMode placeMode;
ObjectPlaceMode(AnchorSampling anchor, StiltShape stilt) {
this.anchor = anchor;
this.stilt = stilt;
ObjectPlaceMode(PlaceMode placeMode) {
this.placeMode = placeMode;
}
/** How a placement without a requested height finds one. */
public AnchorSampling anchor() {
return anchor;
/** What the mode does, for the placement stages to ask. */
public PlaceMode placeMode() {
return placeMode;
}
/** The stilt this mode grows under or above the object. */
public StiltShape stilt() {
return stilt;
}
public boolean isVacuum() {
return this == VACUUM || this == VACUUM_HIGH || this == VACUUM_FAST || this == VACUUM_ORGANIC || this == VACUUM_WAVY;
/**
* 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,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;
}
}
@@ -18,8 +18,8 @@
package art.arcane.iris.engine.framework;
import art.arcane.iris.builtin.anchor.PlaceTrait;
import art.arcane.iris.engine.framework.structure.NativeStartPlanner;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.engine.framework.structure.StructureResources;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.structure.StructureGraphCatalog;
@@ -807,8 +807,7 @@ public final class IrisStructureLocator {
IrisStructurePlacement placement,
IrisStructure structure, int baseY) {
if (placement.isAnchoredUnderground() || pieces.size() <= 1
|| structure.getPlaceMode() == ObjectPlaceMode.STRUCTURE_PIECE
|| structure.getPlaceMode() == ObjectPlaceMode.FLOATING) {
|| structure.getPlaceMode().placeMode().has(PlaceTrait.FREE_HEIGHT)) {
return pieces;
}
int[] bounds = computeBounds(pieces);
@@ -818,8 +817,7 @@ public final class IrisStructureLocator {
static boolean hasExactY(IrisStructurePlacement placement, IrisStructure structure,
KList<PlacedStructurePiece> pieces) {
return placement.isAnchoredUnderground() || pieces.size() > 1
|| structure.getPlaceMode() == ObjectPlaceMode.STRUCTURE_PIECE
|| structure.getPlaceMode() == ObjectPlaceMode.FLOATING;
|| structure.getPlaceMode().placeMode().has(PlaceTrait.FREE_HEIGHT);
}
private static boolean fitsVerticalBounds(KList<PlacedStructurePiece> pieces, int worldMin, int worldMax) {
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.framework.structure;
import art.arcane.iris.builtin.anchor.PlaceTrait;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.core.pack.PackValidationIo;
import art.arcane.volmlib.util.json.JSONArray;
@@ -234,8 +235,7 @@ public final class NativeReplacementValidation {
for (StructureGraphValidation.SampledVerticalEnvelope sampled : sampledVerticalEnvelopes) {
boolean exactY = placementBounds.underground()
|| sampled.pieceCount() > 1
|| placeMode == ObjectPlaceMode.STRUCTURE_PIECE
|| placeMode == ObjectPlaceMode.FLOATING;
|| placeMode.placeMode().has(PlaceTrait.FREE_HEIGHT);
if (!exactY) {
continue;
}
@@ -244,8 +244,7 @@ public final class NativeReplacementValidation {
long maximumYOffset = sampled.maximumYOffset();
boolean surfaceAligned = !placementBounds.underground()
&& sampled.pieceCount() > 1
&& placeMode != ObjectPlaceMode.STRUCTURE_PIECE
&& placeMode != ObjectPlaceMode.FLOATING;
&& !placeMode.placeMode().has(PlaceTrait.FREE_HEIGHT);
if (surfaceAligned) {
maximumYOffset -= minimumYOffset;
minimumYOffset = 0L;
@@ -21,7 +21,6 @@ package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.engine.object.terrain.floating.FloatingChildren;
import art.arcane.iris.builtin.floating.FloatingChildBiome;
import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.IrisComplex;
@@ -272,7 +271,7 @@ public class FloatingObjectPlacing {
int wz = minZ + pickedZf - fp.getTallestKz();
IrisObjectPlacement anchored = placement.toPlacement(obj.getLoadKey());
anchored.setMode(translateStiltModeForFloating(anchored.getMode()));
anchored.setMode(anchored.getMode().onFloatingIsland());
anchored.setTranslate(new IrisObjectTranslate());
anchored.setRotation(ROTATION_NONE);
anchored.setForcePlace(true);
@@ -374,7 +373,7 @@ public class FloatingObjectPlacing {
int wz = invertedBaseZ(minZ, pickedZf, fp, invertedRotation);
IrisObjectPlacement inverted = placement.toPlacement(obj.getLoadKey());
inverted.setMode(translateStiltModeForFloating(inverted.getMode()));
inverted.setMode(inverted.getMode().onFloatingIsland());
inverted.setTranslate(new IrisObjectTranslate());
inverted.setRotation(invertedRotation);
inverted.setForcePlace(true);
@@ -536,19 +535,6 @@ public class FloatingObjectPlacing {
return key + "@" + id;
}
private static ObjectPlaceMode translateStiltModeForFloating(ObjectPlaceMode m) {
return switch (m) {
case STILT -> ObjectPlaceMode.MAX_HEIGHT;
case FAST_STILT -> ObjectPlaceMode.FAST_MAX_HEIGHT;
case MIN_STILT -> ObjectPlaceMode.MIN_HEIGHT;
case FAST_MIN_STILT -> ObjectPlaceMode.FAST_MIN_HEIGHT;
case CENTER_STILT -> ObjectPlaceMode.CENTER_HEIGHT;
case ERODE_STILT -> ObjectPlaceMode.MAX_HEIGHT;
case STRUCTURE_PIECE -> ObjectPlaceMode.CENTER_HEIGHT;
default -> m;
};
}
/** How far, in blocks along X and Z, placements may write beyond their chunk. */
public int reach() {
int maxObjectExtent = 16;
@@ -19,6 +19,7 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.builtin.anchor.PlaceTrait;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.carve.CaveAnchorMode;
import art.arcane.iris.builtin.carve.CaveProfile;
@@ -428,7 +429,7 @@ public class ObjectPlacing {
IrisObjectPlacement placement = p.asPlacement();
boolean carving = placement.getCarvingSupport() == CarvingMode.CARVING_ONLY;
CaveAnchorMode anchorMode = resolveAnchorMode(placement, caveProfile);
if (placement.getMode() == ObjectPlaceMode.CEILING_HANG) {
if (placement.getMode().placeMode().has(PlaceTrait.UPSIDE_DOWN)) {
anchorMode = CaveAnchorMode.CEILING;
}
int anchorScanStep = resolveAnchorScanStep(caveProfile);
@@ -618,7 +619,7 @@ public class ObjectPlacing {
) {
CaveObjectPlacementTransaction transaction = new CaveObjectPlacementTransaction(placer, anchorY, minDepthBelowSurface);
int placeY = anchorY;
if (placement.getMode() == ObjectPlaceMode.CEILING_HANG) {
if (placement.getMode().placeMode().has(PlaceTrait.UPSIDE_DOWN)) {
placeY = Math.max(1, transaction.getCaveCeiling(x, z) - 1 - Math.floorDiv(object.getH(), 2));
}
String marker = placementMarker(object, id, markerContext);
@@ -792,7 +793,7 @@ public class ObjectPlacing {
int minZ = chunkZ << 4;
int density = objectPlacement.getDensity(rng, minX, minZ, engine.getData());
CaveAnchorMode anchorMode = resolveAnchorMode(objectPlacement, caveProfile);
if (objectPlacement.getMode() == ObjectPlaceMode.CEILING_HANG) {
if (objectPlacement.getMode().placeMode().has(PlaceTrait.UPSIDE_DOWN)) {
anchorMode = CaveAnchorMode.CEILING;
}
int anchorScanStep = resolveAnchorScanStep(caveProfile);
@@ -1195,7 +1196,7 @@ public class ObjectPlacing {
}
ObjectPlaceMode mode = objectPlacement.getMode();
if (mode == ObjectPlaceMode.FLOATING || mode == ObjectPlaceMode.STRUCTURE_PIECE) {
if (mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
return objectPlacement;
}
boolean needsModeChange = mode != ObjectPlaceMode.FAST_MIN_STILT;
@@ -1549,8 +1550,8 @@ public class ObjectPlacing {
int warp = placement.getWarp() != null && !placement.getWarp().isFlat()
? (int) Math.ceil(Math.abs(placement.getWarp().getMultiplier()) / 2D)
: 0;
int vacuum = IrisObjectVacuum.isVacuumMode(placement.getMode())
? 2 * IrisObjectVacuum.resolveRadius(placement.getMode(), placement.getVacuumSettings())
int vacuum = placement.getMode().placeMode().bendsTerrain()
? 2 * IrisObjectVacuum.resolveRadius(placement.getMode().placeMode().vacuum(), placement.getVacuumSettings())
: 0;
long reach = (long) footprint + translation + warp + vacuum;
return reach > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) reach;
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.builtin.anchor.PlaceTrait;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.engine.framework.structure.StructureResources;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
@@ -137,7 +138,7 @@ public class StructurePlacing {
? null : new Long2IntOpenHashMap();
boolean supportNonOccluding = stilt != null && stilt.supportNonOccluding();
if (placement.isAnchoredUnderground()) {
ObjectPlaceMode undergroundMode = (mode == ObjectPlaceMode.ORGANIC_STILT || mode == ObjectPlaceMode.CEILING_HANG)
ObjectPlaceMode undergroundMode = mode.placeMode().has(PlaceTrait.CAVE_ANCHORED)
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
for (PlacedStructurePiece p : pieces) {
if (placeObject(writer, structure, p, undergroundMode, p.getY(), rng,
@@ -145,7 +146,7 @@ public class StructurePlacing {
failedPieces++;
}
}
} else if (mode == ObjectPlaceMode.STRUCTURE_PIECE || mode == ObjectPlaceMode.FLOATING) {
} else if (mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
for (PlacedStructurePiece p : pieces) {
if (placeObject(writer, structure, p, ObjectPlaceMode.STRUCTURE_PIECE, p.getY(), rng,
foundationColumns, supportNonOccluding) == -1) {
@@ -543,7 +544,7 @@ public class StructurePlacing {
if (!structure.getEdit().isEmpty()) {
config.setEdit(structure.getEdit());
}
if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
if (!mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
config.setForcePlace(true);
}
int placeY = (y == -1) ? -1 : y - engine.getMinHeight();
@@ -18,8 +18,8 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.PlaceTrait;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.anchor.AnchorHeight;
import art.arcane.iris.core.modules.IrisPlacement;
@@ -57,7 +57,7 @@ public final class AnchorModule implements IrisModule {
IrisPlacement placement = IrisPlacement.current();
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
IrisObjectPlacement config = prepared.config();
boolean structurePiece = prepared.mode() == ObjectPlaceMode.STRUCTURE_PIECE;
boolean structurePiece = prepared.mode().has(PlaceTrait.RAW_STAMP);
if (!config.isFromBottom() && placement.requestedY() < 0) {
return new AnchorHeight(sampled(context, placement, prepared));
}
@@ -18,9 +18,9 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.PlaceTrait;
import art.arcane.iris.engine.spawn.SpawnResources;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.blocks.ObjectReplace;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.IrisStages;
@@ -116,7 +116,7 @@ public final class BlocksModule implements IrisModule {
y = offset.y() + Math.floorDiv(placement.object().h, 2)
+ prepared.terrain().getHighest(x, z, placement.object().getLoader(), config.isUnderwater());
}
boolean structurePiece = prepared.mode() == ObjectPlaceMode.STRUCTURE_PIECE;
boolean structurePiece = prepared.mode().has(PlaceTrait.RAW_STAMP);
if (config.isMeld() && !structurePiece && !world.isSolid(x, y, z)) {
return;
}
@@ -208,6 +208,11 @@ public class IrisObjectPlacement {
/** The pack modules' settings this placement declares, decoded with it. */
private transient ModuleSettings moduleSettings = ModuleSettings.NONE;
/** A placement that stamps each object exactly at the position it is given, as a structure piece. */
public static IrisObjectPlacement stampingStructurePieces() {
return new IrisObjectPlacement().setMode(ObjectPlaceMode.STRUCTURE_PIECE);
}
public IrisObjectPlacement toPlacement(String... place) {
IrisObjectPlacement p = new IrisObjectPlacement();
p.setPlace(new KList<>(place));
@@ -18,7 +18,7 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.anchor.VacuumProfile;
import art.arcane.iris.builtin.vacuum.VacuumSettings;
public final class IrisObjectVacuum {
@@ -30,26 +30,14 @@ public final class IrisObjectVacuum {
private IrisObjectVacuum() {
}
public static boolean isVacuumMode(ObjectPlaceMode mode) {
return mode != null && mode.isVacuum();
}
public static int resolveRadius(ObjectPlaceMode mode, VacuumSettings settings) {
int radius = switch (mode) {
case VACUUM_HIGH -> 20;
case VACUUM_FAST -> 8;
default -> 12;
};
public static int resolveRadius(VacuumProfile vacuum, VacuumSettings settings) {
int radius = vacuum.defaultRadiusBlocks();
if (settings != null && settings.radius() > 0) {
radius = settings.radius();
}
return Math.max(0, Math.min(MAX_RADIUS_BLOCKS, radius));
}
public static int resolveStep(ObjectPlaceMode mode) {
return mode == ObjectPlaceMode.VACUUM_FAST ? 2 : 1;
}
public static double resolveFalloff(VacuumSettings settings) {
return settings != null ? Math.max(0.25, settings.falloff()) : 2.0;
}
@@ -18,7 +18,7 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.anchor.PlaceTrait;
import art.arcane.iris.builtin.prepare.SlopeClip;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
@@ -135,7 +135,7 @@ public final class PrepareModule implements IrisModule {
: null;
int randomY = randomHeightOffset(translate.getYRandom(), rng);
int warpMargin = config.getWarp().isFlat() ? 0 : (int) Math.ceil(Math.abs(config.getWarp().getMultiplier()) / 2D);
TransformedBounds bounds = transformedBounds(object, spin, translation, config.getMode() == ObjectPlaceMode.CEILING_HANG, warpMargin);
TransformedBounds bounds = transformedBounds(object, spin, translation, config.getMode().placeMode().has(PlaceTrait.UPSIDE_DOWN), warpMargin);
CNG surfaceWarp = config.getWarp().isFlat() ? null : config.getSurfaceWarp(rng, object.getLoader());
return new PreparedPlacement(config, terrain, spin, spinX, spinY, spinZ, translation, rotatedCenterY,
translatedCenterY, randomY, warpMargin, bounds, surfaceWarp);
@@ -18,7 +18,8 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.anchor.PlaceMode;
import art.arcane.iris.builtin.anchor.PlaceTrait;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.math.IrisBlockVector;
import art.arcane.iris.util.project.noise.CNG;
@@ -73,8 +74,8 @@ public final class PreparedPlacement {
return terrain;
}
ObjectPlaceMode mode() {
return config.getMode();
PlaceMode mode() {
return config.getMode().placeMode();
}
int spinX() {
@@ -131,7 +132,7 @@ public final class PreparedPlacement {
BlockPosition transform(BlockPosition local) {
IrisBlockVector offset = new IrisBlockVector(local.x(), local.y(), local.z());
spin.rotate(offset);
if (mode() == ObjectPlaceMode.CEILING_HANG) {
if (mode().has(PlaceTrait.UPSIDE_DOWN)) {
offset.setY(-offset.getBlockY());
}
if (translation != null) {
@@ -18,7 +18,7 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.anchor.VacuumProfile;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.vacuum.VacuumSettings;
import art.arcane.iris.builtin.IrisStages;
@@ -69,7 +69,7 @@ public final class VacuumModule implements IrisModule {
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
WrittenBlocks written = context.output(IrisStages.Blocks.WRITE);
Engine engine = prepared.terrain().getEngine();
if (!prepared.mode().isVacuum() || written.isEmpty() || engine == null) {
if (!prepared.mode().bendsTerrain() || written.isEmpty() || engine == null) {
return;
}
int baseY = written.blocks().stream().mapToInt(block -> block.position().y()).min().orElseThrow();
@@ -94,19 +94,19 @@ public final class VacuumModule implements IrisModule {
private final int highestY;
private Bend(PlacementStageContext context, PreparedPlacement prepared, Engine engine) {
ObjectPlaceMode mode = prepared.mode();
VacuumProfile vacuum = prepared.mode().vacuum();
this.placement = IrisPlacement.current();
this.prepared = prepared;
this.world = new PlacementWorld(context.access(), placement.states());
this.complex = engine.getComplex();
VacuumSettings settings = prepared.config().getVacuumSettings();
this.radius = IrisObjectVacuum.resolveRadius(mode, settings);
this.step = IrisObjectVacuum.resolveStep(mode);
this.radius = IrisObjectVacuum.resolveRadius(vacuum, settings);
this.step = vacuum.columnStepBlocks();
this.falloff = IrisObjectVacuum.resolveFalloff(settings);
this.jitter = settings != null ? Math.max(0, settings.organicJitter()) : DEFAULT_ORGANIC_JITTER;
this.waveAmplitude = IrisObjectVacuum.resolveWaveAmplitude(settings);
this.waveScale = IrisObjectVacuum.resolveWaveScale(settings);
this.waves = mode == ObjectPlaceMode.VACUUM_WAVY && waveAmplitude > 0 ? new SimplexNoise(WAVE_SEED) : null;
this.waves = vacuum.edge() == VacuumProfile.Edge.WAVY && waveAmplitude > 0 ? new SimplexNoise(WAVE_SEED) : null;
this.lowestY = IrisObjectVacuum.LOWEST_TARGET_Y;
this.highestY = engine.getHeight() - 1;
}
@@ -142,7 +142,7 @@ public final class VacuumModule implements IrisModule {
/** The radius, perturbed per column for the organic mode. */
private double effectiveRadius(int x, int z) {
if (prepared.mode() != ObjectPlaceMode.VACUUM_ORGANIC || jitter <= 0) {
if (prepared.mode().vacuum().edge() != VacuumProfile.Edge.JITTERED || jitter <= 0) {
return radius;
}
long hash = ((long) x * HASH_X) ^ ((long) z * HASH_Z);
@@ -18,8 +18,8 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.PlaceTrait;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.validate.ObjectLimit;
import com.volmit.FeatureRegistry;
import art.arcane.iris.builtin.IrisStages;
@@ -81,8 +81,7 @@ public final class ValidateModule implements IrisModule {
IrisPlacement placement = IrisPlacement.current();
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
IrisObjectPlacement config = prepared.config();
if (config.isForcePlace() || config.isFromBottom() || prepared.mode() == ObjectPlaceMode.FLOATING
|| prepared.mode() == ObjectPlaceMode.STRUCTURE_PIECE) {
if (config.isForcePlace() || config.isFromBottom() || prepared.mode().has(PlaceTrait.FREE_HEIGHT)) {
return;
}
int y = context.output(IrisStages.Anchor.HEIGHT).y();
@@ -117,13 +116,13 @@ public final class ValidateModule implements IrisModule {
IrisPlacement placement = IrisPlacement.current();
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
IrisObjectPlacement config = prepared.config();
if (config.isForcePlace() || prepared.mode() == ObjectPlaceMode.STRUCTURE_PIECE) {
if (config.isForcePlace() || prepared.mode().has(PlaceTrait.RAW_STAMP)) {
return;
}
int y = context.output(IrisStages.Anchor.HEIGHT).y();
int rotated = prepared.rotatedCenterY();
int translated = prepared.translatedCenterY();
if (placement.requestedY() < 0 && prepared.mode() != ObjectPlaceMode.FLOATING && !config.isUnderwater()
if (placement.requestedY() < 0 && !prepared.mode().has(PlaceTrait.FREE_HEIGHT) && !config.isUnderwater()
&& !config.isOnwater() && prepared.terrain().isUnderwater(placement.x(), placement.z())) {
context.reject("underwater-anchor");
} else if (placement.cave() != null
@@ -138,7 +137,7 @@ public final class ValidateModule implements IrisModule {
private static void checkNativeStructures(PlacementStageContext context) {
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
if (prepared.mode() == ObjectPlaceMode.STRUCTURE_PIECE) {
if (prepared.mode().has(PlaceTrait.RAW_STAMP)) {
return;
}
int y = context.output(IrisStages.Anchor.HEIGHT).y() + prepared.randomY();
@@ -208,7 +207,7 @@ public final class ValidateModule implements IrisModule {
IrisPlacement placement = IrisPlacement.current();
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
IrisObjectPlacement config = prepared.config();
if (config.isForcePlace() || prepared.mode() == ObjectPlaceMode.STRUCTURE_PIECE
if (config.isForcePlace() || prepared.mode().has(PlaceTrait.RAW_STAMP)
|| (config.getAllowedCollisions().isEmpty() && config.getForbiddenCollisions().isEmpty())) {
return;
}
@@ -18,7 +18,7 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.anchor.AnchorSampling;
import art.arcane.iris.core.modules.IrisPlacement;
/**
@@ -51,6 +51,6 @@ record WorldVolume(int minX, int maxX, int minY, int maxY, int minZ, int maxZ) {
/** Whether each block of the placement follows the surface of its own column. */
static boolean isPainted(IrisPlacement placement, PreparedPlacement prepared) {
return placement.requestedY() < 0 && prepared.mode() == ObjectPlaceMode.PAINT;
return placement.requestedY() < 0 && prepared.mode().anchor() == AnchorSampling.SURFACE;
}
}
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.object.structure;
import art.arcane.iris.builtin.anchor.PlaceTrait;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.blocks.ObjectReplace;
import art.arcane.iris.engine.object.loot.IrisLootTable;
@@ -109,6 +110,11 @@ public class IrisStructure extends IrisRegistrant {
@Desc("If this structure was generated by importing a vanilla or datapack structure, this is that structure's key (provenance). Empty for hand-authored structures.")
private String vanillaSource = "";
/** Whether the structure's pieces are stamped where the assembler put them, as a vanilla jigsaw places them. */
public boolean stampsPiecesWhereAssembled() {
return placeMode != null && placeMode.placeMode().has(PlaceTrait.RAW_STAMP);
}
public IrisJigsawMode resolvedMode() {
return mode == null ? IrisJigsawMode.SPATIAL_JIGSAW : mode;
}