mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
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.
This commit is contained in:
1 parent
97ac2a2982
commit
50f51db8b2
25 files changed
+410
-89
No files matched your search
@@ -0,0 +1,19 @@
|
||||
package com.volmit.config;
|
||||
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import java.util.List;
|
||||
|
||||
/** Every settings declaration of the pack the host is loading, for what depends on the whole pack rather
|
||||
* than one column, such as how far a mantle stage reaches ({@link com.volmit.stage.PackReach}).
|
||||
*
|
||||
* <p>The levels are those chunk and mantle stages see: the dimension being generated, and every region
|
||||
* and biome it can reach. Placements are not a level here. Values must be treated as read-only and not
|
||||
* retained.
|
||||
*/
|
||||
public interface PackSettings {
|
||||
/** Every entry of {@code featureType} the pack declares, dimension first, then regions, then biomes;
|
||||
* empty when nothing declares it.
|
||||
*/
|
||||
<F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType);
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public final class ChunkRunner {
|
||||
if (graph.size() == 0) {
|
||||
return;
|
||||
}
|
||||
var settings = ChunkSettings.collect(graph, inputs::settings, inputs.originX(), inputs.originZ());
|
||||
var settings = ChunkSettings.collect(graph.settingsTypes(), inputs::settings, inputs.originX(), inputs.originZ());
|
||||
var chunk = new ChunkInvocation(new StageInvocation(graph, invocationSeed, settings), inputs);
|
||||
for (int position = 0; position < graph.size(); position++) {
|
||||
chunk.stages().runInvocationStage(position, chunk);
|
||||
|
||||
@@ -8,10 +8,11 @@ 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 graph conditions on, each distinct
|
||||
* entry of the chunk's 16 by 16 columns. A stage is therefore active when any column of the chunk
|
||||
/** 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.
|
||||
*/
|
||||
@@ -21,14 +22,14 @@ final class ChunkSettings {
|
||||
|
||||
private ChunkSettings() {}
|
||||
|
||||
/** {@code settings} is asked only when the graph conditions a stage on settings. */
|
||||
static ConfiguredSettings collect(ResolvedGraph graph, Supplier<FeatureSettings> settings, int originX, int originZ) {
|
||||
if (graph.settingsTypes().isEmpty()) {
|
||||
/** {@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 : graph.settingsTypes()) {
|
||||
for (var type : types) {
|
||||
entries.addAll(distinctEntries(type.asSubclass(IrisFeature.class), view, originX, originZ));
|
||||
}
|
||||
return ConfiguredSettings.of(entries);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.stage.PackReach;
|
||||
|
||||
/** A reach declared as a number at install, the same for every pack. */
|
||||
record FixedReach(int blocks) implements PackReach {
|
||||
static final FixedReach NONE = new FixedReach(0);
|
||||
|
||||
FixedReach {
|
||||
if (blocks < 0) throw new IllegalArgumentException("Negative reach: " + blocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int blocks(PackSettings settings) {
|
||||
return blocks;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.volmit.host;
|
||||
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.PackReach;
|
||||
import com.volmit.stage.StageKind;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -47,13 +48,20 @@ final class GraphDescription {
|
||||
if (reach.equals(StageReach.NONE)) {
|
||||
return;
|
||||
}
|
||||
text.append(DETAIL_INDENT).append("reach ").append(reach.blocks()).append(reach.blocks() == 1 ? " block" : " blocks");
|
||||
text.append(DETAIL_INDENT).append("reach ").append(reachText(reach.blocks()));
|
||||
if (!reach.mantleLayers().isEmpty()) {
|
||||
text.append(", writes mantle ").append(joined(reach.mantleLayers().stream().map(MantleKey::id).toList()));
|
||||
}
|
||||
text.append('\n');
|
||||
}
|
||||
|
||||
private static String reachText(PackReach reach) {
|
||||
if (!(reach instanceof FixedReach fixed)) {
|
||||
return "worked out when the pack loads";
|
||||
}
|
||||
return fixed.blocks() + (fixed.blocks() == 1 ? " block" : " blocks");
|
||||
}
|
||||
|
||||
private static String kindLabel(ResolvedStage stage, List<List<ResourceId>> passes) {
|
||||
if (stage.stage().kind() == StageKind.INVOCATION) {
|
||||
return "invocation";
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.volmit.host;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.stage.ConditionalStageDefinition;
|
||||
import com.volmit.stage.PackReach;
|
||||
import com.volmit.stage.SettingsAction;
|
||||
import com.volmit.stage.SettingsFunction;
|
||||
import com.volmit.stage.Stage;
|
||||
@@ -46,6 +47,12 @@ final class InvocationStageDraft<C extends StageContext, S extends IrisFeature,
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvocationStageDraft<C, S, O> reach(PackReach reach) {
|
||||
declaration.reach(reach);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvocationStageDraft<C, S, O> writesMantle(MantleKey<?>... layers) {
|
||||
declaration.writesMantle(layers);
|
||||
|
||||
@@ -2,35 +2,75 @@ package com.volmit.host;
|
||||
|
||||
import com.volmit.generation.MantleGenerationContext;
|
||||
import com.volmit.stage.Pipeline;
|
||||
import com.volmit.stage.Stage;
|
||||
import java.util.BitSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/** Reference executor of a resolved mantle graph: active stages run once per chunk, in resolved order.
|
||||
* The host runs it for every chunk within the pipeline's reach of a chunk before that chunk generates,
|
||||
* each chunk once, and gives it the mantle around the chunk as far as that reach. It does not roll back
|
||||
* mantle writes; a failed invocation must stop the host from generating the chunks it reaches.
|
||||
/** Reference executor of a resolved mantle graph, one stage at a time. Every mantle stage is its own pass:
|
||||
* the host runs a stage for every chunk within that stage's reach plus the reach of every later stage of
|
||||
* a chunk, each chunk once, before the next stage starts, and before that chunk generates. Each call gives
|
||||
* the stage the mantle around one chunk as far as the stage's own reach. It does not roll back mantle
|
||||
* writes; a failed invocation must stop the host from generating the chunks it reaches.
|
||||
*/
|
||||
public final class MantleRunner {
|
||||
private final ResolvedGraph graph;
|
||||
private final Map<Stage<?>, Integer> positions = new IdentityHashMap<>();
|
||||
private final List<List<Class<?>>> activationSettings;
|
||||
|
||||
public MantleRunner(ResolvedGraph graph) {
|
||||
this.graph = Objects.requireNonNull(graph, "graph");
|
||||
if (graph.pipeline() != Pipeline.MANTLE) {
|
||||
throw new IllegalArgumentException("Expected a mantle graph, got " + graph.pipeline());
|
||||
}
|
||||
for (int position = 0; position < graph.size(); position++) {
|
||||
positions.put(graph.executable(position).stage(), position);
|
||||
}
|
||||
activationSettings = activationSettings(graph);
|
||||
}
|
||||
|
||||
/** Runs the mantle stages of one chunk. A conditional stage is active when any of the chunk's
|
||||
* 16 by 16 columns has an entry of its settings, and receives every distinct entry of those columns.
|
||||
* The host derives {@code invocationSeed} from the world seed and the chunk position.
|
||||
/** Runs {@code stage} for one chunk, if it is active there. A conditional stage is active when any of
|
||||
* the chunk's 16 by 16 columns has an entry of its settings, and receives every distinct entry of those
|
||||
* columns; it is inactive wherever a stage it requires is. The host derives {@code invocationSeed} from
|
||||
* the world seed and the chunk position; each stage draws from its own stream of it.
|
||||
*/
|
||||
public void generate(MantleGenerationContext inputs, long invocationSeed) {
|
||||
if (graph.size() == 0) {
|
||||
return;
|
||||
}
|
||||
var settings = ChunkSettings.collect(graph, inputs::settings, inputs.originX(), inputs.originZ());
|
||||
public void generate(Stage<?> stage, MantleGenerationContext inputs, long invocationSeed) {
|
||||
int position = position(stage);
|
||||
var settings = ChunkSettings.collect(activationSettings.get(position), inputs::settings, inputs.originX(), inputs.originZ());
|
||||
var mantle = new MantleInvocation(new StageInvocation(graph, invocationSeed, settings), inputs);
|
||||
for (int position = 0; position < graph.size(); position++) {
|
||||
mantle.stages().runInvocationStage(position, mantle);
|
||||
mantle.stages().runInvocationStage(position, mantle);
|
||||
}
|
||||
|
||||
private int position(Stage<?> stage) {
|
||||
Integer position = positions.get(Objects.requireNonNull(stage, "stage"));
|
||||
if (position == null) {
|
||||
throw new IllegalArgumentException("Stage " + stage + " is not a stage of this mantle graph");
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
/** Per position, the settings types that decide whether the stage is active: its own and those of every
|
||||
* stage it transitively requires, in the graph's order. Requirements come earlier in the order, so one
|
||||
* forward sweep completes each stage's set before a dependent merges it.
|
||||
*/
|
||||
private static List<List<Class<?>>> activationSettings(ResolvedGraph graph) {
|
||||
var slots = new BitSet[graph.size()];
|
||||
for (int position = 0; position < slots.length; position++) {
|
||||
var executable = graph.executable(position);
|
||||
slots[position] = new BitSet();
|
||||
if (executable.settingsSlot() != ExecutableStage.NO_SETTINGS) {
|
||||
slots[position].set(executable.settingsSlot());
|
||||
}
|
||||
for (int requirement : executable.requirements()) {
|
||||
slots[position].or(slots[requirement]);
|
||||
}
|
||||
}
|
||||
var types = graph.settingsTypes();
|
||||
return IntStream.range(0, slots.length)
|
||||
.mapToObj(position -> slots[position].stream().<Class<?>>mapToObj(types::get).toList())
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -18,13 +18,14 @@ public record PipelineReach(int blocks, Map<String, Integer> mantleLayers) {
|
||||
mantleLayers = Collections.unmodifiableMap(new TreeMap<>(mantleLayers));
|
||||
}
|
||||
|
||||
static PipelineReach of(Iterable<StageReach> stages) {
|
||||
static PipelineReach of(Iterable<ResolvedStage> stages) {
|
||||
int blocks = 0;
|
||||
var layers = new TreeMap<String, Integer>();
|
||||
for (var stage : stages) {
|
||||
blocks = Math.max(blocks, stage.blocks());
|
||||
for (var layer : stage.mantleLayers()) {
|
||||
layers.merge(layer.id(), stage.blocks(), Math::max);
|
||||
int stageBlocks = stage.fixedReachBlocks();
|
||||
blocks = Math.max(blocks, stageBlocks);
|
||||
for (var layer : stage.reach().mantleLayers()) {
|
||||
layers.merge(layer.id(), stageBlocks, Math::max);
|
||||
}
|
||||
}
|
||||
return new PipelineReach(blocks, layers);
|
||||
|
||||
@@ -68,9 +68,13 @@ public final class ResolvedGraph {
|
||||
return pairs;
|
||||
}
|
||||
|
||||
/** The most the pipeline's stages write beyond their footprint, overall and per mantle layer. */
|
||||
/** The most the pipeline's stages write beyond their footprint, overall and per mantle layer.
|
||||
*
|
||||
* @throws IllegalStateException when a mantle stage works out its reach when the pack loads: the host
|
||||
* runs each mantle stage as its own pass and asks it with {@link ResolvedStage#reachBlocks}
|
||||
*/
|
||||
public PipelineReach reach() {
|
||||
return PipelineReach.of(stages.stream().map(ResolvedStage::reach).toList());
|
||||
return PipelineReach.of(stages);
|
||||
}
|
||||
|
||||
/** Human-readable order, owners, edges, block passes and unordered pairs. */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.Stage;
|
||||
import com.volmit.stage.StageRef;
|
||||
@@ -10,7 +11,7 @@ import java.util.Optional;
|
||||
/** Diagnostic view of one stage at its resolved position. incoming lists every edge into this
|
||||
* stage, including soft edges other stages declared; absentSoftTargets lists this stage's soft
|
||||
* references that matched no installed stage and therefore add no ordering. reach is what the stage
|
||||
* declared it writes beyond its footprint.
|
||||
* declared it writes beyond its footprint; {@link #reachBlocks(PackSettings)} works it out for a pack.
|
||||
*/
|
||||
public record ResolvedStage(
|
||||
Stage<?> stage,
|
||||
@@ -27,4 +28,29 @@ public record ResolvedStage(
|
||||
incoming = List.copyOf(incoming);
|
||||
absentSoftTargets = List.copyOf(absentSoftTargets);
|
||||
}
|
||||
|
||||
/** How far, in blocks along X and Z, the stage writes beyond its footprint in the pack whose settings
|
||||
* are {@code settings}: the declared number, or what the stage's {@link com.volmit.stage.PackReach}
|
||||
* works out. The host asks once per pack load, before generating.
|
||||
*
|
||||
* @throws IllegalStateException when the stage works out a negative reach
|
||||
*/
|
||||
public int reachBlocks(PackSettings settings) {
|
||||
Objects.requireNonNull(settings, "settings");
|
||||
int blocks = reach.blocks().blocks(settings);
|
||||
if (blocks < 0) {
|
||||
throw new IllegalStateException("Stage " + stage + " of module " + module + " worked out a negative reach of "
|
||||
+ blocks + " blocks for this pack");
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/** The declared number of blocks; for a pipeline whose reaches do not depend on the pack. */
|
||||
int fixedReachBlocks() {
|
||||
if (!(reach.blocks() instanceof FixedReach fixed)) {
|
||||
throw new IllegalStateException("Stage " + stage + " of module " + module + " works out its reach when the pack"
|
||||
+ " loads; ask each mantle stage with ResolvedStage.reachBlocks(settings)");
|
||||
}
|
||||
return fixed.blocks();
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,13 @@ package com.volmit.host;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.PackReach;
|
||||
import com.volmit.stage.Pipeline;
|
||||
import com.volmit.stage.Stage;
|
||||
import com.volmit.stage.StageRef;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -19,7 +21,7 @@ final class StageDeclaration {
|
||||
private final List<StageRef> softAfter = new ArrayList<>();
|
||||
private final List<StageRef> softBefore = new ArrayList<>();
|
||||
private FeatureDescriptor<?> settings;
|
||||
private Integer reachBlocks;
|
||||
private PackReach reach;
|
||||
private final List<MantleKey<?>> mantleLayers = new ArrayList<>();
|
||||
private StageBody body;
|
||||
|
||||
@@ -56,13 +58,34 @@ final class StageDeclaration {
|
||||
void reach(int blocks) {
|
||||
checkOpen();
|
||||
if (blocks > 0) requireOutsideChunkPipeline("a reach of " + blocks + " blocks");
|
||||
if (reachBlocks != null) {
|
||||
throw new IllegalStateException("Stage " + this + " already declares a reach of " + reachBlocks + " blocks");
|
||||
}
|
||||
if (blocks < 0) {
|
||||
throw new IllegalArgumentException("Stage " + this + " declares a negative reach of " + blocks + " blocks");
|
||||
}
|
||||
reachBlocks = blocks;
|
||||
declareReach(new FixedReach(blocks));
|
||||
}
|
||||
|
||||
void reach(PackReach computed) {
|
||||
checkOpen();
|
||||
Objects.requireNonNull(computed, "reach");
|
||||
if (stage.pipeline() != Pipeline.MANTLE) {
|
||||
throw new IllegalArgumentException("Stage " + this + " is a " + stage.pipeline().name().toLowerCase(Locale.ROOT)
|
||||
+ " stage and declares a reach worked out when the pack loads, which only mantle stages may;"
|
||||
+ " declare a number of blocks with reach(blocks)");
|
||||
}
|
||||
declareReach(computed);
|
||||
}
|
||||
|
||||
private void declareReach(PackReach declared) {
|
||||
if (reach != null) {
|
||||
throw new IllegalStateException("Stage " + this + " already declares " + describe(reach));
|
||||
}
|
||||
reach = declared;
|
||||
}
|
||||
|
||||
private static String describe(PackReach reach) {
|
||||
return reach instanceof FixedReach fixed
|
||||
? "a reach of " + fixed.blocks() + " blocks"
|
||||
: "a reach worked out when the pack loads";
|
||||
}
|
||||
|
||||
void writesMantle(MantleKey<?>... layers) {
|
||||
@@ -120,7 +143,7 @@ final class StageDeclaration {
|
||||
}
|
||||
|
||||
StageReach reach() {
|
||||
return new StageReach(reachBlocks == null ? 0 : reachBlocks, mantleLayers);
|
||||
return new StageReach(reach == null ? FixedReach.NONE : reach, mantleLayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.stage.PackReach;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -9,16 +10,17 @@ import java.util.Objects;
|
||||
*
|
||||
* @param blocks how far, in blocks along X and Z, the stage writes blocks or mantle values beyond its
|
||||
* footprint: the chunk's 16 by 16 columns for a mantle stage, the X/Z bounds of the placed object
|
||||
* for a placement stage. 0 means only inside it, and is all a chunk stage may declare. Height is not limited: the footprint is whole
|
||||
* columns.
|
||||
* for a placement stage. 0 means only inside it, and is all a chunk stage may declare. Height is not
|
||||
* limited: the footprint is whole columns. A number declared at install, or for a mantle stage a
|
||||
* {@link PackReach} worked out from the pack's settings when the pack loads.
|
||||
* @param mantleLayers the mantle layers the stage writes, each once, in declaration order
|
||||
*/
|
||||
public record StageReach(int blocks, List<MantleKey<?>> mantleLayers) {
|
||||
public record StageReach(PackReach blocks, List<MantleKey<?>> mantleLayers) {
|
||||
/** A stage that declared nothing: it writes blocks inside its footprint only, and no mantle layer. */
|
||||
public static final StageReach NONE = new StageReach(0, List.of());
|
||||
public static final StageReach NONE = new StageReach(FixedReach.NONE, List.of());
|
||||
|
||||
public StageReach {
|
||||
if (blocks < 0) throw new IllegalArgumentException("Negative reach: " + blocks);
|
||||
Objects.requireNonNull(blocks, "blocks");
|
||||
mantleLayers = List.copyOf(mantleLayers);
|
||||
var ids = new HashSet<String>();
|
||||
for (var layer : mantleLayers) {
|
||||
@@ -27,4 +29,9 @@ public record StageReach(int blocks, List<MantleKey<?>> mantleLayers) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** A reach of a number of blocks declared at install. */
|
||||
public StageReach(int blocks, List<MantleKey<?>> mantleLayers) {
|
||||
this(new FixedReach(blocks), mantleLayers);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ public interface ConditionalStageDefinition<C extends StageContext, S extends Ir
|
||||
|
||||
ConditionalStageDefinition<C, S, O> reach(int blocks);
|
||||
|
||||
ConditionalStageDefinition<C, S, O> reach(PackReach reach);
|
||||
|
||||
ConditionalStageDefinition<C, S, O> writesMantle(MantleKey<?>... layers);
|
||||
|
||||
void run(SettingsAction<C, S> action);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.volmit.stage;
|
||||
|
||||
/** Runs once per chunk in the mantle pipeline, before the chunks it reaches generate. */
|
||||
/** Runs once per chunk in the mantle pipeline, before the chunks it reaches generate. Every mantle stage is
|
||||
* its own pass: the host runs it for every chunk around a generating chunk before the next stage starts,
|
||||
* so a stage sees what earlier stages wrote into neighboring chunks. Mantle stages therefore have no
|
||||
* output; they pass data on through mantle layers.
|
||||
*/
|
||||
public final class MantleStage<O> extends Stage<O> {
|
||||
MantleStage(String id, Class<O> outputType) {
|
||||
super(id, outputType);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.volmit.stage;
|
||||
|
||||
import com.volmit.config.PackSettings;
|
||||
|
||||
/** How far a mantle stage writes beyond its chunk, worked out when the pack loads, for work whose size
|
||||
* depends on the pack, such as the largest object or the longest vein any level configures. The host
|
||||
* calls it once per pack load, before generating, and prepares that much around every chunk.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface PackReach {
|
||||
/** Blocks along X and Z beyond the chunk's 16 by 16 columns; never negative. */
|
||||
int blocks(PackSettings settings);
|
||||
}
|
||||
@@ -9,8 +9,9 @@ public enum Pipeline {
|
||||
*/
|
||||
CHUNK,
|
||||
/** Runs once per chunk before any chunk near it generates, against the mantle only: work that writes
|
||||
* the mantle or reaches beyond its chunk. The host runs it around a chunk as far as the pipeline's
|
||||
* reach, so a chunk's mantle is complete when the chunk pipeline reads it.
|
||||
* the mantle or reaches beyond its chunk. The host runs each stage as its own pass, in resolved order,
|
||||
* around a chunk as far as that stage's reach plus every later stage's, so a chunk's mantle is
|
||||
* complete when the chunk pipeline reads it.
|
||||
*/
|
||||
MANTLE
|
||||
}
|
||||
@@ -46,14 +46,11 @@ public abstract sealed class Stage<O> permits PlacementStage, BlockStage, ChunkS
|
||||
return new ChunkStage<>(id, outputType);
|
||||
}
|
||||
|
||||
/** Mantle stages have no output: each runs as its own pass, so they pass data on through mantle layers. */
|
||||
public static MantleStage<Void> mantle(String id) {
|
||||
return new MantleStage<>(id, Void.class);
|
||||
}
|
||||
|
||||
public static <O> MantleStage<O> mantle(String id, Class<O> outputType) {
|
||||
return new MantleStage<>(id, outputType);
|
||||
}
|
||||
|
||||
public final ResourceId id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,17 @@ public interface StageDefinition<C extends StageContext, O> {
|
||||
|
||||
/** Declares how far, in blocks along X and Z, this stage writes blocks or mantle values beyond its
|
||||
* footprint: the chunk for a mantle stage, the placed object's X/Z bounds for a placement stage. The
|
||||
* host prepares that much around every chunk or placement of the pipeline. Leaving it out means 0.
|
||||
* host prepares that much around every chunk the stage runs for, or every placement. Leaving it out means 0.
|
||||
* Chunk stages write only their own chunk, so a reach above 0 on one fails the install.
|
||||
*/
|
||||
StageDefinition<C, O> reach(int blocks);
|
||||
|
||||
/** Declares a reach the host works out from the pack's settings when the pack loads, for a mantle
|
||||
* stage whose reach depends on the pack. Only mantle stages may declare one: placement areas and
|
||||
* chunks are sized without the pack's settings, so it fails the install on any other stage.
|
||||
*/
|
||||
StageDefinition<C, O> reach(PackReach reach);
|
||||
|
||||
/** Declares the mantle layers this stage writes; each must be registered by some module. Chunk stages
|
||||
* only read the mantle, so declaring layers on one fails the install.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user