mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 10:14:36 +00:00
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:
1 parent
0cfcada4f2
commit
7d9fd3faa6
24 files changed
+385
-126
No files matched your search
+10
-10
@@ -3,7 +3,7 @@ package art.arcane.iris.core.nms.v26_2_R1;
|
|||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.framework.GenerationSessionException;
|
import art.arcane.iris.engine.framework.GenerationSessionException;
|
||||||
import art.arcane.iris.engine.framework.GenerationSessionLease;
|
import art.arcane.iris.engine.framework.GenerationSessionLease;
|
||||||
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
import art.arcane.iris.core.modules.ModuleServices;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureStartPlan;
|
import art.arcane.iris.engine.framework.NativeStructureStartPlan;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
|
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
|
||||||
@@ -208,7 +208,7 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
|||||||
throw new IllegalStateException("Native structure locate received an unregistered structure holder");
|
throw new IllegalStateException("Native structure locate received an unregistered structure holder");
|
||||||
}
|
}
|
||||||
String structureId = id.toString();
|
String structureId = id.toString();
|
||||||
if (!IrisStructureLocator.hasNativePlacement(engine, structureId)) {
|
if (!ModuleServices.startsStructure(engine, structureId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NativeStructureLocatePersistence.Probe probe = NativeStructureLocatePersistence.probe(
|
NativeStructureLocatePersistence.Probe probe = NativeStructureLocatePersistence.probe(
|
||||||
@@ -220,19 +220,19 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
|||||||
searches.sort(Comparator.comparing(IrisNativeLocateSearch::structureId));
|
searches.sort(Comparator.comparing(IrisNativeLocateSearch::structureId));
|
||||||
for (int attempt = 0; attempt < NativeStructureLocatePersistence.MAX_SELECTED_CANDIDATE_RETRIES; attempt++) {
|
for (int attempt = 0; attempt < NativeStructureLocatePersistence.MAX_SELECTED_CANDIDATE_RETRIES; attempt++) {
|
||||||
IrisNativeLocateSearch bestSearch = null;
|
IrisNativeLocateSearch bestSearch = null;
|
||||||
IrisStructureLocator.LocateResult bestResult = null;
|
ModuleServices.StructureSearch bestResult = null;
|
||||||
long bestDistance = Long.MAX_VALUE;
|
long bestDistance = Long.MAX_VALUE;
|
||||||
for (IrisNativeLocateSearch search : searches) {
|
for (IrisNativeLocateSearch search : searches) {
|
||||||
IrisStructureLocator.LocateResult result = search.search().predict();
|
ModuleServices.StructureSearch result = search.search().predict();
|
||||||
if (result.status() == IrisStructureLocator.LocateStatus.SEARCH_LIMIT_REACHED) {
|
if (result.outcome() == ModuleServices.StructureSearch.Outcome.SEARCH_LIMIT_REACHED) {
|
||||||
throw new IllegalStateException("Iris structure locate reached its safety limit for "
|
throw new IllegalStateException("Iris structure locate reached its safety limit for "
|
||||||
+ search.structureId() + " within " + radius + " placement rings");
|
+ search.structureId() + " within " + radius + " placement rings");
|
||||||
}
|
}
|
||||||
if (!result.found()) {
|
if (!result.found()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
long dx = (long) result.originX() - pos.getX();
|
long dx = (long) result.x() - pos.getX();
|
||||||
long dz = (long) result.originZ() - pos.getZ();
|
long dz = (long) result.z() - pos.getZ();
|
||||||
long distance = dx * dx + dz * dz;
|
long distance = dx * dx + dz * dz;
|
||||||
if (distance < bestDistance) {
|
if (distance < bestDistance) {
|
||||||
bestDistance = distance;
|
bestDistance = distance;
|
||||||
@@ -245,7 +245,7 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
|||||||
pos, null, () -> { }, nativeLocated, nativeReference);
|
pos, null, () -> { }, nativeLocated, nativeReference);
|
||||||
}
|
}
|
||||||
Pair<BlockPos, Holder<Structure>> predicted = Pair.of(
|
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());
|
bestSearch.holder());
|
||||||
if (NativeStructureLocateResults.nearest(pos, predicted, nativeLocated) != predicted) {
|
if (NativeStructureLocateResults.nearest(pos, predicted, nativeLocated) != predicted) {
|
||||||
return NativeStructureLocateResults.selectAndReference(
|
return NativeStructureLocateResults.selectAndReference(
|
||||||
@@ -258,8 +258,8 @@ public class IrisChunkGenerator extends CustomChunkGenerator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BlockPos located = new BlockPos(
|
BlockPos located = new BlockPos(
|
||||||
bestResult.originX(), verified.ownership().locatorY(),
|
bestResult.x(), verified.ownership().locatorY(),
|
||||||
bestResult.originZ());
|
bestResult.z());
|
||||||
Pair<BlockPos, Holder<Structure>> irisLocated = Pair.of(located, bestSearch.holder());
|
Pair<BlockPos, Holder<Structure>> irisLocated = Pair.of(located, bestSearch.holder());
|
||||||
IrisNativeLocateSearch selectedSearch = bestSearch;
|
IrisNativeLocateSearch selectedSearch = bestSearch;
|
||||||
NativeStructureLocatePersistence.VerifiedStart selectedStart = verified;
|
NativeStructureLocatePersistence.VerifiedStart selectedStart = verified;
|
||||||
|
|||||||
+2
-2
@@ -31,9 +31,9 @@ public class IrisChunkGeneratorMonumentLocateContractTest {
|
|||||||
String irisHelper = source.substring(irisHelperStart, filterStart);
|
String irisHelper = source.substring(irisHelperStart, filterStart);
|
||||||
int registryLookup = irisHelper.indexOf("level.registryAccess().lookupOrThrow(Registries.STRUCTURE)");
|
int registryLookup = irisHelper.indexOf("level.registryAccess().lookupOrThrow(Registries.STRUCTURE)");
|
||||||
int placedCheck = irisHelper.indexOf(
|
int placedCheck = irisHelper.indexOf(
|
||||||
"if (!IrisStructureLocator.hasNativePlacement(engine, structureId))");
|
"if (!ModuleServices.startsStructure(engine, structureId))");
|
||||||
int irisLocate = irisHelper.indexOf("NativeStructureLocatePersistence.search(", placedCheck);
|
int irisLocate = irisHelper.indexOf("NativeStructureLocatePersistence.search(", placedCheck);
|
||||||
int searchLimit = irisHelper.indexOf("LocateStatus.SEARCH_LIMIT_REACHED", irisLocate);
|
int searchLimit = irisHelper.indexOf("Outcome.SEARCH_LIMIT_REACHED", irisLocate);
|
||||||
int nativeFilter = outerMethod.indexOf("filterReachableStructures(level, holders)");
|
int nativeFilter = outerMethod.indexOf("filterReachableStructures(level, holders)");
|
||||||
int nativePrediction = outerMethod.indexOf("NativeStructureVanillaLocator.predict(", nativeFilter);
|
int nativePrediction = outerMethod.indexOf("NativeStructureVanillaLocator.predict(", nativeFilter);
|
||||||
int irisResolution = outerMethod.indexOf("return findNearestIrisStructure(", nativePrediction);
|
int irisResolution = outerMethod.indexOf("return findNearestIrisStructure(", nativePrediction);
|
||||||
|
|||||||
+9
-10
@@ -26,7 +26,6 @@ import art.arcane.iris.core.localization.IrisLanguage;
|
|||||||
import art.arcane.iris.core.datapack.DatapackIngestService;
|
import art.arcane.iris.core.datapack.DatapackIngestService;
|
||||||
import art.arcane.iris.core.service.ObjectStudioSaveService;
|
import art.arcane.iris.core.service.ObjectStudioSaveService;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
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.NativeStructureGenerationPolicy;
|
||||||
import art.arcane.iris.engine.framework.StructureReachability;
|
import art.arcane.iris.engine.framework.StructureReachability;
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
@@ -146,8 +145,8 @@ public class CommandFind implements DirectorExecutor {
|
|||||||
NativeStructureGenerationStatus status = registered
|
NativeStructureGenerationStatus status = registered
|
||||||
? NativeStructureGenerationPolicy.resolve(e, structureKey)
|
? NativeStructureGenerationPolicy.resolve(e, structureKey)
|
||||||
: null;
|
: null;
|
||||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(e, structureKey);
|
boolean nativePlacement = ModuleServices.startsStructure(e, structureKey);
|
||||||
boolean locatableNativePlacement = IrisStructureLocator.hasLocatableNativePlacement(e, structureKey);
|
boolean locatableNativePlacement = ModuleServices.canLocateStart(e, structureKey);
|
||||||
boolean locatableEditablePlacement = ModuleServices.canLocateStructure(e, structureKey);
|
boolean locatableEditablePlacement = ModuleServices.canLocateStructure(e, structureKey);
|
||||||
World targetWorld = target.getWorld();
|
World targetWorld = target.getWorld();
|
||||||
boolean nativeGenerationEnabled = targetWorld.canGenerateStructures();
|
boolean nativeGenerationEnabled = targetWorld.canGenerateStructures();
|
||||||
@@ -273,8 +272,8 @@ public class CommandFind implements DirectorExecutor {
|
|||||||
String normalizedKey = entry.getKey();
|
String normalizedKey = entry.getKey();
|
||||||
String key = entry.getValue();
|
String key = entry.getValue();
|
||||||
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
|
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
|
||||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
|
boolean nativePlacement = ModuleServices.startsStructure(engine, key);
|
||||||
boolean locatableNativePlacement = IrisStructureLocator.hasLocatableNativePlacement(engine, key);
|
boolean locatableNativePlacement = ModuleServices.canLocateStart(engine, key);
|
||||||
boolean locatableEditablePlacement = ModuleServices.canLocateStructure(engine, key);
|
boolean locatableEditablePlacement = ModuleServices.canLocateStructure(engine, key);
|
||||||
StructureLookupRoute route = selectStructureLookupRoute(
|
StructureLookupRoute route = selectStructureLookupRoute(
|
||||||
true, status, nativePlacement, locatableNativePlacement,
|
true, status, nativePlacement, locatableNativePlacement,
|
||||||
@@ -296,18 +295,18 @@ public class CommandFind implements DirectorExecutor {
|
|||||||
|
|
||||||
int configuredUnregistered = 0;
|
int configuredUnregistered = 0;
|
||||||
Set<String> configuredUnregisteredKeys = new LinkedHashSet<>();
|
Set<String> configuredUnregisteredKeys = new LinkedHashSet<>();
|
||||||
for (String configuredKey : IrisStructureLocator.placedKeys(engine)) {
|
for (String configuredKey : ModuleServices.placedStructures(engine)) {
|
||||||
String normalizedKey = normalizeStructureKey(configuredKey);
|
String normalizedKey = normalizeStructureKey(configuredKey);
|
||||||
if (normalizedKey.isEmpty()
|
if (normalizedKey.isEmpty()
|
||||||
|| registeredKeys.containsKey(normalizedKey)
|
|| registeredKeys.containsKey(normalizedKey)
|
||||||
|| !IrisStructureLocator.hasNativePlacement(engine, configuredKey)
|
|| !ModuleServices.startsStructure(engine, configuredKey)
|
||||||
|| !configuredUnregisteredKeys.add(normalizedKey)) {
|
|| !configuredUnregisteredKeys.add(normalizedKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
exclusions.add(new StructureExclusion(
|
exclusions.add(new StructureExclusion(
|
||||||
StructureExclusionKind.UNREGISTERED, configuredKey, null,
|
StructureExclusionKind.UNREGISTERED, configuredKey, null,
|
||||||
describeConfiguredUnregisteredNative(
|
describeConfiguredUnregisteredNative(
|
||||||
IrisStructureLocator.hasLocatableNativePlacement(engine, configuredKey))));
|
ModuleServices.canLocateStart(engine, configuredKey))));
|
||||||
configuredUnregistered++;
|
configuredUnregistered++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,11 +318,11 @@ public class CommandFind implements DirectorExecutor {
|
|||||||
String normalizedKey = normalizeStructureKey(editableKey);
|
String normalizedKey = normalizeStructureKey(editableKey);
|
||||||
if (!isUnplacedEditableCandidate(
|
if (!isUnplacedEditableCandidate(
|
||||||
normalizedKey, registeredKeys.keySet(), locatableEditableKeys,
|
normalizedKey, registeredKeys.keySet(), locatableEditableKeys,
|
||||||
IrisStructureLocator.hasNativePlacement(engine, editableKey))
|
ModuleServices.startsStructure(engine, editableKey))
|
||||||
|| !unplacedEditableKeys.add(normalizedKey)) {
|
|| !unplacedEditableKeys.add(normalizedKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean configuredPlacement = IrisStructureLocator.hasEditablePlacement(engine, editableKey);
|
boolean configuredPlacement = ModuleServices.placesStructure(engine, editableKey);
|
||||||
String reason = configuredPlacement
|
String reason = configuredPlacement
|
||||||
? "editable Iris structure has a configured placement, but no matching placement is active "
|
? "editable Iris structure has a configured placement, but no matching placement is active "
|
||||||
+ "because its density is not positive or its Y band does not intersect this world"
|
+ "because its density is not positive or its Y band does not intersect this world"
|
||||||
|
|||||||
+8
-8
@@ -28,7 +28,7 @@ import art.arcane.iris.core.structure.StructureCaptureImporter;
|
|||||||
import art.arcane.iris.core.structure.StructureImporter;
|
import art.arcane.iris.core.structure.StructureImporter;
|
||||||
import art.arcane.iris.core.structure.StructureIndexService;
|
import art.arcane.iris.core.structure.StructureIndexService;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
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.NativeStructureGenerationPolicy;
|
||||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||||
import art.arcane.iris.engine.framework.StructureAssembler;
|
import art.arcane.iris.engine.framework.StructureAssembler;
|
||||||
@@ -156,7 +156,7 @@ public class CommandStructure implements DirectorExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String placedKey : IrisStructureLocator.placedKeys(engine)) {
|
for (String placedKey : ModuleServices.placedStructures(engine)) {
|
||||||
if (!structureKeys.contains(placedKey)) {
|
if (!structureKeys.contains(placedKey)) {
|
||||||
structureKeys.add(placedKey);
|
structureKeys.add(placedKey);
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ public class CommandStructure implements DirectorExecutor {
|
|||||||
for (String keyName : structureKeys) {
|
for (String keyName : structureKeys) {
|
||||||
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, keyName);
|
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, keyName);
|
||||||
statuses.put(keyName, status);
|
statuses.put(keyName, status);
|
||||||
requiresNativeReachability |= !IrisStructureLocator.isPlaced(engine, keyName)
|
requiresNativeReachability |= !ModuleServices.placesStructure(engine, keyName)
|
||||||
&& status == NativeStructureGenerationStatus.GENERATE_NATIVE;
|
&& status == NativeStructureGenerationStatus.GENERATE_NATIVE;
|
||||||
}
|
}
|
||||||
Set<String> reachable = Set.of();
|
Set<String> reachable = Set.of();
|
||||||
@@ -199,11 +199,11 @@ public class CommandStructure implements DirectorExecutor {
|
|||||||
int errors = 0;
|
int errors = 0;
|
||||||
for (String keyName : structureKeys) {
|
for (String keyName : structureKeys) {
|
||||||
NativeStructureGenerationStatus status = statuses.get(keyName);
|
NativeStructureGenerationStatus status = statuses.get(keyName);
|
||||||
if (IrisStructureLocator.isPlaced(engine, keyName)) {
|
if (ModuleServices.placesStructure(engine, keyName)) {
|
||||||
try {
|
try {
|
||||||
IrisStructureLocator.LocateResult result =
|
ModuleServices.StructureSearch result =
|
||||||
IrisStructureLocator.locate(engine, keyName, centerX, centerZ, searchRadius);
|
ModuleServices.locateStructure(engine, keyName, centerX, centerZ, searchRadius);
|
||||||
if (result.status() == IrisStructureLocator.LocateStatus.SEARCH_LIMIT_REACHED) {
|
if (result.outcome() == ModuleServices.StructureSearch.Outcome.SEARCH_LIMIT_REACHED) {
|
||||||
searchLimited++;
|
searchLimited++;
|
||||||
messages.add(C.YELLOW + "[iris-search-limit] " + C.WHITE + keyName + C.YELLOW
|
messages.add(C.YELLOW + "[iris-search-limit] " + C.WHITE + keyName + C.YELLOW
|
||||||
+ ": unable to complete the density search before its safety limit was reached");
|
+ ": unable to complete the density search before its safety limit was reached");
|
||||||
@@ -215,7 +215,7 @@ public class CommandStructure implements DirectorExecutor {
|
|||||||
}
|
}
|
||||||
located++;
|
located++;
|
||||||
messages.add(C.AQUA + "[iris-planned] " + C.WHITE + keyName + C.GREEN + " @ "
|
messages.add(C.AQUA + "[iris-planned] " + C.WHITE + keyName + C.GREEN + " @ "
|
||||||
+ result.originX() + "," + result.baseY() + "," + result.originZ());
|
+ result.x() + "," + result.y() + "," + result.z());
|
||||||
} catch (Throwable error) {
|
} catch (Throwable error) {
|
||||||
errors++;
|
errors++;
|
||||||
messages.add(C.RED + "[error] " + C.WHITE + keyName + C.RED + ": "
|
messages.add(C.RED + "[error] " + C.WHITE + keyName + C.RED + ": "
|
||||||
|
|||||||
+4
-4
@@ -35,7 +35,7 @@ public class IrisStructureLocateCommandContractTest {
|
|||||||
int nativeResolution = method.indexOf("resolveNativeStructure(structureKey)");
|
int nativeResolution = method.indexOf("resolveNativeStructure(structureKey)");
|
||||||
int policyResolution = method.indexOf("NativeStructureGenerationPolicy.resolve(", nativeResolution);
|
int policyResolution = method.indexOf("NativeStructureGenerationPolicy.resolve(", nativeResolution);
|
||||||
int nativeLocatableCheck = method.indexOf(
|
int nativeLocatableCheck = method.indexOf(
|
||||||
"IrisStructureLocator.hasLocatableNativePlacement(e, structureKey)", policyResolution);
|
"ModuleServices.canLocateStart(e, structureKey)", policyResolution);
|
||||||
int editableLocatableCheck = method.indexOf(
|
int editableLocatableCheck = method.indexOf(
|
||||||
"ModuleServices.canLocateStructure(e, structureKey)", nativeLocatableCheck);
|
"ModuleServices.canLocateStructure(e, structureKey)", nativeLocatableCheck);
|
||||||
int worldGenerationCheck = method.indexOf("targetWorld.canGenerateStructures()", editableLocatableCheck);
|
int worldGenerationCheck = method.indexOf("targetWorld.canGenerateStructures()", editableLocatableCheck);
|
||||||
@@ -49,7 +49,7 @@ public class IrisStructureLocateCommandContractTest {
|
|||||||
assertTrue(worldGenerationCheck > editableLocatableCheck);
|
assertTrue(worldGenerationCheck > editableLocatableCheck);
|
||||||
assertTrue(routeResolution > editableLocatableCheck);
|
assertTrue(routeResolution > editableLocatableCheck);
|
||||||
assertTrue(nativeLocate > routeResolution);
|
assertTrue(nativeLocate > routeResolution);
|
||||||
assertFalse(method.contains("IrisStructureLocator.isPlaced(e, structureKey)"));
|
assertFalse(method.contains("ModuleServices.placesStructure(e, structureKey)"));
|
||||||
assertFalse(method.contains("NativeStructureLocateCapability"));
|
assertFalse(method.contains("NativeStructureLocateCapability"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ public class IrisStructureLocateCommandContractTest {
|
|||||||
|
|
||||||
assertTrue(source.contains("[iris-search-limit]"));
|
assertTrue(source.contains("[iris-search-limit]"));
|
||||||
assertTrue(source.contains("density searches safety-limited"));
|
assertTrue(source.contains("density searches safety-limited"));
|
||||||
assertTrue(source.contains("result.originX() + \",\" + result.baseY() + \",\" + result.originZ()"));
|
assertTrue(source.contains("result.x() + \",\" + result.y() + \",\" + result.z()"));
|
||||||
assertFalse(source.contains("at[0] + 8"));
|
assertFalse(source.contains("at[0] + 8"));
|
||||||
assertFalse(source.contains("at[2] + 8"));
|
assertFalse(source.contains("at[2] + 8"));
|
||||||
}
|
}
|
||||||
@@ -282,7 +282,7 @@ public class IrisStructureLocateCommandContractTest {
|
|||||||
String method = source.substring(methodStart, methodEnd);
|
String method = source.substring(methodStart, methodEnd);
|
||||||
int policyResolution = method.indexOf("NativeStructureGenerationPolicy.resolve(engine, keyName)");
|
int policyResolution = method.indexOf("NativeStructureGenerationPolicy.resolve(engine, keyName)");
|
||||||
int nativeRequirement = method.indexOf(
|
int nativeRequirement = method.indexOf(
|
||||||
"requiresNativeReachability |= !IrisStructureLocator.isPlaced", policyResolution);
|
"requiresNativeReachability |= !ModuleServices.placesStructure", policyResolution);
|
||||||
int reachabilityGuard = method.indexOf("if (requiresNativeReachability)", nativeRequirement);
|
int reachabilityGuard = method.indexOf("if (requiresNativeReachability)", nativeRequirement);
|
||||||
int reachabilityLookup = method.indexOf("StructureReachability.reachableKeys(engine)", reachabilityGuard);
|
int reachabilityLookup = method.indexOf("StructureReachability.reachableKeys(engine)", reachabilityGuard);
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -1,7 +1,8 @@
|
|||||||
package art.arcane.iris.nativegen;
|
package art.arcane.iris.nativegen;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
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.core.modules.StructureSearchLimitException;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
import art.arcane.iris.engine.framework.NativeStructureOwnershipRecord;
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
@@ -149,7 +150,7 @@ public final class NativeStructureLocatePersistence {
|
|||||||
|
|
||||||
private void claim() {
|
private void claim() {
|
||||||
if (used >= maximum) {
|
if (used >= maximum) {
|
||||||
throw new IrisStructureLocator.CandidateSearchLimitException();
|
throw new StructureSearchLimitException();
|
||||||
}
|
}
|
||||||
used++;
|
used++;
|
||||||
}
|
}
|
||||||
@@ -256,20 +257,19 @@ public final class NativeStructureLocatePersistence {
|
|||||||
this.probe = probe;
|
this.probe = probe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisStructureLocator.LocateResult predict() {
|
public ModuleServices.StructureSearch predict() {
|
||||||
if (rejectedChunks.size() >= MAX_SELECTED_CANDIDATE_RETRIES) {
|
if (rejectedChunks.size() >= MAX_SELECTED_CANDIDATE_RETRIES) {
|
||||||
return new IrisStructureLocator.LocateResult(
|
return ModuleServices.StructureSearch.SEARCH_LIMIT_REACHED;
|
||||||
IrisStructureLocator.LocateStatus.SEARCH_LIMIT_REACHED, 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
return IrisStructureLocator.locateInPlacementRings(
|
return ModuleServices.locateStart(
|
||||||
engine, structureKey, blockX, blockZ, radius,
|
engine, structureKey, blockX, blockZ, radius,
|
||||||
(chunkX, chunkZ) -> !rejectedChunks.contains(ChunkPos.pack(chunkX, chunkZ))
|
(chunkX, chunkZ) -> !rejectedChunks.contains(ChunkPos.pack(chunkX, chunkZ))
|
||||||
&& probe.accepts(chunkX, chunkZ));
|
&& probe.accepts(chunkX, chunkZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public VerifiedStart verify(IrisStructureLocator.LocateResult result) {
|
public VerifiedStart verify(ModuleServices.StructureSearch result) {
|
||||||
int chunkX = result.originX() >> 4;
|
int chunkX = result.x() >> 4;
|
||||||
int chunkZ = result.originZ() >> 4;
|
int chunkZ = result.z() >> 4;
|
||||||
StructureStart start = probe.verifySelected(chunkX, chunkZ);
|
StructureStart start = probe.verifySelected(chunkX, chunkZ);
|
||||||
if (start == null) {
|
if (start == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -282,8 +282,8 @@ public final class NativeStructureLocatePersistence {
|
|||||||
return new VerifiedStart(start, ownership);
|
return new VerifiedStart(start, ownership);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reject(IrisStructureLocator.LocateResult result) {
|
public void reject(ModuleServices.StructureSearch result) {
|
||||||
rejectedChunks.add(ChunkPos.pack(result.originX() >> 4, result.originZ() >> 4));
|
rejectedChunks.add(ChunkPos.pack(result.x() >> 4, result.z() >> 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reference(VerifiedStart verified) {
|
public void reference(VerifiedStart verified) {
|
||||||
|
|||||||
+10
-10
@@ -19,7 +19,7 @@
|
|||||||
package art.arcane.iris.modded;
|
package art.arcane.iris.modded;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
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.NativeStructureGenerationPolicy;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureLayouts;
|
import art.arcane.iris.engine.framework.NativeStructureLayouts;
|
||||||
import art.arcane.iris.engine.framework.nativefit.NativeStructureFitting;
|
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");
|
throw new IllegalStateException("Native structure locate received an unregistered structure holder");
|
||||||
}
|
}
|
||||||
String structureId = id.toString();
|
String structureId = id.toString();
|
||||||
if (!IrisStructureLocator.hasNativePlacement(current, structureId)) {
|
if (!ModuleServices.startsStructure(current, structureId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NativeStructureLocatePersistence.Probe probe = NativeStructureLocatePersistence.probe(
|
NativeStructureLocatePersistence.Probe probe = NativeStructureLocatePersistence.probe(
|
||||||
@@ -141,19 +141,19 @@ final class ModdedNativeStructureStage {
|
|||||||
searches.sort(Comparator.comparing(IrisNativeLocateSearch::structureId));
|
searches.sort(Comparator.comparing(IrisNativeLocateSearch::structureId));
|
||||||
for (int attempt = 0; attempt < NativeStructureLocatePersistence.MAX_SELECTED_CANDIDATE_RETRIES; attempt++) {
|
for (int attempt = 0; attempt < NativeStructureLocatePersistence.MAX_SELECTED_CANDIDATE_RETRIES; attempt++) {
|
||||||
IrisNativeLocateSearch bestSearch = null;
|
IrisNativeLocateSearch bestSearch = null;
|
||||||
IrisStructureLocator.LocateResult bestResult = null;
|
ModuleServices.StructureSearch bestResult = null;
|
||||||
long bestDistance = Long.MAX_VALUE;
|
long bestDistance = Long.MAX_VALUE;
|
||||||
for (IrisNativeLocateSearch search : searches) {
|
for (IrisNativeLocateSearch search : searches) {
|
||||||
IrisStructureLocator.LocateResult result = search.search().predict();
|
ModuleServices.StructureSearch result = search.search().predict();
|
||||||
if (result.status() == IrisStructureLocator.LocateStatus.SEARCH_LIMIT_REACHED) {
|
if (result.outcome() == ModuleServices.StructureSearch.Outcome.SEARCH_LIMIT_REACHED) {
|
||||||
throw new IllegalStateException("Iris structure locate reached its safety limit for "
|
throw new IllegalStateException("Iris structure locate reached its safety limit for "
|
||||||
+ search.structureId() + " within " + radius + " placement rings");
|
+ search.structureId() + " within " + radius + " placement rings");
|
||||||
}
|
}
|
||||||
if (!result.found()) {
|
if (!result.found()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
long dx = (long) result.originX() - pos.getX();
|
long dx = (long) result.x() - pos.getX();
|
||||||
long dz = (long) result.originZ() - pos.getZ();
|
long dz = (long) result.z() - pos.getZ();
|
||||||
long distance = dx * dx + dz * dz;
|
long distance = dx * dx + dz * dz;
|
||||||
if (distance < bestDistance) {
|
if (distance < bestDistance) {
|
||||||
bestDistance = distance;
|
bestDistance = distance;
|
||||||
@@ -166,7 +166,7 @@ final class ModdedNativeStructureStage {
|
|||||||
pos, null, () -> { }, nativeLocated, nativeReference);
|
pos, null, () -> { }, nativeLocated, nativeReference);
|
||||||
}
|
}
|
||||||
Pair<BlockPos, Holder<Structure>> predicted = Pair.of(
|
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());
|
bestSearch.holder());
|
||||||
if (NativeStructureLocateResults.nearest(pos, predicted, nativeLocated) != predicted) {
|
if (NativeStructureLocateResults.nearest(pos, predicted, nativeLocated) != predicted) {
|
||||||
return NativeStructureLocateResults.selectAndReference(
|
return NativeStructureLocateResults.selectAndReference(
|
||||||
@@ -179,8 +179,8 @@ final class ModdedNativeStructureStage {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BlockPos located = new BlockPos(
|
BlockPos located = new BlockPos(
|
||||||
bestResult.originX(), verified.ownership().locatorY(),
|
bestResult.x(), verified.ownership().locatorY(),
|
||||||
bestResult.originZ());
|
bestResult.z());
|
||||||
Pair<BlockPos, Holder<Structure>> irisLocated = Pair.of(located, bestSearch.holder());
|
Pair<BlockPos, Holder<Structure>> irisLocated = Pair.of(located, bestSearch.holder());
|
||||||
IrisNativeLocateSearch selectedSearch = bestSearch;
|
IrisNativeLocateSearch selectedSearch = bestSearch;
|
||||||
NativeStructureLocatePersistence.VerifiedStart selectedStart = verified;
|
NativeStructureLocatePersistence.VerifiedStart selectedStart = verified;
|
||||||
|
|||||||
+3
-4
@@ -23,7 +23,6 @@ import art.arcane.iris.modded.ModdedIrisLog;
|
|||||||
import art.arcane.iris.spi.IrisPlatforms;
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
import art.arcane.iris.core.pack.PackDirectoryResolver;
|
import art.arcane.iris.core.pack.PackDirectoryResolver;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
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.NativeStructureGenerationPolicy;
|
||||||
import art.arcane.iris.engine.framework.StructureReachability;
|
import art.arcane.iris.engine.framework.StructureReachability;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
||||||
@@ -133,9 +132,9 @@ final class ModdedCommandSuggestions {
|
|||||||
String key = identifier.toString();
|
String key = identifier.toString();
|
||||||
registeredKeys.add(normalizeKey(key));
|
registeredKeys.add(normalizeKey(key));
|
||||||
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
|
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
|
||||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
|
boolean nativePlacement = ModuleServices.startsStructure(engine, key);
|
||||||
boolean locatableNativePlacement = nativePlacement
|
boolean locatableNativePlacement = nativePlacement
|
||||||
&& IrisStructureLocator.hasLocatableNativePlacement(engine, key);
|
&& ModuleServices.canLocateStart(engine, key);
|
||||||
boolean locatableEditableReplacement = !nativePlacement
|
boolean locatableEditableReplacement = !nativePlacement
|
||||||
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
|
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
|
||||||
&& ModuleServices.canLocateStructure(engine, key);
|
&& ModuleServices.canLocateStructure(engine, key);
|
||||||
@@ -147,7 +146,7 @@ final class ModdedCommandSuggestions {
|
|||||||
}
|
}
|
||||||
Collection<String> unregisteredIrisKeys = eligibleUnregisteredEditableKeys(
|
Collection<String> unregisteredIrisKeys = eligibleUnregisteredEditableKeys(
|
||||||
irisKeys, registeredKeys,
|
irisKeys, registeredKeys,
|
||||||
(String candidate) -> IrisStructureLocator.hasNativePlacement(engine, candidate));
|
(String candidate) -> ModuleServices.startsStructure(engine, candidate));
|
||||||
return SharedSuggestionProvider.suggest(
|
return SharedSuggestionProvider.suggest(
|
||||||
combineStructureKeys(unregisteredIrisKeys, nativeKeys), builder);
|
combineStructureKeys(unregisteredIrisKeys, nativeKeys), builder);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|||||||
+5
-6
@@ -25,7 +25,6 @@ import art.arcane.iris.core.localization.ModdedCommandMessages;
|
|||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.framework.GenerationSessionException;
|
import art.arcane.iris.engine.framework.GenerationSessionException;
|
||||||
import art.arcane.iris.engine.framework.GenerationSessionLease;
|
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.Locator;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
|
import art.arcane.iris.engine.framework.NativeStructureGenerationPolicy;
|
||||||
import art.arcane.iris.engine.framework.StructureReachability;
|
import art.arcane.iris.engine.framework.StructureReachability;
|
||||||
@@ -156,7 +155,7 @@ final class ModdedLocateCommands {
|
|||||||
}
|
}
|
||||||
Optional<NativeStructureTarget> resolved = resolveNativeStructure(source, level, engine, key);
|
Optional<NativeStructureTarget> resolved = resolveNativeStructure(source, level, engine, key);
|
||||||
if (resolved.isEmpty()) {
|
if (resolved.isEmpty()) {
|
||||||
if (!IrisStructureLocator.hasNativePlacement(engine, key)
|
if (!ModuleServices.startsStructure(engine, key)
|
||||||
&& ModuleServices.canLocateStructure(engine, key)) {
|
&& ModuleServices.canLocateStructure(engine, key)) {
|
||||||
locateIrisStructure(source, level, engine, player, key);
|
locateIrisStructure(source, level, engine, player, key);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -168,9 +167,9 @@ final class ModdedLocateCommands {
|
|||||||
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, target.key());
|
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, target.key());
|
||||||
boolean nativeGenerationEnabled =
|
boolean nativeGenerationEnabled =
|
||||||
source.getServer().getWorldGenSettings().options().generateStructures();
|
source.getServer().getWorldGenSettings().options().generateStructures();
|
||||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, target.key());
|
boolean nativePlacement = ModuleServices.startsStructure(engine, target.key());
|
||||||
boolean locatableNativePlacement = nativePlacement
|
boolean locatableNativePlacement = nativePlacement
|
||||||
&& IrisStructureLocator.hasLocatableNativePlacement(engine, target.key());
|
&& ModuleServices.canLocateStart(engine, target.key());
|
||||||
boolean locatableEditableReplacement = !nativePlacement
|
boolean locatableEditableReplacement = !nativePlacement
|
||||||
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
|
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
|
||||||
&& ModuleServices.canLocateStructure(engine, target.key());
|
&& ModuleServices.canLocateStructure(engine, target.key());
|
||||||
@@ -357,7 +356,7 @@ final class ModdedLocateCommands {
|
|||||||
case NO_PLACEMENT -> unsupported++;
|
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)));
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -365,7 +364,7 @@ final class ModdedLocateCommands {
|
|||||||
private static int verifyStructure(CommandSourceStack source, ServerLevel level, Engine engine, String key) {
|
private static int verifyStructure(CommandSourceStack source, ServerLevel level, Engine engine, String key) {
|
||||||
Optional<NativeStructureTarget> target = resolveNativeStructure(source, level, engine, key);
|
Optional<NativeStructureTarget> target = resolveNativeStructure(source, level, engine, key);
|
||||||
if (target.isEmpty()) {
|
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)));
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-7
@@ -21,7 +21,6 @@ package art.arcane.iris.modded.command;
|
|||||||
import art.arcane.iris.core.modules.ModuleServices;
|
import art.arcane.iris.core.modules.ModuleServices;
|
||||||
import art.arcane.iris.modded.ModdedIrisLog;
|
import art.arcane.iris.modded.ModdedIrisLog;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
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.NativeStructureGenerationPolicy;
|
||||||
import art.arcane.iris.engine.framework.StructureReachability;
|
import art.arcane.iris.engine.framework.StructureReachability;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
||||||
@@ -107,9 +106,9 @@ final class ModdedUnregisteredStructures {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
|
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
|
||||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
|
boolean nativePlacement = ModuleServices.startsStructure(engine, key);
|
||||||
boolean locatableNativePlacement = nativePlacement
|
boolean locatableNativePlacement = nativePlacement
|
||||||
&& IrisStructureLocator.hasLocatableNativePlacement(engine, key);
|
&& ModuleServices.canLocateStart(engine, key);
|
||||||
boolean locatableEditableReplacement = !nativePlacement
|
boolean locatableEditableReplacement = !nativePlacement
|
||||||
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
|
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
|
||||||
&& ModuleServices.canLocateStructure(engine, key);
|
&& ModuleServices.canLocateStructure(engine, key);
|
||||||
@@ -128,8 +127,8 @@ final class ModdedUnregisteredStructures {
|
|||||||
excluded.put(normalizedKey, new ExcludedStructure(ReportStatus.EXCLUDED, key, reason));
|
excluded.put(normalizedKey, new ExcludedStructure(ReportStatus.EXCLUDED, key, reason));
|
||||||
}
|
}
|
||||||
List<String> absentNativeKeys = missingConfiguredNativeKeys(
|
List<String> absentNativeKeys = missingConfiguredNativeKeys(
|
||||||
IrisStructureLocator.placedKeys(engine), registeredKeys,
|
ModuleServices.placedStructures(engine), registeredKeys,
|
||||||
(String key) -> IrisStructureLocator.hasNativePlacement(engine, key));
|
(String key) -> ModuleServices.startsStructure(engine, key));
|
||||||
for (String key : absentNativeKeys) {
|
for (String key : absentNativeKeys) {
|
||||||
String normalizedKey = ModdedCommandSuggestions.normalizeKey(key);
|
String normalizedKey = ModdedCommandSuggestions.normalizeKey(key);
|
||||||
excluded.putIfAbsent(normalizedKey, new ExcludedStructure(ReportStatus.UNREGISTERED, key,
|
excluded.putIfAbsent(normalizedKey, new ExcludedStructure(ReportStatus.UNREGISTERED, key,
|
||||||
@@ -143,12 +142,12 @@ final class ModdedUnregisteredStructures {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean registered = registeredKeys.contains(normalizedKey);
|
boolean registered = registeredKeys.contains(normalizedKey);
|
||||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
|
boolean nativePlacement = ModuleServices.startsStructure(engine, key);
|
||||||
boolean locatableEditable = ModuleServices.canLocateStructure(engine, key);
|
boolean locatableEditable = ModuleServices.canLocateStructure(engine, key);
|
||||||
if (!registered && !nativePlacement && locatableEditable) {
|
if (!registered && !nativePlacement && locatableEditable) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean configured = IrisStructureLocator.hasEditablePlacement(engine, key);
|
boolean configured = ModuleServices.placesStructure(engine, key);
|
||||||
excluded.putIfAbsent(normalizedKey, new ExcludedStructure(
|
excluded.putIfAbsent(normalizedKey, new ExcludedStructure(
|
||||||
ReportStatus.UNPLACED, key.trim(), editableExclusionReason(configured)));
|
ReportStatus.UNPLACED, key.trim(), editableExclusionReason(configured)));
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -197,16 +197,16 @@ public class IrisModdedStructureCommandTest {
|
|||||||
|
|
||||||
assertTrue(method.contains("ServerLevel level = source.getLevel()"));
|
assertTrue(method.contains("ServerLevel level = source.getLevel()"));
|
||||||
assertTrue(method.contains("Engine engine = IrisModdedCommands.engineFor(level)"));
|
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("ModuleServices.locatableStructures(engine)"));
|
||||||
assertTrue(method.contains("StructureReachability.reachableKeys(engine)"));
|
assertTrue(method.contains("StructureReachability.reachableKeys(engine)"));
|
||||||
assertTrue(method.contains("NativeStructureGenerationPolicy.resolve(engine, key)"));
|
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("ModuleServices.canLocateStructure(engine, key)"));
|
||||||
assertTrue(method.contains("reachableNativeKeys.contains(normalizeKey(key))"));
|
assertTrue(method.contains("reachableNativeKeys.contains(normalizeKey(key))"));
|
||||||
assertTrue(method.contains("nativeGenerationEnabled"));
|
assertTrue(method.contains("nativeGenerationEnabled"));
|
||||||
assertTrue(method.contains("eligibleUnregisteredEditableKeys("));
|
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("NativeStructureGenerationKeys.active(level)"));
|
||||||
assertFalse(method.contains("getPlacementsForStructure"));
|
assertFalse(method.contains("getPlacementsForStructure"));
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ public class IrisModdedStructureCommandTest {
|
|||||||
String method = source.substring(methodStart, methodEnd);
|
String method = source.substring(methodStart, methodEnd);
|
||||||
int registryLookup = method.indexOf("level.registryAccess().lookupOrThrow(Registries.STRUCTURE)");
|
int registryLookup = method.indexOf("level.registryAccess().lookupOrThrow(Registries.STRUCTURE)");
|
||||||
int placedCheck = method.indexOf(
|
int placedCheck = method.indexOf(
|
||||||
"if (!IrisStructureLocator.hasNativePlacement(current, structureId))");
|
"if (!ModuleServices.startsStructure(current, structureId))");
|
||||||
int irisLocate = method.indexOf("NativeStructureLocatePersistence.search(", placedCheck);
|
int irisLocate = method.indexOf("NativeStructureLocatePersistence.search(", placedCheck);
|
||||||
int nearestSelection = method.indexOf(
|
int nearestSelection = method.indexOf(
|
||||||
"NativeStructureLocateResults.nearest(pos, predicted, nativeLocated)", irisLocate);
|
"NativeStructureLocateResults.nearest(pos, predicted, nativeLocated)", irisLocate);
|
||||||
@@ -235,7 +235,7 @@ public class IrisModdedStructureCommandTest {
|
|||||||
assertTrue(selectedReference > selectedVerification);
|
assertTrue(selectedReference > selectedVerification);
|
||||||
assertTrue(method.contains("NativeStructureLocatePersistence.probe("));
|
assertTrue(method.contains("NativeStructureLocatePersistence.probe("));
|
||||||
assertTrue(method.contains("findUnexplored"));
|
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("verified.ownership().locatorY()"));
|
||||||
assertTrue(method.contains("selectedSearch.search().reference(selectedStart)"));
|
assertTrue(method.contains("selectedSearch.search().reference(selectedStart)"));
|
||||||
assertTrue(method.contains("NativeStructureLocateResults.selectAndReference("));
|
assertTrue(method.contains("NativeStructureLocateResults.selectAndReference("));
|
||||||
@@ -271,12 +271,12 @@ public class IrisModdedStructureCommandTest {
|
|||||||
assertTrue(eligibilityCheck > policyResolution);
|
assertTrue(eligibilityCheck > policyResolution);
|
||||||
assertTrue(replacementLocate > eligibilityCheck);
|
assertTrue(replacementLocate > eligibilityCheck);
|
||||||
assertTrue(nativeLocate > replacementLocate);
|
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("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("StructureReachability.isReachable(engine, target.key())"));
|
||||||
assertTrue(method.contains("getWorldGenSettings().options().generateStructures()"));
|
assertTrue(method.contains("getWorldGenSettings().options().generateStructures()"));
|
||||||
assertFalse(method.contains("IrisStructureLocator.isPlaced(engine, key)"));
|
assertFalse(method.contains("ModuleServices.placesStructure(engine, key)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -287,7 +287,7 @@ public class IrisModdedStructureCommandTest {
|
|||||||
methodStart);
|
methodStart);
|
||||||
String method = source.substring(methodStart, methodEnd);
|
String method = source.substring(methodStart, methodEnd);
|
||||||
int nativeResolution = method.indexOf("resolveNativeStructure(source, level, engine, key)");
|
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(nativeResolution >= 0);
|
||||||
assertTrue(genericIrisLookup > nativeResolution);
|
assertTrue(genericIrisLookup > nativeResolution);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.volmit.host.FeatureCatalog;
|
|||||||
import com.volmit.host.ServiceRegistration;
|
import com.volmit.host.ServiceRegistration;
|
||||||
import com.volmit.entity.EntitySpec;
|
import com.volmit.entity.EntitySpec;
|
||||||
import com.volmit.item.ItemDrop;
|
import com.volmit.item.ItemDrop;
|
||||||
|
import com.volmit.resource.ResourceId;
|
||||||
import com.volmit.service.AmbientEffects;
|
import com.volmit.service.AmbientEffects;
|
||||||
import com.volmit.service.BlockDrops;
|
import com.volmit.service.BlockDrops;
|
||||||
import com.volmit.service.CaveBiomes;
|
import com.volmit.service.CaveBiomes;
|
||||||
@@ -34,6 +35,7 @@ import com.volmit.service.ObjectsAt;
|
|||||||
import com.volmit.service.SaplingGrowth;
|
import com.volmit.service.SaplingGrowth;
|
||||||
import com.volmit.service.StructureLocator;
|
import com.volmit.service.StructureLocator;
|
||||||
import com.volmit.service.VanillaFeatures;
|
import com.volmit.service.VanillaFeatures;
|
||||||
|
import com.volmit.service.VanillaStructures;
|
||||||
import com.volmit.world.BlockPosition;
|
import com.volmit.world.BlockPosition;
|
||||||
import com.volmit.world.PackWorld;
|
import com.volmit.world.PackWorld;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -42,6 +44,7 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What Iris core asks the pack's modules through their services ({@link com.volmit.service.Service}) instead of reading
|
* What Iris core asks the pack's modules through their services ({@link com.volmit.service.Service}) instead of reading
|
||||||
@@ -236,26 +239,90 @@ public final class ModuleServices {
|
|||||||
|
|
||||||
/** Whether a module of the world can locate structure {@code key}, matched without regard to case. */
|
/** Whether a module of the world can locate structure {@code key}, matched without regard to case. */
|
||||||
public static boolean canLocateStructure(Engine engine, String key) {
|
public static boolean canLocateStructure(Engine engine, String key) {
|
||||||
return structureLocatorOf(engine, key).isPresent();
|
return structureLocatorOf(engine, key, StructureLocator::locatable).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Every key under which the world's modules find what they place, locatable or not: their own structures and the
|
||||||
|
* platform structures they start or stand in for.
|
||||||
|
*/
|
||||||
|
public static Set<String> placedStructures(Engine engine) {
|
||||||
|
Set<String> keys = new LinkedHashSet<>();
|
||||||
|
for (Provider<StructureLocator> provider : providers(engine, StructureLocator.class)) {
|
||||||
|
keys.addAll(provider.service().placed(provider.world()));
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether a module of the world places structure {@code key}, located or not, matched without regard to case. */
|
||||||
|
public static boolean placesStructure(Engine engine, String key) {
|
||||||
|
return structureLocatorOf(engine, key, StructureLocator::placed).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for the start of structure {@code key} nearest to {@code fromX}, {@code fromZ} with the first module that
|
* Searches for the start of structure {@code key} nearest to {@code fromX}, {@code fromZ} with the first module that
|
||||||
* can locate it, in the world's own coordinates; not found when none can.
|
* places it, in the world's own coordinates; not found when none does.
|
||||||
*/
|
*/
|
||||||
public static StructureSearch locateStructure(Engine engine, String key, int fromX, int fromZ, int maxRadiusChunks) {
|
public static StructureSearch locateStructure(Engine engine, String key, int fromX, int fromZ, int maxRadiusChunks) {
|
||||||
LocateResult result = structureLocatorOf(engine, key)
|
LocateResult result = structureLocatorOf(engine, key, StructureLocator::placed)
|
||||||
.map(provider -> provider.service().locate(provider.world(), key, fromX, fromZ, maxRadiusChunks))
|
.map(provider -> provider.service().locate(provider.world(), key, fromX, fromZ, maxRadiusChunks))
|
||||||
.orElse(LocateResult.NOT_FOUND);
|
.orElse(LocateResult.NOT_FOUND);
|
||||||
return StructureSearch.of(result, engine);
|
return StructureSearch.of(result, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The platform structures the world's modules start themselves, as lower-case registry keys. */
|
||||||
|
public static Set<String> startedStructures(Engine engine) {
|
||||||
|
return platformStructures(engine, VanillaStructures::startedStructures);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether a module of the world starts the platform structure {@code key} itself. */
|
||||||
|
public static boolean startsStructure(Engine engine, String key) {
|
||||||
|
return key != null && startedStructures(engine).contains(normalized(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether a module of the world can find the starts it makes of the platform structure {@code key}. */
|
||||||
|
public static boolean canLocateStart(Engine engine, String key) {
|
||||||
|
return key != null && platformStructures(engine, VanillaStructures::locatableStarts).contains(normalized(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches ring by ring, up to {@code maxRings} rings, for the start the first module that can find them makes of the
|
||||||
|
* platform structure {@code key} nearest to {@code fromX}, {@code fromZ}, trying only chunks {@code candidates}
|
||||||
|
* accepts, in the world's own coordinates. A {@link StructureSearchLimitException} from {@code candidates} ends the
|
||||||
|
* search as {@link StructureSearch.Outcome#SEARCH_LIMIT_REACHED}.
|
||||||
|
*/
|
||||||
|
public static StructureSearch locateStart(Engine engine, String key, int fromX, int fromZ, int maxRings,
|
||||||
|
CandidateChunks candidates) {
|
||||||
|
Optional<ResourceId> structure = registryId(key);
|
||||||
|
if (structure.isEmpty()) {
|
||||||
|
return StructureSearch.NOT_FOUND;
|
||||||
|
}
|
||||||
|
for (Provider<VanillaStructures> provider : providers(engine, VanillaStructures.class)) {
|
||||||
|
if (!provider.service().locatableStarts(provider.world()).contains(structure.get())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return StructureSearch.of(provider.service().locateStart(provider.world(), structure.get(), fromX, fromZ,
|
||||||
|
maxRings, candidates::accepts), engine);
|
||||||
|
} catch (StructureSearchLimitException limit) {
|
||||||
|
return StructureSearch.SEARCH_LIMIT_REACHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StructureSearch.NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The chunks a search for a module's start of a platform structure may answer with. */
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface CandidateChunks {
|
||||||
|
boolean accepts(int chunkX, int chunkZ);
|
||||||
|
}
|
||||||
|
|
||||||
/** How a structure search ended. A found start is at {@code x}, {@code y}, {@code z}: world coordinates, Y the world's own. */
|
/** How a structure search ended. A found start is at {@code x}, {@code y}, {@code z}: world coordinates, Y the world's own. */
|
||||||
public record StructureSearch(Outcome outcome, int x, int y, int z) {
|
public record StructureSearch(Outcome outcome, int x, int y, int z) {
|
||||||
public enum Outcome { FOUND, NOT_FOUND, SEARCH_LIMIT_REACHED }
|
public enum Outcome { FOUND, NOT_FOUND, SEARCH_LIMIT_REACHED }
|
||||||
|
|
||||||
private static final StructureSearch NOT_FOUND = new StructureSearch(Outcome.NOT_FOUND, 0, 0, 0);
|
public static final StructureSearch NOT_FOUND = new StructureSearch(Outcome.NOT_FOUND, 0, 0, 0);
|
||||||
private static final StructureSearch SEARCH_LIMIT_REACHED = new StructureSearch(Outcome.SEARCH_LIMIT_REACHED, 0, 0, 0);
|
public static final StructureSearch SEARCH_LIMIT_REACHED = new StructureSearch(Outcome.SEARCH_LIMIT_REACHED, 0, 0, 0);
|
||||||
|
|
||||||
public boolean found() {
|
public boolean found() {
|
||||||
return outcome == Outcome.FOUND;
|
return outcome == Outcome.FOUND;
|
||||||
@@ -272,20 +339,41 @@ public final class ModuleServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The first provider, in the catalog's order, whose locatable structures hold {@code key}. */
|
/** The first provider, in the catalog's order, whose structures of the kind {@code keys} lists hold {@code key}. */
|
||||||
private static Optional<Provider<StructureLocator>> structureLocatorOf(Engine engine, String key) {
|
private static Optional<Provider<StructureLocator>> structureLocatorOf(Engine engine, String key,
|
||||||
|
BiFunction<StructureLocator, PackWorld, Set<String>> keys) {
|
||||||
if (key == null || key.isBlank()) {
|
if (key == null || key.isBlank()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
String wanted = normalized(key);
|
String wanted = normalized(key);
|
||||||
for (Provider<StructureLocator> provider : providers(engine, StructureLocator.class)) {
|
for (Provider<StructureLocator> provider : providers(engine, StructureLocator.class)) {
|
||||||
if (provider.service().locatable(provider.world()).stream().map(ModuleServices::normalized).anyMatch(wanted::equals)) {
|
if (keys.apply(provider.service(), provider.world()).stream().map(ModuleServices::normalized).anyMatch(wanted::equals)) {
|
||||||
return Optional.of(provider);
|
return Optional.of(provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The platform structures every provider lists with {@code structures}, as lower-case registry keys. */
|
||||||
|
private static Set<String> platformStructures(Engine engine, BiFunction<VanillaStructures, PackWorld, Set<ResourceId>> structures) {
|
||||||
|
Set<String> keys = new LinkedHashSet<>();
|
||||||
|
for (Provider<VanillaStructures> provider : providers(engine, VanillaStructures.class)) {
|
||||||
|
structures.apply(provider.service(), provider.world()).forEach(id -> keys.add(id.toString()));
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Optional<ResourceId> registryId(String key) {
|
||||||
|
if (key == null || key.isBlank()) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Optional.of(ResourceId.parse(normalized(key.trim())));
|
||||||
|
} catch (IllegalArgumentException notAnId) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static String normalized(String key) {
|
private static String normalized(String key) {
|
||||||
return key.toLowerCase(Locale.ROOT);
|
return key.toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.core.modules;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown by a host's {@link ModuleServices.CandidateChunks} to end a search for a module's start of a platform structure
|
||||||
|
* when the host's own checks ran out of budget; {@link ModuleServices#locateStart} reports it as a reached search limit.
|
||||||
|
*/
|
||||||
|
public final class StructureSearchLimitException extends RuntimeException {
|
||||||
|
public StructureSearchLimitException() {
|
||||||
|
super(null, null, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,8 +24,6 @@ import art.arcane.iris.engine.EngineRuntime.BiomeMaxes;
|
|||||||
import art.arcane.iris.engine.EngineRuntimeBuilder.RuntimeAssembly;
|
import art.arcane.iris.engine.EngineRuntimeBuilder.RuntimeAssembly;
|
||||||
import art.arcane.iris.engine.IrisEngine.LifecycleState;
|
import art.arcane.iris.engine.IrisEngine.LifecycleState;
|
||||||
import art.arcane.iris.engine.framework.EngineTarget;
|
import art.arcane.iris.engine.framework.EngineTarget;
|
||||||
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
|
||||||
import art.arcane.iris.engine.framework.StructureReachability;
|
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.iris.spi.IrisServices;
|
import art.arcane.iris.spi.IrisServices;
|
||||||
@@ -117,8 +115,6 @@ final class EngineHotloader {
|
|||||||
}
|
}
|
||||||
engine.getPlatformHooks().validateDimensionHotload(engine, replacement);
|
engine.getPlatformHooks().validateDimensionHotload(engine, replacement);
|
||||||
replacementData.registerEngine(engine);
|
replacementData.registerEngine(engine);
|
||||||
IrisStructureLocator.invalidate(engine);
|
|
||||||
StructureReachability.invalidate(engine);
|
|
||||||
EngineTarget replacementTarget = new EngineTarget(engine.getWorld(), replacement, replacementData);
|
EngineTarget replacementTarget = new EngineTarget(engine.getWorld(), replacement, replacementData);
|
||||||
EngineRuntime nextRuntime = engine.runtimeBuilder.buildRuntime(replacementTarget);
|
EngineRuntime nextRuntime = engine.runtimeBuilder.buildRuntime(replacementTarget);
|
||||||
engine.runtimeBuilder.publishRuntime(nextRuntime, previousRuntime);
|
engine.runtimeBuilder.publishRuntime(nextRuntime, previousRuntime);
|
||||||
@@ -151,8 +147,6 @@ final class EngineHotloader {
|
|||||||
e.addSuppressed(replacementDataFailure);
|
e.addSuppressed(replacementDataFailure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IrisStructureLocator.invalidate(engine);
|
|
||||||
StructureReachability.invalidate(engine);
|
|
||||||
if (engine.lifecycleState != LifecycleState.FAILED) {
|
if (engine.lifecycleState != LifecycleState.FAILED) {
|
||||||
Throwable rollbackFailure = runCleanup(null, engine.getMantle()::hotload);
|
Throwable rollbackFailure = runCleanup(null, engine.getMantle()::hotload);
|
||||||
if (rollbackFailure == null) {
|
if (rollbackFailure == null) {
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.engine.framework;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.object.world.IrisWorld;
|
||||||
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines which vanilla/datapack structures can ever generate in a world, using the same biome
|
||||||
|
* gate vanilla applies: a structure is reachable when its biome filter intersects the set of vanilla
|
||||||
|
* biomes the pack actually produces (its {@code possibleBiomes}). Structures whose required biomes are
|
||||||
|
* never produced cannot generate and must not be scanned for by {@code /locate} or {@code /iris find}
|
||||||
|
* (an unbounded scan for an absent biome is what stalls the server).
|
||||||
|
*
|
||||||
|
* <p>The reachable set is fixed per world: it is kept in the world's state, so a hotload's new world builds it again.
|
||||||
|
* It is the platform's answer, so Iris core asks it, not a module.
|
||||||
|
*/
|
||||||
|
public final class StructureReachability {
|
||||||
|
private StructureReachability() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Set<String> reachableKeys(Engine engine) {
|
||||||
|
Engine activeEngine = Objects.requireNonNull(engine, "Structure reachability requires an engine");
|
||||||
|
if (activeEngine.getData() == null) {
|
||||||
|
throw new IllegalStateException("Structure reachability requires a bound pack data loader");
|
||||||
|
}
|
||||||
|
return activeEngine.getGeneration().state(ReachableKeys.class, ReachableKeys::of).keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isReachable(Engine engine, String structureKey) {
|
||||||
|
String normalizedStructureKey = normalizeStructureKey(structureKey);
|
||||||
|
return reachableKeys(engine).contains(normalizedStructureKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Set<String> build(Engine engine) {
|
||||||
|
IrisWorld world = engine.getWorld();
|
||||||
|
if (world == null) {
|
||||||
|
throw new IllegalStateException("Structure reachability requires a bound Iris world");
|
||||||
|
}
|
||||||
|
if (world.platformWorld() == null) {
|
||||||
|
throw new IllegalStateException("Structure reachability requires a bound platform world");
|
||||||
|
}
|
||||||
|
Set<String> reachable = new LinkedHashSet<>();
|
||||||
|
for (String key : IrisPlatforms.get().structureHooks().reachableStructureKeys(world.platformWorld())) {
|
||||||
|
if (key == null || key.isBlank()) {
|
||||||
|
throw new IllegalStateException("Platform structure reachability returned a blank registry key");
|
||||||
|
}
|
||||||
|
reachable.add(key.toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableSet(reachable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The vanilla biome keys (e.g. {@code minecraft:taiga}) from a structure's filter that the pack
|
||||||
|
* does not produce. An empty list means the structure is reachable. Used by the structure verify
|
||||||
|
* diagnostic to explain why a structure cannot generate.
|
||||||
|
*/
|
||||||
|
public static KList<String> missingBiomeKeys(Engine engine, String structureKey) {
|
||||||
|
KList<String> missing = new KList<>();
|
||||||
|
Engine activeEngine = Objects.requireNonNull(engine, "Structure biome diagnostics require an engine");
|
||||||
|
String normalizedStructureKey = normalizeStructureKey(structureKey);
|
||||||
|
IrisWorld world = activeEngine.getWorld();
|
||||||
|
if (world == null) {
|
||||||
|
throw new IllegalStateException("Structure biome diagnostics require a bound Iris world");
|
||||||
|
}
|
||||||
|
if (world.platformWorld() == null) {
|
||||||
|
throw new IllegalStateException("Structure biome diagnostics require a bound platform world");
|
||||||
|
}
|
||||||
|
Set<String> possible = new LinkedHashSet<>();
|
||||||
|
for (String key : IrisPlatforms.get().structureHooks().possibleBiomeKeys(world.platformWorld())) {
|
||||||
|
if (key == null || key.isBlank()) {
|
||||||
|
throw new IllegalStateException("Platform structure biome query returned a blank possible-biome key");
|
||||||
|
}
|
||||||
|
possible.add(key.toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
for (String biomeKey : IrisPlatforms.get().structureHooks().structureBiomeKeys(normalizedStructureKey)) {
|
||||||
|
if (biomeKey == null || biomeKey.isBlank()) {
|
||||||
|
throw new IllegalStateException("Platform structure biome query returned a blank required-biome key for "
|
||||||
|
+ normalizedStructureKey);
|
||||||
|
}
|
||||||
|
if (!possible.contains(biomeKey.toLowerCase(Locale.ROOT))) {
|
||||||
|
missing.add(biomeKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return missing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The world's reachable structure keys, in lower case. */
|
||||||
|
private record ReachableKeys(Set<String> keys) {
|
||||||
|
static ReachableKeys of(Engine engine) {
|
||||||
|
return new ReachableKeys(build(engine));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String normalizeStructureKey(String structureKey) {
|
||||||
|
if (structureKey == null || structureKey.isBlank()) {
|
||||||
|
throw new IllegalArgumentException("Registered structure key must not be blank");
|
||||||
|
}
|
||||||
|
return structureKey.trim().toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-4
@@ -20,7 +20,6 @@ package art.arcane.iris.util.common.director.specialhandlers;
|
|||||||
|
|
||||||
import art.arcane.iris.core.modules.ModuleServices;
|
import art.arcane.iris.core.modules.ModuleServices;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
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.NativeStructureGenerationPolicy;
|
||||||
import art.arcane.iris.engine.framework.StructureReachability;
|
import art.arcane.iris.engine.framework.StructureReachability;
|
||||||
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
import art.arcane.iris.engine.framework.NativeStructureGenerationStatus;
|
||||||
@@ -62,7 +61,7 @@ public class StructureHandler implements DirectorParameterHandler<String> {
|
|||||||
String normalizedKey = normalizeKey(key);
|
String normalizedKey = normalizeKey(key);
|
||||||
if (!normalizedKey.isEmpty()
|
if (!normalizedKey.isEmpty()
|
||||||
&& !registeredKeys.containsKey(normalizedKey)
|
&& !registeredKeys.containsKey(normalizedKey)
|
||||||
&& !IrisStructureLocator.hasNativePlacement(activeEngine, key)) {
|
&& !ModuleServices.startsStructure(activeEngine, key)) {
|
||||||
suggestions.putIfAbsent(normalizedKey, key.trim());
|
suggestions.putIfAbsent(normalizedKey, key.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,9 +115,9 @@ public class StructureHandler implements DirectorParameterHandler<String> {
|
|||||||
private static boolean isEligibleRegisteredKey(Engine engine, String key, String normalizedKey,
|
private static boolean isEligibleRegisteredKey(Engine engine, String key, String normalizedKey,
|
||||||
Set<String> reachableKeys, boolean nativeGenerationEnabled) {
|
Set<String> reachableKeys, boolean nativeGenerationEnabled) {
|
||||||
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
|
NativeStructureGenerationStatus status = NativeStructureGenerationPolicy.resolve(engine, key);
|
||||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
|
boolean nativePlacement = ModuleServices.startsStructure(engine, key);
|
||||||
boolean locatableNativePlacement = nativePlacement
|
boolean locatableNativePlacement = nativePlacement
|
||||||
&& IrisStructureLocator.hasLocatableNativePlacement(engine, key);
|
&& ModuleServices.canLocateStart(engine, key);
|
||||||
boolean locatableEditableReplacement = !nativePlacement
|
boolean locatableEditableReplacement = !nativePlacement
|
||||||
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
|
&& status == NativeStructureGenerationStatus.REPLACED_BY_IRIS
|
||||||
&& ModuleServices.canLocateStructure(engine, key);
|
&& ModuleServices.canLocateStructure(engine, key);
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ public class BuiltInServicesTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void theModulesThatNeedToHearAboutWorldsHearThem() {
|
public void theModulesThatNeedToHearAboutWorldsHearThem() {
|
||||||
assertEquals(List.of("iris:decorant", "iris:objects", "iris:structure", "iris:terrain"), BUILT_INS.lifecycles().stream()
|
assertEquals(List.of("iris:decorant", "iris:objects", "iris:terrain"), BUILT_INS.lifecycles().stream()
|
||||||
.map(LifecycleRegistration::module).map(module -> module.info().id().toString()).toList());
|
.map(LifecycleRegistration::module).map(module -> module.info().id().toString()).toList());
|
||||||
assertTrue(BUILT_INS.lifecycles().stream().anyMatch(registration -> registration.lifecycle() instanceof StructureModule));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+27
-11
@@ -53,6 +53,7 @@ import static org.junit.Assert.assertFalse;
|
|||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.Assert.assertNotSame;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
@@ -77,6 +78,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void isPlacedIsFalseForNullOrEmptyKey() {
|
public void isPlacedIsFalseForNullOrEmptyKey() {
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
assertFalse(IrisStructureLocator.isPlaced(engine, null));
|
assertFalse(IrisStructureLocator.isPlaced(engine, null));
|
||||||
assertFalse(IrisStructureLocator.isPlaced(engine, ""));
|
assertFalse(IrisStructureLocator.isPlaced(engine, ""));
|
||||||
}
|
}
|
||||||
@@ -126,6 +128,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
placements.add(editable);
|
placements.add(editable);
|
||||||
placements.add(nativePlacement);
|
placements.add(nativePlacement);
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
@@ -154,6 +157,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
public void nativeStructureReplacementSuppressesOnlyItsRegisteredSource() {
|
public void nativeStructureReplacementSuppressesOnlyItsRegisteredSource() {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
IrisStructurePlacement placement = new IrisStructurePlacement()
|
||||||
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
@@ -175,6 +179,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void suppressesVanillaIsFalseForNullOrEmptyKey() {
|
public void suppressesVanillaIsFalseForNullOrEmptyKey() {
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
assertFalse(IrisStructureLocator.suppressesVanilla(engine, null));
|
assertFalse(IrisStructureLocator.suppressesVanilla(engine, null));
|
||||||
assertFalse(IrisStructureLocator.suppressesVanilla(engine, ""));
|
assertFalse(IrisStructureLocator.suppressesVanilla(engine, ""));
|
||||||
}
|
}
|
||||||
@@ -198,13 +203,15 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
|
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
|
|
||||||
assertTrue(IrisStructureLocator.isPlaced(engine, "minecraft:ancient_city"));
|
assertTrue(IrisStructureLocator.isPlaced(engine, "minecraft:ancient_city"));
|
||||||
assertFalse(IrisStructureLocator.suppressesVanilla(engine, "minecraft:ancient_city"));
|
assertFalse(IrisStructureLocator.suppressesVanilla(engine, "minecraft:ancient_city"));
|
||||||
placement.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
placement.setNativeSuppression(NativeStructureSuppression.REPLACE_SOURCE);
|
||||||
IrisStructureLocator.invalidate(engine);
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
assertTrue(IrisStructureLocator.suppressesVanilla(engine, "minecraft:ancient_city"));
|
assertTrue(IrisStructureLocator.suppressesVanilla(engine, "minecraft:ancient_city"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,6 +235,8 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
|
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
|
|
||||||
@@ -290,6 +299,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
|
|
||||||
@@ -313,6 +323,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
|
|
||||||
@@ -332,6 +343,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
when(dimension.getAllRegions(any())).thenReturn(new KList<>());
|
||||||
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
when(dimension.getReachableBiomes(any())).thenReturn(new KList<>());
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
|
|
||||||
@@ -384,6 +396,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void locateReturnsNotFoundForNullOrEmptyKey() {
|
public void locateReturnsNotFoundForNullOrEmptyKey() {
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
assertEquals(IrisStructureLocator.LocateStatus.NOT_FOUND,
|
assertEquals(IrisStructureLocator.LocateStatus.NOT_FOUND,
|
||||||
IrisStructureLocator.locate(engine, null, 0, 0, 100).status());
|
IrisStructureLocator.locate(engine, null, 0, 0, 100).status());
|
||||||
assertEquals(IrisStructureLocator.LocateStatus.NOT_FOUND,
|
assertEquals(IrisStructureLocator.LocateStatus.NOT_FOUND,
|
||||||
@@ -478,6 +491,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void searchableDensityRequiresPositiveProbabilityAndWorldHeightOverlap() {
|
public void searchableDensityRequiresPositiveProbabilityAndWorldHeightOverlap() {
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight()).thenReturn(384);
|
when(engine.getHeight()).thenReturn(384);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
IrisStructurePlacement placement = new IrisStructurePlacement();
|
||||||
@@ -497,21 +511,16 @@ public class IrisStructureLocatorContractTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invalidateIsNullSafe() {
|
public void placementIndexIsKeptPerWorld() {
|
||||||
IrisStructureLocator.invalidate(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void placementIndexIsScopedAndInvalidatedPerEngine() {
|
|
||||||
IrisData sharedData = mock(IrisData.class);
|
IrisData sharedData = mock(IrisData.class);
|
||||||
Engine firstEngine = emptyEngine(sharedData);
|
Engine firstEngine = emptyEngine(sharedData);
|
||||||
Engine secondEngine = emptyEngine(sharedData);
|
Engine secondEngine = emptyEngine(sharedData);
|
||||||
Set<String> firstIndex = IrisStructureLocator.placedKeys(firstEngine);
|
Set<String> firstIndex = IrisStructureLocator.placedKeys(firstEngine);
|
||||||
Set<String> secondIndex = IrisStructureLocator.placedKeys(secondEngine);
|
assertSame(firstIndex, IrisStructureLocator.placedKeys(firstEngine));
|
||||||
assertNotSame(firstIndex, secondIndex);
|
assertNotSame(firstIndex, IrisStructureLocator.placedKeys(secondEngine));
|
||||||
|
|
||||||
IrisStructureLocator.invalidate(firstEngine);
|
when(firstEngine.getGeneration()).thenReturn(new EngineGeneration(firstEngine));
|
||||||
assertNotSame(firstIndex, IrisStructureLocator.placedKeys(firstEngine));
|
assertNotSame("a new world builds its own index", firstIndex, IrisStructureLocator.placedKeys(firstEngine));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -604,6 +613,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void caveSearchabilityReservesVerticalBoundaryCells() {
|
public void caveSearchabilityReservesVerticalBoundaryCells() {
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight()).thenReturn(384);
|
when(engine.getHeight()).thenReturn(384);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
IrisStructurePlacement placement = new IrisStructurePlacement()
|
||||||
@@ -625,6 +635,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void undergroundAssemblyIsShiftedBelowEveryTerrainColumn() {
|
public void undergroundAssemblyIsShiftedBelowEveryTerrainColumn() {
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight(anyInt(), anyInt(), eq(true)))
|
when(engine.getHeight(anyInt(), anyInt(), eq(true)))
|
||||||
.thenAnswer(invocation -> invocation.<Integer>getArgument(0) == 1 ? 140 : 164);
|
.thenAnswer(invocation -> invocation.<Integer>getArgument(0) == 1 ? 140 : 164);
|
||||||
@@ -647,6 +658,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void undergroundBurialIncludesForceCarveCeiling() {
|
public void undergroundBurialIncludesForceCarveCeiling() {
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
|
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement();
|
IrisStructurePlacement placement = new IrisStructurePlacement();
|
||||||
@@ -676,6 +688,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
@Test
|
@Test
|
||||||
public void zeroForceCarvePaddingDoesNotExpandTheBurialEnvelope() {
|
public void zeroForceCarvePaddingDoesNotExpandTheBurialEnvelope() {
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
|
when(engine.getHeight(anyInt(), anyInt(), eq(true))).thenReturn(164);
|
||||||
IrisStructurePlacement placement = new IrisStructurePlacement()
|
IrisStructurePlacement placement = new IrisStructurePlacement()
|
||||||
@@ -781,6 +794,7 @@ public class IrisStructureLocatorContractTest {
|
|||||||
|
|
||||||
private Engine emptyEngine(IrisData data) {
|
private Engine emptyEngine(IrisData data) {
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
@@ -807,6 +821,8 @@ public class IrisStructureLocatorContractTest {
|
|||||||
placement.setMaxHeight(placementMax);
|
placement.setMaxHeight(placementMax);
|
||||||
|
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
KList<IrisStructurePlacement> placements = new KList<>();
|
KList<IrisStructurePlacement> placements = new KList<>();
|
||||||
placements.add(placement);
|
placements.add(placement);
|
||||||
|
|||||||
+1
@@ -171,6 +171,7 @@ public class IrisStructurePlacementRingLocatorTest {
|
|||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
KList<IrisStructurePlacement> configured = new KList<>();
|
KList<IrisStructurePlacement> configured = new KList<>();
|
||||||
for (IrisStructurePlacement placement : placements) {
|
for (IrisStructurePlacement placement : placements) {
|
||||||
configured.add(placement);
|
configured.add(placement);
|
||||||
|
|||||||
+1
@@ -236,6 +236,7 @@ public class NativeStructureGenerationPolicyTest {
|
|||||||
KList<IrisStructurePlacement> dimensionPlacements, List<IrisModule> packModules) throws IOException {
|
KList<IrisStructurePlacement> dimensionPlacements, List<IrisModule> packModules) throws IOException {
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
IrisRegion region = mock(IrisRegion.class);
|
IrisRegion region = mock(IrisRegion.class);
|
||||||
when(region.getStructures()).thenReturn(regionPlacements);
|
when(region.getStructures()).thenReturn(regionPlacements);
|
||||||
|
|||||||
+1
@@ -57,6 +57,7 @@ public class NativeStructureVolumeSuppressionTest {
|
|||||||
StructureSettings settings = new StructureSettings(List.of("minecraft:village"), List.of(), 0, true, List.of(), List.of());
|
StructureSettings settings = new StructureSettings(List.of("minecraft:village"), List.of(), 0, true, List.of(), List.of());
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
IrisData data = mock(IrisData.class);
|
IrisData data = mock(IrisData.class);
|
||||||
packs.add(BuiltInPack.serveWithResources(data, folder, List.of()));
|
packs.add(BuiltInPack.serveWithResources(data, folder, List.of()));
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
|
|||||||
+24
-1
@@ -1,10 +1,16 @@
|
|||||||
package art.arcane.iris.engine.framework;
|
package art.arcane.iris.engine.framework;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructureAnchorMode;
|
import art.arcane.iris.engine.object.structure.IrisStructureAnchorMode;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||||
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
|
import art.arcane.iris.spi.IrisPlatform;
|
||||||
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
|
import art.arcane.iris.spi.PlatformBlockState;
|
||||||
|
import art.arcane.iris.spi.PlatformRegistries;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -19,6 +25,7 @@ import static org.junit.Assert.assertNotNull;
|
|||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@@ -27,6 +34,22 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class StructureCaveAnchorResolverTest {
|
public class StructureCaveAnchorResolverTest {
|
||||||
|
@Before
|
||||||
|
public void bindPlatform() {
|
||||||
|
IrisPlatforms.unbind();
|
||||||
|
PlatformBlockState block = mock(PlatformBlockState.class);
|
||||||
|
PlatformRegistries registries = mock(PlatformRegistries.class);
|
||||||
|
when(registries.block(anyString())).thenReturn(block);
|
||||||
|
IrisPlatform platform = mock(IrisPlatform.class);
|
||||||
|
when(platform.registries()).thenReturn(registries);
|
||||||
|
IrisPlatforms.bind(platform);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void unbindPlatform() {
|
||||||
|
IrisPlatforms.unbind();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void floorRequiresSolidBoundaryAndUpwardClearance() {
|
public void floorRequiresSolidBoundaryAndUpwardClearance() {
|
||||||
IntPredicate carved = carvedAt(10, 11, 12, 13);
|
IntPredicate carved = carvedAt(10, 11, 12, 13);
|
||||||
|
|||||||
+1
-7
@@ -87,12 +87,6 @@ public class StructureReachabilityContractTest {
|
|||||||
() -> StructureReachability.missingBiomeKeys(engine, "minecraft:village_taiga"));
|
() -> StructureReachability.missingBiomeKeys(engine, "minecraft:village_taiga"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void invalidateIsNullSafe() {
|
|
||||||
StructureReachability.invalidate(null);
|
|
||||||
StructureReachability.invalidate(mock(Engine.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void failedReachabilityBuildIsNotCachedAsEmpty() {
|
public void failedReachabilityBuildIsNotCachedAsEmpty() {
|
||||||
Engine engine = mock(Engine.class);
|
Engine engine = mock(Engine.class);
|
||||||
@@ -102,6 +96,7 @@ public class StructureReachabilityContractTest {
|
|||||||
PlatformStructureHooks hooks = mock(PlatformStructureHooks.class);
|
PlatformStructureHooks hooks = mock(PlatformStructureHooks.class);
|
||||||
IllegalStateException cause = new IllegalStateException("registry unavailable");
|
IllegalStateException cause = new IllegalStateException("registry unavailable");
|
||||||
when(engine.getData()).thenReturn(mock(IrisData.class));
|
when(engine.getData()).thenReturn(mock(IrisData.class));
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
when(engine.getWorld()).thenReturn(world);
|
when(engine.getWorld()).thenReturn(world);
|
||||||
when(world.platformWorld()).thenReturn(platformWorld);
|
when(world.platformWorld()).thenReturn(platformWorld);
|
||||||
when(platform.structureHooks()).thenReturn(hooks);
|
when(platform.structureHooks()).thenReturn(hooks);
|
||||||
@@ -115,7 +110,6 @@ public class StructureReachabilityContractTest {
|
|||||||
assertThrows(IllegalStateException.class, () -> StructureReachability.reachableKeys(engine));
|
assertThrows(IllegalStateException.class, () -> StructureReachability.reachableKeys(engine));
|
||||||
assertTrue(StructureReachability.reachableKeys(engine).contains("minecraft:monument"));
|
assertTrue(StructureReachability.reachableKeys(engine).contains("minecraft:monument"));
|
||||||
} finally {
|
} finally {
|
||||||
StructureReachability.invalidate(engine);
|
|
||||||
IrisPlatforms.unbind();
|
IrisPlatforms.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-6
@@ -8,9 +8,7 @@ import art.arcane.iris.engine.mantle.components.StructureModule;
|
|||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||||
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
|
||||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||||
import art.arcane.iris.engine.framework.StructureReachability;
|
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
|
import art.arcane.iris.engine.object.structure.vanilla.IrisNativeStructure;
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||||
@@ -151,8 +149,6 @@ public class StructureHandlerTest {
|
|||||||
verify(hooks, times(1)).structureKeys();
|
verify(hooks, times(1)).structureKeys();
|
||||||
verify(hooks, times(1)).reachableStructureKeys(platformWorld);
|
verify(hooks, times(1)).reachableStructureKeys(platformWorld);
|
||||||
} finally {
|
} finally {
|
||||||
IrisStructureLocator.invalidate(engine);
|
|
||||||
StructureReachability.invalidate(engine);
|
|
||||||
IrisPlatforms.unbind();
|
IrisPlatforms.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,8 +209,6 @@ public class StructureHandlerTest {
|
|||||||
assertFalse(possibilities.contains("minecraft:explicit"));
|
assertFalse(possibilities.contains("minecraft:explicit"));
|
||||||
assertFalse(possibilities.contains("minecraft:reachable"));
|
assertFalse(possibilities.contains("minecraft:reachable"));
|
||||||
} finally {
|
} finally {
|
||||||
IrisStructureLocator.invalidate(engine);
|
|
||||||
StructureReachability.invalidate(engine);
|
|
||||||
IrisPlatforms.unbind();
|
IrisPlatforms.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user