Structure services answer what Iris core still asked its locator directly: placed keys and the starts a module makes of platform structures

StructureLocator.placed(world) (default: locatable): every key under which locate finds what the module places, its own
structures and the platform structures it starts or stands in for; the host routes locate by it.
VanillaStructures.startedStructures(world), locatableStarts(world) and locateStart(world, structure, fromX, fromZ,
maxRings, ChunkFilter): the platform structures a module starts itself, the ones it can find, and the nearest start of
one, ring by ring through the module's grids, trying only the chunks the host's filter accepts (the platform's /locate
checks each start in the world and asks again without a refused chunk). README, DESIGN, CONTRACTS; test.
This commit is contained in:
piexel committed 2026-10-10 18:18:01 +02:00
1 parent 030cbbb8fc
commit 750e0691a6
6 files changed
+90 -6

No files matched your search

@@ -2,7 +2,10 @@ package com.volmit;
import com.volmit.block.BlockState;
import com.volmit.config.OptionsMetadata;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
import com.volmit.service.LocateResult;
import com.volmit.service.StructureLocator;
import com.volmit.service.VanillaFeatures;
import com.volmit.service.VanillaStructures;
import com.volmit.vanilla.DecorationStep;
@@ -14,11 +17,13 @@ import com.volmit.vanilla.VanillaStructureContext;
import com.volmit.vanilla.VanillaStructureRule;
import com.volmit.vanilla.VanillaStructureSetup;
import com.volmit.vanilla.VanillaStructureStart;
import com.volmit.world.PackWorld;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.*;
/** The values a vanilla structures provider answers with and how the host combines several modules' answers. */
@@ -123,6 +128,31 @@ class VanillaStructureValuesTest {
assertEquals(StartReach.PLATFORM, provider.reach(CITY, true, Optional.empty(), null));
assertEquals(VanillaStructureSetup.UNCHANGED, provider.setup(null));
assertEquals(VanillaStructureRule.GENERATE, new VanillaStructures() { }.rule(CITY, null));
assertEquals(Set.of(), provider.startedStructures(null));
assertEquals(Set.of(), provider.locatableStarts(null));
assertEquals(LocateResult.NOT_FOUND, provider.locateStart(null, CITY, 0, 0, 8, (chunkX, chunkZ) -> true));
}
@Test
public void aLocatorPlacesWhatItCanLocateUnlessItSaysMore() {
StructureLocator locator = new StructureLocator() {
@Override
public Set<String> structures(PackResources pack) {
return Set.of("castle", "tower");
}
@Override
public Set<String> locatable(PackWorld world) {
return Set.of("castle");
}
@Override
public LocateResult locate(PackWorld world, String key, int fromX, int fromZ, int maxRadiusChunks) {
return LocateResult.NOT_FOUND;
}
};
assertEquals(Set.of("castle"), locator.placed(null));
}
@Test