Core asks for native structure starts and locates through the structure services

ModuleServices gains placedStructures, placesStructure, startedStructures, startsStructure, canLocateStart and
locateStart (a SEARCH_LIMIT_REACHED outcome instead of an exception); StructureHandler, the Bukkit and modded locate
commands and suggestions, the native structure stages, NMS IrisChunkGenerator and NativeStructureLocatePersistence
use them instead of IrisStructureLocator. StructureReachability keeps its keys per world; the hotloader no longer
invalidates locator caches. StructureCaveAnchorResolverTest binds a platform itself (it relied on test order).
This commit is contained in:
piexel committed 2026-10-12 02:06:14 +02:00
1 parent 0cfcada4f2
commit 7d9fd3faa6
24 files changed
+385 -126

No files matched your search

@@ -19,7 +19,7 @@
package art.arcane.iris.modded;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.IrisStructureLocator;
import art.arcane.iris.core.modules.ModuleServices;
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
import art.arcane.iris.engine.framework.NativeStructureLayouts;
import art.arcane.iris.engine.framework.nativefit.NativeStructureFitting;
@@ -129,7 +129,7 @@ final class ModdedNativeStructureStage {
throw new IllegalStateException("Native structure locate received an unregistered structure holder");
}
String structureId = id.toString();
if (!IrisStructureLocator.hasNativePlacement(current, structureId)) {
if (!ModuleServices.startsStructure(current, structureId)) {
continue;
}
NativeStructureLocatePersistence.Probe probe = NativeStructureLocatePersistence.probe(
@@ -141,19 +141,19 @@ final class ModdedNativeStructureStage {
searches.sort(Comparator.comparing(IrisNativeLocateSearch::structureId));
for (int attempt = 0; attempt < NativeStructureLocatePersistence.MAX_SELECTED_CANDIDATE_RETRIES; attempt++) {
IrisNativeLocateSearch bestSearch = null;
IrisStructureLocator.LocateResult bestResult = null;
ModuleServices.StructureSearch bestResult = null;
long bestDistance = Long.MAX_VALUE;
for (IrisNativeLocateSearch search : searches) {
IrisStructureLocator.LocateResult result = search.search().predict();
if (result.status() == IrisStructureLocator.LocateStatus.SEARCH_LIMIT_REACHED) {
ModuleServices.StructureSearch result = search.search().predict();
if (result.outcome() == ModuleServices.StructureSearch.Outcome.SEARCH_LIMIT_REACHED) {
throw new IllegalStateException("Iris structure locate reached its safety limit for "
+ search.structureId() + " within " + radius + " placement rings");
}
if (!result.found()) {
continue;
}
long dx = (long) result.originX() - pos.getX();
long dz = (long) result.originZ() - pos.getZ();
long dx = (long) result.x() - pos.getX();
long dz = (long) result.z() - pos.getZ();
long distance = dx * dx + dz * dz;
if (distance < bestDistance) {
bestDistance = distance;
@@ -166,7 +166,7 @@ final class ModdedNativeStructureStage {
pos, null, () -> { }, nativeLocated, nativeReference);
}
Pair<BlockPos, Holder<Structure>> predicted = Pair.of(
new BlockPos(bestResult.originX(), bestResult.baseY(), bestResult.originZ()),
new BlockPos(bestResult.x(), bestResult.y(), bestResult.z()),
bestSearch.holder());
if (NativeStructureLocateResults.nearest(pos, predicted, nativeLocated) != predicted) {
return NativeStructureLocateResults.selectAndReference(
@@ -179,8 +179,8 @@ final class ModdedNativeStructureStage {
continue;
}
BlockPos located = new BlockPos(
bestResult.originX(), verified.ownership().locatorY(),
bestResult.originZ());
bestResult.x(), verified.ownership().locatorY(),
bestResult.z());
Pair<BlockPos, Holder<Structure>> irisLocated = Pair.of(located, bestSearch.holder());
IrisNativeLocateSearch selectedSearch = bestSearch;
NativeStructureLocatePersistence.VerifiedStart selectedStart = verified;
@@ -23,7 +23,6 @@ import art.arcane.iris.modded.ModdedIrisLog;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.core.pack.PackDirectoryResolver;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.IrisStructureLocator;
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
import art.arcane.iris.engine.framework.StructureReachability;
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
@@ -133,9 +132,9 @@ final class ModdedCommandSuggestions {
String key = identifier.toString();
registeredKeys.add(normalizeKey(key));
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
boolean nativePlacement = ModuleServices.startsStructure(engine, key);
boolean locatableNativePlacement = nativePlacement
&& IrisStructureLocator.hasLocatableNativePlacement(engine, key);
&& ModuleServices.canLocateStart(engine, key);
boolean locatableEditableReplacement = !nativePlacement
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
&& ModuleServices.canLocateStructure(engine, key);
@@ -147,7 +146,7 @@ final class ModdedCommandSuggestions {
}
Collection<String> unregisteredIrisKeys = eligibleUnregisteredEditableKeys(
irisKeys, registeredKeys,
(String candidate) -> IrisStructureLocator.hasNativePlacement(engine, candidate));
(String candidate) -> ModuleServices.startsStructure(engine, candidate));
return SharedSuggestionProvider.suggest(
combineStructureKeys(unregisteredIrisKeys, nativeKeys), builder);
} catch (Throwable e) {
@@ -25,7 +25,6 @@ import art.arcane.iris.core.localization.ModdedCommandMessages;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.GenerationSessionException;
import art.arcane.iris.engine.framework.GenerationSessionLease;
import art.arcane.iris.engine.framework.IrisStructureLocator;
import art.arcane.iris.engine.framework.Locator;
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
import art.arcane.iris.engine.framework.StructureReachability;
@@ -156,7 +155,7 @@ final class ModdedLocateCommands {
}
Optional<NativeStructureTarget> resolved = resolveNativeStructure(source, level, engine, key);
if (resolved.isEmpty()) {
if (!IrisStructureLocator.hasNativePlacement(engine, key)
if (!ModuleServices.startsStructure(engine, key)
&& ModuleServices.canLocateStructure(engine, key)) {
locateIrisStructure(source, level, engine, player, key);
return 1;
@@ -168,9 +167,9 @@ final class ModdedLocateCommands {
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, target.key());
boolean nativeGenerationEnabled =
source.getServer().getWorldGenSettings().options().generateStructures();
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, target.key());
boolean nativePlacement = ModuleServices.startsStructure(engine, target.key());
boolean locatableNativePlacement = nativePlacement
&& IrisStructureLocator.hasLocatableNativePlacement(engine, target.key());
&& ModuleServices.canLocateStart(engine, target.key());
boolean locatableEditableReplacement = !nativePlacement
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
&& ModuleServices.canLocateStructure(engine, target.key());
@@ -357,7 +356,7 @@ final class ModdedLocateCommands {
case NO_PLACEMENT -> unsupported++;
}
}
int irisPlaced = IrisStructureLocator.placedKeys(engine).size();
int irisPlaced = ModuleServices.placedStructures(engine).size();
IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_STRUCTURE_REACHABILITY_NATIVE_GENERATION_ELIGIBLE_IRIS_PLACED_NATIVE_DISABLED_NATIVE, MessageArgument.untrusted("available", available), MessageArgument.untrusted("irisPlaced", irisPlaced), MessageArgument.untrusted("disabled", disabled), MessageArgument.untrusted("suppressed", suppressed), MessageArgument.untrusted("unreachableBiomes", unreachableBiomes), MessageArgument.untrusted("unsupported", unsupported)));
return 1;
}
@@ -365,7 +364,7 @@ final class ModdedLocateCommands {
private static int verifyStructure(CommandSourceStack source, ServerLevel level, Engine engine, String key) {
Optional<NativeStructureTarget> target = resolveNativeStructure(source, level, engine, key);
if (target.isEmpty()) {
if (IrisStructureLocator.isPlaced(engine, key)) {
if (ModuleServices.placesStructure(engine, key)) {
IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_STRUCTURE_IS_IRIS_PLACED_LOCATABLE_WITH_IRIS_GOTO_STRUCTURE, MessageArgument.untrusted("key", key), MessageArgument.untrusted("key2", key)));
return 1;
}
@@ -21,7 +21,6 @@ package art.arcane.iris.modded.command;
import art.arcane.iris.core.modules.ModuleServices;
import art.arcane.iris.modded.ModdedIrisLog;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.IrisStructureLocator;
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
import art.arcane.iris.engine.framework.StructureReachability;
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
@@ -107,9 +106,9 @@ final class ModdedUnregisteredStructures {
continue;
}
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
boolean nativePlacement = ModuleServices.startsStructure(engine, key);
boolean locatableNativePlacement = nativePlacement
&& IrisStructureLocator.hasLocatableNativePlacement(engine, key);
&& ModuleServices.canLocateStart(engine, key);
boolean locatableEditableReplacement = !nativePlacement
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
&& ModuleServices.canLocateStructure(engine, key);
@@ -128,8 +127,8 @@ final class ModdedUnregisteredStructures {
excluded.put(normalizedKey, new ExcludedStructure(ReportStatus.EXCLUDED, key, reason));
}
List<String> absentNativeKeys = missingConfiguredNativeKeys(
IrisStructureLocator.placedKeys(engine), registeredKeys,
(String key) -> IrisStructureLocator.hasNativePlacement(engine, key));
ModuleServices.placedStructures(engine), registeredKeys,
(String key) -> ModuleServices.startsStructure(engine, key));
for (String key : absentNativeKeys) {
String normalizedKey = ModdedCommandSuggestions.normalizeKey(key);
excluded.putIfAbsent(normalizedKey, new ExcludedStructure(ReportStatus.UNREGISTERED, key,
@@ -143,12 +142,12 @@ final class ModdedUnregisteredStructures {
continue;
}
boolean registered = registeredKeys.contains(normalizedKey);
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
boolean nativePlacement = ModuleServices.startsStructure(engine, key);
boolean locatableEditable = ModuleServices.canLocateStructure(engine, key);
if (!registered && !nativePlacement && locatableEditable) {
continue;
}
boolean configured = IrisStructureLocator.hasEditablePlacement(engine, key);
boolean configured = ModuleServices.placesStructure(engine, key);
excluded.putIfAbsent(normalizedKey, new ExcludedStructure(
ReportStatus.UNPLACED, key.trim(), editableExclusionReason(configured)));
}
@@ -197,16 +197,16 @@ public class IrisModdedStructureCommandTest {
assertTrue(method.contains("ServerLevel level = source.getLevel()"));
assertTrue(method.contains("Engine engine = IrisModdedCommands.engineFor(level)"));
assertFalse(method.contains("IrisStructureLocator.locatableKeys(engine)"));
assertFalse(method.contains("IrisStructureLocator"));
assertTrue(method.contains("ModuleServices.locatableStructures(engine)"));
assertTrue(method.contains("StructureReachability.reachableKeys(engine)"));
assertTrue(method.contains("NativeStructureGenerationPolicy.resolve(engine, key)"));
assertTrue(method.contains("IrisStructureLocator.hasLocatableNativePlacement(engine, key)"));
assertTrue(method.contains("ModuleServices.canLocateStart(engine, key)"));
assertTrue(method.contains("ModuleServices.canLocateStructure(engine, key)"));
assertTrue(method.contains("reachableNativeKeys.contains(normalizeKey(key))"));
assertTrue(method.contains("nativeGenerationEnabled"));
assertTrue(method.contains("eligibleUnregisteredEditableKeys("));
assertTrue(method.contains("IrisStructureLocator.hasNativePlacement(engine, candidate)"));
assertTrue(method.contains("ModuleServices.startsStructure(engine, candidate)"));
assertFalse(method.contains("NativeStructureGenerationKeys.active(level)"));
assertFalse(method.contains("getPlacementsForStructure"));
}
@@ -219,7 +219,7 @@ public class IrisModdedStructureCommandTest {
String method = source.substring(methodStart, methodEnd);
int registryLookup = method.indexOf("level.registryAccess().lookupOrThrow(Registries.STRUCTURE)");
int placedCheck = method.indexOf(
"if (!IrisStructureLocator.hasNativePlacement(current, structureId))");
"if (!ModuleServices.startsStructure(current, structureId))");
int irisLocate = method.indexOf("NativeStructureLocatePersistence.search(", placedCheck);
int nearestSelection = method.indexOf(
"NativeStructureLocateResults.nearest(pos, predicted, nativeLocated)", irisLocate);
@@ -235,7 +235,7 @@ public class IrisModdedStructureCommandTest {
assertTrue(selectedReference > selectedVerification);
assertTrue(method.contains("NativeStructureLocatePersistence.probe("));
assertTrue(method.contains("findUnexplored"));
assertTrue(method.contains("LocateStatus.SEARCH_LIMIT_REACHED"));
assertTrue(method.contains("Outcome.SEARCH_LIMIT_REACHED"));
assertTrue(method.contains("verified.ownership().locatorY()"));
assertTrue(method.contains("selectedSearch.search().reference(selectedStart)"));
assertTrue(method.contains("NativeStructureLocateResults.selectAndReference("));
@@ -271,12 +271,12 @@ public class IrisModdedStructureCommandTest {
assertTrue(eligibilityCheck > policyResolution);
assertTrue(replacementLocate > eligibilityCheck);
assertTrue(nativeLocate > replacementLocate);
assertTrue(method.contains("IrisStructureLocator.hasLocatableNativePlacement(engine, target.key())"));
assertTrue(method.contains("ModuleServices.canLocateStart(engine, target.key())"));
assertTrue(method.contains("ModuleServices.canLocateStructure(engine, target.key())"));
assertTrue(method.contains("!IrisStructureLocator.hasNativePlacement(engine, key)"));
assertTrue(method.contains("!ModuleServices.startsStructure(engine, key)"));
assertTrue(method.contains("StructureReachability.isReachable(engine, target.key())"));
assertTrue(method.contains("getWorldGenSettings().options().generateStructures()"));
assertFalse(method.contains("IrisStructureLocator.isPlaced(engine, key)"));
assertFalse(method.contains("ModuleServices.placesStructure(engine, key)"));
}
@Test
@@ -287,7 +287,7 @@ public class IrisModdedStructureCommandTest {
methodStart);
String method = source.substring(methodStart, methodEnd);
int nativeResolution = method.indexOf("resolveNativeStructure(source, level, engine, key)");
int genericIrisLookup = method.indexOf("IrisStructureLocator.isPlaced(engine, key)", nativeResolution);
int genericIrisLookup = method.indexOf("ModuleServices.placesStructure(engine, key)", nativeResolution);
assertTrue(nativeResolution >= 0);
assertTrue(genericIrisLookup > nativeResolution);