Place and locate structures through the api instead of the engine

Structure placement, its locator, the cave anchor resolver and the native start planner now take the pack world and its
running world, and StructurePlacing writes through the mantle stage context and the placement graph. Terrain carving
draws its noise from the pack's noise factory. The api gains clearBlock/clearAttached on PlacementTerrain,
RunningWorld.carvedAt and VanillaStructureContext.world; modules get the host's seed purposes through their world view.
This commit is contained in:
piexel committed 2026-11-10 02:54:54 +01:00
1 parent 5ab99210b2
commit 3d209b393c
47 files changed
+1957 -1127

No files matched your search

@@ -4,6 +4,7 @@ import com.volmit.ModuleLog;
import com.volmit.config.PackSettings;
import com.volmit.placement.Placements;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
import com.volmit.world.PackWorld;
import com.volmit.world.RunningWorld;
import java.util.List;
@@ -37,6 +38,11 @@ final class ModuleWorld implements PackWorld {
return world.seed();
}
@Override
public long seed(ResourceId purpose) {
return world.seed(purpose);
}
@Override
public PackResources resources() {
return world.resources();
@@ -12,6 +12,7 @@ import com.volmit.hunk.Hunk;
import com.volmit.mantle.Mantle;
import com.volmit.placement.Placements;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
import com.volmit.stage.Pipeline;
import com.volmit.stage.Stage;
import com.volmit.support.TestContexts;
@@ -73,6 +74,18 @@ class ExtensionsTest {
assertEquals(Optional.of(new WorldOffer("iris")), view.extension(WorldOffer.class));
}
@Test
void aModulesViewOfAWorldAnswersTheSeedPurposesTheHostAnswers() {
var world = new OfferingWorld(new WorldOffer("iris"));
PackWorld view = ModuleWorld.of(world, ModuleLogs.discarding());
assertEquals(HOST_SEED, view.seed(HOST_SEED_PURPOSE), "the host decides the seed of a purpose it knows");
assertEquals(world.seed(ResourceId.parse("test:other")), view.seed(ResourceId.parse("test:other")));
}
private static final ResourceId HOST_SEED_PURPOSE = ResourceId.parse("test:host-seed");
private static final long HOST_SEED = 31337L;
private static final class OfferingWorld implements PackWorld {
private final WorldStates states = new WorldStates();
private final WorldOffer offer;
@@ -82,6 +95,7 @@ class ExtensionsTest {
}
public long seed() { return TestContexts.SEED; }
@Override public long seed(ResourceId purpose) { return purpose.equals(HOST_SEED_PURPOSE) ? HOST_SEED : PackWorld.super.seed(purpose); }
public PackResources resources() { throw new AssertionError("Unused resources"); }
public PackSettings settings() { throw new AssertionError("Unused settings"); }
public int minWorldY() { return 0; }