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

@@ -6,7 +6,7 @@ import java.util.Set;
/** Finds the structures a module places, for the host's structure commands and index. Structures are named by their
* keys, in the form packs write them ({@code castle}, {@code villages/plains}). The host asks the providers in order and
* sends a key to the first that can locate it in the world.
* sends a key to the first that places it in the world ({@link #placed}).
*/
@Service(Providers.FIRST)
public interface StructureLocator {
@@ -20,10 +20,19 @@ public interface StructureLocator {
*/
Set<String> locatable(PackWorld world);
/** The keys under which {@link #locate} finds the structures this module places in {@code world}, locatable or not: its
* own structures, the platform structures it starts itself and the platform structures its own stand in for (namespaced,
* such as {@code minecraft:ancient_city}). Commands report them and send a search for one of them here. By default the
* {@link #locatable} ones.
*/
default Set<String> placed(PackWorld world) {
return locatable(world);
}
/**
* The start of structure {@code key} nearest to the column {@code fromX}, {@code fromZ} (world coordinates), searched
* up to {@code maxRadiusChunks} chunks away from it. The position is the structure's origin: world X and Z, and Y the
* height above the dimension's bottom of its base. Called with a key from {@link #locatable}. May take long; the
* height above the dimension's bottom of its base. Called with a key from {@link #placed}. May take long; the
* host calls it off the server's main thread.
*/
LocateResult locate(PackWorld world, String key, int fromX, int fromZ, int maxRadiusChunks);
@@ -10,8 +10,10 @@ import com.volmit.vanilla.VanillaStructureRule;
import com.volmit.vanilla.VanillaStructureSetup;
import com.volmit.vanilla.VanillaStructureStart;
import com.volmit.vanilla.VanillaStructureStartContext;
import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Optional;
import java.util.Set;
/** A module's say over the platform's own structures, the ones Minecraft, data packs and mods register, in the pack's
* worlds. The host asks every provider, in module id order:
@@ -91,4 +93,37 @@ public interface VanillaStructures {
default VanillaStructureSetup setup(VanillaStructureContext context) {
return VanillaStructureSetup.UNCHANGED;
}
/** The platform structures this module starts itself in {@code world} ({@link #starts}), wherever its own placements put
* them. The host's locate and structure commands send them to {@link #locateStart}.
*/
default Set<ResourceId> startedStructures(PackWorld world) {
return Set.of();
}
/** Those of {@link #startedStructures} whose starts {@link #locateStart} can find in {@code world}: a start whose
* placement can never start in the world's height, for one, cannot be searched for.
*/
default Set<ResourceId> locatableStarts(PackWorld world) {
return Set.of();
}
/**
* The start of the platform structure {@code structure} this module makes nearest to the column {@code fromX},
* {@code fromZ} (world coordinates), searched ring by ring outward through its placements' grids up to {@code maxRings}
* rings: the nearest start of the first ring that has one. The position is the start's origin: world X and Z, and Y the
* height above the dimension's bottom of its base. Only chunks {@code accepts} allows count; the host checks the start
* the platform made there and searches again without a chunk it refuses. An exception {@code accepts} throws ends the
* search and reaches the caller. Called with a structure from {@link #locatableStarts}, off the server's main thread.
*/
default LocateResult locateStart(PackWorld world, ResourceId structure, int fromX, int fromZ, int maxRings,
ChunkFilter accepts) {
return LocateResult.NOT_FOUND;
}
/** Which chunks a {@link #locateStart} search may answer with. */
@FunctionalInterface
interface ChunkFilter {
boolean accepts(int chunkX, int chunkZ);
}
}