Replace fixed placement hooks with a module-owned stage graph

Modules now define every stage themselves through IrisModule.install(StageGraph):
typed stage constants, hard requires(...) on other modules' constants, soft
ordering by id, when(...) activation and typed outputs. Placement and chunk
generation resolve on the same machinery; adjacent per-block stages fuse into
one block pass.

The host-defined PlacementModifier hooks, string Dependencies, GenerationPlan,
PlacementPipeline, DependencyOrder and OccurrenceOrder are removed.
This commit is contained in:
piexel committed 2026-10-05 17:23:31 +02:00
1 parent 9043d93fbd
commit eeb5486098
76 files changed
+2717 -1567

No files matched your search

@@ -3,9 +3,9 @@ package com.volmit.placement;
import com.volmit.mantle.Mantle;
import com.volmit.world.BlockView;
/** Buffered world-space access for placement hooks, without ownership of commit/close.
* Reads include the overlay. Bounds cover the object's footprint plus declared horizontal reach
* and host-authorized vertical area. Block/entity/marker/mantle writes share the host edit.
/** Buffered world-space access for placement stages, without ownership of commit/close.
* Reads include the overlay. Bounds are the host-prepared placement area.
* Block/entity/marker/mantle writes share the host edit.
* Out-of-area access throws; nested mantle edits are unsupported. Do not retain this view.
*/
public interface PlacementAccess extends BlockView {
@@ -6,13 +6,13 @@ import com.volmit.object.ObjectTransformer;
import com.volmit.world.TerrainSampler;
import com.volmit.world.BlockView;
/** Read-only inputs to placement hooks. Working state is carried by returned immutable requests
* and blocks, never stored on a configured modifier. Context lifetime ends with placement.
/** Host-supplied, read-only inputs of one placement attempt. Working state is carried by stage
* outputs, never stored on a module or stage body. Context lifetime ends with the placement.
*/
public interface PlacementContext extends InvocationContext {
TerrainSampler terrain();
FeatureSettings settings();
ObjectTransformer objects();
/** Prepared blocks before this placement. Use hook access for reads of buffered changes. */
/** Prepared blocks before this placement. Use stage access for reads of buffered changes. */
BlockView blocks();
}
@@ -1,24 +0,0 @@
package com.volmit.placement;
import com.volmit.generation.Dependencies;
import java.util.Optional;
/** Configured placement behavior. IDs are namespaced; dependencies refer only to placement
* modifier IDs, not chunk modifiers. Snapshot settings; calls may occur concurrently.
* The host runs prepare for all modifiers, mapBlock for each candidate, then validate for all
* modifiers before buffering any write. beforePlace runs after validation but before object
* writes, for boring/preparation. afterPlace runs only after all accepted blocks and
* markers are buffered, allowing vacuum/stilts to observe the final footprint and overlay.
* Exceptions discard the attempt. Empty prepare rejects it; empty mapBlock skips one block.
*/
public abstract class PlacementModifier {
public abstract String id();
public Dependencies depends() { return Dependencies.none(); }
/** Horizontal access beyond the resulting object footprint; nonnegative, read at pack load. */
public int writeRadius() { return 0; }
public Optional<PlacementRequest> prepare(PlacementContext context, PlacementRequest request) { return Optional.of(request); }
public Optional<PlacedBlock> mapBlock(PlacementContext context, PlacedBlock block) { return Optional.of(block); }
public boolean validate(PlacementContext context, PlacementPlan plan) { return true; }
public void beforePlace(PlacementContext context, PlacementAccess access, PlacementPlan proposed) {}
public void afterPlace(PlacementContext context, PlacementAccess access, PlacementPlan written) {}
}
@@ -1,8 +0,0 @@
package com.volmit.placement;
import com.volmit.IrisFeature;
@FunctionalInterface
public interface PlacementModifierFactory<F extends IrisFeature> {
PlacementModifier create(F feature);
}
@@ -1,37 +0,0 @@
package com.volmit.placement;
import com.volmit.mantle.BlockBox;
import com.volmit.world.BlockPosition;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
/** Complete proposed writes, constructed before validation or mutation.
* Block positions are unique and ordered x/y/z. writtenBounds describes block writes only;
* markers and the original object's declared footprint are tracked separately.
*/
public record PlacementPlan(PlacementRequest request, List<PlacedBlock> blocks, List<PlacedMarker> markers) {
public PlacementPlan {
Objects.requireNonNull(request, "request");
blocks = List.copyOf(blocks).stream().sorted(Comparator.comparing(PlacedBlock::position)).toList();
markers = List.copyOf(markers).stream().sorted(Comparator.comparing(PlacedMarker::position)).toList();
var positions = new HashSet<BlockPosition>();
for (var block : blocks) {
if (!positions.add(block.position())) throw new IllegalArgumentException("Duplicate placement write: " + block.position());
}
}
public Optional<BlockBox> writtenBounds() {
if (blocks.isEmpty()) return Optional.empty();
int minX = Integer.MAX_VALUE, minY = Integer.MAX_VALUE, minZ = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE, maxY = Integer.MIN_VALUE, maxZ = Integer.MIN_VALUE;
for (var block : blocks) {
var position = block.position();
minX = Math.min(minX, position.x()); minY = Math.min(minY, position.y()); minZ = Math.min(minZ, position.z());
maxX = Math.max(maxX, position.x()); maxY = Math.max(maxY, position.y()); maxZ = Math.max(maxZ, position.z());
}
return Optional.of(new BlockBox(minX, minY, minZ, Math.addExact(maxX, 1), Math.addExact(maxY, 1), Math.addExact(maxZ, 1)));
}
}