mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Batch 7 stage 3: object placing runs on the api
The object, floating and tree placers place through PackWorld.placements() with their own ObjectRun input instead of ObjectHost. ObjectHost, ObjectChunk, ObjectSink, the builtin PlaceableObject and the ObjectPlacement facade are gone; objects come from PackResources.objects(), and Iris's chunk random, density and heightmap noise from the LegacyStreams extension. Placement stage constants move to modules.placement.PlacementStages, and smart bore debugging is the dimension setting iris:blocks/debug-smart-bore. EdgeSimplex is a copy of Iris's 2D simplex, pinned against it in Iris. Structure loot reads the structure's tables through StructureHost until stage 4 moves the structures.
This commit is contained in:
1 parent
1582a2126f
commit
a13593f16e
97 files changed
+3087
-1195
No files matched your search
@@ -86,11 +86,14 @@ include art/arcane/iris/engine/mantle/components/PlacementReach*.class
|
||||
include art/arcane/iris/engine/mantle/components/ObjectWarmUp*.class
|
||||
include art/arcane/iris/engine/mantle/components/ObjectLocating*.class
|
||||
include art/arcane/iris/engine/mantle/components/TreeGrowing*.class
|
||||
include art/arcane/iris/engine/mantle/components/ObjectChunk*.class
|
||||
include art/arcane/iris/engine/mantle/components/GoldenDebugTerrain*.class
|
||||
include art/arcane/iris/engine/object/procedural/**
|
||||
module art.arcane.iris.engine.modifier.FloatingModule
|
||||
include art/arcane/iris/engine/modifier/FloatingIslands*.class
|
||||
include art/arcane/iris/engine/object/terrain/floating/**
|
||||
include art/arcane/iris/engine/mantle/components/FloatingObjectPlacing*.class
|
||||
include art/arcane/iris/engine/mantle/components/FloatingPlacer*.class
|
||||
include art/arcane/iris/engine/mantle/components/FloatingIslandSampleResolver*.class
|
||||
include art/arcane/iris/engine/mantle/components/IslandFace*.class
|
||||
include art/arcane/iris/engine/mantle/components/UndersideTurn*.class
|
||||
|
||||
@@ -36,6 +36,8 @@ public final class IrisSeedPurposes {
|
||||
public static final ResourceId ENTITY = purpose("entity");
|
||||
public static final ResourceId LOOT = purpose("loot");
|
||||
public static final ResourceId MANTLE = purpose("mantle");
|
||||
/** The noise that warps the columns of object placements with a surface warp. */
|
||||
public static final ResourceId OBJECT_WARP = purpose("object-warp");
|
||||
public static final ResourceId POST = purpose("post");
|
||||
public static final ResourceId TERRAIN = purpose("terrain");
|
||||
|
||||
|
||||
@@ -18,111 +18,19 @@
|
||||
|
||||
package art.arcane.iris.builtin;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.AnchorHeight;
|
||||
import art.arcane.iris.builtin.blocks.WrittenBlocks;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.PreparedPlacement;
|
||||
import art.arcane.iris.builtin.stilt.StiltLayers;
|
||||
import com.volmit.stage.BlockStage;
|
||||
import com.volmit.stage.ChunkStage;
|
||||
import com.volmit.stage.MantleStage;
|
||||
import com.volmit.stage.PlacementStage;
|
||||
import com.volmit.stage.Stage;
|
||||
|
||||
/**
|
||||
* Every stage of Iris's built-in modules, one nested class per module. Modules are listed in the order their
|
||||
* pipelines run them: placement, then mantle, then chunk; a module with stages in several pipelines is listed
|
||||
* where its first stage runs. The stage graph decides the actual order.
|
||||
* 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:prepare}: what a placement decides before it looks for its height. */
|
||||
public static final class Prepare {
|
||||
/** The rotation the placement uses: the requested one, turned downhill when the settings ask to face the slope. Rejects {@code slope}. */
|
||||
public static final PlacementStage<ObjectRotation> SLOPE = Stage.placement("iris:prepare/slope", ObjectRotation.class);
|
||||
/** The random rotation, translation and height offset, chosen once per placement. */
|
||||
public static final PlacementStage<PreparedPlacement> TRANSFORMS = Stage.placement("iris:prepare/transforms", PreparedPlacement.class);
|
||||
|
||||
private Prepare() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:anchor}: the height an object is placed at. */
|
||||
public static final class Anchor {
|
||||
/** The requested or sampled height the checks judge. Rejects {@code carving-anchor}. */
|
||||
public static final PlacementStage<AnchorHeight> HEIGHT = Stage.placement("iris:anchor/height", AnchorHeight.class);
|
||||
/** The height the object's blocks are written at: the checked height plus the random offset. */
|
||||
public static final PlacementStage<AnchorHeight> FINAL = Stage.placement("iris:anchor/final", AnchorHeight.class);
|
||||
|
||||
private Anchor() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:validate}: the checks that reject a placement before anything is written, in this order. */
|
||||
public static final class Validate {
|
||||
/** Rejects {@code bedrock-anchor} and {@code surface-support}. */
|
||||
public static final PlacementStage<Void> SURFACE = Stage.placement("iris:validate/surface");
|
||||
/** Rejects {@code underwater-anchor}, {@code cave-clearance}, {@code fluid-height} and {@code height-clamp}. */
|
||||
public static final PlacementStage<Void> LIMITS = Stage.placement("iris:validate/limits");
|
||||
/** Rejects {@code native-structure}, even for placements that force their way past the other checks. */
|
||||
public static final PlacementStage<Void> STRUCTURES = Stage.placement("iris:validate/structures");
|
||||
/** Rejects {@code object-collision}. */
|
||||
public static final PlacementStage<Void> COLLISIONS = Stage.placement("iris:validate/collisions");
|
||||
|
||||
private Validate() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:bore}: clearing the object's volume before its blocks are written. */
|
||||
public static final class Bore {
|
||||
public static final PlacementStage<Void> CLEAR = Stage.placement("iris:bore/clear");
|
||||
|
||||
private Bore() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:blocks}: writing the object's blocks. */
|
||||
public static final class Blocks {
|
||||
/** Writes each object block where the placement puts it. */
|
||||
public static final BlockStage<WrittenBlocks> WRITE = Stage.placementBlock("iris:blocks/write", WrittenBlocks.class);
|
||||
/** Marks some written blocks with the placement's markers. */
|
||||
public static final PlacementStage<Void> MARKERS = Stage.placement("iris:blocks/markers");
|
||||
/** Milestone: stages requiring it run after the object and its markers are written. */
|
||||
public static final PlacementStage<Void> COMPLETE = Stage.placement("iris:blocks/complete");
|
||||
|
||||
private Blocks() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:stilt}: the stilts of the stilt and ceiling placement modes. */
|
||||
public static final class Stilt {
|
||||
/** Finds the layers to repeat. */
|
||||
public static final BlockStage<StiltLayers> LAYERS = Stage.placementBlock("iris:stilt/layers", StiltLayers.class);
|
||||
/** Grows the stilt once the object is written. */
|
||||
public static final PlacementStage<Void> FILL = Stage.placement("iris:stilt/fill");
|
||||
|
||||
private Stilt() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:vacuum}: bending the terrain to meet objects of the vacuum placement modes. */
|
||||
public static final class Vacuum {
|
||||
public static final PlacementStage<Void> TERRAIN = Stage.placement("iris:vacuum/terrain");
|
||||
|
||||
private Vacuum() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:snow}: snow on the object, after its stilt or terrain bend. */
|
||||
public static final class Snow {
|
||||
public static final PlacementStage<Void> COVER = Stage.placement("iris:snow/cover");
|
||||
|
||||
private Snow() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 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. */
|
||||
|
||||
@@ -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;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/**
|
||||
* The random streams and noise of Iris's own generators that decide where existing worlds have their objects, which no
|
||||
* API noise reproduces: Iris's chunk random, and the noise of a placement's density style and virtual heightmap. Iris
|
||||
* offers it as an extension of its worlds: {@code world.extension(LegacyStreams.class)}.
|
||||
*/
|
||||
public interface LegacyStreams {
|
||||
/** The random a chunk's objects are placed with: the same for the same chunk of the same world. */
|
||||
RNG objectChunkRandom(int chunkX, int chunkZ);
|
||||
|
||||
/** How many objects the placement places at the column: its fixed density, or what its density style gives there for {@code rng}. */
|
||||
int density(ObjectPlacement placement, RNG rng, double x, double z);
|
||||
|
||||
/** The height the placement's virtual heightmap gives the column, its noise seeded with {@code seed}; for a placement with a heightmap. */
|
||||
int heightmapSurface(ObjectPlacement placement, long seed, int x, int z);
|
||||
}
|
||||
@@ -25,16 +25,27 @@ import com.volmit.geometry.BlockPosition;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Iris markers as IrisApi placement markers: type {@code iris:marker}, naming the pack's marker under the
|
||||
* {@code marker} attribute. Iris stores markers of this type only.
|
||||
* The placement markers Iris keeps: a pack marker, type {@code iris:marker}, naming the pack's marker under the
|
||||
* {@code marker} attribute; a placed object's block that is a tree's ({@code iris:tree_material}), which Iris keeps
|
||||
* as the block's tree material for felling and growth; and a buried treasure chest ({@code iris:buried_treasure}).
|
||||
*/
|
||||
public final class ObjectMarkers {
|
||||
public static final ResourceId TYPE = ResourceId.parse("iris:marker");
|
||||
public static final ResourceId TREE_MATERIAL = ResourceId.parse("iris:tree_material");
|
||||
public static final ResourceId BURIED_TREASURE = ResourceId.parse("iris:buried_treasure");
|
||||
public static final String MARKER_ATTRIBUTE = "marker";
|
||||
|
||||
private ObjectMarkers() {
|
||||
}
|
||||
|
||||
public static PlacedMarker treeMaterial(BlockPosition position) {
|
||||
return new PlacedMarker(position, TREE_MATERIAL, Map.of());
|
||||
}
|
||||
|
||||
public static PlacedMarker buriedTreasure(BlockPosition position) {
|
||||
return new PlacedMarker(position, BURIED_TREASURE, Map.of());
|
||||
}
|
||||
|
||||
/** {@code markerKey} is the pack's marker, such as {@code spawn/zombie}. */
|
||||
public static PlacedMarker of(BlockPosition position, String markerKey) {
|
||||
return new PlacedMarker(position, TYPE, Map.of(MARKER_ATTRIBUTE, markerKey));
|
||||
|
||||
@@ -18,18 +18,12 @@
|
||||
|
||||
package art.arcane.iris.builtin.floating;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.generation.InvocationContext;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* What {@code iris:floating} asks of Iris beyond the API: a biome's own terrain height, the sky biome an island paints,
|
||||
* and placing Iris objects against an island. Iris offers it as an extension of its worlds:
|
||||
* {@code world.extension(FloatingHost.class)}.
|
||||
* What {@code iris:floating} asks of Iris beyond the API: a biome's own terrain height and the sky biome an island
|
||||
* paints. Iris offers it as an extension of its worlds: {@code world.extension(FloatingHost.class)}.
|
||||
*/
|
||||
public interface FloatingHost {
|
||||
/** The height the terrain generators of {@code biome} give the column, as Iris shapes the biome's terrain with {@code seed}. */
|
||||
@@ -40,28 +34,4 @@ public interface FloatingHost {
|
||||
* pass finds it. {@code random} seeds the biome's generator the first time the biome is asked.
|
||||
*/
|
||||
void paintSkyBiome(ResourceId biome, int worldX, int worldZ, int[] ys, RNG random);
|
||||
|
||||
/** Where {@code object} stands: its solid columns, its tallest column and that column's lowest solid block. */
|
||||
IslandFootprint footprint(PlaceableObject object);
|
||||
|
||||
/** {@code object} shrunk by {@code factor} (below 1), the variant picked with {@code random}. */
|
||||
Optional<PlaceableObject> shrink(PlaceableObject object, double factor, RNG random);
|
||||
|
||||
/** Places {@code object} floating free at the column, into the chunk the mantle invocation {@code context} generates. */
|
||||
void placeFloating(InvocationContext context, PlaceableObject object, int worldX, int worldZ, ObjectPlacement placement,
|
||||
RNG random);
|
||||
|
||||
/**
|
||||
* Places {@code object} on an island's top, its lowest block at {@code y}, into the chunk the mantle invocation
|
||||
* {@code context} generates; nothing is written unless every block it writes is one {@code anchor} lets it write.
|
||||
*/
|
||||
void placeOnTop(InvocationContext context, PlaceableObject object, int worldX, int y, int worldZ,
|
||||
ObjectPlacement placement, IslandAnchor anchor, RNG random);
|
||||
|
||||
/**
|
||||
* Places {@code object} upside down under an island, turned {@code yRotation} degrees about Y, as {@link #placeOnTop} does
|
||||
* on top.
|
||||
*/
|
||||
void placeUnder(InvocationContext context, PlaceableObject object, int worldX, int y, int worldZ, int yRotation,
|
||||
ObjectPlacement placement, IslandAnchor anchor, RNG random);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* 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 java.util.Optional;
|
||||
|
||||
/** The voids the cave carver planned in the mantle around the chunk being placed, which cave objects anchor in. */
|
||||
public interface CarvedSpace {
|
||||
/** Whether the position is carved. */
|
||||
boolean isCarved(int x, int y, int z);
|
||||
|
||||
/** Whether each height from 0 up to {@code height} is carved at the column, 1 for carved and 0 for not. */
|
||||
byte[] column(int x, int z, int height);
|
||||
|
||||
/** The void at the position; empty where nothing was carved. */
|
||||
Optional<Cavern> cavernAt(int x, int y, int z);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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.volmlib.util.math.RNG;
|
||||
|
||||
/**
|
||||
* The chunk whose mantle {@code iris:objects} is placing into: the one place objects are written. Every placement here
|
||||
* runs Iris's placement stages, so it is what a pack's {@code objects} get when they are placed anywhere. Reached through
|
||||
* {@link ObjectHost#chunk()} from a mantle stage.
|
||||
*/
|
||||
public interface ObjectChunk {
|
||||
/** The voids the cave carver planned around the chunk. */
|
||||
CarvedSpace carved();
|
||||
|
||||
/** Whether the golden-debug switch is on for the chunk, which logs every decision of its placements. */
|
||||
boolean goldenDebug(int chunkX, int chunkZ);
|
||||
|
||||
/**
|
||||
* Places an object on the terrain, where it sits at the height its place mode finds.
|
||||
*
|
||||
* @param goldenTag logs the placer's questions under this tag, or null to leave them
|
||||
* @return the height the object was placed at, negative when the placement rejected it
|
||||
*/
|
||||
int placeOnSurface(PlaceableObject object, int x, int z, PlacementSource placement, PlacementChanges changes,
|
||||
PlacementTags tags, RNG rng, String goldenTag);
|
||||
|
||||
/**
|
||||
* Places an object in a cave, anchored at {@code anchorY}, and writes it only when all of it lies inside the cave and
|
||||
* no deeper than {@code minDepthBelowSurface} under the surface.
|
||||
*
|
||||
* @param goldenTag logs the placer's questions under this tag, or null to leave them
|
||||
*/
|
||||
CavePlacement placeInCave(PlaceableObject object, int x, int anchorY, int z, PlacementSource placement, PlacementChanges changes,
|
||||
int minDepthBelowSurface, PlacementTags tags, RNG rng, String goldenTag);
|
||||
|
||||
/** Places an object at a given height, which the terrain stacked above uses for the objects hung from it. */
|
||||
int placeUpper(PlaceableObject object, int x, int anchorY, int z, ObjectPlacement placement, PlacementChanges changes,
|
||||
PlacementTags tags, RNG rng);
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* 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.loot.ObjectLoot;
|
||||
import art.arcane.iris.builtin.loot.ObjectVanillaLoot;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.generation.InvocationContext;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* What {@code iris:objects} asks of Iris's object system: the pack's objects, how Iris scales, picks and places them, and
|
||||
* the loot of what it placed. The layout, settings and seeds around an object are the API's. Iris offers it as an
|
||||
* extension of its worlds and of the settings of the pack it loads: {@code world.extension(ObjectHost.class)},
|
||||
* {@code settings.extension(ObjectHost.class)}.
|
||||
*
|
||||
* <p>Objects are named by the keys placements hold ({@link ObjectPlacement#place()}). The randoms are VolmLib's
|
||||
* {@link RNG}, since the streams Iris draws objects with decide where existing worlds have them.
|
||||
*/
|
||||
public interface ObjectHost {
|
||||
/** Whether Iris's debug setting is on, which makes object placing trace what it does. */
|
||||
boolean debugging();
|
||||
|
||||
/** The random a chunk's objects are placed with: the same for the same chunk of the same world. */
|
||||
RNG chunkRandom(int chunkX, int chunkZ);
|
||||
|
||||
/** The chunk whose objects the mantle invocation {@code context} places. */
|
||||
ObjectChunk chunk(InvocationContext context);
|
||||
|
||||
/** The object of the pack that {@code key} names. */
|
||||
Optional<PlaceableObject> object(String key);
|
||||
|
||||
/** An object of the placement, picked with {@code rng} and scaled the way the placement scales it; empty when it has none. */
|
||||
Optional<PlaceableObject> pickScaled(ObjectPlacement placement, RNG rng);
|
||||
|
||||
/** How many objects the placement places at the column, when its chance check passes. */
|
||||
int density(ObjectPlacement placement, RNG rng, double x, double z);
|
||||
|
||||
/** The size of the pack's object, read without loading its blocks; empty when the pack has no such object. */
|
||||
Optional<ObjectSize> sizeOf(String objectKey);
|
||||
|
||||
/** Builds what placing the placement would build on first use, so the first chunk to place it does not wait. */
|
||||
void warm(ObjectPlacement placement, RNG rng);
|
||||
|
||||
/** A builder for one bake of objects made block by block. */
|
||||
ObjectBuilder builder();
|
||||
|
||||
/** Places the object into {@code sink}, which is outside any chunk's generation, such as a growing sapling's tree. */
|
||||
int placeInto(PlaceableObject object, int x, int y, int z, ObjectPlacement placement, ObjectSink sink, RNG rng);
|
||||
|
||||
/** The loot of the object placed at the block; empty when no object placement covers the block. */
|
||||
Optional<ObjectLoots> placedLoot(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Every region and every reachable biome that declares the settings, regions first. Unlike the sources of
|
||||
* {@link com.volmit.config.PackSettings#declared}, which name the resource that declares them, each is named by the
|
||||
* id a {@link com.volmit.world.BiomeSample} gives it.
|
||||
*/
|
||||
<F extends IrisFeature> List<Declaration<F>> declarations(Class<F> type);
|
||||
|
||||
/** One region's or biome's declaration of settings, by the id of the region or biome. */
|
||||
record Declaration<F extends IrisFeature>(Level level, ResourceId id, F settings) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The loot an object placement gives its containers.
|
||||
*
|
||||
* @param packTables tables of the pack
|
||||
* @param platformTables tables of the platform
|
||||
* @param overridesGlobalLoot whether the placement's tables replace those of the dimension, region and biomes
|
||||
*/
|
||||
record ObjectLoots(List<ObjectLoot> packTables, List<ObjectVanillaLoot> platformTables, boolean overridesGlobalLoot) {
|
||||
public ObjectLoots {
|
||||
packTables = List.copyOf(packTables);
|
||||
platformTables = List.copyOf(platformTables);
|
||||
}
|
||||
|
||||
/** Whether the placement names any table. */
|
||||
public boolean defined() {
|
||||
return !packTables.isEmpty() || !platformTables.isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* 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, 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;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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.block.BlockState;
|
||||
|
||||
/** Where an object placed through {@link ObjectHost#placeInto} reads the world around it and writes its blocks. */
|
||||
public interface ObjectSink {
|
||||
/** The height of the highest block at the column; {@code ignoreFluid} leaves out the fluid above the ground. */
|
||||
int highest(int x, int z, boolean ignoreFluid);
|
||||
|
||||
BlockState get(int x, int y, int z);
|
||||
|
||||
void set(int x, int y, int z, BlockState state);
|
||||
|
||||
/** The height of the dimension's fluid. */
|
||||
int fluidHeight();
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/** An object of the pack, or one made for a placement, that {@link ObjectHost} can place; Iris's own object class is one. */
|
||||
public interface PlaceableObject {
|
||||
/** The key the pack loads the object by, or the key a procedural object is given; null for an object made in code. */
|
||||
String key();
|
||||
|
||||
/** How wide the object is, in blocks. */
|
||||
int width();
|
||||
|
||||
/** How tall the object is, in blocks. */
|
||||
int height();
|
||||
|
||||
/** How deep the object is, in blocks. */
|
||||
int depth();
|
||||
}
|
||||
@@ -30,13 +30,12 @@
|
||||
* <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.spawn.SpawnCooldowns}, {@link art.arcane.iris.builtin.objects.ObjectHost}), and the seed purposes Iris
|
||||
* ({@link art.arcane.iris.builtin.spawn.SpawnCooldowns}, {@link art.arcane.iris.builtin.LegacyStreams}), and the seed purposes Iris
|
||||
* answers with its legacy seeds ({@link art.arcane.iris.builtin.IrisSeedPurposes}). Keep them few: each is
|
||||
* a promise.
|
||||
* <p>
|
||||
* The placement stages ({@code iris:prepare} to {@code iris:snow}) reach the object being placed through
|
||||
* {@link art.arcane.iris.builtin.placement.ObjectPlacement}, a facade Iris implements for each placement. Its types
|
||||
* answer with IrisApi, VolmLib and built-in values only, and the stages' outputs ({@link art.arcane.iris.builtin.prepare.PreparedPlacement})
|
||||
* are built-in types too, so a pack module can require a placement stage and read what it chose.
|
||||
* 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;
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* 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.placement;
|
||||
|
||||
/** The cave an object is placed in: the height of its floor and how many blocks it is high. */
|
||||
public record CaveSpace(int surface, int height) {
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* 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.placement;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The object placement being run, as Iris's built-in placement stages see it: what is placed and with which settings, the
|
||||
* terrain it is placed on, and the few block operations that only the platform can do. Iris implements it for each
|
||||
* placement and offers it as an extension of the placement invocation: {@code context.extension(ObjectPlacement.class)}.
|
||||
* Heights are in the coordinates of the placement stages: above the dimension's bottom.
|
||||
* <p>
|
||||
* It never hands out an engine, pack data or a platform type; everything it answers is an IrisApi, VolmLib or
|
||||
* {@code art.arcane.iris.builtin} value.
|
||||
*/
|
||||
public interface ObjectPlacement {
|
||||
ObjectShape object();
|
||||
|
||||
/** The settings as the caller passed them; the stages derive what they change (the rotation) themselves. */
|
||||
PlacementSettings settings();
|
||||
|
||||
int x();
|
||||
|
||||
/** The height the caller asked for, negative when the placement samples it. */
|
||||
int requestedY();
|
||||
|
||||
int z();
|
||||
|
||||
/** The cave the object is placed in; empty outside caves. */
|
||||
Optional<CaveSpace> cave();
|
||||
|
||||
/** Answers the questions of the terrain the placement was asked to place on. */
|
||||
PlacementTerrain terrain();
|
||||
|
||||
/**
|
||||
* The terrain the placement anchors against: {@link #terrain()}, or, when the settings place on a heightmap, the same
|
||||
* terrain with its heights from the heightmap's noise, seeded from {@code rng}.
|
||||
*/
|
||||
PlacementTerrain terrainFor(RNG rng);
|
||||
|
||||
/** The noise that warps the placement's columns; empty when the settings do not warp. */
|
||||
Optional<SurfaceWarp> surfaceWarp(RNG rng);
|
||||
|
||||
/** Iris's simplex noise of {@code seed}, whose signed reads fill -1 to 1. */
|
||||
PlaneNoise simplex(long seed);
|
||||
|
||||
/** {@code state} turned with the object by {@code rotation}, as the platform turns stairs, logs and other facing blocks. */
|
||||
BlockState rotate(BlockState state, ObjectRotation rotation, int spinX, int spinY, int spinZ);
|
||||
|
||||
/** {@code update} laid over {@code base}: the platform's merge of two states of one block, else {@code update}. */
|
||||
BlockState merge(BlockState base, BlockState update);
|
||||
|
||||
/** Whether {@code state}, as the platform's own state, matches {@code other}: {@code state.matches(other)} of the platform. */
|
||||
boolean matches(BlockState state, BlockState other);
|
||||
|
||||
/**
|
||||
* Whether {@code state} has {@code trait}, as the platform's own state answers it. Unlike the block registry it keeps
|
||||
* the identity of the states this placement handed out, so a content plugin's block, which shares its key with the
|
||||
* block it is drawn as, answers as itself ({@link BlockTrait#CUSTOM}).
|
||||
*/
|
||||
boolean hasTrait(BlockState state, BlockTrait trait);
|
||||
|
||||
/** The resources of the object's pack, where the placement's markers are found. */
|
||||
PackResources resources();
|
||||
|
||||
/** Reports a buffered write as one of the object's own blocks, which Iris's placement listener hears after the commit. */
|
||||
void objectBlockWritten(BlockPosition position);
|
||||
|
||||
/** Reports the height the object was anchored at, which the placement returns to its caller. */
|
||||
void anchoredAt(int y);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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.placement;
|
||||
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** The object being placed: its declared size, the block its offsets count from, and where it must stand on solid ground. */
|
||||
public interface ObjectShape {
|
||||
int width();
|
||||
|
||||
int height();
|
||||
|
||||
int depth();
|
||||
|
||||
/** The block the object's offsets count from, relative to its corner. */
|
||||
int centerX();
|
||||
|
||||
int centerY();
|
||||
|
||||
int centerZ();
|
||||
|
||||
/** The pack object this is; empty for an object the pack does not name, such as a procedural variant. */
|
||||
Optional<ResourceId> id();
|
||||
|
||||
/** The columns of the object's lowest solid layer, as offsets from its anchor before any transform; empty for the origin only. */
|
||||
List<IrisBlockVector> surfaceSupportOffsets();
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* 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.placement;
|
||||
|
||||
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.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/** The settings of one object placement, as the placement stages read them. */
|
||||
public interface PlacementSettings {
|
||||
boolean forcePlace();
|
||||
|
||||
SlopeClip slopeCondition();
|
||||
|
||||
boolean rotateTowardsSlope();
|
||||
|
||||
ObjectRotation rotation();
|
||||
|
||||
ObjectTranslate translate();
|
||||
|
||||
ObjectPlaceMode mode();
|
||||
|
||||
boolean fromBottom();
|
||||
|
||||
/** Whether the object places from the ground up instead of by height checks. */
|
||||
boolean bottom();
|
||||
|
||||
CarvingMode carvingSupport();
|
||||
|
||||
boolean underwater();
|
||||
|
||||
boolean onwater();
|
||||
|
||||
boolean requireSurfaceSupport();
|
||||
|
||||
int surfaceSupportBuffer();
|
||||
|
||||
int surfaceSupportDepth();
|
||||
|
||||
ObjectLimit clamp();
|
||||
|
||||
/** Whether air is placed before the object. */
|
||||
boolean bore();
|
||||
|
||||
int boreExtendMinY();
|
||||
|
||||
int boreExtendMaxY();
|
||||
|
||||
List<ObjectReplace> edit();
|
||||
|
||||
boolean waterloggable();
|
||||
|
||||
boolean meld();
|
||||
|
||||
List<MarkerRule> markers();
|
||||
|
||||
Optional<StiltSettings> stilt();
|
||||
|
||||
Optional<VacuumSettings> vacuum();
|
||||
|
||||
/** The snow filter's depth, 0 for none. */
|
||||
double snow();
|
||||
|
||||
/** The pack objects the placement may overlap even when {@link #forbiddenCollisions()} names them. */
|
||||
Set<ResourceId> allowedCollisions();
|
||||
|
||||
/** The pack objects the placement may not overlap. */
|
||||
Set<ResourceId> forbiddenCollisions();
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* 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.placement;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* What a placement asks of the terrain and the world around it: heights, carving and water at a column, and the
|
||||
* world's own facts. A placement made without a world ({@link #hasWorld()} is false) answers its terrain questions from
|
||||
* the placer alone and the world's facts with nothing.
|
||||
*/
|
||||
public interface PlacementTerrain {
|
||||
/** The surface height of the column, counting fluid unless {@code ignoreFluid}. */
|
||||
int highest(int x, int z, boolean ignoreFluid);
|
||||
|
||||
boolean isCarved(int x, int y, int z);
|
||||
|
||||
/** Whether the block is real, solid ground; the height field alone cannot say at mantle time. */
|
||||
boolean isSurfaceSolid(int x, int y, int z);
|
||||
|
||||
boolean isUnderwater(int x, int z);
|
||||
|
||||
/** The height up to which the dimension is filled with fluid. */
|
||||
int fluidHeight();
|
||||
|
||||
/** Whether leaves the placement writes never decay. */
|
||||
boolean preventsDecay();
|
||||
|
||||
/** Whether bored air is written as a visible block, to see where smart boring bored. */
|
||||
boolean debugsSmartBore();
|
||||
|
||||
boolean hasWorld();
|
||||
|
||||
/** The terrain's slope at the column, as the dimension's slope field gives it. */
|
||||
double slopeAt(int x, int z);
|
||||
|
||||
/** The terrain height at a position between columns, as the dimension's height field gives it. */
|
||||
double heightAt(double x, double z);
|
||||
|
||||
/** The platform's Y of the dimension's bottom block. */
|
||||
int minWorldY();
|
||||
|
||||
/** The dimension's height in blocks. */
|
||||
int worldHeight();
|
||||
|
||||
StructureVolumes structureVolumes(int minX, int minZ, int maxX, int maxZ);
|
||||
|
||||
/** The pack object placed at the block; empty when none was. */
|
||||
Optional<ResourceId> objectAt(int x, int y, int z);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* 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.placement;
|
||||
|
||||
/** Noise over a plane that swings between -1 and 1, such as the rolling wave of a terrain bend. */
|
||||
public interface PlaneNoise {
|
||||
double signed(double x, double z);
|
||||
}
|
||||
@@ -19,6 +19,9 @@ package art.arcane.iris.builtin.structure;
|
||||
|
||||
import com.volmit.generation.InvocationContext;
|
||||
|
||||
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
|
||||
@@ -31,4 +34,7 @@ public interface StructureHost {
|
||||
|
||||
/** 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(String structureKey);
|
||||
}
|
||||
@@ -20,9 +20,8 @@ package art.arcane.iris.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.loot.LootResolver;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost.ObjectLoots;
|
||||
import art.arcane.iris.builtin.loot.LootTable;
|
||||
import art.arcane.iris.engine.loot.PlacedObjectLoot.ObjectLoots;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.item.ItemDrop;
|
||||
import com.volmit.resource.ResourceId;
|
||||
@@ -50,7 +49,7 @@ public final class LootGiving implements Loot {
|
||||
List<Source> sources = new ArrayList<>();
|
||||
boolean objectLootDefined = site.nativeLootDefined();
|
||||
Optional<ObjectLoots> objectLoots = site.container().isEmpty() ? Optional.empty()
|
||||
: world.extension(ObjectHost.class).orElseThrow().placedLoot(x, relativeY, z);
|
||||
: PlacedObjectLoot.at(world, x, relativeY, z);
|
||||
if (objectLoots.isPresent()) {
|
||||
objectLootDefined = objectLootDefined || objectLoots.get().defined();
|
||||
Source picked = placementLoot(world).pick(objectLoots.get().platformTables(), objectLoots.get().packTables(),
|
||||
|
||||
@@ -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.engine.loot;
|
||||
|
||||
import art.arcane.iris.builtin.loot.ObjectLoot;
|
||||
import art.arcane.iris.builtin.loot.ObjectVanillaLoot;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.structure.StructureHost;
|
||||
import art.arcane.iris.builtin.structure.StructurePlacementMarker;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The loot of the object placed at a block, found from the placement the world recorded there: a structure piece gives
|
||||
* its structure's tables; any other object the tables of the first placement of the column's region, then of its
|
||||
* surface biome, that places it. Procedural objects give none.
|
||||
*/
|
||||
final class PlacedObjectLoot {
|
||||
private static final String PROCEDURAL_PREFIX = "procedural/";
|
||||
private static final int STRUCTURE_TABLE_WEIGHT = 1;
|
||||
|
||||
private PlacedObjectLoot() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The loot an object placement gives its containers.
|
||||
*
|
||||
* @param packTables tables of the pack
|
||||
* @param platformTables tables of the platform
|
||||
* @param overridesGlobalLoot whether the placement's tables replace those of the dimension, region and biomes
|
||||
*/
|
||||
record ObjectLoots(List<ObjectLoot> packTables, List<ObjectVanillaLoot> platformTables, boolean overridesGlobalLoot) {
|
||||
ObjectLoots {
|
||||
packTables = List.copyOf(packTables);
|
||||
platformTables = List.copyOf(platformTables);
|
||||
}
|
||||
|
||||
/** Whether the placement names any table. */
|
||||
boolean defined() {
|
||||
return !packTables.isEmpty() || !platformTables.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
/** The loot of the object placed at the block; empty when no object placement covers the block. Y is above the dimension's bottom. */
|
||||
static Optional<ObjectLoots> at(PackWorld world, int x, int y, int z) {
|
||||
RunningWorld running = world.running().orElseThrow();
|
||||
Optional<StructurePlacementMarker.Decoded> marker = running.placementAt(x, y, z).map(StructurePlacementMarker::decode);
|
||||
if (marker.isEmpty() || marker.get().objectKey().startsWith(PROCEDURAL_PREFIX)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
String objectKey = marker.get().objectKey();
|
||||
Optional<ObjectPlacement> placement = marker.get().structureAware()
|
||||
? structurePlacement(world, marker.get().structureKey(), objectKey)
|
||||
: columnPlacement(running.settings().at(ObjectSettings.class, x, z), objectKey);
|
||||
return placement.map(found -> new ObjectLoots(found.loot(), found.vanillaLoot(), found.overrideGlobalLoot()));
|
||||
}
|
||||
|
||||
/** A structure piece's object gives every table its structure names, each once. */
|
||||
private static Optional<ObjectPlacement> structurePlacement(PackWorld world, String structureKey, String objectKey) {
|
||||
Optional<List<String>> tables = world.extension(StructureHost.class).orElseThrow().lootTables(structureKey);
|
||||
PackResources resources = world.resources();
|
||||
if (tables.isEmpty() || resources.objects().object(resources.idOf(objectKey)).isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
List<ObjectLoot> loot = new ArrayList<>();
|
||||
for (String table : tables.get()) {
|
||||
loot.add(new ObjectLoot(table, STRUCTURE_TABLE_WEIGHT));
|
||||
}
|
||||
return Optional.of(ObjectPlacement.builder().place(List.of(objectKey)).loot(loot).build());
|
||||
}
|
||||
|
||||
private static Optional<ObjectPlacement> columnPlacement(SettingsStack<ObjectSettings> declared, String objectKey) {
|
||||
Optional<ObjectPlacement> fromRegion = declared.level(Level.REGION).flatMap(settings -> placing(settings, objectKey));
|
||||
return fromRegion.isPresent() ? fromRegion : declared.level(Level.BIOME).flatMap(settings -> placing(settings, objectKey));
|
||||
}
|
||||
|
||||
private static Optional<ObjectPlacement> placing(ObjectSettings settings, String objectKey) {
|
||||
return settings.objects().stream()
|
||||
.filter(placement -> placement.place().contains(objectKey))
|
||||
.findFirst();
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CaveAnchorMode;
|
||||
import art.arcane.iris.builtin.objects.CarvedSpace;
|
||||
import art.arcane.iris.builtin.objects.Cavern;
|
||||
import art.arcane.iris.modules.objects.CarvedSpace;
|
||||
import art.arcane.iris.modules.objects.Cavern;
|
||||
import art.arcane.volmlib.util.cache.CacheKey;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
@@ -18,9 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.ModuleLog;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -36,13 +35,13 @@ final class CaveRejects {
|
||||
private CaveRejects() {
|
||||
}
|
||||
|
||||
static void log(ObjectHost host, ModuleLog log, String scope, String reason, int chunkX, int chunkZ, ObjectPlacement placement,
|
||||
static void log(ModuleLog log, String scope, String reason, int chunkX, int chunkZ, ObjectPlacement placement,
|
||||
PlaceableObject object, int densityIndex, int density, CaveAnchors.Search search, Integer anchorY, Throwable error) {
|
||||
if (!host.debugging()) {
|
||||
if (!log.debugging()) {
|
||||
return;
|
||||
}
|
||||
String placementKeys = placement == null ? "none" : String.join(",", placement.place());
|
||||
String objectKey = object == null ? "null" : object.key();
|
||||
String objectKey = object == null ? "null" : object.name();
|
||||
String throttleKey = scope + "|" + reason + "|" + placementKeys + "|" + objectKey;
|
||||
State state = STATES.computeIfAbsent(throttleKey, key -> new State());
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
@@ -22,28 +22,29 @@ import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.carve.CaveLavaHeightSettings;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.builtin.objects.CavePlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectChunk;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.builtin.objects.PlacementChanges;
|
||||
import art.arcane.iris.builtin.objects.PlacementSource;
|
||||
import art.arcane.iris.builtin.objects.PlacementTags;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.builtin.objects.RequireSurfaceSupportSettings;
|
||||
import art.arcane.iris.builtin.objects.SurfaceSupportBufferSettings;
|
||||
import art.arcane.iris.builtin.objects.UpperObjectsForceSettings;
|
||||
import art.arcane.iris.builtin.objects.UpperObjectsSettings;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.iris.modules.objects.CavePlacement;
|
||||
import art.arcane.iris.modules.objects.TerrainTransaction;
|
||||
import art.arcane.iris.modules.objects.EffectiveSettings;
|
||||
import art.arcane.iris.modules.objects.ObjectPool;
|
||||
import art.arcane.iris.modules.objects.PlacementChanges;
|
||||
import art.arcane.iris.modules.objects.PlacementTags;
|
||||
import art.arcane.iris.modules.objects.ProceduralPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
@@ -70,7 +71,7 @@ final class ChunkObjectPlacing {
|
||||
private static final String TREE_FOLDER = "trees/";
|
||||
private static final String REGEN_THREAD_PREFIX = "Iris-Regen-";
|
||||
|
||||
private final ObjectHost host;
|
||||
private final ObjectPool objects;
|
||||
private final ModuleLog log;
|
||||
private final MantleStageContext context;
|
||||
private final ObjectChunk chunk;
|
||||
@@ -87,18 +88,18 @@ final class ChunkObjectPlacing {
|
||||
private final int worldHeight;
|
||||
private final int caveLavaHeight;
|
||||
|
||||
ChunkObjectPlacing(ObjectHost host, ModuleLog log, MantleStageContext context) {
|
||||
this.host = host;
|
||||
ChunkObjectPlacing(ObjectPool objects, EffectiveSettings settings, ModuleLog log, MantleStageContext context) {
|
||||
this.objects = objects;
|
||||
this.log = log;
|
||||
this.context = context;
|
||||
this.chunk = host.chunk(context);
|
||||
this.chunk = new ObjectChunk(context, settings, log);
|
||||
this.terrain = context.terrain();
|
||||
this.chunkX = context.chunkX();
|
||||
this.chunkZ = context.chunkZ();
|
||||
this.centerX = context.originX() + OBJECT_COLUMN_OFFSET_BLOCKS;
|
||||
this.centerZ = context.originZ() + OBJECT_COLUMN_OFFSET_BLOCKS;
|
||||
this.rng = host.chunkRandom(chunkX, chunkZ);
|
||||
this.traceRegen = Thread.currentThread().getName().startsWith(REGEN_THREAD_PREFIX) && host.debugging();
|
||||
this.rng = objects.chunkRandom(chunkX, chunkZ);
|
||||
this.traceRegen = Thread.currentThread().getName().startsWith(REGEN_THREAD_PREFIX) && log.debugging();
|
||||
this.golden = chunk.goldenDebug(chunkX, chunkZ);
|
||||
this.worldHeight = context.mantle().bounds().maxY();
|
||||
this.caveLavaHeight = Optional.ofNullable(dimensionLevel(CaveLavaHeightSettings.class)).orElseGet(CaveLavaHeightSettings::new).height();
|
||||
@@ -109,7 +110,7 @@ final class ChunkObjectPlacing {
|
||||
/** Places what originates in this chunk. */
|
||||
void place() {
|
||||
Column column = readColumn();
|
||||
if (host.debugging() && (chunkX & DIAGNOSTIC_CHUNK_MASK) == 0 && (chunkZ & DIAGNOSTIC_CHUNK_MASK) == 0) {
|
||||
if (log.debugging() && (chunkX & DIAGNOSTIC_CHUNK_MASK) == 0 && (chunkZ & DIAGNOSTIC_CHUNK_MASK) == 0) {
|
||||
logCaveDiagnostics(column);
|
||||
}
|
||||
if (traceRegen) {
|
||||
@@ -286,10 +287,10 @@ final class ChunkObjectPlacing {
|
||||
private void placeObject(Tally tally, ObjectPlacement placement, String scope) {
|
||||
int blockX = context.originX();
|
||||
int blockZ = context.originZ();
|
||||
int density = host.density(placement, rng, blockX, blockZ);
|
||||
int density = objects.density(placement, rng, blockX, blockZ);
|
||||
for (int i = 0; i < density; i++) {
|
||||
tally.attempts++;
|
||||
Optional<PlaceableObject> picked = host.pickScaled(placement, rng);
|
||||
Optional<PlaceableObject> picked = objects.pickScaled(placement, rng);
|
||||
if (picked.isEmpty()) {
|
||||
tally.nullObjects++;
|
||||
traceNullObject(scope, i, density, placement);
|
||||
@@ -301,14 +302,14 @@ final class ChunkObjectPlacing {
|
||||
PlacementChanges changes = effective.forSurface(placement, object);
|
||||
boolean treePlacement = isTreePlacement(object, placement);
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
String goldenTag = golden ? scope + "/" + object.key() : null;
|
||||
String goldenTag = golden ? scope + "/" + object.name() : null;
|
||||
if (golden) {
|
||||
log.debug("Goldendebug object attempt: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.key()
|
||||
log.debug("Goldendebug object attempt: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.name()
|
||||
+ " densityIndex=" + i + " xx=" + x + " zz=" + z + " mode=" + placement.mode());
|
||||
}
|
||||
try {
|
||||
PlacementTags tags = tags(object, id, "surface", treePlacement, placement);
|
||||
int result = chunk.placeOnSurface(object, x, z, placement, changes, tags, rng, goldenTag);
|
||||
int result = chunk.placeOnSurface(object, x, z, placement, changes, tags, goldenTag);
|
||||
if (result >= 0) {
|
||||
tally.placed++;
|
||||
} else {
|
||||
@@ -317,7 +318,7 @@ final class ChunkObjectPlacing {
|
||||
traceObjectResult(scope, object, result, x, z, i, density);
|
||||
} catch (Throwable failure) {
|
||||
tally.errors++;
|
||||
log.error("Regen object placement exception: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.key()
|
||||
log.error("Regen object placement exception: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.name()
|
||||
+ " densityIndex=" + i + " density=" + density + " error=" + failure.getClass().getSimpleName() + ":" + failure.getMessage(), failure);
|
||||
}
|
||||
}
|
||||
@@ -327,22 +328,22 @@ final class ChunkObjectPlacing {
|
||||
ResourceId expectedCaveBiome, CaveAnchors anchors) {
|
||||
int minX = context.originX();
|
||||
int minZ = context.originZ();
|
||||
int density = host.density(placement, rng, minX, minZ);
|
||||
int density = objects.density(placement, rng, minX, minZ);
|
||||
CaveAnchors.Search search = caves.searchFor(placement, profile);
|
||||
for (int i = 0; i < density; i++) {
|
||||
tally.attempts++;
|
||||
Optional<PlaceableObject> picked = host.pickScaled(placement, rng);
|
||||
Optional<PlaceableObject> picked = objects.pickScaled(placement, rng);
|
||||
if (picked.isEmpty()) {
|
||||
tally.nullObjects++;
|
||||
traceNullObject(scope, i, density, placement);
|
||||
CaveRejects.log(host, log, scope, "NULL_OBJECT", chunkX, chunkZ, placement, null, i, density, search, null, null);
|
||||
CaveRejects.log(log,scope, "NULL_OBJECT", chunkX, chunkZ, placement, null, i, density, search, null, null);
|
||||
continue;
|
||||
}
|
||||
PlaceableObject object = picked.get();
|
||||
CaveAnchors.Anchor anchor = anchors.find(rng, minX, minZ, search, expectedCaveBiome, placement.underwater());
|
||||
if (anchor == null) {
|
||||
tally.rejected++;
|
||||
CaveRejects.log(host, log, scope, "NO_ANCHOR", chunkX, chunkZ, placement, object, i, density, search, null, null);
|
||||
CaveRejects.log(log,scope, "NO_ANCHOR", chunkX, chunkZ, placement, object, i, density, search, null, null);
|
||||
continue;
|
||||
}
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
@@ -350,13 +351,13 @@ final class ChunkObjectPlacing {
|
||||
try {
|
||||
PlacementTags tags = tags(object, id, "cave", isTreePlacement(object, placement), placement);
|
||||
CavePlacement contained = chunk.placeInCave(object, anchor.x(), anchor.y(), anchor.z(), placement, changes,
|
||||
search.minDepthBelowSurface(), tags, rng, null);
|
||||
search.minDepthBelowSurface(), tags, null);
|
||||
tallyCave(tally, contained, scope, object, placement, i, density, search, anchor);
|
||||
} catch (Throwable failure) {
|
||||
tally.errors++;
|
||||
log.error("Regen cave object placement exception: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.key()
|
||||
log.error("Regen cave object placement exception: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.name()
|
||||
+ " densityIndex=" + i + " density=" + density + " error=" + failure.getClass().getSimpleName() + ":" + failure.getMessage(), failure);
|
||||
CaveRejects.log(host, log, scope, "EXCEPTION", chunkX, chunkZ, placement, object, i, density, search, anchor.y(), failure);
|
||||
CaveRejects.log(log,scope, "EXCEPTION", chunkX, chunkZ, placement, object, i, density, search, anchor.y(), failure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,10 +368,10 @@ final class ChunkObjectPlacing {
|
||||
tally.placed++;
|
||||
} else {
|
||||
tally.rejected++;
|
||||
CaveRejects.log(host, log, scope, rejectReason(contained), chunkX, chunkZ, placement, object, index, density, search, anchor.y(), null);
|
||||
CaveRejects.log(log,scope, rejectReason(contained), chunkX, chunkZ, placement, object, index, density, search, anchor.y(), null);
|
||||
}
|
||||
if (traceRegen) {
|
||||
log.debug("Regen cave object placement result: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.key()
|
||||
log.debug("Regen cave object placement result: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.name()
|
||||
+ " resultY=" + contained.resultY() + " anchorY=" + anchor.y() + " px=" + anchor.x() + " pz=" + anchor.z()
|
||||
+ " wroteBlocks=" + contained.wroteBlocks() + " densityIndex=" + index + " density=" + density);
|
||||
}
|
||||
@@ -380,7 +381,7 @@ final class ChunkObjectPlacing {
|
||||
if (contained.resultY() < 0) {
|
||||
return "PLACE_NEGATIVE";
|
||||
}
|
||||
return contained.commit() == CavePlacement.Commit.REJECTED_BOUNDS ? "CONTAINMENT" : "NO_WRITES";
|
||||
return contained.commit() == TerrainTransaction.Commit.REJECTED ? "CONTAINMENT" : "NO_WRITES";
|
||||
}
|
||||
|
||||
private void placeProceduralObjects(Column column) {
|
||||
@@ -463,22 +464,22 @@ final class ChunkObjectPlacing {
|
||||
String commit = "n/a";
|
||||
if (anchor != null) {
|
||||
PlacementChanges changes = effective.forCave(placement, variant, caveProfile);
|
||||
CavePlacement contained = chunk.placeInCave(variant, x, anchor.y(), z, placement, changes, search.minDepthBelowSurface(), tags, rng, goldenTag);
|
||||
CavePlacement contained = chunk.placeInCave(variant, x, anchor.y(), z, placement, changes, search.minDepthBelowSurface(), tags, goldenTag);
|
||||
resultY = contained.resultY();
|
||||
commit = contained.commit().toString();
|
||||
} else {
|
||||
resultY = chunk.placeOnSurface(variant, x, z, placement, PlacementChanges.NONE, tags, rng, goldenTag);
|
||||
resultY = chunk.placeOnSurface(variant, x, z, placement, PlacementChanges.NONE, tags, goldenTag);
|
||||
}
|
||||
if (golden) {
|
||||
log.debug("Goldendebug procedural result: chunk=" + chunkX + "," + chunkZ + " placement=" + placement.name()
|
||||
+ " variant=" + variant.key() + " xx=" + x + " zz=" + z + " resultY=" + resultY + " commit=" + commit);
|
||||
+ " variant=" + variant.name() + " xx=" + x + " zz=" + z + " resultY=" + resultY + " commit=" + commit);
|
||||
}
|
||||
}
|
||||
|
||||
private void logProceduralPick(ProceduralPlacement placement, PlaceableObject variant, int index, int x, int z, boolean carving) {
|
||||
List<PlaceableObject> pool = placement.variants();
|
||||
log.debug("Goldendebug procedural pick: chunk=" + chunkX + "," + chunkZ + " placement=" + placement.name() + " densityIndex=" + index
|
||||
+ " variant=" + variant.key() + " variantIndex=" + pool.indexOf(variant) + "/" + pool.size() + " xx=" + x + " zz=" + z
|
||||
+ " variant=" + variant.name() + " variantIndex=" + pool.indexOf(variant) + "/" + pool.size() + " xx=" + x + " zz=" + z
|
||||
+ " mode=" + placement.mode() + " carving=" + carving);
|
||||
}
|
||||
|
||||
@@ -528,9 +529,9 @@ final class ChunkObjectPlacing {
|
||||
private void placeUpperObject(ObjectPlacement placement, boolean forcePlace, String scope) {
|
||||
int minX = context.originX();
|
||||
int minZ = context.originZ();
|
||||
int density = host.density(placement, rng, minX, minZ);
|
||||
int density = objects.density(placement, rng, minX, minZ);
|
||||
for (int i = 0; i < density; i++) {
|
||||
Optional<PlaceableObject> picked = host.pickScaled(placement, rng);
|
||||
Optional<PlaceableObject> picked = objects.pickScaled(placement, rng);
|
||||
if (picked.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -546,16 +547,16 @@ final class ChunkObjectPlacing {
|
||||
continue;
|
||||
}
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
PlacementChanges changes = PlacementChanges.NONE.withPlace(List.of(String.valueOf(object.key())))
|
||||
PlacementChanges changes = PlacementChanges.NONE.withPlace(List.of(String.valueOf(object.name())))
|
||||
.withMode(ObjectPlaceMode.CENTER_HEIGHT)
|
||||
.withUpsideDown(true).withCarvingSupport(CarvingMode.ANYWHERE);
|
||||
if (forcePlace) {
|
||||
changes = changes.withForcePlace(true);
|
||||
}
|
||||
PlacementTags tags = tags(object, id, "upper", isTreePlacement(object, placement), placement);
|
||||
int result = chunk.placeUpper(object, x, anchorY, z, placement, changes, tags, rng);
|
||||
int result = chunk.placeUpper(object, x, anchorY, z, placement, changes, tags);
|
||||
if (traceRegen) {
|
||||
log.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.key() + " anchorY="
|
||||
log.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.name() + " anchorY="
|
||||
+ anchorY + " upperSurfaceY=" + upperSurface.getAsInt() + " resultY=" + result + " forcePlace=" + forcePlace);
|
||||
}
|
||||
}
|
||||
@@ -570,7 +571,7 @@ final class ChunkObjectPlacing {
|
||||
}
|
||||
|
||||
private String placementMarker(PlaceableObject object, int id, String context) {
|
||||
String key = object == null ? null : object.key();
|
||||
String key = object == null ? null : object.name();
|
||||
if (key == null || key.isEmpty() || key.equals("null")) {
|
||||
String fingerprint = context + "|" + (object == null ? "<null>" : object.getClass().getSimpleName());
|
||||
log.warnOnce(fingerprint, "Skipping placement marker write: the object has no loadKey (context=" + context + "). "
|
||||
@@ -581,7 +582,7 @@ final class ChunkObjectPlacing {
|
||||
}
|
||||
|
||||
private static boolean isTreePlacement(PlaceableObject object, ObjectPlacement placement) {
|
||||
String key = object == null ? null : object.key();
|
||||
String key = object == null ? null : object.name();
|
||||
return (key != null && key.startsWith(TREE_FOLDER)) || (placement != null && !placement.trees().isEmpty());
|
||||
}
|
||||
|
||||
@@ -603,11 +604,11 @@ final class ChunkObjectPlacing {
|
||||
|
||||
private void traceObjectResult(String scope, PlaceableObject object, int result, int x, int z, int index, int density) {
|
||||
if (golden) {
|
||||
log.debug("Goldendebug object result: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.key()
|
||||
log.debug("Goldendebug object result: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.name()
|
||||
+ " resultY=" + result + " fallback=surface");
|
||||
}
|
||||
if (traceRegen) {
|
||||
log.debug("Regen object placement result: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.key()
|
||||
log.debug("Regen object placement result: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.name()
|
||||
+ " resultY=" + result + " px=" + x + " pz=" + z + " fallback=surface densityIndex=" + index + " density=" + density);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ package art.arcane.iris.engine.mantle.components;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.carve.CaveProfile;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.builtin.objects.PlacementChanges;
|
||||
import art.arcane.iris.builtin.objects.PlacementSource;
|
||||
import art.arcane.iris.modules.objects.PlacementChanges;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -56,14 +56,14 @@ final class EffectivePlacements {
|
||||
if (profileMode == null) {
|
||||
return changes;
|
||||
}
|
||||
String key = object.key();
|
||||
String key = object.name();
|
||||
List<String> place = key == null || key.isBlank() ? List.of() : List.of(key);
|
||||
return changes.withPlace(place).withMode(profileMode);
|
||||
}
|
||||
|
||||
/** Imported objects are placed with the fast minimal stilt unless their mode finds its own height. */
|
||||
private static PlacementChanges withImportedMode(PlacementSource placement, PlaceableObject object, PlacementChanges changes) {
|
||||
String key = object.key();
|
||||
String key = object.name();
|
||||
if (key == null || key.isBlank() || !isImported(key)) {
|
||||
return changes;
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ package art.arcane.iris.engine.mantle.components;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.modules.floating.FloatingChildSettings;
|
||||
import art.arcane.iris.builtin.floating.FloatingHost;
|
||||
import art.arcane.iris.builtin.floating.IslandFootprint;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.modules.floating.IslandFootprint;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ObjectSize;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.modules.objects.ObjectPool;
|
||||
import art.arcane.iris.modules.objects.ObjectSize;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.PackResources;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySampler;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingWorld;
|
||||
@@ -72,15 +72,15 @@ public final class FloatingObjectPlacing {
|
||||
private static final String BIOME_PATH_PREFIX = "biome/";
|
||||
|
||||
private final FloatingWorld world;
|
||||
private final FloatingHost host;
|
||||
private final ObjectHost objects;
|
||||
private final ObjectPool objects;
|
||||
private final FloatingPlacer placer;
|
||||
private final long mantleSeed;
|
||||
private final ModuleLog log;
|
||||
|
||||
FloatingObjectPlacing(FloatingWorld world, long mantleSeed, ModuleLog log) {
|
||||
FloatingObjectPlacing(FloatingWorld world, ObjectPool objects, FloatingPlacer placer, long mantleSeed, ModuleLog log) {
|
||||
this.world = world;
|
||||
this.host = world.host();
|
||||
this.objects = world.objects();
|
||||
this.objects = objects;
|
||||
this.placer = placer;
|
||||
this.mantleSeed = mantleSeed;
|
||||
this.log = log;
|
||||
}
|
||||
@@ -88,8 +88,8 @@ public final class FloatingObjectPlacing {
|
||||
/** The floating object placing of {@code world}. */
|
||||
public static FloatingObjectPlacing of(PackWorld world, ModuleLog log) {
|
||||
return world.state(FloatingObjectPlacing.class,
|
||||
generating -> new FloatingObjectPlacing(FloatingWorld.of(generating),
|
||||
generating.seed(IrisSeedPurposes.MANTLE), log));
|
||||
generating -> new FloatingObjectPlacing(FloatingWorld.of(generating), ObjectPool.of(generating),
|
||||
new FloatingPlacer(generating, log), generating.seed(IrisSeedPurposes.MANTLE), log));
|
||||
}
|
||||
|
||||
/** Places what originates in the chunk of {@code context} into the mantle. */
|
||||
@@ -206,7 +206,7 @@ public final class FloatingObjectPlacing {
|
||||
continue;
|
||||
}
|
||||
int key = columns.get(rng.i(columns.size()));
|
||||
host.placeFloating(chunk.context, picked.get(),chunk.minX + (key & 15), chunk.minZ + (key >> 4), placement, rng);
|
||||
placer.placeFloating(chunk.context, picked.get(), chunk.minX + (key & 15), chunk.minZ + (key >> 4), placement, rng);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public final class FloatingObjectPlacing {
|
||||
continue;
|
||||
}
|
||||
PlaceableObject object = picked.get();
|
||||
IslandFootprint footprint = host.footprint(object);
|
||||
IslandFootprint footprint = placer.footprint(object);
|
||||
|
||||
KList<Integer> pool = interior.isEmpty() ? columns : interior;
|
||||
int pickedKey = pool.get(rng.i(pool.size()));
|
||||
@@ -241,7 +241,7 @@ public final class FloatingObjectPlacing {
|
||||
int x = pickedX - footprint.tallestX();
|
||||
int z = pickedZ - footprint.tallestZ();
|
||||
int y = pickTopY + 1 - footprint.lowestSolidY();
|
||||
host.placeOnTop(chunk.context, object,x, y, z, placement, IslandFace.top(chunk.resolver, entry, pickTopY, chunk.worldHeight), rng);
|
||||
placer.placeOnTop(chunk.context, object, x, y, z, placement, IslandFace.top(chunk.resolver, entry, pickTopY, chunk.worldHeight), rng);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ public final class FloatingObjectPlacing {
|
||||
continue;
|
||||
}
|
||||
PlaceableObject object = picked.get();
|
||||
IslandFootprint footprint = host.footprint(object);
|
||||
IslandFootprint footprint = placer.footprint(object);
|
||||
UndersideTurn turn = new UndersideTurn(rng.i(QUARTER_TURNS) * QUARTER_TURN_DEGREES);
|
||||
|
||||
Optional<BottomAnchor> anchor = pickBottomAnchor(chunk, footprint, turn, interior.isEmpty() ? columns : interior, entry);
|
||||
@@ -268,7 +268,7 @@ public final class FloatingObjectPlacing {
|
||||
int x = invertedBaseX(chunk.minX, pickedXf, footprint, turn);
|
||||
int z = invertedBaseZ(chunk.minZ, pickedZf, footprint, turn);
|
||||
int y = invertedBaseY(pickBottomY, footprint, turn);
|
||||
host.placeUnder(chunk.context, object,x, y, z, turn.yRotation(), placement,
|
||||
placer.placeUnder(chunk.context, object, x, y, z, turn.yRotation(), placement,
|
||||
IslandFace.bottom(chunk.resolver, entry, pickBottomY, chunk.worldHeight), rng);
|
||||
}
|
||||
}
|
||||
@@ -308,7 +308,7 @@ public final class FloatingObjectPlacing {
|
||||
if (scaled.isEmpty() || !entry.hasObjectShrink()) {
|
||||
return scaled;
|
||||
}
|
||||
return host.shrink(scaled.get(), entry.shrinkFactor(), rng);
|
||||
return Optional.of(objects.resized(scaled.get(), entry.shrinkFactor()));
|
||||
}
|
||||
|
||||
static boolean isFootprintFlatBottom(IslandFootprint footprint, UndersideTurn turn, int pickedX, int pickedZ, int pickBottomY,
|
||||
@@ -388,7 +388,7 @@ public final class FloatingObjectPlacing {
|
||||
|
||||
/** How far, in blocks along X and Z, the floating objects of the pack {@code settings} describe may write beyond their chunk. */
|
||||
public static int reach(PackSettings settings, ModuleLog log) {
|
||||
Reach reach = new Reach(settings.extension(ObjectHost.class).orElseThrow(), biomeObjectsOf(settings), log);
|
||||
Reach reach = new Reach(settings.resources(), biomeObjectsOf(settings), log);
|
||||
int maxObjectExtent = MIN_REACH_BLOCKS;
|
||||
try {
|
||||
for (Entry<FloatingChildSettings> declared : settings.declared(FloatingChildSettings.class)) {
|
||||
@@ -425,14 +425,14 @@ public final class FloatingObjectPlacing {
|
||||
|
||||
/** The reach of floating children's objects, each object sized once. */
|
||||
private static final class Reach {
|
||||
private final ObjectHost objects;
|
||||
private final PackResources resources;
|
||||
private final Map<ResourceId, ObjectSettings> biomeObjects;
|
||||
private final ModuleLog log;
|
||||
private final Map<String, Optional<ObjectSize>> sizes = new HashMap<>();
|
||||
private final Set<String> warnedLargeObjects = new HashSet<>();
|
||||
|
||||
private Reach(ObjectHost objects, Map<ResourceId, ObjectSettings> biomeObjects, ModuleLog log) {
|
||||
this.objects = objects;
|
||||
private Reach(PackResources resources, Map<ResourceId, ObjectSettings> biomeObjects, ModuleLog log) {
|
||||
this.resources = resources;
|
||||
this.biomeObjects = biomeObjects;
|
||||
this.log = log;
|
||||
}
|
||||
@@ -479,7 +479,7 @@ public final class FloatingObjectPlacing {
|
||||
|
||||
private int objectReach(String objectKey, ObjectPlacement placement) {
|
||||
try {
|
||||
Optional<ObjectSize> size = sizes.computeIfAbsent(objectKey, objects::sizeOf);
|
||||
Optional<ObjectSize> size = sizes.computeIfAbsent(objectKey, key -> PlacementReach.sizeOf(resources, key));
|
||||
if (size.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* 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.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectRun;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.modules.floating.IslandAnchor;
|
||||
import art.arcane.iris.modules.floating.IslandFootprint;
|
||||
import art.arcane.iris.modules.objects.ForwardingTerrain;
|
||||
import art.arcane.iris.modules.objects.TerrainTransaction;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
import com.volmit.object.ObjectBlock;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.placement.PlacedMarker;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Places the objects of floating islands through the pack's placement stages into the mantle of the chunk being
|
||||
* generated: floating free, or against an island's top or underside, where nothing is written unless every block lands
|
||||
* where the island lets it. Each object's blocks are recorded as its placement.
|
||||
*/
|
||||
final class FloatingPlacer {
|
||||
private static final ObjectRotation NO_ROTATION = ObjectRotation.of(0, 0, 0);
|
||||
private static final int SAMPLED_HEIGHT = -1;
|
||||
private static final Set<String> AIR_MATERIALS = Set.of("minecraft:air", "minecraft:cave_air");
|
||||
|
||||
private final PackWorld world;
|
||||
private final BlockRegistry blocks;
|
||||
private final ModuleLog log;
|
||||
|
||||
FloatingPlacer(PackWorld world, ModuleLog log) {
|
||||
this.world = world;
|
||||
this.blocks = world.resources().blocks();
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/** Where {@code object} stands: its solid columns, its tallest column and that column's lowest solid block. */
|
||||
IslandFootprint footprint(PlaceableObject object) {
|
||||
Map<Long, int[]> columns = new HashMap<>();
|
||||
for (ObjectBlock block : object.geometry().blocks()) {
|
||||
if (!blocks.hasTrait(block.state(), BlockTrait.SOLID)) {
|
||||
continue;
|
||||
}
|
||||
BlockPosition position = block.position();
|
||||
int[] column = columns.computeIfAbsent(IslandFootprint.column(position.x(), position.z()),
|
||||
ignored -> new int[]{position.y(), 0});
|
||||
column[0] = Math.min(column[0], position.y());
|
||||
column[1]++;
|
||||
}
|
||||
if (columns.isEmpty()) {
|
||||
return new IslandFootprint(0, 0, object.center().y(), new long[0]);
|
||||
}
|
||||
long tallest = tallestColumn(columns);
|
||||
long[] footprint = columns.keySet().stream().mapToLong(Long::longValue).toArray();
|
||||
return new IslandFootprint(IslandFootprint.columnX(tallest), IslandFootprint.columnZ(tallest), columns.get(tallest)[0], footprint);
|
||||
}
|
||||
|
||||
/** The column with the most solid blocks; the lowest bottom wins a tie. */
|
||||
private static long tallestColumn(Map<Long, int[]> columns) {
|
||||
long best = 0L;
|
||||
int tallestCount = 0;
|
||||
int tallestLow = Integer.MAX_VALUE;
|
||||
for (Map.Entry<Long, int[]> entry : columns.entrySet()) {
|
||||
int low = entry.getValue()[0];
|
||||
int count = entry.getValue()[1];
|
||||
if (count > tallestCount || (count == tallestCount && low < tallestLow)) {
|
||||
tallestCount = count;
|
||||
tallestLow = low;
|
||||
best = entry.getKey();
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/** Places {@code object} floating free at the column, into the chunk {@code context} generates. */
|
||||
void placeFloating(MantleStageContext context, PlaceableObject object, int worldX, int worldZ, ObjectPlacement placement,
|
||||
RNG random) {
|
||||
ObjectPlacement floating = placement.toBuilder().place(List.of(object.name())).build();
|
||||
int id = random.i(0, Integer.MAX_VALUE);
|
||||
try {
|
||||
place(ObjectRun.of(object, floating, worldX, SAMPLED_HEIGHT, worldZ), context.placementTerrain(), object, id);
|
||||
} catch (Throwable failure) {
|
||||
log.error("Failed to place a floating object", failure);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Places {@code object} on an island's top, its lowest block at {@code y}; nothing is written unless every block it
|
||||
* writes is one {@code anchor} lets it write.
|
||||
*/
|
||||
void placeOnTop(MantleStageContext context, PlaceableObject object, int worldX, int y, int worldZ, ObjectPlacement placement,
|
||||
IslandAnchor anchor, RNG random) {
|
||||
placeAgainstIsland(context, object, worldX, y, worldZ, placement, NO_ROTATION, anchor, random, "anchored");
|
||||
}
|
||||
|
||||
/** Places {@code object} upside down under an island, turned {@code yRotation} degrees about Y, as {@link #placeOnTop} does on top. */
|
||||
void placeUnder(MantleStageContext context, PlaceableObject object, int worldX, int y, int worldZ, int yRotation,
|
||||
ObjectPlacement placement, IslandAnchor anchor, RNG random) {
|
||||
placeAgainstIsland(context, object, worldX, y, worldZ, placement, ObjectRotation.xFlip180WithY(yRotation), anchor, random,
|
||||
"inverted");
|
||||
}
|
||||
|
||||
private void placeAgainstIsland(MantleStageContext context, PlaceableObject object, int worldX, int y, int worldZ,
|
||||
ObjectPlacement placement, ObjectRotation rotation, IslandAnchor anchor, RNG random, String kind) {
|
||||
ObjectPlacement anchored = placement.toBuilder()
|
||||
.place(List.of(object.name()))
|
||||
.mode(placement.mode().onFloatingIsland())
|
||||
.translate(new ObjectTranslate())
|
||||
.rotation(rotation)
|
||||
.forcePlace(true)
|
||||
.bottom(false)
|
||||
.build();
|
||||
IslandTransaction transaction = new IslandTransaction(new IslandTerrain(context.placementTerrain(), anchor), anchor);
|
||||
int id = random.i(0, Integer.MAX_VALUE);
|
||||
try {
|
||||
boolean placed = place(ObjectRun.of(object, anchored, worldX, y, worldZ), transaction, object, id);
|
||||
if (placed) {
|
||||
transaction.commit();
|
||||
} else {
|
||||
transaction.discard();
|
||||
}
|
||||
} catch (Throwable failure) {
|
||||
transaction.discard();
|
||||
log.error("Failed to place an " + kind + " floating object", failure);
|
||||
}
|
||||
}
|
||||
|
||||
/** Places the run and records the object's placement beside each block it wrote that is not air. */
|
||||
private boolean place(ObjectRun run, PlacementTerrain terrain, PlaceableObject object, int id) {
|
||||
if (!run.placeIn(world, terrain).isPlaced()) {
|
||||
return false;
|
||||
}
|
||||
String placementName = object.name() + "@" + id;
|
||||
for (BlockPosition position : run.objectBlocks()) {
|
||||
if (placesBlock(terrain.get(position.x(), position.y(), position.z()))) {
|
||||
terrain.recordPlacement(position.x(), position.y(), position.z(), placementName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean placesBlock(BlockState state) {
|
||||
return blocks.hasTrait(state, BlockTrait.CUSTOM) || !AIR_MATERIALS.contains(state.material().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* The mantle as an object placed against an island sees it: heights are the island face's, nothing is under water,
|
||||
* and only the blocks the anchor lets the object write are written.
|
||||
*/
|
||||
private static final class IslandTerrain extends ForwardingTerrain {
|
||||
private final IslandAnchor anchor;
|
||||
|
||||
private IslandTerrain(PlacementTerrain delegate, IslandAnchor anchor) {
|
||||
super(delegate);
|
||||
this.anchor = anchor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int highest(int x, int z, boolean ignoreFluid) {
|
||||
return anchor.faceY(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderwater(int x, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockState state) {
|
||||
if (anchor.writes(x, y, z)) {
|
||||
delegate().set(x, y, z, state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockState state, BlockEntityData blockEntity) {
|
||||
if (anchor.writes(x, y, z)) {
|
||||
delegate().set(x, y, z, state, blockEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordPlacement(int x, int y, int z, String placement) {
|
||||
if (anchor.writes(x, y, z)) {
|
||||
delegate().recordPlacement(x, y, z, placement);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mark(PlacedMarker marker) {
|
||||
BlockPosition position = marker.position();
|
||||
if (anchor.writes(position.x(), position.y(), position.z())) {
|
||||
delegate().mark(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Writes an object placed against an island only when the anchor lets it write every block. */
|
||||
private static final class IslandTransaction extends TerrainTransaction {
|
||||
private final IslandAnchor anchor;
|
||||
|
||||
private IslandTransaction(PlacementTerrain delegate, IslandAnchor anchor) {
|
||||
super(delegate);
|
||||
this.anchor = anchor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean accepts(int x, int y, int z) {
|
||||
return anchor.writes(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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.mantle.components;
|
||||
|
||||
import art.arcane.iris.modules.objects.ForwardingTerrain;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
/**
|
||||
* A terrain that logs the questions a placement asks of it, for the chunks the golden-debug switch names: the
|
||||
* {@code iris.goldendebug} system property, or else {@code plugins/Iris/goldendebug.txt}, holding
|
||||
* {@code chunkX,chunkZ[,radius]}.
|
||||
*/
|
||||
final class GoldenDebugTerrain extends ForwardingTerrain {
|
||||
private static final String SWITCH_PROPERTY = "iris.goldendebug";
|
||||
private static final File SWITCH_FILE = new File("plugins/Iris/goldendebug.txt");
|
||||
private static final int[] TARGET = parseTarget(readSwitch());
|
||||
|
||||
private final String tag;
|
||||
private final ModuleLog log;
|
||||
|
||||
GoldenDebugTerrain(PlacementTerrain delegate, String tag, ModuleLog log) {
|
||||
super(delegate);
|
||||
this.tag = tag;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/** Whether the switch names the chunk. */
|
||||
static boolean isGoldenDebugChunk(int chunkX, int chunkZ) {
|
||||
return TARGET != null
|
||||
&& Math.abs(TARGET[0] - chunkX) <= TARGET[2]
|
||||
&& Math.abs(TARGET[1] - chunkZ) <= TARGET[2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int highest(int x, int z, boolean ignoreFluid) {
|
||||
int result = delegate().highest(x, z, ignoreFluid);
|
||||
log.debug("Goldendebug query: tag=" + tag + " getHighest(" + x + "," + z + ",ignoreFluid=" + ignoreFluid + ")=" + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
boolean result = delegate().isCarved(x, y, z);
|
||||
log.debug("Goldendebug query: tag=" + tag + " isCarved(" + x + "," + y + "," + z + ")=" + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String readSwitch() {
|
||||
String property = System.getProperty(SWITCH_PROPERTY);
|
||||
if (property != null && !property.isBlank()) {
|
||||
return property;
|
||||
}
|
||||
if (!SWITCH_FILE.isFile()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Files.readString(SWITCH_FILE.toPath()).trim();
|
||||
} catch (IOException | SecurityException unreadable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static int[] parseTarget(String raw) {
|
||||
if (raw == null || raw.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
String[] parts = raw.split(",");
|
||||
if (parts.length != 2 && parts.length != 3) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
int radius = parts.length == 3 ? Integer.parseInt(parts[2].trim()) : 0;
|
||||
return new int[]{Integer.parseInt(parts[0].trim()), Integer.parseInt(parts[1].trim()), radius};
|
||||
} catch (NumberFormatException malformed) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.floating.IslandAnchor;
|
||||
import art.arcane.iris.modules.floating.IslandAnchor;
|
||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
|
||||
import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild;
|
||||
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* 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.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.MatterMantle;
|
||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.blocks.ObjectMarkers;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectRun;
|
||||
import art.arcane.iris.builtin.objects.PlacementSource;
|
||||
import art.arcane.iris.modules.objects.CarvedSpace;
|
||||
import art.arcane.iris.modules.objects.CavePlacement;
|
||||
import art.arcane.iris.modules.objects.CaveTransaction;
|
||||
import art.arcane.iris.modules.objects.EffectiveSettings;
|
||||
import art.arcane.iris.modules.objects.ForwardingTerrain;
|
||||
import art.arcane.iris.modules.objects.PlacementChanges;
|
||||
import art.arcane.iris.modules.objects.PlacementTags;
|
||||
import art.arcane.iris.modules.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.modules.objects.TerrainTransaction;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.placement.PlacementOutcome;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
/**
|
||||
* The chunk whose mantle {@code iris:objects} is placing into: the one place its objects are written. Every placement
|
||||
* here runs the pack's placement stages ({@link com.volmit.placement.Placements}) over the chunk's mantle, then writes the
|
||||
* placement's tags beside the object's own blocks.
|
||||
*/
|
||||
final class ObjectChunk {
|
||||
private static final int REJECTED = -1;
|
||||
private static final int SAMPLED_HEIGHT = -1;
|
||||
|
||||
private final PackWorld world;
|
||||
private final PlacementTerrain terrain;
|
||||
private final CarvedSpace carved;
|
||||
private final EffectiveSettings settings;
|
||||
private final BlockRegistry blocks;
|
||||
private final ModuleLog log;
|
||||
private final int worldHeight;
|
||||
|
||||
ObjectChunk(MantleStageContext context, EffectiveSettings settings, ModuleLog log) {
|
||||
this.world = context.world();
|
||||
this.terrain = context.placementTerrain();
|
||||
this.worldHeight = context.terrain().bounds().maxY();
|
||||
this.carved = new CarvedSpace(context.extension(MatterMantle.class).orElseThrow(), worldHeight);
|
||||
this.settings = settings;
|
||||
this.blocks = world.resources().blocks();
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/** The voids the cave carver planned around the chunk. */
|
||||
CarvedSpace carved() {
|
||||
return carved;
|
||||
}
|
||||
|
||||
/** Whether the golden-debug switch is on for the chunk, which logs every decision of its placements. */
|
||||
boolean goldenDebug(int chunkX, int chunkZ) {
|
||||
return GoldenDebugTerrain.isGoldenDebugChunk(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Places an object on the terrain, where it sits at the height its place mode finds.
|
||||
*
|
||||
* @param goldenTag logs the placement's questions under this tag, or null to leave them
|
||||
* @return the height the object was placed at, negative when the placement rejected it
|
||||
*/
|
||||
int placeOnSurface(PlaceableObject object, int x, int z, PlacementSource placement, PlacementChanges changes,
|
||||
PlacementTags tags, String goldenTag) {
|
||||
PlacementTerrain placer = proceduralTerrain(terrain, placement, goldenTag);
|
||||
return place(ObjectRun.of(object, settings.of(placement, changes), x, SAMPLED_HEIGHT, z), placer, tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Places an object in a cave, anchored at {@code anchorY}, and writes it only when all of it lies inside the cave and
|
||||
* no deeper than {@code minDepthBelowSurface} under the surface.
|
||||
*
|
||||
* @param goldenTag logs the placement's questions under this tag, or null to leave them
|
||||
*/
|
||||
CavePlacement placeInCave(PlaceableObject object, int x, int anchorY, int z, PlacementSource placement, PlacementChanges changes,
|
||||
int minDepthBelowSurface, PlacementTags tags, String goldenTag) {
|
||||
ObjectPlacement effective = settings.of(placement, changes);
|
||||
CaveTransaction transaction = new CaveTransaction(proceduralTerrain(terrain, placement, goldenTag), worldHeight, anchorY,
|
||||
minDepthBelowSurface);
|
||||
int placeY = anchorY;
|
||||
if (effective.mode().placeMode().has(PlaceTrait.UPSIDE_DOWN)) {
|
||||
placeY = Math.max(1, transaction.caveCeiling(x, z) - 1 - Math.floorDiv(object.height(), 2));
|
||||
}
|
||||
int result = place(ObjectRun.of(object, effective, x, placeY, z), transaction, tags);
|
||||
if (result < 0) {
|
||||
transaction.discard();
|
||||
return new CavePlacement(result, TerrainTransaction.Commit.EMPTY);
|
||||
}
|
||||
return new CavePlacement(result, transaction.commit());
|
||||
}
|
||||
|
||||
/** Places an object at a given height, which the terrain stacked above uses for the objects hung from it. */
|
||||
int placeUpper(PlaceableObject object, int x, int anchorY, int z, ObjectPlacement placement, PlacementChanges changes,
|
||||
PlacementTags tags) {
|
||||
return place(ObjectRun.of(object, EffectiveSettings.withChanges(placement, changes), x, anchorY, z), terrain, tags);
|
||||
}
|
||||
|
||||
private int place(ObjectRun run, PlacementTerrain placer, PlacementTags tags) {
|
||||
PlacementOutcome outcome = run.placeIn(world, placer);
|
||||
if (!outcome.isPlaced()) {
|
||||
return REJECTED;
|
||||
}
|
||||
writeTags(placer, run, tags);
|
||||
return run.anchorY().orElse(REJECTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* A procedural object's terrain: its leaves decay when it is meant to look real, and the golden-debug switch logs
|
||||
* its questions. Object placements use the chunk's terrain as it is.
|
||||
*/
|
||||
private PlacementTerrain proceduralTerrain(PlacementTerrain base, PlacementSource placement, String goldenTag) {
|
||||
if (!(placement instanceof ProceduralPlacement procedural)) {
|
||||
return base;
|
||||
}
|
||||
PlacementTerrain decaying = procedural.plausible() ? new DecayingTerrain(base) : base;
|
||||
return goldenTag == null ? decaying : new GoldenDebugTerrain(decaying, goldenTag, log);
|
||||
}
|
||||
|
||||
/** Writes the tags beside each of the object's own blocks. */
|
||||
private void writeTags(PlacementTerrain placer, ObjectRun run, PlacementTags tags) {
|
||||
for (BlockPosition position : run.objectBlocks()) {
|
||||
if (tags.marker() != null) {
|
||||
placer.recordPlacement(position.x(), position.y(), position.z(), tags.marker());
|
||||
if (tags.treeMaterial()) {
|
||||
placer.mark(ObjectMarkers.treeMaterial(position));
|
||||
}
|
||||
}
|
||||
if (tags.buriedTreasure() && blocks.hasTrait(placer.get(position.x(), position.y(), position.z()), BlockTrait.STORAGE)) {
|
||||
placer.mark(ObjectMarkers.buriedTreasure(position));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** A terrain whose leaves decay, for procedural objects meant to look like the real thing. */
|
||||
private static final class DecayingTerrain extends ForwardingTerrain {
|
||||
private DecayingTerrain(PlacementTerrain delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preventsDecay() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost.Declaration;
|
||||
import art.arcane.iris.modules.objects.Declaration;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import com.volmit.config.Level;
|
||||
@@ -50,7 +49,7 @@ public final class ObjectLocating implements ObjectsAt {
|
||||
PackResources resources = world.resources();
|
||||
Set<ResourceId> biomes = new LinkedHashSet<>();
|
||||
Set<ResourceId> regions = new LinkedHashSet<>();
|
||||
for (Declaration<ObjectSettings> declaration : world.extension(ObjectHost.class).orElseThrow().declarations(ObjectSettings.class)) {
|
||||
for (Declaration<ObjectSettings> declaration : Declaration.allOf(world, ObjectSettings.class)) {
|
||||
if (!placesObject(declaration.settings().objects(), resources, object)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.RequireSurfaceSupportSettings;
|
||||
@@ -79,6 +78,6 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle {
|
||||
}
|
||||
|
||||
private static int reach(PackSettings settings, ModuleLog log) {
|
||||
return new PlacementReach(settings.extension(ObjectHost.class).orElseThrow(), log).ofPack(settings);
|
||||
return new PlacementReach(settings.resources(), log).ofPack(settings);
|
||||
}
|
||||
}
|
||||
@@ -18,15 +18,15 @@
|
||||
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.modules.objects.EffectiveSettings;
|
||||
import art.arcane.iris.modules.objects.ObjectPool;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.stage.MantleStageContext;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
@@ -36,8 +36,7 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* Places the objects the dimension's regions and biomes declare, one chunk at a time, into the mantle of a world: the worker
|
||||
* of {@link ObjectModule}, one per world. It also works out which objects a chunk would get, without placing them, and how far
|
||||
* the pack's objects reach.
|
||||
* of {@link ObjectModule}, one per world. It also works out which objects a chunk would get, without placing them.
|
||||
*/
|
||||
public final class ObjectPlacing {
|
||||
private static final int CHUNK_CENTER_OFFSET_BLOCKS = 8;
|
||||
@@ -47,12 +46,13 @@ public final class ObjectPlacing {
|
||||
private static final Level[] GUESSED_LEVELS = {Level.BIOME, Level.REGION};
|
||||
|
||||
private final PackWorld world;
|
||||
private final ObjectHost host;
|
||||
private final ObjectPool objects;
|
||||
private final EffectiveSettings settings = new EffectiveSettings();
|
||||
private final ModuleLog log;
|
||||
|
||||
private ObjectPlacing(PackWorld world) {
|
||||
this.world = world;
|
||||
this.host = world.extension(ObjectHost.class).orElseThrow();
|
||||
this.objects = ObjectPool.of(world);
|
||||
this.log = world.log();
|
||||
}
|
||||
|
||||
@@ -63,12 +63,12 @@ public final class ObjectPlacing {
|
||||
|
||||
/** Places what originates in the chunk {@code context} generates. */
|
||||
void place(MantleStageContext context) {
|
||||
new ChunkObjectPlacing(host, log, context).place();
|
||||
new ChunkObjectPlacing(objects, settings, log, context).place();
|
||||
}
|
||||
|
||||
/** The keys of the objects the chunk would get, as far as the chunk's surface objects go. */
|
||||
public Set<String> guess(int chunkX, int chunkZ) {
|
||||
RNG rng = host.chunkRandom(chunkX, chunkZ);
|
||||
RNG rng = objects.chunkRandom(chunkX, chunkZ);
|
||||
int centerX = (chunkX << CHUNK_SHIFT) + CHUNK_CENTER_OFFSET_BLOCKS;
|
||||
int centerZ = (chunkZ << CHUNK_SHIFT) + CHUNK_CENTER_OFFSET_BLOCKS;
|
||||
SettingsStack<ObjectSettings> declared = world.running().orElseThrow().settings().at(ObjectSettings.class, centerX, centerZ);
|
||||
@@ -89,15 +89,10 @@ public final class ObjectPlacing {
|
||||
|
||||
private Set<String> guessPlacedKeys(RNG rng, int x, int z, ObjectPlacement placement) {
|
||||
Set<String> keys = new HashSet<>();
|
||||
for (int i = 0; i < host.density(placement, rng, x, z); i++) {
|
||||
Optional<PlaceableObject> picked = host.pickScaled(placement, rng);
|
||||
picked.ifPresent(object -> keys.add(object.key()));
|
||||
for (int i = 0; i < objects.density(placement, rng, x, z); i++) {
|
||||
Optional<PlaceableObject> picked = objects.pickScaled(placement, rng);
|
||||
picked.ifPresent(object -> keys.add(object.name()));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
/** How far, in blocks along X and Z, placements may write beyond their chunk. */
|
||||
public int reach(PackSettings settings) {
|
||||
return new PlacementReach(host, log).ofPack(settings);
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost.Declaration;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.iris.modules.objects.Declaration;
|
||||
import art.arcane.iris.modules.objects.ObjectPool;
|
||||
import art.arcane.iris.modules.objects.ProceduralPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.world.PackWorld;
|
||||
@@ -35,28 +35,27 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Builds what object placing would build on first use, for every object placement and procedural object the world's
|
||||
* biomes and regions declare: the placement's surface warp and density noise, and a procedural object's variants. None
|
||||
* of it depends on the random it is warmed with; the warp is seeded from the world, the density noise is cached per seed
|
||||
* and the variants are baked whatever picks one.
|
||||
* biomes and regions declare: the placement's density noise, and a procedural object's variants. None of it depends on
|
||||
* the random it is warmed with; the density noise is cached per seed and the variants are baked whatever picks one.
|
||||
*/
|
||||
final class ObjectWarmUp {
|
||||
private static final long ROOT_SEED_SALT = 7777L;
|
||||
private static final Level[] WARMED_LEVELS = {Level.BIOME, Level.REGION};
|
||||
|
||||
private final PackWorld world;
|
||||
private final ObjectHost host;
|
||||
private final ObjectPool objects;
|
||||
private final RNG root;
|
||||
private int warmed;
|
||||
|
||||
ObjectWarmUp(PackWorld world) {
|
||||
this.world = world;
|
||||
this.host = world.extension(ObjectHost.class).orElseThrow();
|
||||
this.objects = ObjectPool.of(world);
|
||||
this.root = new RNG(world.seed(IrisSeedPurposes.COMPONENT) + ROOT_SEED_SALT);
|
||||
}
|
||||
|
||||
void warm() {
|
||||
List<Declaration<ObjectSettings>> placements = byKey(host.declarations(ObjectSettings.class));
|
||||
List<Declaration<ProceduralObjectSettings>> procedural = byKey(host.declarations(ProceduralObjectSettings.class));
|
||||
List<Declaration<ObjectSettings>> placements = byKey(Declaration.allOf(world, ObjectSettings.class));
|
||||
List<Declaration<ProceduralObjectSettings>> procedural = byKey(Declaration.allOf(world, ProceduralObjectSettings.class));
|
||||
for (Level level : WARMED_LEVELS) {
|
||||
for (Declaration<ObjectSettings> declaration : placements) {
|
||||
if (declaration.level() == level) {
|
||||
@@ -78,7 +77,7 @@ final class ObjectWarmUp {
|
||||
private void warmPlacements(List<ObjectPlacement> placements) {
|
||||
for (ObjectPlacement placement : placements) {
|
||||
if (placement != null) {
|
||||
host.warm(placement, root.nextParallelRNG(warmed++));
|
||||
objects.warm(placement, root.nextParallelRNG(warmed++));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,20 +20,21 @@ package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.PlaceMode;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSize;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.builtin.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralObjects;
|
||||
import art.arcane.iris.modules.objects.ObjectSize;
|
||||
import art.arcane.iris.modules.objects.ProceduralPlacement;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -48,13 +49,13 @@ final class PlacementReach {
|
||||
private static final int MAX_VACUUM_RADIUS_BLOCKS = 128;
|
||||
private static final double SCALE_PADDING_FACTOR = 2D;
|
||||
|
||||
private final ObjectHost host;
|
||||
private final PackResources resources;
|
||||
private final ModuleLog log;
|
||||
private final Map<String, Optional<ObjectSize>> sizes = new HashMap<>();
|
||||
private final Set<String> warnedLargeObjects = new HashSet<>();
|
||||
|
||||
PlacementReach(ObjectHost host, ModuleLog log) {
|
||||
this.host = host;
|
||||
PlacementReach(PackResources resources, ModuleLog log) {
|
||||
this.resources = resources;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ final class PlacementReach {
|
||||
|
||||
private int ofObject(ObjectPlacement placement, String objectKey) {
|
||||
try {
|
||||
Optional<ObjectSize> size = sizes.computeIfAbsent(objectKey, host::sizeOf);
|
||||
Optional<ObjectSize> size = sizes.computeIfAbsent(objectKey, key -> sizeOf(resources, key));
|
||||
if (size.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
@@ -100,9 +101,18 @@ final class PlacementReach {
|
||||
}
|
||||
}
|
||||
|
||||
/** The size of the pack object {@code objectKey} names; empty when the pack has none. */
|
||||
static Optional<ObjectSize> sizeOf(PackResources resources, String objectKey) {
|
||||
return resources.objects().sizeOf(resources.idOf(objectKey)).map(PlacementReach::sizeOf);
|
||||
}
|
||||
|
||||
private static ObjectSize sizeOf(BlockBox box) {
|
||||
return new ObjectSize(box.maxX() - box.minX(), box.maxY() - box.minY(), box.maxZ() - box.minZ());
|
||||
}
|
||||
|
||||
private int ofProcedural(ProceduralObjectSettings settings) {
|
||||
int radius = 0;
|
||||
for (ProceduralPlacement placement : ResolvedProceduralObjects.resolve(settings, host)) {
|
||||
for (ProceduralPlacement placement : ResolvedProceduralObjects.resolve(settings, resources)) {
|
||||
for (PlaceableObject variant : placement.variants()) {
|
||||
radius = Math.max(radius, of(new ObjectSize(variant.width(), variant.height(), variant.depth()), placement));
|
||||
}
|
||||
|
||||
@@ -18,24 +18,30 @@
|
||||
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost.Declaration;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectRun;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ObjectSink;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.TreeGrowthSettings;
|
||||
import art.arcane.iris.builtin.objects.TreeMode;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.engine.loot.BlockBiomes;
|
||||
import art.arcane.iris.modules.objects.Declaration;
|
||||
import art.arcane.iris.modules.objects.ObjectPool;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.placement.PlacedBlock;
|
||||
import com.volmit.placement.PlacedMarker;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
import com.volmit.placement.StructureVolumes;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.SaplingGrowth;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
|
||||
@@ -57,7 +63,6 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
|
||||
@Override
|
||||
public Optional<Growth> grow(PackWorld world, Sapling sapling, Surroundings surroundings) {
|
||||
ObjectHost host = world.extension(ObjectHost.class).orElseThrow();
|
||||
RunningWorld running = world.running().orElseThrow();
|
||||
BlockPosition at = sapling.at();
|
||||
TreeGrowthSettings growth = treeGrowth(running, at);
|
||||
@@ -69,26 +74,26 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
return Optional.empty();
|
||||
}
|
||||
List<String> keys = placement.get().place();
|
||||
Optional<PlaceableObject> tree = host.object(keys.get(RNG.r.i(keys.size())));
|
||||
Optional<PlaceableObject> tree = ObjectPool.of(world).object(keys.get(RNG.r.i(keys.size())));
|
||||
if (tree.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
PlaceableObject object = tree.get();
|
||||
GrowthSink sink = new GrowthSink(surroundings, running.layout().fluidHeight());
|
||||
GrowthTerrain terrain = new GrowthTerrain(surroundings, running.layout().fluidHeight(), world.resources().blocks());
|
||||
BlockPosition center = sapling.center();
|
||||
host.placeInto(object, center.x(), center.y() + object.height() / 2, center.z(), placement.get(), sink, RNG.r);
|
||||
return Optional.of(new Growth(world.resources().idOf(object.key()), sink.placed()));
|
||||
ObjectRun run = ObjectRun.of(object, placement.get(), center.x(), center.y() + object.height() / 2, center.z());
|
||||
run.placeIn(world, terrain);
|
||||
return Optional.of(new Growth(world.resources().idOf(object.name()), terrain.placed()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeObjects treeObjects(PackWorld world) {
|
||||
ObjectHost host = world.extension(ObjectHost.class).orElseThrow();
|
||||
Set<String> objects = new HashSet<>();
|
||||
Set<String> procedural = new HashSet<>();
|
||||
for (Declaration<ObjectSettings> declaration : host.declarations(ObjectSettings.class)) {
|
||||
for (Declaration<ObjectSettings> declaration : Declaration.allOf(world, ObjectSettings.class)) {
|
||||
collectPlacements(declaration.settings().objects(), objects);
|
||||
}
|
||||
for (Declaration<ProceduralObjectSettings> declaration : host.declarations(ProceduralObjectSettings.class)) {
|
||||
for (Declaration<ProceduralObjectSettings> declaration : Declaration.allOf(world, ProceduralObjectSettings.class)) {
|
||||
collectProceduralTrees(declaration.settings().trees(), procedural);
|
||||
}
|
||||
return new TreeObjects(idsOf(world, objects), idsOf(world, procedural));
|
||||
@@ -153,15 +158,38 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
}
|
||||
}
|
||||
|
||||
/** Places an object into a list of blocks, reading the world around the sapling through the host. */
|
||||
private static final class GrowthSink implements ObjectSink {
|
||||
/**
|
||||
* The world around a sapling, read through the host, collecting what a tree writes into a list of blocks the host
|
||||
* then places. Its leaves never decay; it has no caves, water, structures or placement records, and keeps no block
|
||||
* entities or markers.
|
||||
*/
|
||||
private static final class GrowthTerrain implements PlacementTerrain {
|
||||
private static final StructureVolumes NO_STRUCTURES = new StructureVolumes() {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean intersects(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsWithin(int x, int y, int z, int margin) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private final Surroundings surroundings;
|
||||
private final int fluidHeight;
|
||||
private final BlockRegistry blocks;
|
||||
private final List<PlacedBlock> placed = new ArrayList<>();
|
||||
|
||||
private GrowthSink(Surroundings surroundings, int fluidHeight) {
|
||||
private GrowthTerrain(Surroundings surroundings, int fluidHeight, BlockRegistry blocks) {
|
||||
this.surroundings = surroundings;
|
||||
this.fluidHeight = fluidHeight;
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
private List<PlacedBlock> placed() {
|
||||
@@ -183,9 +211,52 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
placed.add(new PlacedBlock(new BlockPosition(x, y, z), state, Optional.empty()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockState state, BlockEntityData blockEntity) {
|
||||
set(x, y, z, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSurfaceSolid(int x, int y, int z) {
|
||||
return blocks.hasTrait(get(x, y, z), BlockTrait.SOLID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderwater(int x, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fluidHeight() {
|
||||
return fluidHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preventsDecay() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordPlacement(int x, int y, int z, String placement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> placementAt(int x, int y, int z) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureVolumes structureVolumes(int minX, int minZ, int maxX, int maxZ) {
|
||||
return NO_STRUCTURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mark(PlacedMarker marker) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,17 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.anchor.AnchorHeight;
|
||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.placement.CaveSpace;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.placement.ObjectShape;
|
||||
import art.arcane.iris.builtin.placement.PlacementSettings;
|
||||
import art.arcane.iris.builtin.placement.PlacementTerrain;
|
||||
import art.arcane.iris.builtin.prepare.PreparedPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectRun;
|
||||
import art.arcane.iris.builtin.prepare.TransformedBounds;
|
||||
import art.arcane.iris.modules.placement.ObjectShape;
|
||||
import art.arcane.iris.modules.placement.PlacementSettings;
|
||||
import art.arcane.iris.modules.placement.PlacementStages;
|
||||
import art.arcane.iris.modules.placement.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.RunningPlacement;
|
||||
import art.arcane.iris.modules.placement.StageTerrain;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleSetup;
|
||||
@@ -53,17 +53,17 @@ public final class AnchorModule implements IrisModule {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
var graph = setup.stages();
|
||||
graph.define(IrisStages.Anchor.HEIGHT)
|
||||
.requires(IrisStages.Prepare.TRANSFORMS)
|
||||
graph.define(PlacementStages.Anchor.HEIGHT)
|
||||
.requires(PlacementStages.Prepare.TRANSFORMS)
|
||||
.produce(AnchorModule::height);
|
||||
graph.define(IrisStages.Anchor.FINAL)
|
||||
.requires(IrisStages.Anchor.HEIGHT, IrisStages.Validate.COLLISIONS)
|
||||
graph.define(PlacementStages.Anchor.FINAL)
|
||||
.requires(PlacementStages.Anchor.HEIGHT, PlacementStages.Validate.COLLISIONS)
|
||||
.produce(AnchorModule::finalHeight);
|
||||
}
|
||||
|
||||
private static AnchorHeight height(PlacementStageContext context) {
|
||||
ObjectPlacement placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
RunningPlacement placement = context.output(PlacementStages.Prepare.TRANSFORMS).placement();
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
PlacementSettings settings = prepared.settings();
|
||||
boolean structurePiece = prepared.mode().has(PlaceTrait.RAW_STAMP);
|
||||
if (!settings.fromBottom() && placement.requestedY() < 0) {
|
||||
@@ -88,12 +88,12 @@ public final class AnchorModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static AnchorHeight finalHeight(PlacementStageContext context) {
|
||||
int y = context.output(IrisStages.Anchor.HEIGHT).y() + context.output(IrisStages.Prepare.TRANSFORMS).randomY();
|
||||
context.extension(ObjectPlacement.class).orElseThrow().anchoredAt(y);
|
||||
int y = context.output(PlacementStages.Anchor.HEIGHT).y() + context.output(PlacementStages.Prepare.TRANSFORMS).randomY();
|
||||
context.output(PlacementStages.Prepare.TRANSFORMS).placement().anchoredAt(y);
|
||||
return new AnchorHeight(y);
|
||||
}
|
||||
|
||||
private static int sampled(PlacementStageContext context, ObjectPlacement placement, PreparedPlacement prepared) {
|
||||
private static int sampled(PlacementStageContext context, RunningPlacement placement, PreparedPlacement prepared) {
|
||||
return switch (prepared.mode().anchor()) {
|
||||
case CENTER -> checked(context, prepared, placement.x(), centerSurface(placement, prepared), placement.z());
|
||||
case SURFACE -> checked(context, prepared, placement.x(), surface(prepared, placement.x(), placement.z()), placement.z());
|
||||
@@ -107,8 +107,8 @@ public final class AnchorModule implements IrisModule {
|
||||
}
|
||||
|
||||
/** The floor of the cave the object is placed in, otherwise the surface at its center. */
|
||||
private static int centerSurface(ObjectPlacement placement, PreparedPlacement prepared) {
|
||||
Optional<CaveSpace> cave = placement.cave();
|
||||
private static int centerSurface(RunningPlacement placement, PreparedPlacement prepared) {
|
||||
Optional<ObjectRun.Cave> cave = placement.cave();
|
||||
if (cave.isPresent()) {
|
||||
return cave.get().surface() + prepared.rotatedCenterY();
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public final class AnchorModule implements IrisModule {
|
||||
}
|
||||
|
||||
/** The highest or lowest surface under the object's columns, or under its four corners only. */
|
||||
private static int extremeSurface(PlacementStageContext context, ObjectPlacement placement, PreparedPlacement prepared,
|
||||
private static int extremeSurface(PlacementStageContext context, RunningPlacement placement, PreparedPlacement prepared,
|
||||
boolean highest, boolean cornersOnly) {
|
||||
TransformedBounds bounds = prepared.bounds();
|
||||
int minX = placement.x() + bounds.minX();
|
||||
@@ -152,7 +152,7 @@ public final class AnchorModule implements IrisModule {
|
||||
|
||||
/** Whether the placement's carving support forbids anchoring at this block. */
|
||||
private static boolean rejectsCarvingAnchor(PreparedPlacement prepared, int x, int y, int z) {
|
||||
PlacementTerrain terrain = prepared.terrain();
|
||||
StageTerrain terrain = prepared.terrain();
|
||||
return switch (prepared.settings().carvingSupport()) {
|
||||
case SURFACE_ONLY -> terrain.isCarved(x, y, z);
|
||||
case CARVING_ONLY -> !carvedWithin(terrain, x, y, z);
|
||||
@@ -160,7 +160,7 @@ public final class AnchorModule implements IrisModule {
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean carvedWithin(PlacementTerrain terrain, int x, int y, int z) {
|
||||
private static boolean carvedWithin(StageTerrain terrain, int x, int y, int z) {
|
||||
for (int depth = 0; depth < CARVING_CLEARANCE_BLOCKS; depth++) {
|
||||
if (terrain.isCarved(x, y - depth, z)) {
|
||||
return true;
|
||||
|
||||
@@ -18,18 +18,19 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.blocks.ObjectMarkers;
|
||||
import art.arcane.iris.builtin.blocks.WrittenBlocks;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.placement.MarkerRule;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.placement.PlacementSettings;
|
||||
import art.arcane.iris.builtin.placement.PlacementTerrain;
|
||||
import art.arcane.iris.builtin.prepare.PreparedPlacement;
|
||||
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
||||
import art.arcane.iris.modules.blocks.SmartBoreDebugSettings;
|
||||
import art.arcane.iris.modules.placement.MarkerRule;
|
||||
import art.arcane.iris.modules.placement.PlacementSettings;
|
||||
import art.arcane.iris.modules.placement.PlacementStages;
|
||||
import art.arcane.iris.modules.placement.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.RunningPlacement;
|
||||
import art.arcane.iris.modules.placement.StageTerrain;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.IrisModule;
|
||||
@@ -75,27 +76,28 @@ public final class BlocksModule implements IrisModule {
|
||||
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.registry().registerSettings(SmartBoreDebugSettings.class);
|
||||
var graph = setup.stages();
|
||||
graph.define(IrisStages.Blocks.WRITE)
|
||||
.requires(IrisStages.Prepare.TRANSFORMS, IrisStages.Anchor.FINAL, IrisStages.Bore.CLEAR)
|
||||
graph.define(PlacementStages.Blocks.WRITE)
|
||||
.requires(PlacementStages.Prepare.TRANSFORMS, PlacementStages.Anchor.FINAL, PlacementStages.Bore.CLEAR)
|
||||
.accumulate(WrittenBlocks::new, BlocksModule::write);
|
||||
graph.define(IrisStages.Blocks.MARKERS)
|
||||
.requires(IrisStages.Blocks.WRITE, IrisStages.Prepare.TRANSFORMS)
|
||||
graph.define(PlacementStages.Blocks.MARKERS)
|
||||
.requires(PlacementStages.Blocks.WRITE, PlacementStages.Prepare.TRANSFORMS)
|
||||
.run(BlocksModule::placeMarkers);
|
||||
graph.define(IrisStages.Blocks.COMPLETE)
|
||||
.requires(IrisStages.Blocks.WRITE, IrisStages.Blocks.MARKERS)
|
||||
graph.define(PlacementStages.Blocks.COMPLETE)
|
||||
.requires(PlacementStages.Blocks.WRITE, PlacementStages.Blocks.MARKERS)
|
||||
.run(context -> {
|
||||
});
|
||||
}
|
||||
|
||||
private static void write(BlockStageContext context, WrittenBlocks written) {
|
||||
ObjectPlacement placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
RunningPlacement placement = prepared.placement();
|
||||
PlacementSettings settings = prepared.settings();
|
||||
PlacementWorld world = new PlacementWorld(context.access(), prepared.traits());
|
||||
ObjectBlock block = context.block();
|
||||
BlockPosition offset = prepared.transform(block.position());
|
||||
int anchorY = context.output(IrisStages.Anchor.FINAL).y();
|
||||
int anchorY = context.output(PlacementStages.Anchor.FINAL).y();
|
||||
BlockState data = sourceState(block, placement, prepared);
|
||||
Optional<BlockEntityData> blockEntity = block.blockEntity();
|
||||
if (!settings.edit().isEmpty()) {
|
||||
@@ -137,10 +139,10 @@ public final class BlocksModule implements IrisModule {
|
||||
}
|
||||
|
||||
/** The object block as Iris places it: debug air shows where smart boring bored, and leaves never decay where the placer prevents it. */
|
||||
private static BlockState sourceState(ObjectBlock block, ObjectPlacement placement, PreparedPlacement prepared) {
|
||||
private static BlockState sourceState(ObjectBlock block, RunningPlacement placement, PreparedPlacement prepared) {
|
||||
BlockState data = block.state();
|
||||
PlacementTerrain terrain = prepared.terrain();
|
||||
if (terrain.debugsSmartBore() && placement.matches(data, VOID_AIR)) {
|
||||
StageTerrain terrain = prepared.terrain();
|
||||
if (placement.matches(data, VOID_AIR) && terrain.debugsSmartBore(placement.x(), placement.z())) {
|
||||
data = VOID_AIR_DEBUG;
|
||||
}
|
||||
if (terrain.preventsDecay() && data.properties().containsKey(DISTANCE)
|
||||
@@ -196,13 +198,13 @@ public final class BlocksModule implements IrisModule {
|
||||
* where the marker either allows anything above or finds two blocks of air.
|
||||
*/
|
||||
private static void placeMarkers(PlacementStageContext context) {
|
||||
ObjectPlacement placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
RunningPlacement placement = prepared.placement();
|
||||
PlacementSettings settings = prepared.settings();
|
||||
if (settings.markers().isEmpty() || !prepared.terrain().hasWorld()) {
|
||||
return;
|
||||
}
|
||||
WrittenBlocks written = context.output(IrisStages.Blocks.WRITE);
|
||||
WrittenBlocks written = context.output(PlacementStages.Blocks.WRITE);
|
||||
PlacementWorld world = new PlacementWorld(context.access(), prepared.traits());
|
||||
RNG markerRandom = new RNG(context.random().nextLong());
|
||||
int salt = 0;
|
||||
@@ -226,7 +228,7 @@ public final class BlocksModule implements IrisModule {
|
||||
}
|
||||
}
|
||||
|
||||
private static KList<BlockPosition> candidates(WrittenBlocks written, MarkerRule rule, ObjectPlacement placement) {
|
||||
private static KList<BlockPosition> candidates(WrittenBlocks written, MarkerRule rule, RunningPlacement placement) {
|
||||
KList<BlockPosition> candidates = new KList<>();
|
||||
written.forEach((position, state) -> {
|
||||
if (rule.targets().stream().anyMatch(target -> marks(placement, rule, target, state))) {
|
||||
@@ -236,7 +238,7 @@ public final class BlocksModule implements IrisModule {
|
||||
return candidates;
|
||||
}
|
||||
|
||||
private static boolean marks(ObjectPlacement placement, MarkerRule rule, BlockState target, BlockState state) {
|
||||
private static boolean marks(RunningPlacement placement, MarkerRule rule, BlockState target, BlockState state) {
|
||||
return rule.exact()
|
||||
? placement.matches(target, state)
|
||||
: target.material().equals(state.material());
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.placement.PlacementSettings;
|
||||
import art.arcane.iris.builtin.prepare.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.PlacementSettings;
|
||||
import art.arcane.iris.modules.placement.PlacementStages;
|
||||
import art.arcane.iris.modules.placement.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.RunningPlacement;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleSetup;
|
||||
@@ -39,19 +39,19 @@ public final class BoreModule implements IrisModule {
|
||||
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(IrisStages.Bore.CLEAR)
|
||||
.requires(IrisStages.Anchor.FINAL, IrisStages.Validate.COLLISIONS)
|
||||
setup.stages().define(PlacementStages.Bore.CLEAR)
|
||||
.requires(PlacementStages.Anchor.FINAL, PlacementStages.Validate.COLLISIONS)
|
||||
.run(BoreModule::clear);
|
||||
}
|
||||
|
||||
private static void clear(PlacementStageContext context) {
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
PlacementSettings settings = prepared.settings();
|
||||
if (!settings.bore()) {
|
||||
return;
|
||||
}
|
||||
ObjectPlacement placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
WorldVolume volume = WorldVolume.of(placement, prepared, context.output(IrisStages.Anchor.FINAL).y());
|
||||
RunningPlacement placement = prepared.placement();
|
||||
WorldVolume volume = WorldVolume.of(placement, prepared, context.output(PlacementStages.Anchor.FINAL).y());
|
||||
PlacementWorld world = new PlacementWorld(context.access(), prepared.traits());
|
||||
for (int x = volume.minX(); x <= volume.maxX(); x++) {
|
||||
for (int y = volume.minY() - settings.boreExtendMinY(); y <= volume.maxY() + settings.boreExtendMaxY(); y++) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.placement.PlacementTerrain;
|
||||
import art.arcane.iris.modules.placement.StageTerrain;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectSpinKernel;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
@@ -21,7 +21,7 @@ public final class IrisSurfaceSupport {
|
||||
private IrisSurfaceSupport() {
|
||||
}
|
||||
|
||||
public static boolean isUnsupported(PlacementTerrain terrain, int x, int z,
|
||||
public static boolean isUnsupported(StageTerrain terrain, int x, int z,
|
||||
ObjectTranslate translate, ObjectRotation rotation,
|
||||
int spinX, int spinY, int spinZ,
|
||||
List<IrisBlockVector> supportOffsets, int buffer, int minSolidDepth) {
|
||||
@@ -162,7 +162,7 @@ public final class IrisSurfaceSupport {
|
||||
}
|
||||
|
||||
/** Centre-outward so the common failure, a hole right under the anchor, costs one column. */
|
||||
private boolean anyColumnUnsupported(PlacementTerrain terrain, int x, int z, int minSolidDepth) {
|
||||
private boolean anyColumnUnsupported(StageTerrain terrain, int x, int z, int minSolidDepth) {
|
||||
int maxRing = Math.max(
|
||||
Math.max(centerX, width - 1 - centerX),
|
||||
Math.max(centerZ, depth - 1 - centerZ));
|
||||
@@ -194,7 +194,7 @@ public final class IrisSurfaceSupport {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isColumnUnsupported(PlacementTerrain terrain, int x, int z,
|
||||
private boolean isColumnUnsupported(StageTerrain terrain, int x, int z,
|
||||
int stencilX, int stencilZ, int minSolidDepth) {
|
||||
if (stencilX < 0 || stencilX >= width || stencilZ < 0 || stencilZ >= depth
|
||||
|| !cells[(stencilX * depth) + stencilZ]) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.blocks.ObjectReplace;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.modules.placement.RunningPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
@@ -39,7 +39,7 @@ final class ObjectEdits {
|
||||
|
||||
/** The result's block entity is the last replacement's, if it has one. */
|
||||
static Edited apply(List<ObjectReplace> edits, BlockState data, Optional<BlockEntityData> blockEntity, RNG rng,
|
||||
double x, double y, double z, ResolvedReplaces replaces, ObjectPlacement placement) {
|
||||
double x, double y, double z, ResolvedReplaces replaces, RunningPlacement placement) {
|
||||
BlockState edited = data;
|
||||
Optional<BlockEntityData> editedEntity = blockEntity;
|
||||
for (ObjectReplace settings : edits) {
|
||||
@@ -61,13 +61,13 @@ final class ObjectEdits {
|
||||
return new Edited(edited, editedEntity);
|
||||
}
|
||||
|
||||
private static boolean finds(ObjectPlacement placement, ResolvedReplace replace, BlockState find, BlockState data) {
|
||||
private static boolean finds(RunningPlacement placement, ResolvedReplace replace, BlockState find, BlockState data) {
|
||||
return replace.exact()
|
||||
? placement.matches(find, data)
|
||||
: find.material().equals(data.material());
|
||||
}
|
||||
|
||||
private static BlockState replaced(ObjectPlacement placement, BlockState data, BlockState replacement) {
|
||||
private static BlockState replaced(RunningPlacement placement, BlockState data, BlockState replacement) {
|
||||
boolean sameMaterial = replacement.material().equals(data.material());
|
||||
if (sameMaterial && !placement.hasTrait(replacement, BlockTrait.CUSTOM) && !placement.hasTrait(data, BlockTrait.CUSTOM)) {
|
||||
return placement.merge(data, replacement);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.placement.BlockTraits;
|
||||
import art.arcane.iris.modules.placement.BlockTraits;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
|
||||
@@ -18,20 +18,20 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.placement.BlockTraits;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.placement.ObjectShape;
|
||||
import art.arcane.iris.builtin.placement.PlacementSettings;
|
||||
import art.arcane.iris.builtin.placement.PlacementTerrain;
|
||||
import art.arcane.iris.builtin.placement.SurfaceWarp;
|
||||
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectSpinKernel;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.prepare.PreparedPlacement;
|
||||
import art.arcane.iris.builtin.prepare.TransformedBounds;
|
||||
import art.arcane.iris.modules.placement.BlockTraits;
|
||||
import art.arcane.iris.modules.placement.ObjectShape;
|
||||
import art.arcane.iris.modules.placement.PlacementSettings;
|
||||
import art.arcane.iris.modules.placement.PlacementStages;
|
||||
import art.arcane.iris.modules.placement.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.RunningPlacement;
|
||||
import art.arcane.iris.modules.placement.StageTerrain;
|
||||
import art.arcane.iris.modules.placement.SurfaceWarp;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.IrisModule;
|
||||
@@ -61,14 +61,14 @@ public final class PrepareModule implements IrisModule {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
var graph = setup.stages();
|
||||
graph.define(IrisStages.Prepare.SLOPE).produce(PrepareModule::slope);
|
||||
graph.define(IrisStages.Prepare.TRANSFORMS)
|
||||
.requires(IrisStages.Prepare.SLOPE)
|
||||
graph.define(PlacementStages.Prepare.SLOPE).produce(PrepareModule::slope);
|
||||
graph.define(PlacementStages.Prepare.TRANSFORMS)
|
||||
.requires(PlacementStages.Prepare.SLOPE)
|
||||
.produce(PrepareModule::transforms);
|
||||
}
|
||||
|
||||
private static ObjectRotation slope(PlacementStageContext context) {
|
||||
ObjectPlacement placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
RunningPlacement placement = RunningPlacement.of(context);
|
||||
PlacementSettings settings = placement.settings();
|
||||
ObjectRotation requested = settings.rotation();
|
||||
boolean checksSlope = !settings.forcePlace() && !settings.slopeCondition().isDefault();
|
||||
@@ -86,8 +86,8 @@ public final class PrepareModule implements IrisModule {
|
||||
}
|
||||
|
||||
/** A copy of {@code requested} whose Y rotation faces the lowest side of the rectangle around the object. */
|
||||
private static ObjectRotation turnedDownhill(ObjectPlacement placement, ObjectRotation requested) {
|
||||
PlacementTerrain terrain = placement.terrain();
|
||||
private static ObjectRotation turnedDownhill(RunningPlacement placement, ObjectRotation requested) {
|
||||
StageTerrain terrain = placement.terrain();
|
||||
ObjectShape object = placement.object();
|
||||
int x = placement.x();
|
||||
int z = placement.z();
|
||||
@@ -108,12 +108,12 @@ public final class PrepareModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static PreparedPlacement transforms(PlacementStageContext context) {
|
||||
ObjectPlacement placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
RunningPlacement placement = RunningPlacement.of(context);
|
||||
PlacementSettings settings = placement.settings();
|
||||
ObjectRotation rotation = context.output(IrisStages.Prepare.SLOPE);
|
||||
ObjectRotation rotation = context.output(PlacementStages.Prepare.SLOPE);
|
||||
ObjectShape object = placement.object();
|
||||
RNG rng = new RNG(context.random().nextLong());
|
||||
PlacementTerrain terrain = placement.terrainFor(rng);
|
||||
StageTerrain terrain = placement.terrainFor(rng);
|
||||
int spinX = rng.imax() / SPIN_DIVISOR;
|
||||
int spinY = rng.imax() / SPIN_DIVISOR;
|
||||
int spinZ = rng.imax() / SPIN_DIVISOR;
|
||||
@@ -130,7 +130,7 @@ public final class PrepareModule implements IrisModule {
|
||||
Optional<SurfaceWarp> surfaceWarp = placement.surfaceWarp(rng);
|
||||
int warpMargin = surfaceWarp.map(warp -> (int) Math.ceil(Math.abs(warp.multiplier()) / 2D)).orElse(0);
|
||||
TransformedBounds bounds = transformedBounds(object, spin, translation, settings.mode().placeMode().has(PlaceTrait.UPSIDE_DOWN), warpMargin);
|
||||
return new PreparedPlacement(placement, rotation, new BlockTraits(placement), terrain, spin,
|
||||
return new PreparedPlacement(placement, rotation, new BlockTraits(context.world().resources().blocks()), terrain, spin,
|
||||
spinX, spinY, spinZ, translation, rotatedCenter.getBlockY(), translatedCenter.getBlockY(), randomY,
|
||||
warpMargin, bounds, surfaceWarp.orElse(null));
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.blocks.WrittenBlocks;
|
||||
import art.arcane.iris.builtin.prepare.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.PlacementStages;
|
||||
import art.arcane.iris.modules.placement.PreparedPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
@@ -50,16 +50,16 @@ public final class SnowModule implements IrisModule {
|
||||
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(IrisStages.Snow.COVER)
|
||||
.requires(IrisStages.Blocks.WRITE, IrisStages.Blocks.COMPLETE, IrisStages.Prepare.TRANSFORMS)
|
||||
.softAfter(IrisStages.Stilt.FILL, IrisStages.Vacuum.TERRAIN)
|
||||
setup.stages().define(PlacementStages.Snow.COVER)
|
||||
.requires(PlacementStages.Blocks.WRITE, PlacementStages.Blocks.COMPLETE, PlacementStages.Prepare.TRANSFORMS)
|
||||
.softAfter(PlacementStages.Stilt.FILL, PlacementStages.Vacuum.TERRAIN)
|
||||
.run(SnowModule::cover);
|
||||
}
|
||||
|
||||
private static void cover(PlacementStageContext context) {
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
double snow = prepared.settings().snow();
|
||||
WrittenBlocks written = context.output(IrisStages.Blocks.WRITE);
|
||||
WrittenBlocks written = context.output(PlacementStages.Blocks.WRITE);
|
||||
if (!(snow > 0) || written.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.anchor.StiltShape;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.placement.PlacementSettings;
|
||||
import art.arcane.iris.builtin.prepare.PreparedPlacement;
|
||||
import art.arcane.iris.builtin.stilt.StiltLayers;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.modules.placement.PlacementSettings;
|
||||
import art.arcane.iris.modules.placement.PlacementStages;
|
||||
import art.arcane.iris.modules.placement.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.RunningPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
@@ -71,18 +71,18 @@ public final class StiltModule implements IrisModule {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
var graph = setup.stages();
|
||||
graph.define(IrisStages.Stilt.LAYERS)
|
||||
.requires(IrisStages.Prepare.TRANSFORMS)
|
||||
graph.define(PlacementStages.Stilt.LAYERS)
|
||||
.requires(PlacementStages.Prepare.TRANSFORMS)
|
||||
// Ordered after boring only so it shares the block pass that writes the object.
|
||||
.softAfter(IrisStages.Bore.CLEAR)
|
||||
.softAfter(PlacementStages.Bore.CLEAR)
|
||||
.accumulate(StiltLayers::new, StiltModule::collectLayer);
|
||||
graph.define(IrisStages.Stilt.FILL)
|
||||
.requires(IrisStages.Stilt.LAYERS, IrisStages.Anchor.FINAL, IrisStages.Blocks.COMPLETE)
|
||||
graph.define(PlacementStages.Stilt.FILL)
|
||||
.requires(PlacementStages.Stilt.LAYERS, PlacementStages.Anchor.FINAL, PlacementStages.Blocks.COMPLETE)
|
||||
.run(StiltModule::fill);
|
||||
}
|
||||
|
||||
private static void collectLayer(BlockStageContext context, StiltLayers layers) {
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
if (prepared.mode().stilt() == StiltShape.NONE) {
|
||||
return;
|
||||
}
|
||||
@@ -103,9 +103,9 @@ public final class StiltModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static void fill(PlacementStageContext context) {
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
StiltShape shape = prepared.mode().stilt();
|
||||
StiltLayers layers = context.output(IrisStages.Stilt.LAYERS);
|
||||
StiltLayers layers = context.output(PlacementStages.Stilt.LAYERS);
|
||||
if (shape == StiltShape.NONE || layers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public final class StiltModule implements IrisModule {
|
||||
|
||||
/** One placement's stilt, grown column by column under (or above) the blocks of its repeated layer. */
|
||||
private static final class StiltColumns {
|
||||
private final ObjectPlacement placement;
|
||||
private final RunningPlacement placement;
|
||||
private final PreparedPlacement prepared;
|
||||
private final PlacementSettings config;
|
||||
private final StiltSettings settings;
|
||||
@@ -132,7 +132,7 @@ public final class StiltModule implements IrisModule {
|
||||
private final ErodeShape erode;
|
||||
|
||||
private StiltColumns(PlacementStageContext context, PreparedPlacement prepared, StiltLayers layers) {
|
||||
this.placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
this.placement = context.output(PlacementStages.Prepare.TRANSFORMS).placement();
|
||||
this.prepared = prepared;
|
||||
this.context = context;
|
||||
this.config = prepared.settings();
|
||||
@@ -140,7 +140,7 @@ public final class StiltModule implements IrisModule {
|
||||
this.shape = prepared.mode().stilt();
|
||||
this.world = new PlacementWorld(context.access(), prepared.traits());
|
||||
this.rng = new RNG(context.random().nextLong());
|
||||
this.anchorY = context.output(IrisStages.Anchor.FINAL).y();
|
||||
this.anchorY = context.output(PlacementStages.Anchor.FINAL).y();
|
||||
this.palette = settings == null ? null : paletteBlock(settings);
|
||||
this.layerY = shape == StiltShape.CEILING ? layers.topY() : layers.bottomY();
|
||||
this.erode = shape == StiltShape.ERODE ? ErodeShape.of(layers.bottom()) : null;
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.anchor.VacuumProfile;
|
||||
import art.arcane.iris.builtin.blocks.WrittenBlocks;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.placement.PlacementTerrain;
|
||||
import art.arcane.iris.builtin.placement.PlaneNoise;
|
||||
import art.arcane.iris.builtin.prepare.PreparedPlacement;
|
||||
import art.arcane.iris.builtin.prepare.TransformedBounds;
|
||||
import art.arcane.iris.modules.placement.EdgeSimplex;
|
||||
import art.arcane.iris.modules.placement.PlacementStages;
|
||||
import art.arcane.iris.modules.placement.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.RunningPlacement;
|
||||
import art.arcane.iris.modules.placement.StageTerrain;
|
||||
import art.arcane.iris.modules.terrain.TerrainPalettes;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import com.volmit.IrisModule;
|
||||
@@ -57,15 +57,15 @@ public final class VacuumModule implements IrisModule {
|
||||
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(IrisStages.Vacuum.TERRAIN)
|
||||
.requires(IrisStages.Blocks.WRITE, IrisStages.Blocks.COMPLETE, IrisStages.Prepare.TRANSFORMS)
|
||||
setup.stages().define(PlacementStages.Vacuum.TERRAIN)
|
||||
.requires(PlacementStages.Blocks.WRITE, PlacementStages.Blocks.COMPLETE, PlacementStages.Prepare.TRANSFORMS)
|
||||
.reach(IrisObjectVacuum.MAX_RADIUS_BLOCKS)
|
||||
.run(VacuumModule::bendTerrain);
|
||||
}
|
||||
|
||||
private static void bendTerrain(PlacementStageContext context) {
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
WrittenBlocks written = context.output(IrisStages.Blocks.WRITE);
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
WrittenBlocks written = context.output(PlacementStages.Blocks.WRITE);
|
||||
if (!prepared.mode().bendsTerrain() || written.isEmpty() || !prepared.terrain().hasWorld()) {
|
||||
return;
|
||||
}
|
||||
@@ -76,9 +76,9 @@ public final class VacuumModule implements IrisModule {
|
||||
|
||||
/** One placement's terrain bend over the columns within its radius of the object's footprint. */
|
||||
private static final class Bend {
|
||||
private final ObjectPlacement placement;
|
||||
private final RunningPlacement placement;
|
||||
private final PreparedPlacement prepared;
|
||||
private final PlacementTerrain terrain;
|
||||
private final StageTerrain terrain;
|
||||
private final PlacementWorld world;
|
||||
private final PlacementStageContext context;
|
||||
private final int radius;
|
||||
@@ -87,13 +87,13 @@ public final class VacuumModule implements IrisModule {
|
||||
private final int jitter;
|
||||
private final double waveAmplitude;
|
||||
private final double waveScale;
|
||||
private final PlaneNoise waves;
|
||||
private final EdgeSimplex waves;
|
||||
private final int lowestY;
|
||||
private final int highestY;
|
||||
|
||||
private Bend(PlacementStageContext context, PreparedPlacement prepared) {
|
||||
VacuumProfile vacuum = prepared.mode().vacuum();
|
||||
this.placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
this.placement = prepared.placement();
|
||||
this.prepared = prepared;
|
||||
this.terrain = prepared.terrain();
|
||||
this.world = new PlacementWorld(context.access(), prepared.traits());
|
||||
@@ -105,7 +105,7 @@ public final class VacuumModule implements IrisModule {
|
||||
this.jitter = settings != null ? Math.max(0, settings.organicJitter()) : DEFAULT_ORGANIC_JITTER;
|
||||
this.waveAmplitude = IrisObjectVacuum.resolveWaveAmplitude(settings);
|
||||
this.waveScale = IrisObjectVacuum.resolveWaveScale(settings);
|
||||
this.waves = vacuum.edge() == VacuumProfile.Edge.WAVY && waveAmplitude > 0 ? placement.simplex(WAVE_SEED) : null;
|
||||
this.waves = vacuum.edge() == VacuumProfile.Edge.WAVY && waveAmplitude > 0 ? new EdgeSimplex(WAVE_SEED) : null;
|
||||
this.lowestY = IrisObjectVacuum.LOWEST_TARGET_Y;
|
||||
this.highestY = terrain.worldHeight() - 1;
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.placement.CaveSpace;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.placement.ObjectShape;
|
||||
import art.arcane.iris.builtin.placement.PlacementSettings;
|
||||
import art.arcane.iris.builtin.placement.PlacementTerrain;
|
||||
import art.arcane.iris.builtin.placement.StructureVolumes;
|
||||
import art.arcane.iris.builtin.prepare.PreparedPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectRun;
|
||||
import art.arcane.iris.builtin.terrain.BedrockSettings;
|
||||
import art.arcane.iris.modules.placement.ObjectShape;
|
||||
import art.arcane.iris.modules.placement.PlacementSettings;
|
||||
import art.arcane.iris.modules.placement.PlacementStages;
|
||||
import art.arcane.iris.modules.placement.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.RunningPlacement;
|
||||
import art.arcane.iris.modules.placement.StageTerrain;
|
||||
import com.volmit.placement.StructureVolumes;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleLog;
|
||||
@@ -62,28 +62,28 @@ public final class ValidateModule implements IrisModule {
|
||||
@Override
|
||||
public void setup(ModuleSetup setup) {
|
||||
var graph = setup.stages();
|
||||
graph.define(IrisStages.Validate.SURFACE)
|
||||
.requires(IrisStages.Anchor.HEIGHT)
|
||||
graph.define(PlacementStages.Validate.SURFACE)
|
||||
.requires(PlacementStages.Anchor.HEIGHT)
|
||||
.run(ValidateModule::checkSurface);
|
||||
graph.define(IrisStages.Validate.LIMITS)
|
||||
.requires(IrisStages.Validate.SURFACE, IrisStages.Anchor.HEIGHT)
|
||||
graph.define(PlacementStages.Validate.LIMITS)
|
||||
.requires(PlacementStages.Validate.SURFACE, PlacementStages.Anchor.HEIGHT)
|
||||
.run(ValidateModule::checkLimits);
|
||||
graph.define(IrisStages.Validate.STRUCTURES)
|
||||
.requires(IrisStages.Validate.LIMITS, IrisStages.Anchor.HEIGHT)
|
||||
graph.define(PlacementStages.Validate.STRUCTURES)
|
||||
.requires(PlacementStages.Validate.LIMITS, PlacementStages.Anchor.HEIGHT)
|
||||
.run(ValidateModule::checkNativeStructures);
|
||||
graph.define(IrisStages.Validate.COLLISIONS)
|
||||
.requires(IrisStages.Validate.STRUCTURES, IrisStages.Anchor.HEIGHT)
|
||||
graph.define(PlacementStages.Validate.COLLISIONS)
|
||||
.requires(PlacementStages.Validate.STRUCTURES, PlacementStages.Anchor.HEIGHT)
|
||||
.run(ValidateModule::checkCollisions);
|
||||
}
|
||||
|
||||
private static void checkSurface(PlacementStageContext context) {
|
||||
ObjectPlacement placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
RunningPlacement placement = context.output(PlacementStages.Prepare.TRANSFORMS).placement();
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
PlacementSettings settings = prepared.settings();
|
||||
if (settings.forcePlace() || settings.fromBottom() || prepared.mode().has(PlaceTrait.FREE_HEIGHT)) {
|
||||
return;
|
||||
}
|
||||
int y = context.output(IrisStages.Anchor.HEIGHT).y();
|
||||
int y = context.output(PlacementStages.Anchor.HEIGHT).y();
|
||||
boolean sampled = placement.requestedY() < 0;
|
||||
if (sampled && settings.carvingSupport().supportsSurface() && isOnBedrock(context, prepared, y)) {
|
||||
warnImplausibleBedrockPlacement(placement, settings, y, context.log());
|
||||
@@ -106,7 +106,7 @@ public final class ValidateModule implements IrisModule {
|
||||
return world.settings().declared(BedrockSettings.class).dimension().map(BedrockSettings::bedrock).orElse(true);
|
||||
}
|
||||
|
||||
private static boolean lacksSurfaceSupport(ObjectPlacement placement, PreparedPlacement prepared) {
|
||||
private static boolean lacksSurfaceSupport(RunningPlacement placement, PreparedPlacement prepared) {
|
||||
PlacementSettings settings = prepared.settings();
|
||||
return IrisSurfaceSupport.isUnsupported(prepared.terrain(), placement.x(), placement.z(), settings.translate(),
|
||||
prepared.rotation(), prepared.spinX(), prepared.spinY(), prepared.spinZ(),
|
||||
@@ -114,16 +114,16 @@ public final class ValidateModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static void checkLimits(PlacementStageContext context) {
|
||||
ObjectPlacement placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
RunningPlacement placement = context.output(PlacementStages.Prepare.TRANSFORMS).placement();
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
PlacementSettings settings = prepared.settings();
|
||||
if (settings.forcePlace() || prepared.mode().has(PlaceTrait.RAW_STAMP)) {
|
||||
return;
|
||||
}
|
||||
int y = context.output(IrisStages.Anchor.HEIGHT).y();
|
||||
int y = context.output(PlacementStages.Anchor.HEIGHT).y();
|
||||
int rotated = prepared.rotatedCenterY();
|
||||
int translated = prepared.translatedCenterY();
|
||||
Optional<CaveSpace> cave = placement.cave();
|
||||
Optional<ObjectRun.Cave> cave = placement.cave();
|
||||
if (placement.requestedY() < 0 && !prepared.mode().has(PlaceTrait.FREE_HEIGHT) && !settings.underwater()
|
||||
&& !settings.onwater() && prepared.terrain().isUnderwater(placement.x(), placement.z())) {
|
||||
context.reject("underwater-anchor");
|
||||
@@ -138,19 +138,19 @@ public final class ValidateModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static void checkNativeStructures(PlacementStageContext context) {
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
if (prepared.mode().has(PlaceTrait.RAW_STAMP)) {
|
||||
return;
|
||||
}
|
||||
int y = context.output(IrisStages.Anchor.HEIGHT).y() + prepared.randomY();
|
||||
if (meetsNativeStructure(context, context.extension(ObjectPlacement.class).orElseThrow(), prepared, y)) {
|
||||
int y = context.output(PlacementStages.Anchor.HEIGHT).y() + prepared.randomY();
|
||||
if (meetsNativeStructure(context, context.output(PlacementStages.Prepare.TRANSFORMS).placement(), prepared, y)) {
|
||||
context.reject("native-structure");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean meetsNativeStructure(PlacementStageContext context, ObjectPlacement placement,
|
||||
private static boolean meetsNativeStructure(PlacementStageContext context, RunningPlacement placement,
|
||||
PreparedPlacement prepared, int y) {
|
||||
PlacementTerrain terrain = prepared.terrain();
|
||||
StageTerrain terrain = prepared.terrain();
|
||||
if (!terrain.hasWorld()) {
|
||||
return false;
|
||||
}
|
||||
@@ -162,9 +162,8 @@ public final class ValidateModule implements IrisModule {
|
||||
return false;
|
||||
}
|
||||
boolean painted = WorldVolume.isPainted(placement, prepared);
|
||||
int worldY = y + terrain.minWorldY();
|
||||
int envelopeMinY = painted ? Integer.MIN_VALUE : worldY - margin;
|
||||
int envelopeMaxY = painted ? Integer.MAX_VALUE : worldY + margin;
|
||||
int envelopeMinY = painted ? Integer.MIN_VALUE : y - margin;
|
||||
int envelopeMaxY = painted ? Integer.MAX_VALUE : y + margin;
|
||||
if (!volumes.intersects(x - margin, envelopeMinY, z - margin, x + margin, envelopeMaxY, z + margin)) {
|
||||
return false;
|
||||
}
|
||||
@@ -179,8 +178,7 @@ public final class ValidateModule implements IrisModule {
|
||||
? offset.y() + Math.floorDiv(placement.object().height(), 2)
|
||||
+ terrain.highest(blockX, blockZ, prepared.settings().underwater())
|
||||
: y + offset.y();
|
||||
int worldBlockY = blockY + terrain.minWorldY();
|
||||
if (volumes.containsWithin(blockX, worldBlockY, blockZ, prepared.warpMargin())) {
|
||||
if (volumes.containsWithin(blockX, blockY, blockZ, prepared.warpMargin())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -202,20 +200,20 @@ public final class ValidateModule implements IrisModule {
|
||||
}
|
||||
|
||||
private static void checkCollisions(PlacementStageContext context) {
|
||||
ObjectPlacement placement = context.extension(ObjectPlacement.class).orElseThrow();
|
||||
PreparedPlacement prepared = context.output(IrisStages.Prepare.TRANSFORMS);
|
||||
RunningPlacement placement = context.output(PlacementStages.Prepare.TRANSFORMS).placement();
|
||||
PreparedPlacement prepared = context.output(PlacementStages.Prepare.TRANSFORMS);
|
||||
PlacementSettings settings = prepared.settings();
|
||||
if (settings.forcePlace() || prepared.mode().has(PlaceTrait.RAW_STAMP)
|
||||
|| (settings.allowedCollisions().isEmpty() && settings.forbiddenCollisions().isEmpty())) {
|
||||
return;
|
||||
}
|
||||
WorldVolume volume = WorldVolume.of(placement, prepared, context.output(IrisStages.Anchor.HEIGHT).y() + prepared.randomY());
|
||||
WorldVolume volume = WorldVolume.of(placement, prepared, context.output(PlacementStages.Anchor.HEIGHT).y() + prepared.randomY());
|
||||
if (collidesWithForbiddenObject(prepared.terrain(), settings, volume)) {
|
||||
context.reject("object-collision");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean collidesWithForbiddenObject(PlacementTerrain terrain, PlacementSettings settings, WorldVolume volume) {
|
||||
private static boolean collidesWithForbiddenObject(StageTerrain terrain, PlacementSettings settings, WorldVolume volume) {
|
||||
Set<ResourceId> forbidden = settings.forbiddenCollisions();
|
||||
Set<ResourceId> allowed = settings.allowedCollisions();
|
||||
for (int x = volume.minX(); x <= volume.maxX(); x++) {
|
||||
@@ -231,7 +229,7 @@ public final class ValidateModule implements IrisModule {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void warnImplausibleBedrockPlacement(ObjectPlacement placement, PlacementSettings settings, int y, ModuleLog log) {
|
||||
private static void warnImplausibleBedrockPlacement(RunningPlacement placement, PlacementSettings settings, int y, ModuleLog log) {
|
||||
String key = placement.object().id().map(ResourceId::toString).orElse(null);
|
||||
String fingerprint = (key == null ? "<null>" : key) + "|" + settings.mode();
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.AnchorSampling;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.prepare.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.PreparedPlacement;
|
||||
import art.arcane.iris.modules.placement.RunningPlacement;
|
||||
import art.arcane.iris.builtin.prepare.TransformedBounds;
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ import art.arcane.iris.builtin.prepare.TransformedBounds;
|
||||
* object follows the surface column by column, so its volume spans every surface height under it.
|
||||
*/
|
||||
record WorldVolume(int minX, int maxX, int minY, int maxY, int minZ, int maxZ) {
|
||||
static WorldVolume of(ObjectPlacement placement, PreparedPlacement prepared, int anchorY) {
|
||||
static WorldVolume of(RunningPlacement placement, PreparedPlacement prepared, int anchorY) {
|
||||
TransformedBounds bounds = prepared.bounds();
|
||||
int minX = placement.x() + bounds.minX();
|
||||
int maxX = placement.x() + bounds.maxX();
|
||||
@@ -52,7 +52,7 @@ 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(ObjectPlacement placement, PreparedPlacement prepared) {
|
||||
static boolean isPainted(RunningPlacement placement, PreparedPlacement prepared) {
|
||||
return placement.requestedY() < 0 && prepared.mode().anchor() == AnchorSampling.SURFACE;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
+14
-15
@@ -18,9 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.engine.object.procedural.coral.ResolvedCoral;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.ResolvedCrystal;
|
||||
@@ -28,7 +26,8 @@ import art.arcane.iris.engine.object.procedural.formation.ResolvedFormation;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.ResolvedFungus;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.ResolvedRuin;
|
||||
import art.arcane.iris.engine.object.procedural.tree.ResolvedTree;
|
||||
|
||||
import art.arcane.iris.modules.objects.ProceduralPlacement;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -44,29 +43,29 @@ public final class ResolvedProceduralObjects {
|
||||
|
||||
/** The placements {@code settings} declare in {@code world}, resolved the first time the world asks. */
|
||||
public static List<ProceduralPlacement> of(PackWorld world, ProceduralObjectSettings settings) {
|
||||
ObjectHost host = world.extension(ObjectHost.class).orElseThrow();
|
||||
PackResources resources = world.resources();
|
||||
return world.state(ResolvedByDeclaration.class, ignored -> new ResolvedByDeclaration()).placements
|
||||
.computeIfAbsent(settings, declared -> resolve(declared, host));
|
||||
.computeIfAbsent(settings, declared -> resolve(declared, resources));
|
||||
}
|
||||
|
||||
/** The placements {@code settings} declare, resolved anew, for work outside any world such as working out the pack's reach. */
|
||||
public static List<ProceduralPlacement> resolve(ProceduralObjectSettings settings, ObjectHost host) {
|
||||
public static List<ProceduralPlacement> resolve(ProceduralObjectSettings settings, PackResources resources) {
|
||||
List<ProceduralPlacement> all = new ArrayList<>();
|
||||
for (Tree tree : settings.trees()) {
|
||||
all.add(new ResolvedTree(tree, host));
|
||||
all.add(new ResolvedTree(tree, resources));
|
||||
}
|
||||
addAll(all, settings.ruins(), host, ResolvedRuin::new);
|
||||
addAll(all, settings.formations(), host, ResolvedFormation::new);
|
||||
addAll(all, settings.coral(), host, ResolvedCoral::new);
|
||||
addAll(all, settings.fungi(), host, ResolvedFungus::new);
|
||||
addAll(all, settings.crystals(), host, ResolvedCrystal::new);
|
||||
addAll(all, settings.ruins(), resources, ResolvedRuin::new);
|
||||
addAll(all, settings.formations(), resources, ResolvedFormation::new);
|
||||
addAll(all, settings.coral(), resources, ResolvedCoral::new);
|
||||
addAll(all, settings.fungi(), resources, ResolvedFungus::new);
|
||||
addAll(all, settings.crystals(), resources, ResolvedCrystal::new);
|
||||
return List.copyOf(all);
|
||||
}
|
||||
|
||||
private static <S> void addAll(List<ProceduralPlacement> all, List<S> settings, ObjectHost host,
|
||||
BiFunction<S, ObjectHost, ResolvedProceduralPlacement> resolve) {
|
||||
private static <S> void addAll(List<ProceduralPlacement> all, List<S> settings, PackResources resources,
|
||||
BiFunction<S, PackResources, ResolvedProceduralPlacement> resolve) {
|
||||
for (S entry : settings) {
|
||||
all.add(resolve.apply(entry, host));
|
||||
all.add(resolve.apply(entry, resources));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -21,17 +21,17 @@ package art.arcane.iris.engine.object.procedural;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.carve.CaveAnchorMode;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.builtin.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ProceduralPlacement;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -39,7 +39,7 @@ import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A procedural object's settings made placeable: bakes a deterministic pool of variants from them, once, through the
|
||||
* host's object builder, and hands the placement options to {@code iris:objects}.
|
||||
* pack's objects ({@link ObjectBuilder}), and hands the placement options to {@code iris:objects}.
|
||||
*/
|
||||
public abstract class ResolvedProceduralPlacement implements ProceduralPlacement {
|
||||
private static final long VARIANT_SEED_STRIDE = 7919L;
|
||||
@@ -51,12 +51,12 @@ public abstract class ResolvedProceduralPlacement implements ProceduralPlacement
|
||||
}
|
||||
|
||||
private final Shape shape;
|
||||
private final ObjectHost host;
|
||||
private final PackResources resources;
|
||||
private final AtomicCache<List<PlaceableObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
protected ResolvedProceduralPlacement(Shape shape, ObjectHost host) {
|
||||
protected ResolvedProceduralPlacement(Shape shape, PackResources resources) {
|
||||
this.shape = shape;
|
||||
this.host = host;
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
/** The shape variant {@code index} is baked as, from its own seeded stream; null when it has no blocks. */
|
||||
@@ -139,7 +139,7 @@ public abstract class ResolvedProceduralPlacement implements ProceduralPlacement
|
||||
|
||||
@Override
|
||||
public List<PlaceableObject> variants() {
|
||||
return variantCache.aquire(() -> bake(host.builder()));
|
||||
return variantCache.aquire(() -> bake(new ObjectBuilder(resources)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
/** A coral reef made placeable: its variants are baked by {@link CoralGenerator}. */
|
||||
public final class ResolvedCoral extends ResolvedProceduralPlacement {
|
||||
private final Coral settings;
|
||||
|
||||
public ResolvedCoral(Coral settings, ObjectHost host) {
|
||||
public ResolvedCoral(Coral settings, PackResources resources) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), host);
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), resources);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
/** A crystal cluster made placeable: its variants are baked by {@link CrystalGenerator}. */
|
||||
public final class ResolvedCrystal extends ResolvedProceduralPlacement {
|
||||
private final Crystal settings;
|
||||
|
||||
public ResolvedCrystal(Crystal settings, ObjectHost host) {
|
||||
public ResolvedCrystal(Crystal settings, PackResources resources) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), host);
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), resources);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ package art.arcane.iris.engine.object.procedural.formation;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import java.util.Optional;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import com.volmit.block.BlockState;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
+4
-4
@@ -19,20 +19,20 @@
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
/** A rock formation made placeable: its variants are baked by {@link FormationGenerator}. */
|
||||
public final class ResolvedFormation extends ResolvedProceduralPlacement {
|
||||
private final Formation settings;
|
||||
|
||||
public ResolvedFormation(Formation settings, ObjectHost host) {
|
||||
public ResolvedFormation(Formation settings, PackResources resources) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), host);
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), resources);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -33,10 +33,10 @@ import java.util.List;
|
||||
public final class ResolvedFungus extends ResolvedProceduralPlacement {
|
||||
private final Fungus settings;
|
||||
|
||||
public ResolvedFungus(Fungus settings, ObjectHost host) {
|
||||
public ResolvedFungus(Fungus settings, PackResources resources) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), host);
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), resources);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
/** A ruin made placeable: its variants are baked by {@link RuinGenerator}. */
|
||||
public final class ResolvedRuin extends ResolvedProceduralPlacement {
|
||||
private final Ruin settings;
|
||||
|
||||
public ResolvedRuin(Ruin settings, ObjectHost host) {
|
||||
public ResolvedRuin(Ruin settings, PackResources resources) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), host);
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), resources);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ruin.RuinDecorator;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import com.volmit.block.BlockState;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
|
||||
@@ -20,7 +20,7 @@ package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ruin.RuinDecorator;
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.engine.object.procedural.ProceduralShape;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -37,10 +37,10 @@ public final class ResolvedTree extends ResolvedProceduralPlacement {
|
||||
|
||||
private final Tree settings;
|
||||
|
||||
public ResolvedTree(Tree settings, ObjectHost host) {
|
||||
public ResolvedTree(Tree settings, PackResources resources) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), host);
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)), resources);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
|
||||
@@ -20,7 +20,7 @@ package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.builtin.objects.tree.Tree;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.modules.objects.ObjectBuilder;
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
@@ -26,7 +26,6 @@ import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.modules.floating.FloatingChildSettings;
|
||||
import art.arcane.iris.builtin.floating.FloatingHost;
|
||||
import art.arcane.iris.modules.floating.MergeFloatingChildrenSettings;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
@@ -50,7 +49,6 @@ public final class FloatingWorld {
|
||||
private static final long BASE_SEED_SALT = 0x5EED_F107_00F1B10CL;
|
||||
|
||||
private final FloatingHost host;
|
||||
private final ObjectHost objects;
|
||||
private final PackResources resources;
|
||||
private final RunningWorld running;
|
||||
private final long baseSeed;
|
||||
@@ -59,10 +57,9 @@ public final class FloatingWorld {
|
||||
private final List<CarvingEntry> dimensionCarving;
|
||||
private final Map<FloatingChildBiome, ResolvedFloatingChild> resolved = new ConcurrentHashMap<>();
|
||||
|
||||
FloatingWorld(FloatingHost host, ObjectHost objects, PackResources resources, RunningWorld running, long terrainSeed,
|
||||
FloatingWorld(FloatingHost host, PackResources resources, RunningWorld running, long terrainSeed,
|
||||
long carveSeed, int minWorldY, List<CarvingEntry> dimensionCarving) {
|
||||
this.host = host;
|
||||
this.objects = objects;
|
||||
this.resources = resources;
|
||||
this.running = running;
|
||||
this.baseSeed = terrainSeed ^ BASE_SEED_SALT;
|
||||
@@ -77,8 +74,7 @@ public final class FloatingWorld {
|
||||
}
|
||||
|
||||
private static FloatingWorld create(PackWorld world) {
|
||||
return new FloatingWorld(world.extension(FloatingHost.class).orElseThrow(), world.extension(ObjectHost.class).orElseThrow(),
|
||||
world.resources(), world.running().orElseThrow(), world.seed(IrisSeedPurposes.TERRAIN), world.seed(IrisSeedPurposes.CARVE),
|
||||
return new FloatingWorld(world.extension(FloatingHost.class).orElseThrow(), world.resources(), world.running().orElseThrow(), world.seed(IrisSeedPurposes.TERRAIN), world.seed(IrisSeedPurposes.CARVE),
|
||||
world.minWorldY(), dimensionCarvingOf(world));
|
||||
}
|
||||
|
||||
@@ -92,10 +88,6 @@ public final class FloatingWorld {
|
||||
return host;
|
||||
}
|
||||
|
||||
public ObjectHost objects() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
public NoiseFactory noise() {
|
||||
return resources.noise();
|
||||
}
|
||||
|
||||
+17
-8
@@ -16,15 +16,24 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.placement;
|
||||
package art.arcane.iris.modules.blocks;
|
||||
|
||||
/** The world-space bounds of the native structure pieces around a placement, in the world's real Y. */
|
||||
public interface StructureVolumes {
|
||||
boolean isEmpty();
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.Desc;
|
||||
import com.volmit.config.Feature;
|
||||
import com.volmit.config.Level;
|
||||
|
||||
/** Whether any piece meets the box, bounds inclusive. */
|
||||
boolean intersects(int minX, int minY, int minZ, int maxX, int maxY, int maxZ);
|
||||
/** Whether a dimension shows the air smart boring writes as cobwebs, written as {@code "debugSmartBore": true}. */
|
||||
@Desc("Write the air that smart boring places as cobwebs, to see where it bored.")
|
||||
@Feature(id = "iris:blocks/debug-smart-bore", name = "Debug smart bore", key = "debugSmartBore", root = "show", targets = Level.DIMENSION)
|
||||
public final class SmartBoreDebugSettings implements IrisFeature {
|
||||
@Desc("Write the air that smart boring places as cobwebs, to see where it bored.")
|
||||
private boolean show = false;
|
||||
|
||||
/** Whether any piece contains the block or comes within {@code margin} blocks of it. */
|
||||
boolean containsWithin(int x, int y, int z, int margin);
|
||||
public SmartBoreDebugSettings() {
|
||||
}
|
||||
|
||||
public boolean show() {
|
||||
return show;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.floating;
|
||||
package art.arcane.iris.modules.floating;
|
||||
|
||||
/**
|
||||
* The face of one island an object is placed against, as {@code iris:floating} samples it: how high the face is, which
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.floating;
|
||||
package art.arcane.iris.modules.floating;
|
||||
|
||||
/**
|
||||
* Where an object stands, in its own block positions: the columns holding a solid block ({@link #column} packs each), the
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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.modules.objects;
|
||||
|
||||
import art.arcane.iris.builtin.MatterMantle;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import art.arcane.volmlib.util.matter.MatterSlice;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The voids the cave carver planned in the mantle around the chunk being placed, which cave objects anchor in. Heights
|
||||
* are above the dimension's bottom; outside the mantle the invocation reaches nothing is carved.
|
||||
*/
|
||||
public final class CarvedSpace {
|
||||
private static final int CHUNK_SHIFT = 4;
|
||||
private static final int SECTION_SHIFT = 4;
|
||||
private static final int SECTION_HEIGHT = 16;
|
||||
private static final int LOCAL_MASK = 15;
|
||||
private static final byte CARVED = 1;
|
||||
|
||||
private final MatterMantle mantle;
|
||||
private final int worldHeight;
|
||||
|
||||
public CarvedSpace(MatterMantle mantle, int worldHeight) {
|
||||
this.mantle = mantle;
|
||||
this.worldHeight = worldHeight;
|
||||
}
|
||||
|
||||
/** Whether the position is carved. */
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
return cavernData(x, y, z) != null;
|
||||
}
|
||||
|
||||
/** Whether each height from 0 up to {@code height} is carved at the column, 1 for carved and 0 for not. */
|
||||
public byte[] column(int x, int z, int height) {
|
||||
int cappedHeight = Math.min(Math.max(height, 0), worldHeight);
|
||||
byte[] carvedColumn = new byte[cappedHeight];
|
||||
if (cappedHeight <= 0) {
|
||||
return carvedColumn;
|
||||
}
|
||||
MantleChunk<Matter> chunk = mantle.chunk(x >> CHUNK_SHIFT, z >> CHUNK_SHIFT);
|
||||
if (chunk == null) {
|
||||
return carvedColumn;
|
||||
}
|
||||
int localX = x & LOCAL_MASK;
|
||||
int localZ = z & LOCAL_MASK;
|
||||
int lastSection = (cappedHeight - 1) >> SECTION_SHIFT;
|
||||
for (int section = 0; section <= lastSection; section++) {
|
||||
MatterSlice<MatterCavern> slice = cavernSlice(chunk, section);
|
||||
if (slice == null) {
|
||||
continue;
|
||||
}
|
||||
int sectionBaseY = section << SECTION_SHIFT;
|
||||
int sectionMaxY = Math.min(cappedHeight, sectionBaseY + SECTION_HEIGHT);
|
||||
for (int y = sectionBaseY; y < sectionMaxY; y++) {
|
||||
if (slice.get(localX, y & LOCAL_MASK, localZ) != null) {
|
||||
carvedColumn[y] = CARVED;
|
||||
}
|
||||
}
|
||||
}
|
||||
return carvedColumn;
|
||||
}
|
||||
|
||||
/** The void at the position; empty where nothing was carved. */
|
||||
public Optional<Cavern> cavernAt(int x, int y, int z) {
|
||||
MatterCavern cavern = cavernData(x, y, z);
|
||||
if (cavern == null || !cavern.isCavern()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(new Cavern(cavern.isAir(), cavern.getLiquid()));
|
||||
}
|
||||
|
||||
private MatterCavern cavernData(int x, int y, int z) {
|
||||
if (y < 0 || y >= worldHeight) {
|
||||
return null;
|
||||
}
|
||||
MantleChunk<Matter> chunk = mantle.chunk(x >> CHUNK_SHIFT, z >> CHUNK_SHIFT);
|
||||
if (chunk == null) {
|
||||
return null;
|
||||
}
|
||||
MatterSlice<MatterCavern> slice = cavernSlice(chunk, y >> SECTION_SHIFT);
|
||||
return slice == null ? null : slice.get(x & LOCAL_MASK, y & LOCAL_MASK, z & LOCAL_MASK);
|
||||
}
|
||||
|
||||
private static MatterSlice<MatterCavern> cavernSlice(MantleChunk<Matter> chunk, int section) {
|
||||
if (!chunk.exists(section)) {
|
||||
return null;
|
||||
}
|
||||
Matter matter = chunk.get(section);
|
||||
if (matter == null || !matter.hasSlice(MatterCavern.class)) {
|
||||
return null;
|
||||
}
|
||||
return matter.getSlice(MatterCavern.class);
|
||||
}
|
||||
}
|
||||
+5
-13
@@ -16,25 +16,17 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.objects;
|
||||
package art.arcane.iris.modules.objects;
|
||||
|
||||
/**
|
||||
* The outcome of placing an object in a cave.
|
||||
*
|
||||
* @param resultY the height the object was placed at, negative when the placement rejected it
|
||||
* @param commit what became of the blocks the object wrote
|
||||
* @param commit what became of the blocks the object wrote; {@link TerrainTransaction.Commit#EMPTY} for a rejected
|
||||
* placement, {@link TerrainTransaction.Commit#REJECTED} when some block lay outside the cave
|
||||
*/
|
||||
public record CavePlacement(int resultY, Commit commit) {
|
||||
public enum Commit {
|
||||
/** The blocks were written. */
|
||||
COMMITTED,
|
||||
/** The object wrote no blocks, or the placement was rejected. */
|
||||
EMPTY,
|
||||
/** Some block lay outside the cave, so nothing was written. */
|
||||
REJECTED_BOUNDS
|
||||
}
|
||||
|
||||
public record CavePlacement(int resultY, TerrainTransaction.Commit commit) {
|
||||
public boolean wroteBlocks() {
|
||||
return commit == Commit.COMMITTED;
|
||||
return commit == TerrainTransaction.Commit.COMMITTED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.modules.objects;
|
||||
|
||||
import art.arcane.volmlib.util.cache.CacheKey;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Holds back what a cave object writes until all of it is known to lie inside the cave: in the world, no shallower than
|
||||
* the burial depth under the surface and under the cave's ceiling at its column.
|
||||
*/
|
||||
public final class CaveTransaction extends TerrainTransaction {
|
||||
private final int worldHeight;
|
||||
private final int anchorY;
|
||||
private final int minDepthBelowSurface;
|
||||
private final Map<Long, Integer> surfaceHeights = new HashMap<>();
|
||||
private final Map<Long, Integer> caveCeilings = new HashMap<>();
|
||||
|
||||
/** @param worldHeight the dimension's height in blocks */
|
||||
public CaveTransaction(PlacementTerrain delegate, int worldHeight, int anchorY, int minDepthBelowSurface) {
|
||||
super(delegate);
|
||||
this.worldHeight = worldHeight;
|
||||
this.anchorY = anchorY;
|
||||
this.minDepthBelowSurface = Math.max(0, minDepthBelowSurface);
|
||||
}
|
||||
|
||||
/** The first height above the anchor that the cave does not reach at the column. */
|
||||
public int caveCeiling(int x, int z) {
|
||||
return caveCeilings.computeIfAbsent(CacheKey.key(x, z), ignored -> findCaveCeiling(x, z));
|
||||
}
|
||||
|
||||
/** The highest height an object buried {@code minDepthBelowSurface} under {@code surfaceY} may reach. */
|
||||
public static int maxBuriedY(int worldHeight, int surfaceY, int minDepthBelowSurface) {
|
||||
return Math.min(worldHeight - 1, surfaceY - Math.max(0, minDepthBelowSurface));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean accepts(int x, int y, int z) {
|
||||
if (y < 0 || y >= worldHeight) {
|
||||
return false;
|
||||
}
|
||||
if (y > maxBuriedY(worldHeight, surfaceHeight(x, z), minDepthBelowSurface)) {
|
||||
return false;
|
||||
}
|
||||
return y < caveCeiling(x, z);
|
||||
}
|
||||
|
||||
private int surfaceHeight(int x, int z) {
|
||||
return surfaceHeights.computeIfAbsent(CacheKey.key(x, z), ignored -> delegate().highest(x, z, true));
|
||||
}
|
||||
|
||||
private int findCaveCeiling(int x, int z) {
|
||||
if (worldHeight <= 0 || anchorY < 0 || anchorY >= worldHeight) {
|
||||
return 0;
|
||||
}
|
||||
if (!delegate().isCarved(x, anchorY, z)) {
|
||||
return Math.min(worldHeight, anchorY + 1);
|
||||
}
|
||||
int scanLimit = Math.min(worldHeight - 1, Math.max(anchorY, surfaceHeight(x, z)));
|
||||
for (int y = anchorY + 1; y <= scanLimit; y++) {
|
||||
if (!delegate().isCarved(x, y, z)) {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
return Math.min(worldHeight, scanLimit + 1);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.objects;
|
||||
package art.arcane.iris.modules.objects;
|
||||
|
||||
/**
|
||||
* A carved void of the mantle, as the cave carver left it.
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.modules.objects;
|
||||
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* One region's or biome's declaration of settings, named by the id a {@link com.volmit.world.BiomeSample} gives the
|
||||
* region or biome ({@code overworld:desert/dunes}) rather than the source id of its settings entry
|
||||
* ({@code overworld:biome/desert/dunes}).
|
||||
*/
|
||||
public record Declaration<F extends IrisFeature>(Level level, ResourceId id, F settings) {
|
||||
private static final char KIND_SEPARATOR = '/';
|
||||
|
||||
/** Every region and every reachable biome of {@code world}'s dimension that declares the settings, regions first. */
|
||||
public static <F extends IrisFeature> List<Declaration<F>> allOf(PackWorld world, Class<F> type) {
|
||||
List<Declaration<F>> found = new ArrayList<>();
|
||||
for (Entry<F> entry : world.settings().declared(type)) {
|
||||
if (entry.level() == Level.REGION || entry.level() == Level.BIOME) {
|
||||
found.add(new Declaration<>(entry.level(), sampleId(entry.source()), entry.value()));
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
private static ResourceId sampleId(ResourceId source) {
|
||||
String path = source.path();
|
||||
return new ResourceId(source.namespace(), path.substring(path.indexOf(KIND_SEPARATOR) + 1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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.modules.objects;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.PlacementSource;
|
||||
import art.arcane.iris.builtin.prepare.AxisRotationClamp;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* The object placement settings a placement is made with: an object placement's own, or the options a procedural object
|
||||
* is scattered with, with the changes {@code iris:objects} makes for where it places them. One per world, so each
|
||||
* procedural object's options are made once.
|
||||
*/
|
||||
public final class EffectiveSettings {
|
||||
private static final double UPSIDE_DOWN_TURN_DEGREES = 180D;
|
||||
private static final double QUARTER_TURN_DEGREES = 90D;
|
||||
|
||||
private final Map<ProceduralPlacement, ObjectPlacement> proceduralOptions = new ConcurrentHashMap<>();
|
||||
|
||||
/** The settings {@code placement} places with, with {@code changes} made to a copy of them. */
|
||||
public ObjectPlacement of(PlacementSource placement, PlacementChanges changes) {
|
||||
ObjectPlacement base = placement instanceof ObjectPlacement settings
|
||||
? settings
|
||||
: proceduralOptions.computeIfAbsent((ProceduralPlacement) placement, EffectiveSettings::optionsOf);
|
||||
return withChanges(base, changes);
|
||||
}
|
||||
|
||||
/** {@code base} with {@code changes} made to a copy of it; {@code base} itself when there are none. */
|
||||
public static ObjectPlacement withChanges(ObjectPlacement base, PlacementChanges changes) {
|
||||
if (changes.isNone()) {
|
||||
return base;
|
||||
}
|
||||
ObjectPlacement.Builder changed = base.toBuilder();
|
||||
if (changes.place() != null) {
|
||||
changed.place(changes.place());
|
||||
}
|
||||
if (changes.mode() != null) {
|
||||
changed.mode(changes.mode());
|
||||
}
|
||||
if (changes.upsideDown() != null && changes.upsideDown()) {
|
||||
changed.rotation(upsideDownRotation());
|
||||
}
|
||||
if (changes.carvingSupport() != null) {
|
||||
changed.carvingSupport(changes.carvingSupport());
|
||||
}
|
||||
if (changes.requireSurfaceSupport() != null) {
|
||||
changed.requireSurfaceSupport(changes.requireSurfaceSupport());
|
||||
}
|
||||
if (changes.surfaceSupportBuffer() != null) {
|
||||
changed.surfaceSupportBuffer(changes.surfaceSupportBuffer());
|
||||
}
|
||||
if (changes.forcePlace() != null) {
|
||||
changed.forcePlace(changes.forcePlace());
|
||||
}
|
||||
return changed.build();
|
||||
}
|
||||
|
||||
/** The options a procedural object is scattered with, as an object placement. */
|
||||
private static ObjectPlacement optionsOf(ProceduralPlacement procedural) {
|
||||
return ObjectPlacement.builder()
|
||||
.mode(procedural.mode())
|
||||
.rotation(procedural.rotation())
|
||||
.clamp(procedural.clamp())
|
||||
.carvingSupport(procedural.carvingSupport())
|
||||
.underwater(procedural.underwater())
|
||||
.translate(procedural.translate())
|
||||
.stiltSettings(procedural.stiltSettings().orElse(null))
|
||||
.vacuumSettings(procedural.vacuumSettings().orElse(null))
|
||||
.chance(procedural.chance())
|
||||
.density(procedural.density())
|
||||
.surfaceSupportBuffer(procedural.surfaceSupportBuffer())
|
||||
.build();
|
||||
}
|
||||
|
||||
private static ObjectRotation upsideDownRotation() {
|
||||
return ObjectRotation.of(true,
|
||||
AxisRotationClamp.of(true, true, UPSIDE_DOWN_TURN_DEGREES, UPSIDE_DOWN_TURN_DEGREES, QUARTER_TURN_DEGREES),
|
||||
AxisRotationClamp.of(true, false, 0D, 0D, QUARTER_TURN_DEGREES),
|
||||
new AxisRotationClamp());
|
||||
}
|
||||
}
|
||||
@@ -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.modules.objects;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
import com.volmit.placement.PlacedMarker;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
import com.volmit.placement.StructureVolumes;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/** A terrain that answers everything as another does; subclasses change what they need. */
|
||||
public abstract class ForwardingTerrain implements PlacementTerrain {
|
||||
private final PlacementTerrain delegate;
|
||||
|
||||
protected ForwardingTerrain(PlacementTerrain delegate) {
|
||||
this.delegate = Objects.requireNonNull(delegate, "delegate");
|
||||
}
|
||||
|
||||
protected final PlacementTerrain delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int highest(int x, int z, boolean ignoreFluid) {
|
||||
return delegate.highest(x, z, ignoreFluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState get(int x, int y, int z) {
|
||||
return delegate.get(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockState state) {
|
||||
delegate.set(x, y, z, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockState state, BlockEntityData blockEntity) {
|
||||
delegate.set(x, y, z, state, blockEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
return delegate.isCarved(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSurfaceSolid(int x, int y, int z) {
|
||||
return delegate.isSurfaceSolid(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderwater(int x, int z) {
|
||||
return delegate.isUnderwater(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fluidHeight() {
|
||||
return delegate.fluidHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preventsDecay() {
|
||||
return delegate.preventsDecay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordPlacement(int x, int y, int z, String placement) {
|
||||
delegate.recordPlacement(x, y, z, placement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> placementAt(int x, int y, int z) {
|
||||
return delegate.placementAt(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureVolumes structureVolumes(int minX, int minZ, int maxX, int maxZ) {
|
||||
return delegate.structureVolumes(minX, minZ, maxX, maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mark(PlacedMarker marker) {
|
||||
delegate.mark(marker);
|
||||
}
|
||||
}
|
||||
+29
-9
@@ -15,29 +15,49 @@
|
||||
* 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;
|
||||
|
||||
package art.arcane.iris.modules.objects;
|
||||
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import com.volmit.object.ObjectBlock;
|
||||
import com.volmit.object.PackObjects;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Builds objects block by block for a module, with blocks as the platform has them: a state the builder handed out
|
||||
* keeps what the platform knows about it when a property is set or the object is built, so a content plugin's block
|
||||
* stays itself. One builder serves one bake on one thread.
|
||||
* Builds objects block by block for the procedural objects, with blocks as the platform has them: the registry keeps a
|
||||
* content plugin's block itself when a property is set on it or the object is built ({@link BlockRegistry}).
|
||||
*/
|
||||
public interface ObjectBuilder {
|
||||
public final class ObjectBuilder {
|
||||
private final BlockRegistry blocks;
|
||||
private final PackObjects objects;
|
||||
|
||||
public ObjectBuilder(PackResources resources) {
|
||||
this.blocks = resources.blocks();
|
||||
this.objects = resources.objects();
|
||||
}
|
||||
|
||||
/** The platform's state for {@code key}; null when the platform has no such block. */
|
||||
BlockState block(String key);
|
||||
public BlockState block(String key) {
|
||||
return blocks.find(key).orElse(null);
|
||||
}
|
||||
|
||||
/** The block {@code palette} gives at the position when its noise is seeded with {@code seed}. */
|
||||
BlockState pick(PaletteSpec palette, long seed, int x, int y, int z);
|
||||
public BlockState pick(PaletteSpec palette, long seed, int x, int y, int z) {
|
||||
return blocks.palette(palette, seed).at(x, y, z);
|
||||
}
|
||||
|
||||
/** {@code state} with the property set, as the platform sets it. */
|
||||
BlockState withProperty(BlockState state, String name, String value);
|
||||
public BlockState withProperty(BlockState state, String name, String value) {
|
||||
return blocks.withProperty(state, name, value);
|
||||
}
|
||||
|
||||
/** The object of {@code blocks}, put in their order, {@code width} by {@code height} by {@code depth}, placeable like the pack's objects. */
|
||||
PlaceableObject build(String loadKey, int width, int height, int depth, List<ObjectBlock> blocks);
|
||||
public PlaceableObject build(String name, int width, int height, int depth, List<ObjectBlock> blocks) {
|
||||
return objects.build(name, width, height, depth, blocks);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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.modules.objects;
|
||||
|
||||
import art.arcane.iris.builtin.LegacyStreams;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectScale;
|
||||
import art.arcane.iris.builtin.objects.ScaleInterpolation;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.object.PackObjects;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.object.ScaleMethod;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The pack's objects as object placements pick them: by key, scaled the way a placement scales them, and as many at a
|
||||
* column as its density says, drawn from Iris's own streams so existing worlds keep their objects.
|
||||
*/
|
||||
public final class ObjectPool {
|
||||
private static final double NO_SCALE = 1D;
|
||||
private static final int MAX_SCALE_VARIANTS = 32;
|
||||
|
||||
private final PackResources resources;
|
||||
private final LegacyStreams streams;
|
||||
|
||||
private ObjectPool(PackResources resources, LegacyStreams streams) {
|
||||
this.resources = resources;
|
||||
this.streams = streams;
|
||||
}
|
||||
|
||||
/** The objects of {@code world}'s pack. */
|
||||
public static ObjectPool of(PackWorld world) {
|
||||
return new ObjectPool(world.resources(), world.extension(LegacyStreams.class).orElseThrow());
|
||||
}
|
||||
|
||||
/** The random a chunk's objects are placed with. */
|
||||
public RNG chunkRandom(int chunkX, int chunkZ) {
|
||||
return streams.objectChunkRandom(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
/** The pack object {@code key} names. */
|
||||
public Optional<PlaceableObject> object(String key) {
|
||||
return objects().object(resources.idOf(key));
|
||||
}
|
||||
|
||||
/** An object of the placement, picked with {@code rng} and scaled the way the placement scales it; empty when it has none. */
|
||||
public Optional<PlaceableObject> pickScaled(ObjectPlacement placement, RNG rng) {
|
||||
List<String> keys = placement.place();
|
||||
if (keys.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return object(keys.get(rng.nextInt(keys.size()))).map(origin -> scaled(origin, placement.scale(), rng));
|
||||
}
|
||||
|
||||
/** {@code origin} shrunk or grown by exactly {@code factor}, without filling between its blocks. */
|
||||
public PlaceableObject resized(PlaceableObject origin, double factor) {
|
||||
return factor == NO_SCALE ? origin : objects().scaled(origin, factor, ScaleMethod.NONE);
|
||||
}
|
||||
|
||||
/** How many objects the placement places at the column, when its chance check passes. */
|
||||
public int density(ObjectPlacement placement, RNG rng, double x, double z) {
|
||||
return streams.density(placement, rng, x, z);
|
||||
}
|
||||
|
||||
/** Builds the noise the placement draws its density from, so the first chunk to place it does not wait. */
|
||||
public void warm(ObjectPlacement placement, RNG rng) {
|
||||
streams.density(placement, rng, 0, 0);
|
||||
}
|
||||
|
||||
private PlaceableObject scaled(PlaceableObject origin, ObjectScale scale, RNG rng) {
|
||||
if (!shouldScale(scale)) {
|
||||
return origin;
|
||||
}
|
||||
int variants = variantCount(scale);
|
||||
int variant = variants == 1 ? 0 : rng.nextInt(variants);
|
||||
return objects().scaled(origin, scaleAt(scale, variant, variants), methodOf(scale.interpolation()));
|
||||
}
|
||||
|
||||
private PackObjects objects() {
|
||||
return resources.objects();
|
||||
}
|
||||
|
||||
private static boolean shouldScale(ObjectScale scale) {
|
||||
if (scale.size() != NO_SCALE) {
|
||||
return true;
|
||||
}
|
||||
return scale.variations() > 0 && (scale.minimumScale() != NO_SCALE || scale.maximumScale() != NO_SCALE);
|
||||
}
|
||||
|
||||
/** How many evenly spread factors the scale picks from. */
|
||||
private static int variantCount(ObjectScale scale) {
|
||||
if (scale.size() != NO_SCALE || scale.minimumScale() == scale.maximumScale()) {
|
||||
return 1;
|
||||
}
|
||||
return Math.max(1, Math.min(scale.variations(), MAX_SCALE_VARIANTS));
|
||||
}
|
||||
|
||||
private static double scaleAt(ObjectScale scale, int variant, int variants) {
|
||||
if (scale.size() != NO_SCALE) {
|
||||
return scale.size();
|
||||
}
|
||||
if (scale.minimumScale() == scale.maximumScale()) {
|
||||
return scale.minimumScale();
|
||||
}
|
||||
return scale.minimumScale() + (((scale.maximumScale() - scale.minimumScale()) / variants) * variant);
|
||||
}
|
||||
|
||||
private static ScaleMethod methodOf(ScaleInterpolation interpolation) {
|
||||
return switch (interpolation) {
|
||||
case NONE -> ScaleMethod.NONE;
|
||||
case TRILINEAR -> ScaleMethod.TRILINEAR;
|
||||
case TRICUBIC -> ScaleMethod.TRICUBIC;
|
||||
case TRIHERMITE -> ScaleMethod.TRIHERMITE;
|
||||
};
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.objects;
|
||||
package art.arcane.iris.modules.objects;
|
||||
|
||||
/** The size of an object, in blocks. */
|
||||
public record ObjectSize(int width, int height, int depth) {
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.objects;
|
||||
package art.arcane.iris.modules.objects;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.objects;
|
||||
package art.arcane.iris.modules.objects;
|
||||
|
||||
/**
|
||||
* What a placement writes into the mantle besides the blocks, beside each block of the object.
|
||||
+3
-1
@@ -16,9 +16,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.objects;
|
||||
package art.arcane.iris.modules.objects;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.objects.PlacementSource;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.carve.CaveAnchorMode;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* 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.modules.objects;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
import com.volmit.placement.PlacedMarker;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Holds back what an object writes until all of it is known to be acceptable, then writes everything in the order it was
|
||||
* written, or nothing. Reads see the held writes. Subclasses say which blocks are acceptable.
|
||||
*/
|
||||
public abstract class TerrainTransaction extends ForwardingTerrain {
|
||||
private final List<Write> writes = new ArrayList<>();
|
||||
private final Map<BlockPosition, BlockState> heldBlocks = new HashMap<>();
|
||||
private int blockWrites;
|
||||
|
||||
public enum Commit {
|
||||
/** Everything was written. */
|
||||
COMMITTED,
|
||||
/** No block was written, so nothing was. */
|
||||
EMPTY,
|
||||
/** Some write was not acceptable, so nothing was written. */
|
||||
REJECTED
|
||||
}
|
||||
|
||||
protected TerrainTransaction(PlacementTerrain delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
/** Whether the transaction may write the block. */
|
||||
protected abstract boolean accepts(int x, int y, int z);
|
||||
|
||||
public final Commit commit() {
|
||||
if (blockWrites == 0) {
|
||||
discard();
|
||||
return Commit.EMPTY;
|
||||
}
|
||||
for (Write write : writes) {
|
||||
BlockPosition position = write.position();
|
||||
if (!accepts(position.x(), position.y(), position.z())) {
|
||||
discard();
|
||||
return Commit.REJECTED;
|
||||
}
|
||||
}
|
||||
for (Write write : writes) {
|
||||
write.applyTo(delegate());
|
||||
}
|
||||
discard();
|
||||
return Commit.COMMITTED;
|
||||
}
|
||||
|
||||
public final void discard() {
|
||||
writes.clear();
|
||||
heldBlocks.clear();
|
||||
blockWrites = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState get(int x, int y, int z) {
|
||||
BlockState held = heldBlocks.get(new BlockPosition(x, y, z));
|
||||
return held == null ? delegate().get(x, y, z) : held;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockState state) {
|
||||
holdBlock(new BlockWrite(new BlockPosition(x, y, z), state, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockState state, BlockEntityData blockEntity) {
|
||||
holdBlock(new BlockWrite(new BlockPosition(x, y, z), state, blockEntity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordPlacement(int x, int y, int z, String placement) {
|
||||
writes.add(new PlacementRecord(new BlockPosition(x, y, z), placement));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> placementAt(int x, int y, int z) {
|
||||
BlockPosition position = new BlockPosition(x, y, z);
|
||||
for (int index = writes.size() - 1; index >= 0; index--) {
|
||||
if (writes.get(index) instanceof PlacementRecord record && record.position().equals(position)) {
|
||||
return Optional.of(record.placement());
|
||||
}
|
||||
}
|
||||
return delegate().placementAt(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mark(PlacedMarker marker) {
|
||||
writes.add(new MarkerWrite(marker));
|
||||
}
|
||||
|
||||
private void holdBlock(BlockWrite write) {
|
||||
writes.add(write);
|
||||
heldBlocks.put(write.position(), write.state());
|
||||
blockWrites++;
|
||||
}
|
||||
|
||||
private sealed interface Write permits BlockWrite, PlacementRecord, MarkerWrite {
|
||||
BlockPosition position();
|
||||
|
||||
void applyTo(PlacementTerrain terrain);
|
||||
}
|
||||
|
||||
private record BlockWrite(BlockPosition position, BlockState state, BlockEntityData blockEntity) implements Write {
|
||||
@Override
|
||||
public void applyTo(PlacementTerrain terrain) {
|
||||
if (blockEntity == null) {
|
||||
terrain.set(position.x(), position.y(), position.z(), state);
|
||||
} else {
|
||||
terrain.set(position.x(), position.y(), position.z(), state, blockEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record PlacementRecord(BlockPosition position, String placement) implements Write {
|
||||
@Override
|
||||
public void applyTo(PlacementTerrain terrain) {
|
||||
terrain.recordPlacement(position.x(), position.y(), position.z(), placement);
|
||||
}
|
||||
}
|
||||
|
||||
private record MarkerWrite(PlacedMarker marker) implements Write {
|
||||
@Override
|
||||
public BlockPosition position() {
|
||||
return marker.position();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(PlacementTerrain terrain) {
|
||||
terrain.mark(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-8
@@ -16,8 +16,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.placement;
|
||||
package art.arcane.iris.modules.placement;
|
||||
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
|
||||
@@ -25,30 +26,30 @@ import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The traits of the block states one placement handles, asked of the placement once per state instance. A placement
|
||||
* The traits of the block states one placement handles, asked of the block registry once per state instance. A placement
|
||||
* reads the same few states over and over and the platform looks every state up by its value, so the answers are kept by
|
||||
* identity. For one placement on one thread.
|
||||
*/
|
||||
public final class BlockTraits {
|
||||
private final ObjectPlacement placement;
|
||||
private final BlockRegistry blocks;
|
||||
private final Map<BlockState, TraitAnswers> answers = new IdentityHashMap<>();
|
||||
|
||||
public BlockTraits(ObjectPlacement placement) {
|
||||
this.placement = placement;
|
||||
public BlockTraits(BlockRegistry blocks) {
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
public boolean has(BlockState state, BlockTrait trait) {
|
||||
return answers.computeIfAbsent(state, ignored -> new TraitAnswers()).has(placement, state, trait);
|
||||
return answers.computeIfAbsent(state, ignored -> new TraitAnswers()).has(blocks, state, trait);
|
||||
}
|
||||
|
||||
private static final class TraitAnswers {
|
||||
private int asked;
|
||||
private int held;
|
||||
|
||||
boolean has(ObjectPlacement placement, BlockState state, BlockTrait trait) {
|
||||
boolean has(BlockRegistry blocks, BlockState state, BlockTrait trait) {
|
||||
int flag = 1 << trait.ordinal();
|
||||
if ((asked & flag) == 0) {
|
||||
if (placement.hasTrait(state, trait)) {
|
||||
if (blocks.hasTrait(state, trait)) {
|
||||
held |= flag;
|
||||
}
|
||||
asked |= flag;
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.modules.placement;
|
||||
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/**
|
||||
* Single-octave simplex noise over a plane that swings between -1 and 1, the rolling wave of a terrain bend's edge. It
|
||||
* is a copy of the two-dimensional simplex of Iris's {@code SimplexNoise} and draws exactly what that draws for the same
|
||||
* seed, so worlds bent before keep their edges; Iris pins the two against each other in a test.
|
||||
*/
|
||||
public final class EdgeSimplex {
|
||||
private static final double FREQUENCY = 0.01;
|
||||
private static final double F2 = 0.5 * (Math.sqrt(3.0) - 1.0);
|
||||
private static final double G2 = (3.0 - Math.sqrt(3.0)) / 6.0;
|
||||
private static final long X_PRIME = 1619;
|
||||
private static final long Y_PRIME = 31337;
|
||||
private static final long HASH_MULTIPLIER = 60493;
|
||||
private static final double SCALE = 50;
|
||||
private static final double[] GRADIENTS = {-1D, -1D, 1D, -1D, -1D, 1D, 1D, 1D, 0D, -1D, -1D, 0D, 0D, 1D, 1D, 0D};
|
||||
|
||||
private final long seed;
|
||||
|
||||
public EdgeSimplex(long seed) {
|
||||
this.seed = new RNG(seed).lmax();
|
||||
}
|
||||
|
||||
public double signed(double x, double z) {
|
||||
return simplex(x * FREQUENCY, z * FREQUENCY);
|
||||
}
|
||||
|
||||
private double simplex(double x, double y) {
|
||||
double skew = (x + y) * F2;
|
||||
long i = floor(x + skew);
|
||||
long j = floor(y + skew);
|
||||
double unskew = (i + j) * G2;
|
||||
double x0 = x - (i - unskew);
|
||||
double y0 = y - (j - unskew);
|
||||
long i1 = x0 > y0 ? 1 : 0;
|
||||
long j1 = x0 > y0 ? 0 : 1;
|
||||
double x1 = x0 - i1 + G2;
|
||||
double y1 = y0 - j1 + G2;
|
||||
double x2 = x0 - 1 + (2 * G2);
|
||||
double y2 = y0 - 1 + (2 * G2);
|
||||
return SCALE * (corner(i, j, x0, y0) + corner(i + i1, j + j1, x1, y1) + corner(i + 1, j + 1, x2, y2));
|
||||
}
|
||||
|
||||
private double corner(long cellX, long cellY, double x, double y) {
|
||||
double falloff = 0.5 - x * x - y * y;
|
||||
if (falloff < 0) {
|
||||
return 0;
|
||||
}
|
||||
falloff *= falloff;
|
||||
return falloff * falloff * gradient(cellX, cellY, x, y);
|
||||
}
|
||||
|
||||
private double gradient(long cellX, long cellY, double x, double y) {
|
||||
long hash = seed;
|
||||
hash ^= X_PRIME * cellX;
|
||||
hash ^= Y_PRIME * cellY;
|
||||
hash = hash * hash * hash * HASH_MULTIPLIER;
|
||||
hash = (hash >> 13) ^ hash;
|
||||
int index = ((int) hash & 7) << 1;
|
||||
return (x * GRADIENTS[index]) + (y * GRADIENTS[index + 1]);
|
||||
}
|
||||
|
||||
private static long floor(double value) {
|
||||
return value >= 0 ? (long) value : (long) value - 1;
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -16,22 +16,22 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.placement;
|
||||
package art.arcane.iris.modules.placement;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** One marker of a placement, an entry of its {@code markers}: the blocks it marks and how many. */
|
||||
public interface MarkerRule {
|
||||
/** The pack's marker to add. */
|
||||
String marker();
|
||||
|
||||
/** The blocks to mark. */
|
||||
List<BlockState> targets();
|
||||
|
||||
/** Whether a block must match a target exactly; otherwise its material is enough. */
|
||||
boolean exact();
|
||||
|
||||
int maximum();
|
||||
/**
|
||||
* One marker of a placement, an entry of its {@code markers}, with its blocks resolved in the pack.
|
||||
*
|
||||
* @param marker the pack's marker to add
|
||||
* @param targets the blocks to mark
|
||||
* @param exact whether a block must match a target exactly; otherwise its material is enough
|
||||
* @param maximum how many blocks to mark at most
|
||||
*/
|
||||
public record MarkerRule(String marker, List<BlockState> targets, boolean exact, int maximum) {
|
||||
public MarkerRule {
|
||||
targets = List.copyOf(targets);
|
||||
}
|
||||
}
|
||||
@@ -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.modules.placement;
|
||||
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** The object being placed as the placement stages see it: its declared size, the block its offsets count from, and where it must stand on solid ground. */
|
||||
public final class ObjectShape {
|
||||
private final PlaceableObject object;
|
||||
private final PackWorld world;
|
||||
|
||||
ObjectShape(PlaceableObject object, PackWorld world) {
|
||||
this.object = object;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public int width() {
|
||||
return object.width();
|
||||
}
|
||||
|
||||
public int height() {
|
||||
return object.height();
|
||||
}
|
||||
|
||||
public int depth() {
|
||||
return object.depth();
|
||||
}
|
||||
|
||||
/** The block the object's offsets count from, relative to its corner. */
|
||||
public int centerX() {
|
||||
return object.center().x();
|
||||
}
|
||||
|
||||
public int centerY() {
|
||||
return object.center().y();
|
||||
}
|
||||
|
||||
public int centerZ() {
|
||||
return object.center().z();
|
||||
}
|
||||
|
||||
/** The pack object this is, by the id the pack gives its name. */
|
||||
public Optional<ResourceId> id() {
|
||||
return Optional.of(world.resources().idOf(object.name()));
|
||||
}
|
||||
|
||||
/** The columns of the object's lowest solid layer, as offsets from its anchor before any transform; empty for the origin only. */
|
||||
public List<IrisBlockVector> surfaceSupportOffsets() {
|
||||
return SurfaceSupportOffsets.of(world).of(object, world.resources().blocks());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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.modules.placement;
|
||||
|
||||
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.objects.ObjectPlacement;
|
||||
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.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/** The settings of one object placement as the placement stages read them, its markers and collisions resolved in the pack. */
|
||||
public final class PlacementSettings {
|
||||
private final ObjectPlacement config;
|
||||
private final PackResources resources;
|
||||
|
||||
public PlacementSettings(ObjectPlacement config, PackResources resources) {
|
||||
this.config = config;
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
public boolean forcePlace() {
|
||||
return config.forcePlace();
|
||||
}
|
||||
|
||||
public SlopeClip slopeCondition() {
|
||||
return config.slopeCondition();
|
||||
}
|
||||
|
||||
public boolean rotateTowardsSlope() {
|
||||
return config.rotateTowardsSlope();
|
||||
}
|
||||
|
||||
public ObjectRotation rotation() {
|
||||
return config.rotation();
|
||||
}
|
||||
|
||||
public ObjectTranslate translate() {
|
||||
return config.translate();
|
||||
}
|
||||
|
||||
public ObjectPlaceMode mode() {
|
||||
return config.mode();
|
||||
}
|
||||
|
||||
public boolean fromBottom() {
|
||||
return config.fromBottom();
|
||||
}
|
||||
|
||||
/** Whether the object places from the ground up instead of by height checks. */
|
||||
public boolean bottom() {
|
||||
return config.bottom();
|
||||
}
|
||||
|
||||
public CarvingMode carvingSupport() {
|
||||
return config.carvingSupport();
|
||||
}
|
||||
|
||||
public boolean underwater() {
|
||||
return config.underwater();
|
||||
}
|
||||
|
||||
public boolean onwater() {
|
||||
return config.onwater();
|
||||
}
|
||||
|
||||
public boolean requireSurfaceSupport() {
|
||||
return config.requireSurfaceSupport();
|
||||
}
|
||||
|
||||
public int surfaceSupportBuffer() {
|
||||
return config.surfaceSupportBuffer();
|
||||
}
|
||||
|
||||
public int surfaceSupportDepth() {
|
||||
return config.surfaceSupportDepth();
|
||||
}
|
||||
|
||||
public ObjectLimit clamp() {
|
||||
return config.clamp();
|
||||
}
|
||||
|
||||
/** Whether air is placed before the object. */
|
||||
public boolean bore() {
|
||||
return config.bore();
|
||||
}
|
||||
|
||||
public int boreExtendMinY() {
|
||||
return config.boreExtendMinY();
|
||||
}
|
||||
|
||||
public int boreExtendMaxY() {
|
||||
return config.boreExtendMaxY();
|
||||
}
|
||||
|
||||
public List<ObjectReplace> edit() {
|
||||
return config.edit();
|
||||
}
|
||||
|
||||
public boolean waterloggable() {
|
||||
return config.waterloggable();
|
||||
}
|
||||
|
||||
public boolean meld() {
|
||||
return config.meld();
|
||||
}
|
||||
|
||||
public List<MarkerRule> markers() {
|
||||
return config.markers().stream()
|
||||
.map(marker -> new MarkerRule(marker.marker(), marker.mark().stream().map(spec -> resources.blocks().resolve(spec)).toList(),
|
||||
marker.exact(), marker.maximumMarkers()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public Optional<StiltSettings> stilt() {
|
||||
return config.stiltSettings();
|
||||
}
|
||||
|
||||
public Optional<VacuumSettings> vacuum() {
|
||||
return config.vacuumSettings();
|
||||
}
|
||||
|
||||
/** The snow filter's depth, 0 for none. */
|
||||
public double snow() {
|
||||
return config.snow();
|
||||
}
|
||||
|
||||
/** The pack objects the placement may overlap even when {@link #forbiddenCollisions()} names them. */
|
||||
public Set<ResourceId> allowedCollisions() {
|
||||
return objectIds(config.allowedCollisions());
|
||||
}
|
||||
|
||||
/** The pack objects the placement may not overlap. */
|
||||
public Set<ResourceId> forbiddenCollisions() {
|
||||
return objectIds(config.forbiddenCollisions());
|
||||
}
|
||||
|
||||
private Set<ResourceId> objectIds(List<String> keys) {
|
||||
return keys.stream().filter(Objects::nonNull).map(resources::idOf).collect(Collectors.toUnmodifiableSet());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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.modules.placement;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.AnchorHeight;
|
||||
import art.arcane.iris.builtin.blocks.WrittenBlocks;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.stilt.StiltLayers;
|
||||
import com.volmit.stage.BlockStage;
|
||||
import com.volmit.stage.PlacementStage;
|
||||
import com.volmit.stage.Stage;
|
||||
|
||||
/**
|
||||
* The stages of Iris's built-in object placement modules, one nested class per module, in the order a placement runs
|
||||
* them. The stage graph decides the actual order.
|
||||
*/
|
||||
public final class PlacementStages {
|
||||
private PlacementStages() {
|
||||
}
|
||||
|
||||
/** Module {@code iris:prepare}: what a placement decides before it looks for its height. */
|
||||
public static final class Prepare {
|
||||
/** The rotation the placement uses: the requested one, turned downhill when the settings ask to face the slope. Rejects {@code slope}. */
|
||||
public static final PlacementStage<ObjectRotation> SLOPE = Stage.placement("iris:prepare/slope", ObjectRotation.class);
|
||||
/** The random rotation, translation and height offset, chosen once per placement. */
|
||||
public static final PlacementStage<PreparedPlacement> TRANSFORMS = Stage.placement("iris:prepare/transforms", PreparedPlacement.class);
|
||||
|
||||
private Prepare() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:anchor}: the height an object is placed at. */
|
||||
public static final class Anchor {
|
||||
/** The requested or sampled height the checks judge. Rejects {@code carving-anchor}. */
|
||||
public static final PlacementStage<AnchorHeight> HEIGHT = Stage.placement("iris:anchor/height", AnchorHeight.class);
|
||||
/** The height the object's blocks are written at: the checked height plus the random offset. */
|
||||
public static final PlacementStage<AnchorHeight> FINAL = Stage.placement("iris:anchor/final", AnchorHeight.class);
|
||||
|
||||
private Anchor() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:validate}: the checks that reject a placement before anything is written, in this order. */
|
||||
public static final class Validate {
|
||||
/** Rejects {@code bedrock-anchor} and {@code surface-support}. */
|
||||
public static final PlacementStage<Void> SURFACE = Stage.placement("iris:validate/surface");
|
||||
/** Rejects {@code underwater-anchor}, {@code cave-clearance}, {@code fluid-height} and {@code height-clamp}. */
|
||||
public static final PlacementStage<Void> LIMITS = Stage.placement("iris:validate/limits");
|
||||
/** Rejects {@code native-structure}, even for placements that force their way past the other checks. */
|
||||
public static final PlacementStage<Void> STRUCTURES = Stage.placement("iris:validate/structures");
|
||||
/** Rejects {@code object-collision}. */
|
||||
public static final PlacementStage<Void> COLLISIONS = Stage.placement("iris:validate/collisions");
|
||||
|
||||
private Validate() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:bore}: clearing the object's volume before its blocks are written. */
|
||||
public static final class Bore {
|
||||
public static final PlacementStage<Void> CLEAR = Stage.placement("iris:bore/clear");
|
||||
|
||||
private Bore() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:blocks}: writing the object's blocks. */
|
||||
public static final class Blocks {
|
||||
/** Writes each object block where the placement puts it. */
|
||||
public static final BlockStage<WrittenBlocks> WRITE = Stage.placementBlock("iris:blocks/write", WrittenBlocks.class);
|
||||
/** Marks some written blocks with the placement's markers. */
|
||||
public static final PlacementStage<Void> MARKERS = Stage.placement("iris:blocks/markers");
|
||||
/** Milestone: stages requiring it run after the object and its markers are written. */
|
||||
public static final PlacementStage<Void> COMPLETE = Stage.placement("iris:blocks/complete");
|
||||
|
||||
private Blocks() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:stilt}: the stilts of the stilt and ceiling placement modes. */
|
||||
public static final class Stilt {
|
||||
/** Finds the layers to repeat. */
|
||||
public static final BlockStage<StiltLayers> LAYERS = Stage.placementBlock("iris:stilt/layers", StiltLayers.class);
|
||||
/** Grows the stilt once the object is written. */
|
||||
public static final PlacementStage<Void> FILL = Stage.placement("iris:stilt/fill");
|
||||
|
||||
private Stilt() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:vacuum}: bending the terrain to meet objects of the vacuum placement modes. */
|
||||
public static final class Vacuum {
|
||||
public static final PlacementStage<Void> TERRAIN = Stage.placement("iris:vacuum/terrain");
|
||||
|
||||
private Vacuum() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Module {@code iris:snow}: snow on the object, after its stilt or terrain bend. */
|
||||
public static final class Snow {
|
||||
public static final PlacementStage<Void> COVER = Stage.placement("iris:snow/cover");
|
||||
|
||||
private Snow() {
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-14
@@ -16,32 +16,30 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.prepare;
|
||||
package art.arcane.iris.modules.placement;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.PlaceMode;
|
||||
import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.placement.BlockTraits;
|
||||
import art.arcane.iris.builtin.placement.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.placement.PlacementSettings;
|
||||
import art.arcane.iris.builtin.placement.PlacementTerrain;
|
||||
import art.arcane.iris.builtin.placement.SurfaceWarp;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectSpinKernel;
|
||||
import art.arcane.iris.builtin.prepare.TransformedBounds;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
/**
|
||||
* What one placement chose before it is anchored: the settings it uses, the rotation it ended up with, the terrain
|
||||
* that answers its height, water and carving questions, its random spin and height offsets, and the bounds of the
|
||||
* transformed object around its anchor. Object blocks are transformed by rotating them, flipping them for a ceiling
|
||||
* hang and translating them.
|
||||
* What one placement chose before it is anchored: the placement it belongs to, the settings it uses, the rotation it
|
||||
* ended up with, the terrain that answers its height, water and carving questions, its random spin and height offsets,
|
||||
* and the bounds of the transformed object around its anchor. Object blocks are transformed by rotating them, flipping
|
||||
* them for a ceiling hang and translating them.
|
||||
*/
|
||||
public final class PreparedPlacement {
|
||||
private final ObjectPlacement placement;
|
||||
private final RunningPlacement placement;
|
||||
private final PlacementSettings settings;
|
||||
private final PlaceMode mode;
|
||||
private final ObjectRotation rotation;
|
||||
private final BlockTraits traits;
|
||||
private final PlacementTerrain terrain;
|
||||
private final StageTerrain terrain;
|
||||
private final ObjectSpinKernel spin;
|
||||
private final int spinX;
|
||||
private final int spinY;
|
||||
@@ -55,7 +53,7 @@ public final class PreparedPlacement {
|
||||
private final SurfaceWarp surfaceWarp;
|
||||
|
||||
/** Everything the preparation worked out; {@code translation} and {@code surfaceWarp} are null when the placement has none. */
|
||||
public PreparedPlacement(ObjectPlacement placement, ObjectRotation rotation, BlockTraits traits, PlacementTerrain terrain,
|
||||
public PreparedPlacement(RunningPlacement placement, ObjectRotation rotation, BlockTraits traits, StageTerrain terrain,
|
||||
ObjectSpinKernel spin, int spinX, int spinY, int spinZ, IrisBlockVector translation, int rotatedCenterY,
|
||||
int translatedCenterY, int randomY, int warpMargin, TransformedBounds bounds, SurfaceWarp surfaceWarp) {
|
||||
this.placement = placement;
|
||||
@@ -77,6 +75,11 @@ public final class PreparedPlacement {
|
||||
this.surfaceWarp = surfaceWarp;
|
||||
}
|
||||
|
||||
/** The placement being run. */
|
||||
public RunningPlacement placement() {
|
||||
return placement;
|
||||
}
|
||||
|
||||
/** The settings the placement was asked for; the rotation may differ, see {@link #rotation()}. */
|
||||
public PlacementSettings settings() {
|
||||
return settings;
|
||||
@@ -93,7 +96,7 @@ public final class PreparedPlacement {
|
||||
}
|
||||
|
||||
/** Answers height, water and carving questions; a heightmap placement answers heights from its noise. */
|
||||
public PlacementTerrain terrain() {
|
||||
public StageTerrain terrain() {
|
||||
return terrain;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 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.modules.placement;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.LegacyStreams;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectRun;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.block.BlockTurn;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.placement.PlacementContext;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The object placement being run, as Iris's built-in placement stages see it: what is placed and with which settings
|
||||
* ({@link ObjectRun}, the run's input), the terrain it is placed on, and the block operations of the pack's registry.
|
||||
* Heights are above the dimension's bottom.
|
||||
*/
|
||||
public final class RunningPlacement {
|
||||
private static final double QUARTER_TURN_DEGREES = 90D;
|
||||
private static final double FULL_TURN_DEGREES = 360D;
|
||||
|
||||
private final PlacementContext context;
|
||||
private final ObjectRun run;
|
||||
private final ObjectShape object;
|
||||
private final PlacementSettings settings;
|
||||
private final StageTerrain terrain;
|
||||
|
||||
private RunningPlacement(PlacementContext context, ObjectRun run) {
|
||||
this.context = context;
|
||||
this.run = run;
|
||||
this.object = new ObjectShape(run.object(), context.world());
|
||||
this.settings = new PlacementSettings(run.settings(), context.world().resources());
|
||||
this.terrain = StageTerrain.of(context);
|
||||
}
|
||||
|
||||
/** The placement {@code context} runs. */
|
||||
public static RunningPlacement of(PlacementContext context) {
|
||||
ObjectRun run = context.input(ObjectRun.class).orElseThrow(() -> new IllegalStateException(
|
||||
"Iris's object placement stages place an object run, and this placement was started without one"));
|
||||
return new RunningPlacement(context, run);
|
||||
}
|
||||
|
||||
public ObjectShape object() {
|
||||
return object;
|
||||
}
|
||||
|
||||
/** The settings as the caller passed them; the stages derive what they change (the rotation) themselves. */
|
||||
public PlacementSettings settings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return run.x();
|
||||
}
|
||||
|
||||
/** The height the caller asked for, negative when the placement samples it. */
|
||||
public int requestedY() {
|
||||
return run.requestedY();
|
||||
}
|
||||
|
||||
public int z() {
|
||||
return run.z();
|
||||
}
|
||||
|
||||
/** The cave the object is placed in; empty outside caves. */
|
||||
public Optional<ObjectRun.Cave> cave() {
|
||||
return run.cave();
|
||||
}
|
||||
|
||||
/** Answers the questions of the terrain the placement was asked to place on. */
|
||||
public StageTerrain terrain() {
|
||||
return terrain;
|
||||
}
|
||||
|
||||
/**
|
||||
* The terrain the placement anchors against: {@link #terrain()}, or, when the settings place on a heightmap, the same
|
||||
* terrain with its heights from the heightmap's noise, seeded from {@code rng}.
|
||||
*/
|
||||
public StageTerrain terrainFor(RNG rng) {
|
||||
ObjectPlacement config = run.settings();
|
||||
if (config.heightmap().isEmpty()) {
|
||||
return terrain;
|
||||
}
|
||||
long heightmapSeed = rng.nextLong() + run.requestedY() + run.z() - run.x();
|
||||
LegacyStreams streams = world().extension(LegacyStreams.class).orElseThrow();
|
||||
return terrain.withHeights((x, z) -> streams.heightmapSurface(config, heightmapSeed, x, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* The noise that warps the placement's columns; empty when the settings do not warp. A generated world seeds it from
|
||||
* the world, so every placement of the world warps alike; a placement without one seeds it from {@code rng}.
|
||||
*/
|
||||
public Optional<SurfaceWarp> surfaceWarp(RNG rng) {
|
||||
ObjectPlacement config = run.settings();
|
||||
if (!ObjectRun.warps(config.warp())) {
|
||||
return Optional.empty();
|
||||
}
|
||||
PackWorld world = world();
|
||||
long seed = world.running().isPresent() ? world.seed(IrisSeedPurposes.OBJECT_WARP) : rng.getSeed();
|
||||
return Optional.of(new SurfaceWarp(world.resources().noise().sampler(config.warp(), seed), config.warp().multiplier()));
|
||||
}
|
||||
|
||||
/** {@code state} turned with the object by {@code rotation}, as the platform turns stairs, logs and other facing blocks. */
|
||||
public BlockState rotate(BlockState state, ObjectRotation rotation, int spinX, int spinY, int spinZ) {
|
||||
if (!rotation.canRotate()) {
|
||||
return state;
|
||||
}
|
||||
int turnsX = wholeQuarterTurns(spinX);
|
||||
int turnsY = wholeQuarterTurns(spinY);
|
||||
int turnsZ = wholeQuarterTurns(spinZ);
|
||||
BlockTurn turn = (x, y, z) -> {
|
||||
IrisBlockVector turned = rotation.rotate(new IrisBlockVector(x, y, z), turnsX, turnsY, turnsZ);
|
||||
return new BlockTurn.Direction(turned.getX(), turned.getY(), turned.getZ());
|
||||
};
|
||||
return blocks().rotate(state, turn);
|
||||
}
|
||||
|
||||
/** {@code update} laid over {@code base}: the platform's merge of two states of one block, else {@code update}. */
|
||||
public BlockState merge(BlockState base, BlockState update) {
|
||||
return blocks().merge(base, update);
|
||||
}
|
||||
|
||||
/** Whether {@code state} matches {@code other} as the platform compares them. */
|
||||
public boolean matches(BlockState state, BlockState other) {
|
||||
return blocks().matches(state, other);
|
||||
}
|
||||
|
||||
public boolean hasTrait(BlockState state, BlockTrait trait) {
|
||||
return blocks().hasTrait(state, trait);
|
||||
}
|
||||
|
||||
/** The resources of the object's pack, where the placement's markers are found. */
|
||||
public PackResources resources() {
|
||||
return world().resources();
|
||||
}
|
||||
|
||||
/** Reports a buffered write as one of the object's own blocks, which the placing module reads once the object is placed. */
|
||||
public void objectBlockWritten(BlockPosition position) {
|
||||
run.objectBlockWritten(position);
|
||||
}
|
||||
|
||||
/** Reports the height the object was anchored at, which the placement returns to its caller. */
|
||||
public void anchoredAt(int y) {
|
||||
run.anchoredAt(y);
|
||||
}
|
||||
|
||||
private BlockRegistry blocks() {
|
||||
return world().resources().blocks();
|
||||
}
|
||||
|
||||
private PackWorld world() {
|
||||
return context.world();
|
||||
}
|
||||
|
||||
/** The spin in whole quarter turns, as the platform turns blocks: any part of a quarter turn counts as one. */
|
||||
private static int wholeQuarterTurns(int degrees) {
|
||||
return (int) (QUARTER_TURN_DEGREES * Math.ceil(Math.abs((degrees % FULL_TURN_DEGREES) / QUARTER_TURN_DEGREES)));
|
||||
}
|
||||
}
|
||||
@@ -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.modules.placement;
|
||||
|
||||
import art.arcane.iris.builtin.structure.StructurePlacementMarker;
|
||||
import art.arcane.iris.modules.blocks.SmartBoreDebugSettings;
|
||||
import com.volmit.placement.PlacementContext;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
import com.volmit.placement.StructureVolumes;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
|
||||
/**
|
||||
* What a placement stage asks of the terrain and the world around it: heights, carving and water at a column, the
|
||||
* terrain's shape, and the world's own facts. A placement made without a world ({@link #hasWorld()} is false) answers
|
||||
* its terrain questions from the placement's terrain alone.
|
||||
*/
|
||||
public final class StageTerrain {
|
||||
private static final String PROCEDURAL_PREFIX = "procedural/";
|
||||
|
||||
private final PlacementTerrain terrain;
|
||||
private final PlacementContext context;
|
||||
private final IntBinaryOperator heightmap;
|
||||
|
||||
private StageTerrain(PlacementTerrain terrain, PlacementContext context, IntBinaryOperator heightmap) {
|
||||
this.terrain = terrain;
|
||||
this.context = context;
|
||||
this.heightmap = heightmap;
|
||||
}
|
||||
|
||||
static StageTerrain of(PlacementContext context) {
|
||||
return new StageTerrain(context.placementTerrain(), context, null);
|
||||
}
|
||||
|
||||
/** This terrain with its heights from {@code heightmap}, for a placement that sits on a virtual heightmap. */
|
||||
StageTerrain withHeights(IntBinaryOperator heightmap) {
|
||||
return new StageTerrain(terrain, context, heightmap);
|
||||
}
|
||||
|
||||
/** The surface height of the column, counting fluid unless {@code ignoreFluid}. */
|
||||
public int highest(int x, int z, boolean ignoreFluid) {
|
||||
return heightmap != null ? heightmap.applyAsInt(x, z) : terrain.highest(x, z, ignoreFluid);
|
||||
}
|
||||
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
return terrain.isCarved(x, y, z);
|
||||
}
|
||||
|
||||
/** Whether the block is real, solid ground; the height field alone cannot say at mantle time. */
|
||||
public boolean isSurfaceSolid(int x, int y, int z) {
|
||||
return terrain.isSurfaceSolid(x, y, z);
|
||||
}
|
||||
|
||||
public boolean isUnderwater(int x, int z) {
|
||||
return terrain.isUnderwater(x, z);
|
||||
}
|
||||
|
||||
/** The height up to which the dimension is filled with fluid. */
|
||||
public int fluidHeight() {
|
||||
return terrain.fluidHeight();
|
||||
}
|
||||
|
||||
/** Whether leaves the placement writes never decay. */
|
||||
public boolean preventsDecay() {
|
||||
return terrain.preventsDecay();
|
||||
}
|
||||
|
||||
/** Whether bored air is written as a visible block, to see where smart boring bored. */
|
||||
public boolean debugsSmartBore(int x, int z) {
|
||||
return context.settings().at(SmartBoreDebugSettings.class, x, z).dimension().map(SmartBoreDebugSettings::show).orElse(false);
|
||||
}
|
||||
|
||||
/** Whether the placement is made in a world the host generates, rather than a tool's world. */
|
||||
public boolean hasWorld() {
|
||||
return context.world().running().isPresent();
|
||||
}
|
||||
|
||||
/** The terrain's slope at the column, as the dimension's slope field gives it. */
|
||||
public double slopeAt(int x, int z) {
|
||||
return sampler().column(x, z).slope();
|
||||
}
|
||||
|
||||
/** The terrain height at a position between columns: the height of the column the position lies in, counted toward zero. */
|
||||
public double heightAt(double x, double z) {
|
||||
return sampler().surfaceY((int) x, (int) z);
|
||||
}
|
||||
|
||||
/** The dimension's height in blocks. */
|
||||
public int worldHeight() {
|
||||
return sampler().bounds().maxY();
|
||||
}
|
||||
|
||||
public StructureVolumes structureVolumes(int minX, int minZ, int maxX, int maxZ) {
|
||||
return terrain.structureVolumes(minX, minZ, maxX, maxZ);
|
||||
}
|
||||
|
||||
/** The pack object placed at the block; empty when none was, or when a procedural object was. */
|
||||
public Optional<ResourceId> objectAt(int x, int y, int z) {
|
||||
Optional<String> recorded = terrain.placementAt(x, y, z);
|
||||
if (recorded.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
StructurePlacementMarker.Decoded marker = StructurePlacementMarker.decode(recorded.get());
|
||||
if (marker == null || marker.objectKey().startsWith(PROCEDURAL_PREFIX)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(context.world().resources().idOf(marker.objectKey()));
|
||||
}
|
||||
|
||||
private TerrainSampler sampler() {
|
||||
return context.terrain();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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.modules.placement;
|
||||
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.object.ObjectBlock;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* The columns of each object's lowest solid layer, worked out once per object of a world and kept while the object is: an
|
||||
* object stands on these when its placement needs surface support. Foliage does not count as solid.
|
||||
*/
|
||||
final class SurfaceSupportOffsets {
|
||||
private final ReferenceQueue<PlaceableObject> collected = new ReferenceQueue<>();
|
||||
private final Map<ObjectKey, List<IrisBlockVector>> offsets = new ConcurrentHashMap<>();
|
||||
|
||||
static SurfaceSupportOffsets of(PackWorld world) {
|
||||
return world.state(SurfaceSupportOffsets.class, ignored -> new SurfaceSupportOffsets());
|
||||
}
|
||||
|
||||
/** {@code blocks} tells which of the object's blocks are solid. */
|
||||
List<IrisBlockVector> of(PlaceableObject object, BlockRegistry blocks) {
|
||||
forgetCollected();
|
||||
return offsets.computeIfAbsent(new ObjectKey(object, collected), ignored -> lowestSolidLayer(object, blocks));
|
||||
}
|
||||
|
||||
private static List<IrisBlockVector> lowestSolidLayer(PlaceableObject object, BlockRegistry blocks) {
|
||||
Map<BlockState, Boolean> supporting = new HashMap<>();
|
||||
int lowestY = Integer.MAX_VALUE;
|
||||
List<IrisBlockVector> layer = new ArrayList<>();
|
||||
for (ObjectBlock block : object.geometry().blocks()) {
|
||||
if (!supporting.computeIfAbsent(block.state(), state -> supports(state, blocks))) {
|
||||
continue;
|
||||
}
|
||||
BlockPosition position = block.position();
|
||||
if (position.y() < lowestY) {
|
||||
lowestY = position.y();
|
||||
layer.clear();
|
||||
}
|
||||
if (position.y() == lowestY) {
|
||||
layer.add(new IrisBlockVector(position.x(), position.y(), position.z()));
|
||||
}
|
||||
}
|
||||
return List.copyOf(layer);
|
||||
}
|
||||
|
||||
private static boolean supports(BlockState state, BlockRegistry blocks) {
|
||||
return blocks.hasTrait(state, BlockTrait.SOLID) && !blocks.hasTrait(state, BlockTrait.FOLIAGE);
|
||||
}
|
||||
|
||||
private void forgetCollected() {
|
||||
Object gone;
|
||||
while ((gone = collected.poll()) != null) {
|
||||
offsets.remove((ObjectKey) gone);
|
||||
}
|
||||
}
|
||||
|
||||
/** An object by identity, held weakly so its entry goes once the object is collected. */
|
||||
private static final class ObjectKey extends WeakReference<PlaceableObject> {
|
||||
private final int hash;
|
||||
|
||||
private ObjectKey(PlaceableObject object, ReferenceQueue<PlaceableObject> queue) {
|
||||
super(object, queue);
|
||||
this.hash = System.identityHashCode(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ObjectKey key)) {
|
||||
return false;
|
||||
}
|
||||
PlaceableObject object = get();
|
||||
return object != null && object == key.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-6
@@ -16,13 +16,18 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.builtin.placement;
|
||||
package art.arcane.iris.modules.placement;
|
||||
|
||||
/** Noise that moves the columns of a placement sideways, so a square object warps like a flag. */
|
||||
public interface SurfaceWarp {
|
||||
/** How far, in blocks, the warp may move a column in total. */
|
||||
double multiplier();
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
|
||||
/**
|
||||
* Noise that moves the columns of a placement sideways, so a square object warps like a flag.
|
||||
*
|
||||
* @param multiplier how far, in blocks, the warp may move a column in total
|
||||
*/
|
||||
public record SurfaceWarp(NoiseSampler noise, double multiplier) {
|
||||
/** The noise at the position, fitted to the range from {@code min} to {@code max}. */
|
||||
double fit(double min, double max, double x, double y, double z);
|
||||
public double fit(double min, double max, double x, double y, double z) {
|
||||
return min + noise.sample(x, y, z) * (max - min);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user