mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 09:44:24 +00:00
Bound find river search
- HydrologyFeatureSearch stops after its timeout or when the caller cancels, waiting on plans in 50 ms slices - Types the dimension cannot form answer at once without planning, naming the setting that turns them off - channelType reads the tier name (stream, river, major or major_river) and falls back to rank, so one-tier packs match stream - HydrologyRuntime adds unavailable(type) and passes FEATURE_SEARCH_TIMEOUT (30 s) and a running check to the search - nearestRiver returns a RiverSearch outcome, reports disabled and timed-out searches, and keeps recorded water on timeout - startRiverSearch keeps one search per player; a new search cancels the previous one without a message - Bukkit and modded find river run through the shared per-player search - Tier name description and schema digest follow the new tier naming - HydrologyFeatureSearchTest plus new query, Bukkit and modded cases cover the bounds
This commit is contained in:
1 parent
75d28d16b2
commit
474b1e873a
12 files changed
+826
-167
No files matched your search
@@ -70,6 +70,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CancellationException;
|
||||
|
||||
@Director(name = "find", origin = DirectorOrigin.PLAYER, description = "Iris Find commands", descriptionKey = "iris.director.commandfind.director.iris_find_commands", aliases = "goto")
|
||||
public class CommandFind implements DirectorExecutor {
|
||||
@@ -218,41 +219,49 @@ public class CommandFind implements DirectorExecutor {
|
||||
commandSender.sendMessage(C.RED + error.getMessage());
|
||||
return;
|
||||
}
|
||||
String label = featureType.key().replace('_', ' ');
|
||||
Location origin = target.getLocation();
|
||||
World originWorld = origin.getWorld();
|
||||
int maximumDistance = GenerationSemanticQueries.RIVER_SEARCH_DISTANCE;
|
||||
commandSender.sendMessage(C.GRAY + GenerationSemanticQueries.riverSearchMessage(featureType, maximumDistance));
|
||||
J.a(() -> {
|
||||
try {
|
||||
GenerationSemanticQueries.RiverResult feature = GenerationSemanticQueries.nearestRiver(
|
||||
activeEngine,
|
||||
featureType,
|
||||
origin.getBlockX(),
|
||||
origin.getBlockZ(),
|
||||
maximumDistance
|
||||
).orElse(null);
|
||||
if (feature == null) {
|
||||
sendStructureMessage(target, commandSender,
|
||||
C.YELLOW + GenerationSemanticQueries.riverNotFoundMessage(featureType, maximumDistance));
|
||||
return;
|
||||
}
|
||||
if (!teleport) {
|
||||
sendStructureMessage(target, commandSender,
|
||||
C.GREEN + "Found " + label + " at " + feature.x() + ", " + feature.y() + ", " + feature.z() + ".");
|
||||
return;
|
||||
}
|
||||
Location destination = new Location(
|
||||
originWorld, feature.x(), feature.y(), feature.z());
|
||||
prepareStructureTeleport(
|
||||
target, originWorld, commandSender, label, destination, true);
|
||||
} catch (Throwable error) {
|
||||
sendStructureMessage(target, commandSender,
|
||||
C.RED + "Could not search for " + label + ": " + error.getClass().getSimpleName()
|
||||
+ (error.getMessage() == null ? "" : " - " + error.getMessage()));
|
||||
Iris.reportError("Could not locate hydrology feature '" + featureType.key() + "'.", error);
|
||||
RiverRequest request = new RiverRequest(target, origin.getWorld(), commandSender, featureType, teleport);
|
||||
commandSender.sendMessage(C.GRAY + GenerationSemanticQueries.riverSearchMessage(featureType,
|
||||
GenerationSemanticQueries.RIVER_SEARCH_DISTANCE));
|
||||
GenerationSemanticQueries.startRiverSearch(target.getUniqueId(), J::a, activeEngine, featureType, origin.getBlockX(),
|
||||
origin.getBlockZ())
|
||||
.whenComplete((search, failure) -> finishRiverSearch(request, search, failure));
|
||||
}
|
||||
|
||||
private void finishRiverSearch(RiverRequest request, GenerationSemanticQueries.RiverSearch search, Throwable failure) {
|
||||
if (failure instanceof CancellationException) {
|
||||
return;
|
||||
}
|
||||
if (failure != null) {
|
||||
reportRiverFailure(request, failure);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
switch (search) {
|
||||
case GenerationSemanticQueries.RiverSearch.Missing missing ->
|
||||
sendStructureMessage(request.target(), request.sender(), C.YELLOW + missing.message());
|
||||
case GenerationSemanticQueries.RiverSearch.Found found -> arriveAtRiver(request, found.feature());
|
||||
}
|
||||
});
|
||||
} catch (RuntimeException error) {
|
||||
reportRiverFailure(request, error);
|
||||
}
|
||||
}
|
||||
|
||||
private void arriveAtRiver(RiverRequest request, GenerationSemanticQueries.RiverResult feature) {
|
||||
if (!request.teleport()) {
|
||||
sendStructureMessage(request.target(), request.sender(),
|
||||
C.GREEN + "Found " + request.label() + " at " + feature.x() + ", " + feature.y() + ", " + feature.z() + ".");
|
||||
return;
|
||||
}
|
||||
Location destination = new Location(request.world(), feature.x(), feature.y(), feature.z());
|
||||
prepareStructureTeleport(request.target(), request.world(), request.sender(), request.label(), destination, true);
|
||||
}
|
||||
|
||||
private void reportRiverFailure(RiverRequest request, Throwable failure) {
|
||||
sendStructureMessage(request.target(), request.sender(),
|
||||
C.RED + "Could not search for " + request.label() + ": " + failure.getClass().getSimpleName()
|
||||
+ (failure.getMessage() == null ? "" : " - " + failure.getMessage()));
|
||||
Iris.reportError("Could not locate hydrology feature '" + request.type().key() + "'.", failure);
|
||||
}
|
||||
|
||||
@Director(description = "Find a structure (a vanilla key like minecraft:village_plains or minecraft:stronghold, or an imported iris structure key)", descriptionKey = "iris.director.commandfind.director.find_structure_vanilla_key_like_minecraft_village_plains_minecraft_stronghold_imported_iris", sync = true)
|
||||
@@ -919,6 +928,12 @@ public class CommandFind implements DirectorExecutor {
|
||||
int configuredUnregistered, int editableUnplaced, int managedUnregistered) {
|
||||
}
|
||||
|
||||
private record RiverRequest(Player target, World world, VolmitSender sender, HydrologyFeatureType type, boolean teleport) {
|
||||
private String label() {
|
||||
return type.key().replace('_', ' ');
|
||||
}
|
||||
}
|
||||
|
||||
private record ManagedDatapackStructure(String key, Set<String> sourceIds) {
|
||||
private ManagedDatapackStructure(String key) {
|
||||
this(key, new LinkedHashSet<>());
|
||||
|
||||
Reference in new issue
Block a user