mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
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:
1 parent
9043d93fbd
commit
eeb5486098
76 files changed
+2717
-1567
No files matched your search
@@ -0,0 +1,93 @@
|
||||
package com.volmit.support;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.placement.PlacedBlock;
|
||||
import com.volmit.placement.PlacedMarker;
|
||||
import com.volmit.placement.PlacementEdit;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.world.BlockView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** In-memory transactional test adapter over a base view; production storage is absent. */
|
||||
public final class MemoryEdit implements PlacementEdit {
|
||||
public enum Status { OPEN, COMMITTED, CLOSED }
|
||||
|
||||
private final BlockView base;
|
||||
private final Map<BlockPosition, BlockState> pending = new HashMap<>();
|
||||
private final Map<BlockPosition, BlockState> published = new HashMap<>();
|
||||
private final List<PlacedMarker> pendingMarkers = new ArrayList<>();
|
||||
private final List<PlacedMarker> publishedMarkers = new ArrayList<>();
|
||||
private Status status = Status.OPEN;
|
||||
private boolean committed;
|
||||
|
||||
public MemoryEdit(BlockView base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public boolean committed() { return committed; }
|
||||
public Status status() { return status; }
|
||||
public Map<BlockPosition, BlockState> published() { return Map.copyOf(published); }
|
||||
public List<PlacedMarker> publishedMarkers() { return List.copyOf(publishedMarkers); }
|
||||
|
||||
public BlockState publishedAt(int x, int y, int z) {
|
||||
return published.getOrDefault(new BlockPosition(x, y, z), base.get(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBox bounds() {
|
||||
checkOpen();
|
||||
return base.bounds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState get(int x, int y, int z) {
|
||||
checkOpen();
|
||||
return pending.getOrDefault(new BlockPosition(x, y, z), base.get(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(PlacedBlock block) {
|
||||
checkOpen();
|
||||
var position = block.position();
|
||||
if (!base.bounds().contains(position.x(), position.y(), position.z())) {
|
||||
throw new IndexOutOfBoundsException("Write outside prepared area: " + position);
|
||||
}
|
||||
pending.put(position, block.state());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marker(PlacedMarker marker) {
|
||||
checkOpen();
|
||||
pendingMarkers.add(marker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mantle mantle() {
|
||||
throw new AssertionError("Unused mantle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
checkOpen();
|
||||
published.putAll(pending);
|
||||
publishedMarkers.addAll(pendingMarkers);
|
||||
committed = true;
|
||||
status = Status.COMMITTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
pending.clear();
|
||||
pendingMarkers.clear();
|
||||
status = Status.CLOSED;
|
||||
}
|
||||
|
||||
private void checkOpen() {
|
||||
if (status != Status.OPEN) throw new IllegalStateException("Edit is " + status);
|
||||
}
|
||||
}
|
||||
@@ -2,44 +2,61 @@ package com.volmit.support;
|
||||
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.generation.GenerationContext;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.object.ObjectTransformer;
|
||||
import com.volmit.placement.PlacementContext;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import com.volmit.world.BlockView;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
/** Tests needing no platform facilities fail loudly if code starts using one. */
|
||||
public final class TestContexts {
|
||||
public static final long SEED = 42;
|
||||
|
||||
private TestContexts() {}
|
||||
|
||||
public static GenerationContext generation() {
|
||||
public static GenerationContext generation(Map<Class<?>, Hunk<?>> hunks) {
|
||||
return new GenerationContext() {
|
||||
private final RandomGenerator random = new Random(42);
|
||||
private final RandomGenerator random = new Random(SEED);
|
||||
public int originX() { return 0; }
|
||||
public int originY() { return -64; }
|
||||
public int originZ() { return 0; }
|
||||
public long worldSeed() { return 42; }
|
||||
public long worldSeed() { return SEED; }
|
||||
public RandomGenerator random() { return random; }
|
||||
public PackResources resources() { throw new AssertionError("Unused resources"); }
|
||||
public TerrainSampler terrain() { throw new AssertionError("Unused terrain"); }
|
||||
public FeatureSettings settings() { throw new AssertionError("Unused settings"); }
|
||||
public Mantle mantle() { throw new AssertionError("Unused mantle"); }
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Hunk<T> hunk(Class<T> type) {
|
||||
var hunk = hunks.get(type);
|
||||
if (hunk == null) throw new IllegalArgumentException("No hunk of " + type.getName());
|
||||
return (Hunk<T>) hunk;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static PlacementContext placement() {
|
||||
return placement(null);
|
||||
}
|
||||
|
||||
public static PlacementContext placement(BlockView blocks) {
|
||||
return new PlacementContext() {
|
||||
private final RandomGenerator random = new Random(42);
|
||||
public long worldSeed() { return 42; }
|
||||
private final RandomGenerator random = new Random(SEED);
|
||||
public long worldSeed() { return SEED; }
|
||||
public RandomGenerator random() { return random; }
|
||||
public PackResources resources() { throw new AssertionError("Unused resources"); }
|
||||
public TerrainSampler terrain() { throw new AssertionError("Unused terrain"); }
|
||||
public FeatureSettings settings() { throw new AssertionError("Unused settings"); }
|
||||
public ObjectTransformer objects() { throw new AssertionError("Unused transforms"); }
|
||||
public BlockView blocks() { throw new AssertionError("Unused blocks"); }
|
||||
public BlockView blocks() {
|
||||
if (blocks == null) throw new AssertionError("Unused blocks");
|
||||
return blocks;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.volmit.support;
|
||||
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.world.BlockView;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
|
||||
/** Prepared pre-placement blocks: stone below a per-column ground height, air above. */
|
||||
public final class TestTerrain implements BlockView {
|
||||
public static final BlockState STONE = new BlockState("minecraft:stone");
|
||||
public static final BlockState AIR = new BlockState("minecraft:air");
|
||||
public static final BlockBox BOUNDS = new BlockBox(-16, 0, -16, 16, 32, 16);
|
||||
|
||||
private final IntBinaryOperator groundHeight;
|
||||
|
||||
public TestTerrain(IntBinaryOperator groundHeight) {
|
||||
this.groundHeight = groundHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBox bounds() {
|
||||
return BOUNDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState get(int x, int y, int z) {
|
||||
if (!BOUNDS.contains(x, y, z)) throw new IndexOutOfBoundsException("Outside test terrain: " + x + "," + y + "," + z);
|
||||
return y < groundHeight.applyAsInt(x, z) ? STONE : AIR;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user