From 9378f7e8a07b41b928f17e1505cf6cd2da910267 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 21 Jan 2024 01:32:30 +0100 Subject: [PATCH] Unhardcode `ORE_LOCATIONS_COUNT` --- src/api/java/baritone/api/Settings.java | 7 +++++++ src/main/java/baritone/process/MineProcess.java | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 9171a3d68..31d33010c 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -900,6 +900,13 @@ public final class Settings { */ public final Setting maxCachedWorldScanCount = new Setting<>(10); + /** + * Mine will not scan for or remember more than this many target locations. + * Note that the number of locations retrieved from cache is additionaly + * limited by {@link #maxCachedWorldScanCount}. + */ + public final Setting mineMaxOreLocationsCount = new Setting<>(64); + /** * Sets the minimum y level whilst mining - set to 0 to turn off. * if world has negative y values, subtract the min world height to get the value to put here diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index b6f2be526..d1bec672f 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -53,8 +53,6 @@ import static baritone.api.pathing.movement.ActionCosts.COST_INF; */ public final class MineProcess extends BaritoneProcessHelper implements IMineProcess { - private static final int ORE_LOCATIONS_COUNT = 64; - private BlockOptionalMetaLookup filter; private List knownOreLocations; private List blacklist; // inaccessible @@ -186,7 +184,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro List locs = knownOreLocations; if (!locs.isEmpty()) { CalculationContext context = new CalculationContext(baritone); - List locs2 = prune(context, new ArrayList<>(locs), filter, ORE_LOCATIONS_COUNT, blacklist, droppedItemsScan()); + List locs2 = prune(context, new ArrayList<>(locs), filter, Baritone.settings().mineMaxOreLocationsCount.value, blacklist, droppedItemsScan()); // can't reassign locs, gotta make a new var locs2, because we use it in a lambda right here, and variables you use in a lambda must be effectively final Goal goal = new GoalComposite(locs2.stream().map(loc -> coalesce(loc, locs2, context)).toArray(Goal[]::new)); knownOreLocations = locs2; @@ -235,7 +233,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return; } List dropped = droppedItemsScan(); - List locs = searchWorld(context, filter, ORE_LOCATIONS_COUNT, already, blacklist, dropped); + List locs = searchWorld(context, filter, Baritone.settings().mineMaxOreLocationsCount.value, already, blacklist, dropped); locs.addAll(dropped); if (locs.isEmpty() && !Baritone.settings().exploreForBlocks.value) { logDirect("No locations for " + filter + " known, cancelling"); @@ -425,7 +423,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } } } - knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, filter, ORE_LOCATIONS_COUNT, blacklist, dropped); + knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, filter, Baritone.settings().mineMaxOreLocationsCount.value, blacklist, dropped); return true; }