HintedLocator asks the ObjectsAt services which biomes and regions place an object

The object search plan no longer reads IrisObjectPlacement: it builds its coarse sampler from the layout entries the
modules name and the biome tree it owns.
This commit is contained in:
piexel committed 2026-10-09 20:51:05 +02:00
1 parent 7a3f5961cc
commit 8137f6dba9
4 files changed
+55 -19

No files matched your search

@@ -87,7 +87,17 @@ public class ModuleServicesTest {
@Override
public void register(FeatureRegistry registry) {
registry.registerService(ObjectsAt.class, (world, chunkX, chunkZ) -> Set.of(object + "@" + chunkX + "," + chunkZ));
registry.registerService(ObjectsAt.class, new ObjectsAt() {
@Override
public Set<String> objectsAt(PackWorld world, int chunkX, int chunkZ) {
return Set.of(object + "@" + chunkX + "," + chunkZ);
}
@Override
public PlacedBy placedBy(PackWorld world, String objectKey) {
return new PlacedBy(Set.of(object + "-biome"), Set.of(id + "-region"));
}
});
registry.registerService(StructureLocator.class, new StructureLocator() {
@Override
public Set<String> structures(PackResources resources) {
@@ -141,6 +151,14 @@ public class ModuleServicesTest {
assertEquals(List.of("tree@3,-4", "bush@3,-4", "rock@3,-4"), List.copyOf(ModuleServices.objectsAt(engine, 3, -4)));
}
@Test
public void objectPlacersCombineTheBiomesAndRegionsOfEveryModule() {
ObjectsAt.PlacedBy placers = ModuleServices.objectPlacers(engine, "trees/oak");
assertEquals(Set.of("rock-biome", "tree-biome", "bush-biome"), placers.biomes());
assertEquals(Set.of("test:zeta-region", "test:alpha-region", "test:beta-region"), placers.regions());
}
@Test
public void structureListsCombineEveryModule() {
assertEquals(Set.of("tower", "castle"), ModuleServices.locatableStructures(engine));
@@ -4,6 +4,8 @@ import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.core.modules.ModuleResourceFixture;
import art.arcane.iris.engine.mantle.components.ObjectModule;
import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
@@ -92,6 +94,9 @@ public class HintedLocatorTest {
when(engine.isClosed()).thenReturn(false);
when(engine.acquireGenerationLease(any(String.class))).thenReturn(GenerationSessionLease.noop());
when(data.getBiomeLoader()).thenReturn(biomeLoader);
ModuleResourceFixture.serveModules(data, new ObjectModule());
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
stubReachableBiomes();
}
private static IrisBiome biome(String key) {
@@ -137,6 +142,10 @@ public class HintedLocatorTest {
when(biomeLoader.load(biome.getLoadKey())).thenReturn(biome);
}
private void stubReachableBiomes(IrisBiome... biomes) {
when(dimension.getReachableBiomes(engine)).thenReturn(new KList<>(biomes));
}
@Test
public void appendRingZeroAddsOnlyOrigin() {
KList<Position2> batch = new KList<>();
@@ -285,6 +294,7 @@ public class HintedLocatorTest {
placements.add(placement);
host.setObjects(placements);
stubBiome(host);
stubReachableBiomes(host);
stubRegions(regionA);
when(complex.getRegionStream()).thenReturn(constantStream(regionA));
@@ -326,6 +336,7 @@ public class HintedLocatorTest {
IrisRegion regionA = region("reg_a");
regionA.setLandBiomes(keys("plains"));
stubBiome(biome("plains"));
stubReachableBiomes(biome("plains"));
stubRegions(regionA);
HintedLocator.SearchPlan plan = HintedLocator.objectPlan(engine, "missing/object");
@@ -416,6 +427,7 @@ public class HintedLocatorTest {
placements.add(placement);
host.setObjects(placements);
stubBiome(host);
stubReachableBiomes(host);
stubRegions(regionA);
when(complex.getRegionStream()).thenReturn(constantStream(regionA));