mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-03 19:51:49 +00:00
Port Iris's object, floating object and structure mantle components to built-in mantle stages
The three mantle components become per-runtime workers constructed from the engine, like CaveCarving: ObjectPlacing, FloatingObjectPlacing and StructurePlacing, each with place(writer, x, z, context) and reach(). New built-in mantle stages run them: iris:objects/place (after the caves), iris:floating/objects (after objects) and iris:structure/place (after objects and floating objects). Each works out its reach from the pack when it loads, as the component's radius used to be. CarveModule no longer checks disabledComponents itself: Iris disables the cave stage's pass by its CARVED flag like any other. Studio's disabledComponents list offers the flags of Iris's own mantle stages, CARVED included again.
This commit is contained in:
1 parent
a77a097baf
commit
847dba8212
12 files changed
+349
-133
No files matched your search
@@ -6,18 +6,20 @@ direct dependencies on Iris internals.
|
|||||||
|
|
||||||
Ported features are IrisApi modules that every pack loads before its own: object placement
|
Ported features are IrisApi modules that every pack loads before its own: object placement
|
||||||
(`iris:prepare`, `iris:anchor`, `iris:validate`, `iris:bore`, `iris:blocks`, `iris:stilt`,
|
(`iris:prepare`, `iris:anchor`, `iris:validate`, `iris:bore`, `iris:blocks`, `iris:stilt`,
|
||||||
`iris:vacuum`, `iris:snow`) and chunk generation, which every world runs in this order: `iris:biome`,
|
`iris:vacuum`, `iris:snow`), the mantle, and chunk generation. Every mantle stage is a pass of Iris's
|
||||||
`iris:terrain`, `iris:carve` (a mantle stage planning caves, and a chunk stage cutting them),
|
mantle of its own, in the stage graph's order: `iris:carve/caves`, `iris:objects/place`,
|
||||||
`iris:post`, `iris:floating` (solids), `iris:deposit`, `iris:matter`, `iris:decorant`, `iris:floating`
|
`iris:floating/objects`, `iris:structure/place`, so a pack's mantle stage can order itself after any of
|
||||||
(decoration), `iris:perfection` and `iris:custom`. There are no world modes any more. Their stage
|
them. Chunk generation then runs, in this order: `iris:biome`, `iris:terrain`, `iris:carve` (cutting the
|
||||||
constants, and the settings and output types packs may read, live in
|
planned caves), `iris:post`, `iris:floating` (solids), `iris:deposit`, `iris:matter`, `iris:decorant`,
|
||||||
`src/main/java/art/arcane/iris/builtin`, the package Iris exposes to pack modules; their stage bodies live
|
`iris:floating` (decoration), `iris:perfection` and `iris:custom`. There are no world modes and no Iris
|
||||||
beside the features they replace.
|
mantle components outside the stage graph any more. Their stage constants, and the settings and output
|
||||||
|
types packs may read, live in `src/main/java/art/arcane/iris/builtin`, the package Iris exposes to pack
|
||||||
|
modules; their stage bodies live beside the features they replace.
|
||||||
|
|
||||||
`iris:biome` and `iris:deposit` (chunk stages) and the cave planning of `iris:carve` (a mantle stage) are
|
`iris:biome` and `iris:deposit` (chunk stages) and every mantle stage (caves, objects, floating objects,
|
||||||
full ports: the module owns its logic and per-engine state. The other generation stages are thin wrappers
|
structures) are full ports: the module owns its logic and per-engine state, and the mantle stages work out
|
||||||
that run the existing actuator or modifier unchanged. Iris's object, floating object and structure mantle
|
their reach from the pack when it loads. The other chunk stages are thin wrappers that run the existing
|
||||||
components are still Iris mantle components.
|
actuator or modifier unchanged.
|
||||||
|
|
||||||
Iris core and these sources still depend on each other. The Iris host build therefore compiles them
|
Iris core and these sources still depend on each other. The Iris host build therefore compiles them
|
||||||
together as one source set. This keeps the existing class names and platform artifacts while the
|
together as one source set. This keeps the existing class names and platform artifacts while the
|
||||||
|
|||||||
@@ -19,10 +19,13 @@
|
|||||||
package art.arcane.iris.builtin.floating;
|
package art.arcane.iris.builtin.floating;
|
||||||
|
|
||||||
import com.volmit.stage.ChunkStage;
|
import com.volmit.stage.ChunkStage;
|
||||||
|
import com.volmit.stage.MantleStage;
|
||||||
import com.volmit.stage.Stage;
|
import com.volmit.stage.Stage;
|
||||||
|
|
||||||
/** Module {@code iris:floating}: the floating islands of floating child biomes. */
|
/** Module {@code iris:floating}: the floating islands of floating child biomes. */
|
||||||
public final class FloatingStages {
|
public final class FloatingStages {
|
||||||
|
/** Places the objects on and under the islands into the mantle, after the dimension's other objects. */
|
||||||
|
public static final MantleStage<Void> OBJECTS = Stage.mantle("iris:floating/objects");
|
||||||
/** Writes the islands' solid blocks. */
|
/** Writes the islands' solid blocks. */
|
||||||
public static final ChunkStage<Void> SOLIDS = Stage.chunk("iris:floating/solids");
|
public static final ChunkStage<Void> SOLIDS = Stage.chunk("iris:floating/solids");
|
||||||
/** Decorates the islands' tops and bottoms once the chunk's own decoration is done. */
|
/** Decorates the islands' tops and bottoms once the chunk's own decoration is done. */
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.builtin.objects;
|
||||||
|
|
||||||
|
import com.volmit.stage.MantleStage;
|
||||||
|
import com.volmit.stage.Stage;
|
||||||
|
|
||||||
|
/** Module {@code iris:objects}: the objects the dimension's regions and biomes place. */
|
||||||
|
public final class ObjectStages {
|
||||||
|
/** Places surface, cave and upper-dimension objects into the mantle, after the caves they anchor in. */
|
||||||
|
public static final MantleStage<Void> PLACE = Stage.mantle("iris:objects/place");
|
||||||
|
|
||||||
|
private ObjectStages() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.builtin.structure;
|
||||||
|
|
||||||
|
import com.volmit.stage.MantleStage;
|
||||||
|
import com.volmit.stage.Stage;
|
||||||
|
|
||||||
|
/** Module {@code iris:structure}: Iris structures, assembled from pieces. */
|
||||||
|
public final class StructureStages {
|
||||||
|
/** Places the structures of the dimension, its regions and biomes into the mantle, after objects and floating objects. */
|
||||||
|
public static final MantleStage<Void> PLACE = Stage.mantle("iris:structure/place");
|
||||||
|
|
||||||
|
private StructureStages() {
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
-18
@@ -22,9 +22,7 @@ import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
|||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.engine.IrisComplex;
|
import art.arcane.iris.engine.IrisComplex;
|
||||||
import art.arcane.iris.engine.data.cache.Cache;
|
import art.arcane.iris.engine.data.cache.Cache;
|
||||||
import art.arcane.iris.engine.mantle.ComponentFlag;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
|
||||||
import art.arcane.iris.engine.mantle.IrisMantleComponent;
|
|
||||||
import art.arcane.iris.engine.mantle.MantleWriter;
|
import art.arcane.iris.engine.mantle.MantleWriter;
|
||||||
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
|
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
|
||||||
import art.arcane.iris.engine.object.placement.FloatingObjectFootprint;
|
import art.arcane.iris.engine.object.placement.FloatingObjectFootprint;
|
||||||
@@ -43,7 +41,6 @@ import art.arcane.iris.util.common.math.IrisBlockVector;
|
|||||||
import art.arcane.iris.util.project.context.ChunkContext;
|
import art.arcane.iris.util.project.context.ChunkContext;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.documentation.ChunkCoordinates;
|
import art.arcane.volmlib.util.documentation.ChunkCoordinates;
|
||||||
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -53,23 +50,29 @@ import java.util.IdentityHashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ComponentFlag(ReservedFlag.FLOATING_OBJECT)
|
/**
|
||||||
public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
* Places the objects of floating child biomes on and under their islands into the mantle for
|
||||||
|
* {@link art.arcane.iris.engine.modifier.FloatingModule}. One per engine runtime. Its reach is the
|
||||||
|
* largest placement reach of any floating object the dimension's biomes can place, at least 16 blocks.
|
||||||
|
*/
|
||||||
|
public class FloatingObjectPlacing {
|
||||||
private static final int INVERTED_PICK_ATTEMPTS = 8;
|
private static final int INVERTED_PICK_ATTEMPTS = 8;
|
||||||
private static final IrisObjectRotation ROTATION_NONE = IrisObjectRotation.of(0, 0, 0);
|
private static final IrisObjectRotation ROTATION_NONE = IrisObjectRotation.of(0, 0, 0);
|
||||||
|
|
||||||
public MantleFloatingObjectComponent(EngineMantle engineMantle) {
|
private final Engine engine;
|
||||||
super(engineMantle, ReservedFlag.FLOATING_OBJECT, 2);
|
|
||||||
|
public FloatingObjectPlacing(Engine engine) {
|
||||||
|
this.engine = engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/** Places what originates in the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */
|
||||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
public void place(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||||
IrisComplex complex = context.getComplex();
|
IrisComplex complex = context.getComplex();
|
||||||
IrisData data = getData();
|
IrisData data = engine.getData();
|
||||||
int minX = x << 4;
|
int minX = x << 4;
|
||||||
int minZ = z << 4;
|
int minZ = z << 4;
|
||||||
RNG chunkRng = new RNG(Cache.key(x, z) + seed() + 0x0FA710BEL);
|
RNG chunkRng = new RNG(Cache.key(x, z) + engine.getSeedManager().getMantle() + 0x0FA710BEL);
|
||||||
FloatingIslandSampleResolver sampleResolver = new FloatingIslandSampleResolver(getEngineMantle(), context.getFloatingIslandBoundarySampler());
|
FloatingIslandSampleResolver sampleResolver = new FloatingIslandSampleResolver(engine.getMantle(), context.getFloatingIslandBoundarySampler());
|
||||||
|
|
||||||
FloatingIslandSample.clearChunkMemo();
|
FloatingIslandSample.clearChunkMemo();
|
||||||
|
|
||||||
@@ -543,14 +546,14 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/** How far, in blocks along X and Z, placements may write beyond their chunk. */
|
||||||
protected int computeRadius() {
|
public int reach() {
|
||||||
int maxObjectExtent = 16;
|
int maxObjectExtent = 16;
|
||||||
Map<String, IrisBlockVector> sizeCache = new HashMap<>();
|
Map<String, IrisBlockVector> sizeCache = new HashMap<>();
|
||||||
Set<String> warnedLargeObjects = new HashSet<>();
|
Set<String> warnedLargeObjects = new HashSet<>();
|
||||||
try {
|
try {
|
||||||
IrisData data = getData();
|
IrisData data = engine.getData();
|
||||||
for (IrisBiome biome : getDimension().getReachableBiomes(this::getData)) {
|
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
|
||||||
KList<IrisFloatingChildBiomes> entries = biome.getFloatingChildBiomes();
|
KList<IrisFloatingChildBiomes> entries = biome.getFloatingChildBiomes();
|
||||||
if (entries == null || entries.isEmpty()) {
|
if (entries == null || entries.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -599,7 +602,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
|||||||
size = IrisObject.sampleSize(file);
|
size = IrisObject.sampleSize(file);
|
||||||
sizeCache.put(objectKey, size);
|
sizeCache.put(objectKey, size);
|
||||||
}
|
}
|
||||||
int reach = MantleObjectComponent.calculatePlacementReach(size, placement);
|
int reach = ObjectPlacing.calculatePlacementReach(size, placement);
|
||||||
if (reach > 128 && warnedLargeObjects.add(objectKey)) {
|
if (reach > 128 && warnedLargeObjects.add(objectKey)) {
|
||||||
IrisLogging.warn("Floating object " + objectKey + " has a large placement reach (" + reach + " blocks) and may increase memory usage!");
|
IrisLogging.warn("Floating object " + objectKey + " has a large placement reach (" + reach + " blocks) and may increase memory usage!");
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.mantle.components;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.carve.CarveStages;
|
||||||
|
import art.arcane.iris.builtin.objects.ObjectStages;
|
||||||
|
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||||
|
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||||
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import com.volmit.IrisModule;
|
||||||
|
import com.volmit.ModuleInfo;
|
||||||
|
import com.volmit.config.PackSettings;
|
||||||
|
import com.volmit.stage.MantleStageContext;
|
||||||
|
import com.volmit.stage.StageGraph;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module {@code iris:objects}: the objects the dimension's regions and biomes place, written into the mantle
|
||||||
|
* once the caves they may anchor in are planned. A port of what was Iris's object mantle component, its work
|
||||||
|
* done by {@link ObjectPlacing}, one per engine runtime. Its reach is the pack's largest object placement.
|
||||||
|
*/
|
||||||
|
public final class ObjectModule implements IrisModule {
|
||||||
|
private static final String VERSION = "built-in";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModuleInfo info() {
|
||||||
|
return ModuleInfo.of("iris:objects", "Objects", VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void install(StageGraph graph) {
|
||||||
|
graph.define(ObjectStages.PLACE).requires(CarveStages.CAVES).reach(ObjectModule::reach).run(ObjectModule::place);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void place(MantleStageContext context) {
|
||||||
|
IrisMantleChunk chunk = IrisMantleChunk.current();
|
||||||
|
placing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int reach(PackSettings settings) {
|
||||||
|
return placing(IrisPackSettings.of(settings).engine()).reach();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The engine runtime's object placing, which {@link Engine#getObjectsAt} also asks. */
|
||||||
|
public static ObjectPlacing placing(Engine engine) {
|
||||||
|
return engine.getGeneration().state(ObjectPlacing.class, ObjectPlacing::new);
|
||||||
|
}
|
||||||
|
}
|
||||||
+48
-45
@@ -26,9 +26,6 @@ import art.arcane.iris.util.common.data.B;
|
|||||||
import art.arcane.iris.engine.data.cache.Cache;
|
import art.arcane.iris.engine.data.cache.Cache;
|
||||||
import art.arcane.iris.engine.IrisComplex;
|
import art.arcane.iris.engine.IrisComplex;
|
||||||
import art.arcane.iris.engine.UpperDimensionContext;
|
import art.arcane.iris.engine.UpperDimensionContext;
|
||||||
import art.arcane.iris.engine.mantle.ComponentFlag;
|
|
||||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
|
||||||
import art.arcane.iris.engine.mantle.IrisMantleComponent;
|
|
||||||
import art.arcane.iris.engine.mantle.MantleWriter;
|
import art.arcane.iris.engine.mantle.MantleWriter;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
||||||
@@ -55,7 +52,6 @@ import art.arcane.volmlib.util.collection.KSet;
|
|||||||
import art.arcane.iris.util.project.context.ChunkContext;
|
import art.arcane.iris.util.project.context.ChunkContext;
|
||||||
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
import art.arcane.volmlib.util.documentation.BlockCoordinates;
|
||||||
import art.arcane.volmlib.util.documentation.ChunkCoordinates;
|
import art.arcane.volmlib.util.documentation.ChunkCoordinates;
|
||||||
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||||
import art.arcane.volmlib.util.matter.MatterStructurePOI;
|
import art.arcane.volmlib.util.matter.MatterStructurePOI;
|
||||||
@@ -74,16 +70,23 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
@ComponentFlag(ReservedFlag.OBJECT)
|
/**
|
||||||
public class MantleObjectComponent extends IrisMantleComponent {
|
* Places the objects of the dimension's regions and biomes into the mantle for
|
||||||
|
* {@link ObjectModule}: surface, cave and upper-dimension objects, and procedural objects, one chunk at a
|
||||||
|
* time after the caves they anchor in are planned. One per engine runtime. Its reach is the largest
|
||||||
|
* placement reach of any object the dimension can place.
|
||||||
|
*/
|
||||||
|
public class ObjectPlacing {
|
||||||
private static final long CAVE_REJECT_LOG_THROTTLE_MS = 5000L;
|
private static final long CAVE_REJECT_LOG_THROTTLE_MS = 5000L;
|
||||||
private static final int BEDROCK_CLEARANCE = 6;
|
private static final int BEDROCK_CLEARANCE = 6;
|
||||||
private static final byte LIQUID_FORCED_AIR = 3;
|
private static final byte LIQUID_FORCED_AIR = 3;
|
||||||
private static final Map<String, CaveRejectLogState> CAVE_REJECT_LOG_STATE = new ConcurrentHashMap<>();
|
private static final Map<String, CaveRejectLogState> CAVE_REJECT_LOG_STATE = new ConcurrentHashMap<>();
|
||||||
private static final Set<String> MISSING_LOAD_KEY_WARNED = ConcurrentHashMap.newKeySet();
|
private static final Set<String> MISSING_LOAD_KEY_WARNED = ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
public MantleObjectComponent(EngineMantle engineMantle) {
|
private final Engine engine;
|
||||||
super(engineMantle, ReservedFlag.OBJECT, 1);
|
|
||||||
|
public ObjectPlacing(Engine engine) {
|
||||||
|
this.engine = engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String placementMarker(IrisObject object, int id, String context) {
|
private static String placementMarker(IrisObject object, int id, String context) {
|
||||||
@@ -111,21 +114,21 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
placer.setData(x, y, z, TreeBlockMaterial.of(data));
|
placer.setData(x, y, z, TreeBlockMaterial.of(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/** Places what originates in the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */
|
||||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
public void place(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||||
IrisComplex complex = context.getComplex();
|
IrisComplex complex = context.getComplex();
|
||||||
boolean traceRegen = isRegenTraceThread();
|
boolean traceRegen = isRegenTraceThread();
|
||||||
RNG rng = applyNoise(x, z, Cache.key(x, z) + seed());
|
RNG rng = applyNoise(x, z, Cache.key(x, z) + engine.getSeedManager().getMantle());
|
||||||
int xxx = 8 + (x << 4);
|
int xxx = 8 + (x << 4);
|
||||||
int zzz = 8 + (z << 4);
|
int zzz = 8 + (z << 4);
|
||||||
IrisRegion region = complex.getRegionStream().get(xxx, zzz);
|
IrisRegion region = complex.getRegionStream().get(xxx, zzz);
|
||||||
IrisBiome surfaceBiome = complex.getTrueBiomeStream().get(xxx, zzz);
|
IrisBiome surfaceBiome = complex.getTrueBiomeStream().get(xxx, zzz);
|
||||||
int surfaceY = getEngineMantle().getEngine().getHeight(xxx, zzz, true);
|
int surfaceY = engine.getHeight(xxx, zzz, true);
|
||||||
IrisBiome caveBiome = resolveCaveObjectBiome(xxx, zzz, surfaceY, surfaceBiome);
|
IrisBiome caveBiome = resolveCaveObjectBiome(xxx, zzz, surfaceY, surfaceBiome);
|
||||||
if (IrisSettings.get().getGeneral().isDebug() && (x & 31) == 0 && (z & 31) == 0) {
|
if (IrisSettings.get().getGeneral().isDebug() && (x & 31) == 0 && (z & 31) == 0) {
|
||||||
int carvedBlocks = 0;
|
int carvedBlocks = 0;
|
||||||
int minY = 1;
|
int minY = 1;
|
||||||
int maxY = Math.min(getEngineMantle().getEngine().getHeight() - 1, surfaceY - 14);
|
int maxY = Math.min(engine.getHeight() - 1, surfaceY - 14);
|
||||||
for (int sy = minY; sy < maxY; sy++) {
|
for (int sy = minY; sy < maxY; sy++) {
|
||||||
if (writer.isCarved(8 + (x << 4), sy, 8 + (z << 4))) {
|
if (writer.isCarved(8 + (x << 4), sy, 8 + (z << 4))) {
|
||||||
carvedBlocks++;
|
carvedBlocks++;
|
||||||
@@ -153,8 +156,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
}
|
}
|
||||||
ObjectPlacementSummary summary = placeObjects(writer, rng, x, z, surfaceBiome, caveBiome, region, complex, traceRegen);
|
ObjectPlacementSummary summary = placeObjects(writer, rng, x, z, surfaceBiome, caveBiome, region, complex, traceRegen);
|
||||||
placeProceduralObjects(writer, rng, x, z, surfaceBiome, caveBiome, region);
|
placeProceduralObjects(writer, rng, x, z, surfaceBiome, caveBiome, region);
|
||||||
UpperDimensionContext upperCtx = getEngineMantle().getEngine().getUpperContext();
|
UpperDimensionContext upperCtx = engine.getUpperContext();
|
||||||
IrisDimension dimension = getDimension();
|
IrisDimension dimension = engine.getDimension();
|
||||||
if (upperCtx != null && dimension.isUpperDimensionObjects()) {
|
if (upperCtx != null && dimension.isUpperDimensionObjects()) {
|
||||||
placeUpperObjects(writer, rng, x, z, xxx, zzz, surfaceY, upperCtx, dimension, complex, traceRegen);
|
placeUpperObjects(writer, rng, x, z, xxx, zzz, surfaceY, upperCtx, dimension, complex, traceRegen);
|
||||||
}
|
}
|
||||||
@@ -183,7 +186,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
|
|
||||||
private IrisBiome resolveCaveObjectBiome(int x, int z, int surfaceY, IrisBiome surfaceBiome) {
|
private IrisBiome resolveCaveObjectBiome(int x, int z, int surfaceY, IrisBiome surfaceBiome) {
|
||||||
int legacySampleY = Math.max(1, surfaceY - 48);
|
int legacySampleY = Math.max(1, surfaceY - 48);
|
||||||
IrisBiome legacyCaveBiome = getEngineMantle().getEngine().getCaveBiome(x, legacySampleY, z);
|
IrisBiome legacyCaveBiome = engine.getCaveBiome(x, legacySampleY, z);
|
||||||
if (legacyCaveBiome == null) {
|
if (legacyCaveBiome == null) {
|
||||||
legacyCaveBiome = surfaceBiome;
|
legacyCaveBiome = surfaceBiome;
|
||||||
}
|
}
|
||||||
@@ -192,7 +195,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
IrisBiome ladderChoice = null;
|
IrisBiome ladderChoice = null;
|
||||||
for (int sampleDepth : sampleDepths) {
|
for (int sampleDepth : sampleDepths) {
|
||||||
int sampleY = Math.max(1, surfaceY - sampleDepth);
|
int sampleY = Math.max(1, surfaceY - sampleDepth);
|
||||||
IrisBiome sampled = getEngineMantle().getEngine().getCaveBiome(x, sampleY, z);
|
IrisBiome sampled = engine.getCaveBiome(x, sampleY, z);
|
||||||
boolean sameSurface = sampled == surfaceBiome;
|
boolean sameSurface = sampled == surfaceBiome;
|
||||||
if (!sameSurface && sampled != null && surfaceBiome != null) {
|
if (!sameSurface && sampled != null && surfaceBiome != null) {
|
||||||
String sampledKey = sampled.getLoadKey();
|
String sampledKey = sampled.getLoadKey();
|
||||||
@@ -435,7 +438,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
IObjectPlacer placer = golden ? new GoldenDebugObjectPlacer(basePlacer, scope + "/" + p.getName()) : basePlacer;
|
IObjectPlacer placer = golden ? new GoldenDebugObjectPlacer(basePlacer, scope + "/" + p.getName()) : basePlacer;
|
||||||
int density = Math.max(1, p.getDensity());
|
int density = Math.max(1, p.getDensity());
|
||||||
for (int i = 0; i < density; i++) {
|
for (int i = 0; i < density; i++) {
|
||||||
IrisObject variant = p.getVariantObject(getData(), rng);
|
IrisObject variant = p.getVariantObject(engine.getData(), rng);
|
||||||
if (variant == null) {
|
if (variant == null) {
|
||||||
if (golden) {
|
if (golden) {
|
||||||
IrisLogging.debug("Goldendebug procedural pick: chunk=" + x + "," + z
|
IrisLogging.debug("Goldendebug procedural pick: chunk=" + x + "," + z
|
||||||
@@ -473,7 +476,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
int zz = caveAnchor == null ? rng.i(blockZ, blockZ + 16) : caveAnchor.z();
|
int zz = caveAnchor == null ? rng.i(blockZ, blockZ + 16) : caveAnchor.z();
|
||||||
int id = rng.i(0, Integer.MAX_VALUE);
|
int id = rng.i(0, Integer.MAX_VALUE);
|
||||||
if (golden) {
|
if (golden) {
|
||||||
KList<IrisObject> pool = p.getVariantObjects(getData());
|
KList<IrisObject> pool = p.getVariantObjects(engine.getData());
|
||||||
IrisLogging.debug("Goldendebug procedural pick: chunk=" + x + "," + z
|
IrisLogging.debug("Goldendebug procedural pick: chunk=" + x + "," + z
|
||||||
+ " placement=" + p.getName()
|
+ " placement=" + p.getName()
|
||||||
+ " densityIndex=" + i
|
+ " densityIndex=" + i
|
||||||
@@ -521,7 +524,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
if (treePlacement && marker != null) {
|
if (treePlacement && marker != null) {
|
||||||
writeTreeMaterial(placer, b.getX(), b.getY(), b.getZ(), data);
|
writeTreeMaterial(placer, b.getX(), b.getY(), b.getZ(), data);
|
||||||
}
|
}
|
||||||
}, null, getData());
|
}, null, engine.getData());
|
||||||
}
|
}
|
||||||
if (golden) {
|
if (golden) {
|
||||||
IrisLogging.debug("Goldendebug procedural result: chunk=" + x + "," + z
|
IrisLogging.debug("Goldendebug procedural result: chunk=" + x + "," + z
|
||||||
@@ -582,7 +585,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
underwater,
|
underwater,
|
||||||
writer.getDataIfPresent(candidateX, candidateY, candidateZ, MatterCavern.class),
|
writer.getDataIfPresent(candidateX, candidateY, candidateZ, MatterCavern.class),
|
||||||
candidateY,
|
candidateY,
|
||||||
getDimension().getCaveLavaHeight())) {
|
engine.getDimension().getCaveLavaHeight())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return new CavePlacementAnchor(candidateX, candidateY, candidateZ);
|
return new CavePlacementAnchor(candidateX, candidateY, candidateZ);
|
||||||
@@ -629,7 +632,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
if (placement.isDolphinTarget() && placement.isUnderwater() && B.isStorageChest(data)) {
|
if (placement.isDolphinTarget() && placement.isUnderwater() && B.isStorageChest(data)) {
|
||||||
transaction.setData(block.getX(), block.getY(), block.getZ(), MatterStructurePOI.BURIED_TREASURE);
|
transaction.setData(block.getX(), block.getY(), block.getZ(), MatterStructurePOI.BURIED_TREASURE);
|
||||||
}
|
}
|
||||||
}, null, getData());
|
}, null, engine.getData());
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
transaction.discard();
|
transaction.discard();
|
||||||
return new ContainedPlacementResult(result, CaveObjectPlacementTransaction.CommitResult.EMPTY);
|
return new ContainedPlacementResult(result, CaveObjectPlacementTransaction.CommitResult.EMPTY);
|
||||||
@@ -655,7 +658,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
int rejected = 0;
|
int rejected = 0;
|
||||||
int nullObjects = 0;
|
int nullObjects = 0;
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
int density = objectPlacement.getDensity(rng, x, z, getData());
|
int density = objectPlacement.getDensity(rng, x, z, engine.getData());
|
||||||
boolean golden = GoldenDebugObjectPlacer.isGoldenDebugChunk(chunkX, chunkZ);
|
boolean golden = GoldenDebugObjectPlacer.isGoldenDebugChunk(chunkX, chunkZ);
|
||||||
|
|
||||||
for (int i = 0; i < density; i++) {
|
for (int i = 0; i < density; i++) {
|
||||||
@@ -699,7 +702,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
if (effectivePlacement.isDolphinTarget() && effectivePlacement.isUnderwater() && B.isStorageChest(data)) {
|
if (effectivePlacement.isDolphinTarget() && effectivePlacement.isUnderwater() && B.isStorageChest(data)) {
|
||||||
writer.setData(b.getX(), b.getY(), b.getZ(), MatterStructurePOI.BURIED_TREASURE);
|
writer.setData(b.getX(), b.getY(), b.getZ(), MatterStructurePOI.BURIED_TREASURE);
|
||||||
}
|
}
|
||||||
}, null, getData());
|
}, null, engine.getData());
|
||||||
|
|
||||||
if (result >= 0) {
|
if (result >= 0) {
|
||||||
placed++;
|
placed++;
|
||||||
@@ -746,7 +749,6 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
if (expectedCaveBiomeKey == null) {
|
if (expectedCaveBiomeKey == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Engine engine = getEngineMantle().getEngine();
|
|
||||||
IrisBiome at = engine.getCaveBiome(x, y, z);
|
IrisBiome at = engine.getCaveBiome(x, y, z);
|
||||||
IrisBiome surface = engine.getSurfaceBiome(x, z);
|
IrisBiome surface = engine.getSurfaceBiome(x, z);
|
||||||
return caveAnchorBiomeConflicts(at, surface, expectedCaveBiomeKey);
|
return caveAnchorBiomeConflicts(at, surface, expectedCaveBiomeKey);
|
||||||
@@ -788,7 +790,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
int errors = 0;
|
int errors = 0;
|
||||||
int minX = chunkX << 4;
|
int minX = chunkX << 4;
|
||||||
int minZ = chunkZ << 4;
|
int minZ = chunkZ << 4;
|
||||||
int density = objectPlacement.getDensity(rng, minX, minZ, getData());
|
int density = objectPlacement.getDensity(rng, minX, minZ, engine.getData());
|
||||||
IrisCaveAnchorMode anchorMode = resolveAnchorMode(objectPlacement, caveProfile);
|
IrisCaveAnchorMode anchorMode = resolveAnchorMode(objectPlacement, caveProfile);
|
||||||
if (objectPlacement.getMode() == ObjectPlaceMode.CEILING_HANG) {
|
if (objectPlacement.getMode() == ObjectPlaceMode.CEILING_HANG) {
|
||||||
anchorMode = IrisCaveAnchorMode.CEILING;
|
anchorMode = IrisCaveAnchorMode.CEILING;
|
||||||
@@ -1025,11 +1027,11 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
boolean traceRegen,
|
boolean traceRegen,
|
||||||
String scope
|
String scope
|
||||||
) {
|
) {
|
||||||
int chunkHeight = getEngineMantle().getEngine().getHeight();
|
int chunkHeight = engine.getHeight();
|
||||||
int upperGap = dimension.getUpperDimensionGap();
|
int upperGap = dimension.getUpperDimensionGap();
|
||||||
int minX = chunkX << 4;
|
int minX = chunkX << 4;
|
||||||
int minZ = chunkZ << 4;
|
int minZ = chunkZ << 4;
|
||||||
int density = objectPlacement.getDensity(rng, minX, minZ, getData());
|
int density = objectPlacement.getDensity(rng, minX, minZ, engine.getData());
|
||||||
|
|
||||||
for (int i = 0; i < density; i++) {
|
for (int i = 0; i < density; i++) {
|
||||||
IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(complex, rng));
|
IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(complex, rng));
|
||||||
@@ -1039,7 +1041,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
|
|
||||||
int xx = rng.i(minX, minX + 16);
|
int xx = rng.i(minX, minX + 16);
|
||||||
int zz = rng.i(minZ, minZ + 16);
|
int zz = rng.i(minZ, minZ + 16);
|
||||||
int columnLowerSurfaceY = getEngineMantle().getEngine().getHeight(xx, zz, true);
|
int columnLowerSurfaceY = engine.getHeight(xx, zz, true);
|
||||||
int rawUpperSurface = upperCtx.getUpperSurfaceY(xx, zz);
|
int rawUpperSurface = upperCtx.getUpperSurfaceY(xx, zz);
|
||||||
int upperSurfaceY = Math.max(rawUpperSurface, columnLowerSurfaceY + upperGap);
|
int upperSurfaceY = Math.max(rawUpperSurface, columnLowerSurfaceY + upperGap);
|
||||||
if (upperSurfaceY >= chunkHeight - 2) {
|
if (upperSurfaceY >= chunkHeight - 2) {
|
||||||
@@ -1073,7 +1075,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
if (placement.isDolphinTarget() && placement.isUnderwater() && B.isStorageChest(data)) {
|
if (placement.isDolphinTarget() && placement.isUnderwater() && B.isStorageChest(data)) {
|
||||||
writer.setData(b.getX(), b.getY(), b.getZ(), MatterStructurePOI.BURIED_TREASURE);
|
writer.setData(b.getX(), b.getY(), b.getZ(), MatterStructurePOI.BURIED_TREASURE);
|
||||||
}
|
}
|
||||||
}, null, getData());
|
}, null, engine.getData());
|
||||||
|
|
||||||
if (traceRegen) {
|
if (traceRegen) {
|
||||||
IrisLogging.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ
|
IrisLogging.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ
|
||||||
@@ -1164,7 +1166,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
|
|
||||||
/** Dimension acts as the floor: it can force support on and widen the buffer, never weaken either. */
|
/** Dimension acts as the floor: it can force support on and widen the buffer, never weaken either. */
|
||||||
private IrisObjectPlacement applyDimensionSurfaceSupport(IrisObjectPlacement placement) {
|
private IrisObjectPlacement applyDimensionSurfaceSupport(IrisObjectPlacement placement) {
|
||||||
IrisDimension dimension = getDimension();
|
IrisDimension dimension = engine.getDimension();
|
||||||
boolean require = placement.isRequireSurfaceSupport() && dimension.isRequireObjectSurfaceSupport();
|
boolean require = placement.isRequireSurfaceSupport() && dimension.isRequireObjectSurfaceSupport();
|
||||||
int buffer = Math.max(placement.getSurfaceSupportBuffer(), dimension.getObjectSurfaceSupportBuffer());
|
int buffer = Math.max(placement.getSurfaceSupportBuffer(), dimension.getObjectSurfaceSupportBuffer());
|
||||||
if (require == placement.isRequireSurfaceSupport() && buffer == placement.getSurfaceSupportBuffer()) {
|
if (require == placement.isRequireSurfaceSupport() && buffer == placement.getSurfaceSupportBuffer()) {
|
||||||
@@ -1249,7 +1251,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private KList<Integer> scanCaveAnchorColumn(MantleWriter writer, IrisCaveAnchorMode anchorMode, int anchorScanStep, int objectMinDepthBelowSurface, int x, int z, CaveAnchorCache anchorCache) {
|
private KList<Integer> scanCaveAnchorColumn(MantleWriter writer, IrisCaveAnchorMode anchorMode, int anchorScanStep, int objectMinDepthBelowSurface, int x, int z, CaveAnchorCache anchorCache) {
|
||||||
int height = getEngineMantle().getEngine().getHeight();
|
int height = engine.getHeight();
|
||||||
int step = Math.max(1, anchorScanStep);
|
int step = Math.max(1, anchorScanStep);
|
||||||
int surfaceY = anchorCache.getSurfaceHeight(x, z);
|
int surfaceY = anchorCache.getSurfaceHeight(x, z);
|
||||||
int maxAnchorExclusive = caveAnchorScanUpperBound(height, surfaceY, objectMinDepthBelowSurface);
|
int maxAnchorExclusive = caveAnchorScanUpperBound(height, surfaceY, objectMinDepthBelowSurface);
|
||||||
@@ -1316,7 +1318,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private IrisCaveProfile resolveCaveProfile(IrisCaveProfile preferred, IrisCaveProfile secondary) {
|
private IrisCaveProfile resolveCaveProfile(IrisCaveProfile preferred, IrisCaveProfile secondary) {
|
||||||
IrisCaveProfile dimensionProfile = getDimension().getCaveProfile();
|
IrisCaveProfile dimensionProfile = engine.getDimension().getCaveProfile();
|
||||||
if (preferred != null && preferred.isEnabled()) {
|
if (preferred != null && preferred.isEnabled()) {
|
||||||
return preferred;
|
return preferred;
|
||||||
}
|
}
|
||||||
@@ -1416,8 +1418,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
private Set<String> guessPlacedKeys(RNG rng, int x, int z, IrisObjectPlacement objectPlacement) {
|
private Set<String> guessPlacedKeys(RNG rng, int x, int z, IrisObjectPlacement objectPlacement) {
|
||||||
Set<String> f = new KSet<>();
|
Set<String> f = new KSet<>();
|
||||||
for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) {
|
for (int i = 0; i < objectPlacement.getDensity(rng, x, z, engine.getData()); i++) {
|
||||||
IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(getComplex(), rng));
|
IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(engine.getComplex(), rng));
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1430,9 +1432,9 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
|
|
||||||
public Set<String> guess(int x, int z) {
|
public Set<String> guess(int x, int z) {
|
||||||
// todo The guess doesnt bring into account that the placer may return -1
|
// todo The guess doesnt bring into account that the placer may return -1
|
||||||
RNG rng = applyNoise(x, z, Cache.key(x, z) + seed());
|
RNG rng = applyNoise(x, z, Cache.key(x, z) + engine.getSeedManager().getMantle());
|
||||||
IrisBiome biome = getEngineMantle().getEngine().getSurfaceBiome((x << 4) + 8, (z << 4) + 8);
|
IrisBiome biome = engine.getSurfaceBiome((x << 4) + 8, (z << 4) + 8);
|
||||||
IrisRegion region = getEngineMantle().getEngine().getRegion((x << 4) + 8, (z << 4) + 8);
|
IrisRegion region = engine.getRegion((x << 4) + 8, (z << 4) + 8);
|
||||||
Set<String> v = new KSet<>();
|
Set<String> v = new KSet<>();
|
||||||
for (IrisObjectPlacement i : biome.getSurfaceObjects()) {
|
for (IrisObjectPlacement i : biome.getSurfaceObjects()) {
|
||||||
if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||||
@@ -1449,19 +1451,20 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int computeRadius() {
|
/** How far, in blocks along X and Z, placements may write beyond their chunk. */
|
||||||
IrisDimension dimension = getDimension();
|
public int reach() {
|
||||||
|
IrisDimension dimension = engine.getDimension();
|
||||||
KMap<String, IrisBlockVector> sizeCache = new KMap<>();
|
KMap<String, IrisBlockVector> sizeCache = new KMap<>();
|
||||||
KSet<String> warnedLargeObjects = new KSet<>();
|
KSet<String> warnedLargeObjects = new KSet<>();
|
||||||
int radius = 0;
|
int radius = 0;
|
||||||
for (IrisRegion region : dimension.getAllRegions(this::getData)) {
|
for (IrisRegion region : dimension.getAllRegions(engine)) {
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
radius = Math.max(radius, computePlacementRadius(region.getObjects(), sizeCache, warnedLargeObjects));
|
radius = Math.max(radius, computePlacementRadius(region.getObjects(), sizeCache, warnedLargeObjects));
|
||||||
radius = Math.max(radius, computeProceduralRadius(region.getProceduralObjects()));
|
radius = Math.max(radius, computeProceduralRadius(region.getProceduralObjects()));
|
||||||
}
|
}
|
||||||
for (IrisBiome biome : dimension.getReachableBiomes(this::getData)) {
|
for (IrisBiome biome : dimension.getReachableBiomes(engine)) {
|
||||||
if (biome == null) {
|
if (biome == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1510,7 +1513,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
if (placement == null) {
|
if (placement == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
KList<IrisObject> variants = placement.getVariantObjects(getData());
|
KList<IrisObject> variants = placement.getVariantObjects(engine.getData());
|
||||||
if (variants == null) {
|
if (variants == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1578,7 +1581,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
private IrisBlockVector loadObjectSize(KMap<String, IrisBlockVector> sizeCache, String objectKey) {
|
private IrisBlockVector loadObjectSize(KMap<String, IrisBlockVector> sizeCache, String objectKey) {
|
||||||
return sizeCache.computeIfAbsent(objectKey, k -> {
|
return sizeCache.computeIfAbsent(objectKey, k -> {
|
||||||
try {
|
try {
|
||||||
return IrisObject.sampleSize(getData().getObjectLoader().findFile(objectKey));
|
return IrisObject.sampleSize(engine.getData().getObjectLoader().findFile(objectKey));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
IrisLogging.reportError(e);
|
IrisLogging.reportError(e);
|
||||||
}
|
}
|
||||||
@@ -1641,7 +1644,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
return surfaceY;
|
return surfaceY;
|
||||||
}
|
}
|
||||||
|
|
||||||
surfaceY = getEngineMantle().getEngine().getHeight(x, z);
|
surfaceY = engine.getHeight(x, z);
|
||||||
surfaceHeights.put(columnKey, surfaceY);
|
surfaceHeights.put(columnKey, surfaceY);
|
||||||
return surfaceY;
|
return surfaceY;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.mantle.components;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.floating.FloatingStages;
|
||||||
|
import art.arcane.iris.builtin.objects.ObjectStages;
|
||||||
|
import art.arcane.iris.builtin.structure.StructureStages;
|
||||||
|
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||||
|
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||||
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import com.volmit.IrisModule;
|
||||||
|
import com.volmit.ModuleInfo;
|
||||||
|
import com.volmit.config.PackSettings;
|
||||||
|
import com.volmit.stage.MantleStageContext;
|
||||||
|
import com.volmit.stage.StageGraph;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module {@code iris:structure}: Iris structures, written into the mantle after objects, whose trees they clear
|
||||||
|
* where they intersect, and after floating objects. A port of what was Iris's structure mantle component, its
|
||||||
|
* work done by {@link StructurePlacing}, one per engine runtime. Its reach is the pack's largest structure.
|
||||||
|
*/
|
||||||
|
public final class StructureModule implements IrisModule {
|
||||||
|
private static final String VERSION = "built-in";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModuleInfo info() {
|
||||||
|
return ModuleInfo.of("iris:structure", "Structures", VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void install(StageGraph graph) {
|
||||||
|
graph.define(StructureStages.PLACE).requires(ObjectStages.PLACE).softAfter(FloatingStages.OBJECTS.ref())
|
||||||
|
.reach(StructureModule::reach).run(StructureModule::place);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void place(MantleStageContext context) {
|
||||||
|
IrisMantleChunk chunk = IrisMantleChunk.current();
|
||||||
|
placing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int reach(PackSettings settings) {
|
||||||
|
return placing(IrisPackSettings.of(settings).engine()).reach();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static StructurePlacing placing(Engine engine) {
|
||||||
|
return engine.getGeneration().state(StructurePlacing.class, StructurePlacing::new);
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
-33
@@ -27,9 +27,7 @@ import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
|||||||
import art.arcane.iris.engine.framework.StructurePlacementScope;
|
import art.arcane.iris.engine.framework.StructurePlacementScope;
|
||||||
import art.arcane.iris.engine.framework.StructurePlacementMarker;
|
import art.arcane.iris.engine.framework.StructurePlacementMarker;
|
||||||
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
||||||
import art.arcane.iris.engine.mantle.ComponentFlag;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
|
||||||
import art.arcane.iris.engine.mantle.IrisMantleComponent;
|
|
||||||
import art.arcane.iris.engine.mantle.MantleWriter;
|
import art.arcane.iris.engine.mantle.MantleWriter;
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
@@ -56,7 +54,6 @@ import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
|||||||
import art.arcane.volmlib.util.matter.Matter;
|
import art.arcane.volmlib.util.matter.Matter;
|
||||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||||
import art.arcane.volmlib.util.matter.MatterStructurePOI;
|
import art.arcane.volmlib.util.matter.MatterStructurePOI;
|
||||||
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||||
@@ -65,19 +62,25 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ComponentFlag(ReservedFlag.JIGSAW)
|
/**
|
||||||
public class IrisStructureComponent extends IrisMantleComponent {
|
* Places the Iris structures of the dimension, its regions and biomes into the mantle for
|
||||||
|
* {@link StructureModule}: their pieces, foundations, bores and carves, clearing object trees they
|
||||||
|
* intersect. One per engine runtime. Its reach is the largest structure any placement can produce.
|
||||||
|
*/
|
||||||
|
public class StructurePlacing {
|
||||||
private static final MatterCavern CARVE_CAVERN = new MatterCavern(true, "", (byte) 3);
|
private static final MatterCavern CARVE_CAVERN = new MatterCavern(true, "", (byte) 3);
|
||||||
|
|
||||||
public IrisStructureComponent(EngineMantle engineMantle) {
|
private final Engine engine;
|
||||||
super(engineMantle, ReservedFlag.JIGSAW, 3);
|
|
||||||
|
public StructurePlacing(Engine engine) {
|
||||||
|
this.engine = engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/** Places what originates in the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */
|
||||||
@ChunkCoordinates
|
@ChunkCoordinates
|
||||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
public void place(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||||
for (IrisStructurePlacement placement : StructurePlacementScope.placementsAt(
|
for (IrisStructurePlacement placement : StructurePlacementScope.placementsAt(
|
||||||
getEngineMantle().getEngine(), x, z)) {
|
engine, x, z)) {
|
||||||
if (!placement.hasIrisStructures()) {
|
if (!placement.hasIrisStructures()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -88,7 +91,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
@ChunkCoordinates
|
@ChunkCoordinates
|
||||||
private void placeFromPlacement(MantleWriter writer, IrisStructurePlacement placement, int cx, int cz) {
|
private void placeFromPlacement(MantleWriter writer, IrisStructurePlacement placement, int cx, int cz) {
|
||||||
IrisStructureLocator.ResolvedPlacement resolved = IrisStructureLocator.resolvePlacement(
|
IrisStructureLocator.ResolvedPlacement resolved = IrisStructureLocator.resolvePlacement(
|
||||||
getEngineMantle().getEngine(), placement, cx, cz);
|
engine, placement, cx, cz);
|
||||||
if (resolved == null) {
|
if (resolved == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -173,7 +176,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
boolean surfaceStructure) {
|
boolean surfaceStructure) {
|
||||||
IrisMaterialPalette palette = Objects.requireNonNull(
|
IrisMaterialPalette palette = Objects.requireNonNull(
|
||||||
settings.getPalette(), "Structure stilt palette must not be null");
|
settings.getPalette(), "Structure stilt palette must not be null");
|
||||||
int mantleOffset = getEngineMantle().getEngine().getMinHeight();
|
int mantleOffset = engine.getMinHeight();
|
||||||
int maxDepth = Math.max(1, settings.getMaxDepth());
|
int maxDepth = Math.max(1, settings.getMaxDepth());
|
||||||
for (Long2IntMap.Entry column : columns.long2IntEntrySet()) {
|
for (Long2IntMap.Entry column : columns.long2IntEntrySet()) {
|
||||||
int worldX = StructureFoundationPlanner.unpackX(column.getLongKey());
|
int worldX = StructureFoundationPlanner.unpackX(column.getLongKey());
|
||||||
@@ -184,7 +187,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
if (foundationState == null || !foundationState.isSolid()) {
|
if (foundationState == null || !foundationState.isSolid()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int terrainHeight = getEngineMantle().trueHeight(worldX, worldZ);
|
int terrainHeight = engine.getMantle().trueHeight(worldX, worldZ);
|
||||||
int groundY = StructureFoundationPlanner.findGroundY(
|
int groundY = StructureFoundationPlanner.findGroundY(
|
||||||
foundationY, maxDepth, 0,
|
foundationY, maxDepth, 0,
|
||||||
y -> {
|
y -> {
|
||||||
@@ -203,7 +206,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
}
|
}
|
||||||
StructureFoundationPlanner.fillSupportColumn(foundationY, groundY, y -> {
|
StructureFoundationPlanner.fillSupportColumn(foundationY, groundY, y -> {
|
||||||
writeFoundationSupport(
|
writeFoundationSupport(
|
||||||
writer, palette, rng, getData(), worldX, y, worldZ, mantleOffset);
|
writer, palette, rng, engine.getData(), worldX, y, worldZ, mantleOffset);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,14 +262,14 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
int maxX = bounds[3] + pad;
|
int maxX = bounds[3] + pad;
|
||||||
int maxY = bounds[4] + Math.max(0, terrain.getCeilingPadding());
|
int maxY = bounds[4] + Math.max(0, terrain.getCeilingPadding());
|
||||||
int maxZ = bounds[5] + pad;
|
int maxZ = bounds[5] + pad;
|
||||||
int worldMin = getEngineMantle().getEngine().getMinHeight() + 1;
|
int worldMin = engine.getMinHeight() + 1;
|
||||||
int worldMax = getEngineMantle().getEngine().getMinHeight() + getEngineMantle().getEngine().getHeight() - 1;
|
int worldMax = engine.getMinHeight() + engine.getHeight() - 1;
|
||||||
minY = Math.max(minY, worldMin);
|
minY = Math.max(minY, worldMin);
|
||||||
maxY = Math.min(maxY, worldMax);
|
maxY = Math.min(maxY, worldMax);
|
||||||
if (maxX < minX || maxY < minY || maxZ < minZ) {
|
if (maxX < minX || maxY < minY || maxZ < minZ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int mantleOffset = getEngineMantle().getEngine().getMinHeight();
|
int mantleOffset = engine.getMinHeight();
|
||||||
for (int bx = minX; bx <= maxX; bx++) {
|
for (int bx = minX; bx <= maxX; bx++) {
|
||||||
for (int by = minY; by <= maxY; by++) {
|
for (int by = minY; by <= maxY; by++) {
|
||||||
for (int bz = minZ; bz <= maxZ; bz++) {
|
for (int bz = minZ; bz <= maxZ; bz++) {
|
||||||
@@ -287,9 +290,9 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
int head = Math.max(0, terrain.getCeilingPadding());
|
int head = Math.max(0, terrain.getCeilingPadding());
|
||||||
int floorCut = Math.max(0, terrain.getFloorPadding());
|
int floorCut = Math.max(0, terrain.getFloorPadding());
|
||||||
double strength = terrain.resolvedErosionStrength();
|
double strength = terrain.resolvedErosionStrength();
|
||||||
int mantleOffset = getEngineMantle().getEngine().getMinHeight();
|
int mantleOffset = engine.getMinHeight();
|
||||||
int worldMin = getEngineMantle().getEngine().getMinHeight() + 1;
|
int worldMin = engine.getMinHeight() + 1;
|
||||||
int worldMax = getEngineMantle().getEngine().getMinHeight() + getEngineMantle().getEngine().getHeight() - 1;
|
int worldMax = engine.getMinHeight() + engine.getHeight() - 1;
|
||||||
int upExtension = shape.maximumCeilingExtension(head, strength);
|
int upExtension = shape.maximumCeilingExtension(head, strength);
|
||||||
|
|
||||||
if (shape == IrisStructureCarveShape.BOX) {
|
if (shape == IrisStructureCarveShape.BOX) {
|
||||||
@@ -309,7 +312,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
CNG blob = null;
|
CNG blob = null;
|
||||||
CNG roll = null;
|
CNG roll = null;
|
||||||
if (eroded) {
|
if (eroded) {
|
||||||
RNG noiseRng = new RNG(seed() + Cache.key(bounds[0], bounds[2]));
|
RNG noiseRng = new RNG(engine.getSeedManager().getMantle() + Cache.key(bounds[0], bounds[2]));
|
||||||
blob = CNG.signature(noiseRng);
|
blob = CNG.signature(noiseRng);
|
||||||
roll = CNG.signature(noiseRng.nextParallelRNG(0x2A17));
|
roll = CNG.signature(noiseRng.nextParallelRNG(0x2A17));
|
||||||
}
|
}
|
||||||
@@ -404,8 +407,8 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void clearIntersectingObjectTrees(MantleWriter writer, IrisStructureLocator.ResolvedPlacement resolved) {
|
private void clearIntersectingObjectTrees(MantleWriter writer, IrisStructureLocator.ResolvedPlacement resolved) {
|
||||||
int mantleOffset = getEngineMantle().getEngine().getMinHeight();
|
int mantleOffset = engine.getMinHeight();
|
||||||
int worldHeight = getEngineMantle().getEngine().getHeight();
|
int worldHeight = engine.getHeight();
|
||||||
Map<String, ObjectMarkerBounds> intersectingObjects = new HashMap<>();
|
Map<String, ObjectMarkerBounds> intersectingObjects = new HashMap<>();
|
||||||
for (PlacedStructurePiece piece : resolved.pieces()) {
|
for (PlacedStructurePiece piece : resolved.pieces()) {
|
||||||
for (IrisBlockVector local : piece.getObject().getBlocks().keys()) {
|
for (IrisBlockVector local : piece.getObject().getBlocks().keys()) {
|
||||||
@@ -450,7 +453,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
if (decoded == null) {
|
if (decoded == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IrisObject object = getData().load(IrisObject.class, decoded.objectKey(), false);
|
IrisObject object = engine.getData().load(IrisObject.class, decoded.objectKey(), false);
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -543,7 +546,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
|
if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
|
||||||
config.setForcePlace(true);
|
config.setForcePlace(true);
|
||||||
}
|
}
|
||||||
int placeY = (y == -1) ? -1 : y - getEngineMantle().getEngine().getMinHeight();
|
int placeY = (y == -1) ? -1 : y - engine.getMinHeight();
|
||||||
String marker = structurePlacementMarker(structure, p, objectKey);
|
String marker = structurePlacementMarker(structure, p, objectKey);
|
||||||
return object.place(p.getX(), placeY, p.getZ(), writer, config, rng, (position, state) -> {
|
return object.place(p.getX(), placeY, p.getZ(), writer, config, rng, (position, state) -> {
|
||||||
StructureFoundationPlanner.recordBaseCell(
|
StructureFoundationPlanner.recordBaseCell(
|
||||||
@@ -552,7 +555,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
if (marker != null && shouldWriteStructureMarker(state)) {
|
if (marker != null && shouldWriteStructureMarker(state)) {
|
||||||
writer.setData(position.getX(), position.getY(), position.getZ(), marker);
|
writer.setData(position.getX(), position.getY(), position.getZ(), marker);
|
||||||
}
|
}
|
||||||
}, null, getData());
|
}, null, engine.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean shouldWriteStructureMarker(PlatformBlockState state) {
|
static boolean shouldWriteStructureMarker(PlatformBlockState state) {
|
||||||
@@ -578,15 +581,15 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
return StructurePlacementMarker.encodeStructure(objectKey, placementId, structureKey);
|
return StructurePlacementMarker.encodeStructure(objectKey, placementId, structureKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/** How far, in blocks along X and Z, placements may write beyond their chunk. */
|
||||||
protected int computeRadius() {
|
public int reach() {
|
||||||
IrisDimension dimension = getDimension();
|
IrisDimension dimension = engine.getDimension();
|
||||||
int maxBlocks = 0;
|
int maxBlocks = 0;
|
||||||
|
|
||||||
for (IrisRegion region : dimension.getAllRegions(this::getData)) {
|
for (IrisRegion region : dimension.getAllRegions(engine)) {
|
||||||
maxBlocks = Math.max(maxBlocks, maxBlocksFrom(region.getStructures()));
|
maxBlocks = Math.max(maxBlocks, maxBlocksFrom(region.getStructures()));
|
||||||
}
|
}
|
||||||
for (IrisBiome biome : dimension.getReachableBiomes(this::getData)) {
|
for (IrisBiome biome : dimension.getReachableBiomes(engine)) {
|
||||||
maxBlocks = Math.max(maxBlocks, maxBlocksFrom(biome.getStructures()));
|
maxBlocks = Math.max(maxBlocks, maxBlocksFrom(biome.getStructures()));
|
||||||
}
|
}
|
||||||
maxBlocks = Math.max(maxBlocks, maxBlocksFrom(dimension.getStructures()));
|
maxBlocks = Math.max(maxBlocks, maxBlocksFrom(dimension.getStructures()));
|
||||||
@@ -605,7 +608,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
|||||||
|| terrain.resolvedMode() == IrisStructureTerrainMode.BORE
|
|| terrain.resolvedMode() == IrisStructureTerrainMode.BORE
|
||||||
? Math.max(0, terrain.getHorizontalPadding()) : 0;
|
? Math.max(0, terrain.getHorizontalPadding()) : 0;
|
||||||
for (String key : placement.getStructures()) {
|
for (String key : placement.getStructures()) {
|
||||||
IrisStructure structure = getData().load(IrisStructure.class, key, false);
|
IrisStructure structure = engine.getData().load(IrisStructure.class, key, false);
|
||||||
if (structure != null) {
|
if (structure != null) {
|
||||||
max = Math.max(max, Math.max(1, structure.getMaxSizeChunks()) * 16 + carvePadding);
|
max = Math.max(max, Math.max(1, structure.getMaxSizeChunks()) * 16 + carvePadding);
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,6 @@ import art.arcane.iris.core.modules.IrisChunk;
|
|||||||
import art.arcane.iris.core.modules.IrisMantleChunk;
|
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||||
import art.arcane.iris.engine.mantle.components.CaveCarving;
|
import art.arcane.iris.engine.mantle.components.CaveCarving;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
|
||||||
import com.volmit.IrisModule;
|
import com.volmit.IrisModule;
|
||||||
import com.volmit.ModuleInfo;
|
import com.volmit.ModuleInfo;
|
||||||
import com.volmit.stage.ChunkStageContext;
|
import com.volmit.stage.ChunkStageContext;
|
||||||
@@ -71,8 +70,11 @@ public final class CarveModule implements IrisModule {
|
|||||||
chunk.blocks(), chunk.multicore(), chunk.context());
|
chunk.blocks(), chunk.multicore(), chunk.context());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A dimension turns carving off with {@code carvingEnabled}, or by listing {@code CARVED} in {@code disabledComponents}. */
|
/**
|
||||||
|
* A dimension turns carving off with {@code carvingEnabled}. Listing {@code CARVED} in {@code disabledComponents}
|
||||||
|
* also does: Iris then skips this stage's mantle pass like any disabled component.
|
||||||
|
*/
|
||||||
private static boolean carves(IrisDimension dimension) {
|
private static boolean carves(IrisDimension dimension) {
|
||||||
return dimension.isCarvingEnabled() && !dimension.getDisabledComponents().contains(ReservedFlag.CARVED);
|
return dimension.isCarvingEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,17 +20,26 @@ package art.arcane.iris.engine.modifier;
|
|||||||
|
|
||||||
import art.arcane.iris.builtin.decorant.DecorantStages;
|
import art.arcane.iris.builtin.decorant.DecorantStages;
|
||||||
import art.arcane.iris.builtin.floating.FloatingStages;
|
import art.arcane.iris.builtin.floating.FloatingStages;
|
||||||
|
import art.arcane.iris.builtin.objects.ObjectStages;
|
||||||
import art.arcane.iris.builtin.post.PostStages;
|
import art.arcane.iris.builtin.post.PostStages;
|
||||||
import art.arcane.iris.core.modules.IrisChunk;
|
import art.arcane.iris.core.modules.IrisChunk;
|
||||||
|
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||||
|
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||||
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import art.arcane.iris.engine.mantle.components.FloatingObjectPlacing;
|
||||||
import com.volmit.IrisModule;
|
import com.volmit.IrisModule;
|
||||||
import com.volmit.ModuleInfo;
|
import com.volmit.ModuleInfo;
|
||||||
|
import com.volmit.config.PackSettings;
|
||||||
import com.volmit.stage.ChunkStageContext;
|
import com.volmit.stage.ChunkStageContext;
|
||||||
|
import com.volmit.stage.MantleStageContext;
|
||||||
import com.volmit.stage.StageGraph;
|
import com.volmit.stage.StageGraph;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module {@code iris:floating}: the islands of floating child biomes, their solids after smoothing and their
|
* Module {@code iris:floating}: the islands of floating child biomes, their objects in the mantle after the
|
||||||
* decoration after the chunk's own. A thin wrapper: both stages run {@link IrisFloatingChildBiomeModifier}
|
* dimension's other objects, their solids after smoothing and their decoration after the chunk's own. The
|
||||||
* unchanged, one per engine runtime.
|
* mantle stage is a port of what was Iris's floating object mantle component, its work done by
|
||||||
|
* {@link FloatingObjectPlacing}, whose reach is the pack's largest floating object placement. The chunk
|
||||||
|
* stages are a thin wrapper: both run {@link IrisFloatingChildBiomeModifier} unchanged, one per engine runtime.
|
||||||
*/
|
*/
|
||||||
public final class FloatingModule implements IrisModule {
|
public final class FloatingModule implements IrisModule {
|
||||||
private static final String VERSION = "built-in";
|
private static final String VERSION = "built-in";
|
||||||
@@ -42,10 +51,21 @@ public final class FloatingModule implements IrisModule {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void install(StageGraph graph) {
|
public void install(StageGraph graph) {
|
||||||
|
graph.define(FloatingStages.OBJECTS).softAfter(ObjectStages.PLACE.ref()).reach(FloatingModule::objectReach)
|
||||||
|
.run(FloatingModule::objects);
|
||||||
graph.define(FloatingStages.SOLIDS).requires(PostStages.SMOOTH).run(FloatingModule::solids);
|
graph.define(FloatingStages.SOLIDS).requires(PostStages.SMOOTH).run(FloatingModule::solids);
|
||||||
graph.define(FloatingStages.DECORATE).requires(DecorantStages.DECORATE).run(FloatingModule::decorate);
|
graph.define(FloatingStages.DECORATE).requires(DecorantStages.DECORATE).run(FloatingModule::decorate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void objects(MantleStageContext context) {
|
||||||
|
IrisMantleChunk chunk = IrisMantleChunk.current();
|
||||||
|
objectPlacing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int objectReach(PackSettings settings) {
|
||||||
|
return objectPlacing(IrisPackSettings.of(settings).engine()).reach();
|
||||||
|
}
|
||||||
|
|
||||||
private static void solids(ChunkStageContext context) {
|
private static void solids(ChunkStageContext context) {
|
||||||
IrisChunk chunk = IrisChunk.current();
|
IrisChunk chunk = IrisChunk.current();
|
||||||
islands(chunk).modify(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context());
|
islands(chunk).modify(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context());
|
||||||
@@ -56,6 +76,10 @@ public final class FloatingModule implements IrisModule {
|
|||||||
islands(chunk).decorateColumns(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context());
|
islands(chunk).decorateColumns(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static FloatingObjectPlacing objectPlacing(Engine engine) {
|
||||||
|
return engine.getGeneration().state(FloatingObjectPlacing.class, FloatingObjectPlacing::new);
|
||||||
|
}
|
||||||
|
|
||||||
private static IrisFloatingChildBiomeModifier islands(IrisChunk chunk) {
|
private static IrisFloatingChildBiomeModifier islands(IrisChunk chunk) {
|
||||||
return chunk.state(IrisFloatingChildBiomeModifier.class, IrisFloatingChildBiomeModifier::new);
|
return chunk.state(IrisFloatingChildBiomeModifier.class, IrisFloatingChildBiomeModifier::new);
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-20
@@ -1,17 +1,16 @@
|
|||||||
package art.arcane.iris.engine.object.annotations.functions;
|
package art.arcane.iris.engine.object.annotations.functions;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.core.modules.MantleStageFlags;
|
||||||
import art.arcane.iris.engine.framework.ListFunction;
|
import art.arcane.iris.engine.framework.ListFunction;
|
||||||
import art.arcane.iris.engine.mantle.ComponentFlag;
|
|
||||||
import art.arcane.iris.engine.mantle.MantleComponent;
|
|
||||||
import art.arcane.iris.spi.IrisPlatforms;
|
|
||||||
import art.arcane.iris.util.common.scheduling.J;
|
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.io.JarScanner;
|
|
||||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||||
|
|
||||||
import java.util.Objects;
|
/**
|
||||||
|
* What studio offers for a dimension's {@code disabledComponents}: the flags of Iris's own mantle stages, such as
|
||||||
|
* {@code CARVED} for caves. Pack mantle stages are left out: their flags follow their position in the pack's
|
||||||
|
* stage order, so a name written today could disable another stage once the pack changes.
|
||||||
|
*/
|
||||||
public class ComponentFlagFunction implements ListFunction<KList<String>> {
|
public class ComponentFlagFunction implements ListFunction<KList<String>> {
|
||||||
@Override
|
@Override
|
||||||
public String key() {
|
public String key() {
|
||||||
@@ -25,18 +24,6 @@ public class ComponentFlagFunction implements ListFunction<KList<String>> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KList<String> apply(IrisData data) {
|
public KList<String> apply(IrisData data) {
|
||||||
var engine = data.getEngine();
|
return MantleStageFlags.builtIn().stream().map(MantleFlag::toString).collect(KList.collector());
|
||||||
if (engine != null) return engine.getMantle().getComponentFlags().toStringList();
|
|
||||||
JarScanner scanner = new JarScanner(IrisPlatforms.get().pluginJar(), "art.arcane.iris.engine.mantle.components");
|
|
||||||
J.attempt(scanner::scan);
|
|
||||||
return scanner.getClasses()
|
|
||||||
.stream()
|
|
||||||
.filter(c -> c.isAnnotationPresent(ComponentFlag.class))
|
|
||||||
.filter(MantleComponent.class::isAssignableFrom)
|
|
||||||
.map(c -> c.getDeclaredAnnotation(ComponentFlag.class))
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.map(ComponentFlag::value)
|
|
||||||
.map(MantleFlag::toString)
|
|
||||||
.collect(KList.collector());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user