Files
Iris/src/main/java/com/volmit/host/ChunkSettings.java
T
piexel 50f51db8b2 Run each mantle stage as its own pass and let mantle stages work out their reach per pack
MantleRunner.generate(stage, inputs, seed) runs one mantle stage for one chunk. The host runs every
mantle stage as its own pass in resolved order, so a stage sees what earlier stages wrote into the
chunks around it. Activation still follows requires(...): the runner collects the settings of the stage
and of everything it requires, and only those. Because the stages of one chunk now run in different
invocations, mantle stages have no output (Stage.mantle declares Void) and pass data on through
mantle layers.

A mantle stage whose reach depends on the pack declares reach(PackReach). The host works it out once
per pack load from PackSettings, every entry the dimension and its regions and biomes declare, with
ResolvedStage.reachBlocks(settings); a negative result fails naming the stage. Placement and chunk
stages may not declare one, and ResolvedGraph.reach() throws for a mantle pipeline that has one.
VeinModule now sizes its reach from the pack's longest vein.
2026-10-08 12:35:04 +02:00

53 lines
2.2 KiB
Java

package com.volmit.host;
import com.volmit.FeatureAttachment;
import com.volmit.IrisFeature;
import com.volmit.config.FeatureSettings;
import com.volmit.config.FeatureSettings.Entry;
import com.volmit.resource.ResourceId;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.function.Supplier;
/** The settings one chunk's stages see: for every settings type the running stages condition on, each
* distinct entry of the chunk's 16 by 16 columns. A stage is therefore active when any column of the chunk
* configures its settings, also where a biome border crosses the chunk. Entries are distinct by level
* and source and keep the order their first column was read in, columns by X and then Z.
*/
final class ChunkSettings {
/** The chunk's width along X and Z, in blocks: the footprint of chunk and mantle stages. */
static final int CHUNK_WIDTH = 16;
private ChunkSettings() {}
/** {@code settings} is asked only when {@code types} is not empty. */
static ConfiguredSettings collect(List<Class<?>> types, Supplier<FeatureSettings> settings, int originX, int originZ) {
if (types.isEmpty()) {
return ConfiguredSettings.none();
}
var view = settings.get();
var entries = new ArrayList<Entry<?>>();
for (var type : types) {
entries.addAll(distinctEntries(type.asSubclass(IrisFeature.class), view, originX, originZ));
}
return ConfiguredSettings.of(entries);
}
private static Collection<Entry<?>> distinctEntries(
Class<? extends IrisFeature> type, FeatureSettings view, int originX, int originZ) {
var distinct = new LinkedHashMap<Declaration, Entry<?>>();
for (int x = 0; x < CHUNK_WIDTH; x++) {
for (int z = 0; z < CHUNK_WIDTH; z++) {
for (var entry : view.at(type, originX + x, originZ + z)) {
distinct.putIfAbsent(new Declaration(entry.level(), entry.source()), entry);
}
}
}
return distinct.values();
}
private record Declaration(FeatureAttachment.Target level, ResourceId source) {}
}