mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 09:44:24 +00:00
Give modules a world per engine runtime and pack snapshot with lifecycle hooks, and ask them through services: IrisPackWorld and ModuleWorlds (start on publish, restart when the pack's resources reload, stop on retire), contexts' world(), ModuleServices, Engine.getObjectsAt through ObjectsAt and the Iris structure find path and structure index through StructureLocator
This commit is contained in:
1 parent
2f3ba3cebe
commit
f501e3baf7
33 files changed
+1101
-80
No files matched your search
+8
-10
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.core.commands;
|
||||
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.core.modules.ModuleServices;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.core.localization.BukkitCommandMessages;
|
||||
import art.arcane.iris.core.localization.BukkitCommandMessagesExtended;
|
||||
@@ -149,7 +149,7 @@ public class CommandFind implements DirectorExecutor {
|
||||
: null;
|
||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(e, structureKey);
|
||||
boolean locatableNativePlacement = IrisStructureLocator.hasLocatableNativePlacement(e, structureKey);
|
||||
boolean locatableEditablePlacement = IrisStructureLocator.hasLocatableEditablePlacement(e, structureKey);
|
||||
boolean locatableEditablePlacement = ModuleServices.canLocateStructure(e, structureKey);
|
||||
World targetWorld = target.getWorld();
|
||||
boolean nativeGenerationEnabled = targetWorld.canGenerateStructures();
|
||||
boolean requiresReachability = registered && decision.generate()
|
||||
@@ -276,7 +276,7 @@ public class CommandFind implements DirectorExecutor {
|
||||
IrisNativeStructureDecision decision = NativeStructureGenerationPolicy.resolve(engine, key, false);
|
||||
boolean nativePlacement = IrisStructureLocator.hasNativePlacement(engine, key);
|
||||
boolean locatableNativePlacement = IrisStructureLocator.hasLocatableNativePlacement(engine, key);
|
||||
boolean locatableEditablePlacement = IrisStructureLocator.hasLocatableEditablePlacement(engine, key);
|
||||
boolean locatableEditablePlacement = ModuleServices.canLocateStructure(engine, key);
|
||||
StructureLookupRoute route = selectStructureLookupRoute(
|
||||
true, decision, nativePlacement, locatableNativePlacement,
|
||||
locatableEditablePlacement, nativeGenerationEnabled,
|
||||
@@ -315,8 +315,8 @@ public class CommandFind implements DirectorExecutor {
|
||||
int editableUnplaced = 0;
|
||||
Set<String> unplacedEditableKeys = new LinkedHashSet<>();
|
||||
Set<String> locatableEditableKeys = normalizedStructureKeys(
|
||||
IrisStructureLocator.locatableEditableKeys(engine));
|
||||
for (String editableKey : StructureResources.structureKeys(engine.getData())) {
|
||||
ModuleServices.locatableStructures(engine));
|
||||
for (String editableKey : ModuleServices.structureKeys(engine.getData())) {
|
||||
String normalizedKey = normalizeStructureKey(editableKey);
|
||||
if (!isUnplacedEditableCandidate(
|
||||
normalizedKey, registeredKeys.keySet(), locatableEditableKeys,
|
||||
@@ -598,9 +598,8 @@ public class CommandFind implements DirectorExecutor {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_FIND_LOCATING_2, MessageArgument.untrusted("structure", structure)));
|
||||
J.a(() -> {
|
||||
try {
|
||||
IrisStructureLocator.LocateResult result =
|
||||
IrisStructureLocator.locate(engine, structure, blockX, blockZ, 1024);
|
||||
if (result.status() == IrisStructureLocator.LocateStatus.SEARCH_LIMIT_REACHED) {
|
||||
ModuleServices.StructureSearch result = ModuleServices.locateStructure(engine, structure, blockX, blockZ, 1024);
|
||||
if (result.outcome() == ModuleServices.StructureSearch.Outcome.SEARCH_LIMIT_REACHED) {
|
||||
sendStructureMessage(target, commandSender,
|
||||
C.YELLOW + "Unable to locate " + structure
|
||||
+ ": the density search safety limit was reached before the full 1024-chunk radius was searched.");
|
||||
@@ -611,8 +610,7 @@ public class CommandFind implements DirectorExecutor {
|
||||
C.YELLOW + "No " + structure + " found within 1024 chunks of you.");
|
||||
return;
|
||||
}
|
||||
Location destination = new Location(
|
||||
targetWorld, result.originX(), result.baseY(), result.originZ());
|
||||
Location destination = new Location(targetWorld, result.x(), result.y(), result.z());
|
||||
prepareStructureTeleport(target, targetWorld, commandSender, structure, destination, true);
|
||||
} catch (Throwable t) {
|
||||
sendStructureMessage(target, commandSender,
|
||||
|
||||
+4
-4
@@ -20,9 +20,9 @@ public class IrisStructureLocateCommandContractTest {
|
||||
public void findReportsDensityLimitAndUsesExactLocatedOrigin() throws IOException {
|
||||
String source = Files.readString(Path.of(System.getProperty("iris.commandFindSource")));
|
||||
|
||||
assertTrue(source.contains("LocateStatus.SEARCH_LIMIT_REACHED"));
|
||||
assertTrue(source.contains("StructureSearch.Outcome.SEARCH_LIMIT_REACHED"));
|
||||
assertTrue(source.contains("the density search safety limit was reached"));
|
||||
assertTrue(source.contains("result.originX(), result.baseY(), result.originZ()"));
|
||||
assertTrue(source.contains("new Location(targetWorld, result.x(), result.y(), result.z())"));
|
||||
assertFalse(source.contains("at[0] + 8"));
|
||||
assertFalse(source.contains("at[2] + 8"));
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class IrisStructureLocateCommandContractTest {
|
||||
int nativeLocatableCheck = method.indexOf(
|
||||
"IrisStructureLocator.hasLocatableNativePlacement(e, structureKey)", policyResolution);
|
||||
int editableLocatableCheck = method.indexOf(
|
||||
"IrisStructureLocator.hasLocatableEditablePlacement(e, structureKey)", nativeLocatableCheck);
|
||||
"ModuleServices.canLocateStructure(e, structureKey)", nativeLocatableCheck);
|
||||
int worldGenerationCheck = method.indexOf("targetWorld.canGenerateStructures()", editableLocatableCheck);
|
||||
int routeResolution = method.indexOf("selectStructureLookupRoute(", editableLocatableCheck);
|
||||
int nativeLocate = method.indexOf("targetWorld.locateNearestStructure(", routeResolution);
|
||||
@@ -207,7 +207,7 @@ public class IrisStructureLocateCommandContractTest {
|
||||
assertTrue(method.indexOf("DatapackIngestService.installed()") > method.indexOf("J.a(() ->"));
|
||||
assertTrue(source.contains("engine.getDimension().getDatapackImports()"));
|
||||
assertTrue(source.contains("snapshot.configuredImportUrls().contains(importUrl)"));
|
||||
assertTrue(source.contains("StructureResources.structureKeys(engine.getData())"));
|
||||
assertTrue(source.contains("ModuleServices.structureKeys(engine.getData())"));
|
||||
assertFalse(method.contains("commandSender.sendMessage(exclusion"));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user