Skip to content

Commit

Permalink
Merge pull request cabaletta#4248 from ZacSharp/pr/1.19.4/mine/unhard…
Browse files Browse the repository at this point in the history
…codeMaxOreLocations

Unhardcode `ORE_LOCATIONS_COUNT`
  • Loading branch information
leijurv authored Jan 23, 2024
2 parents 48f309a + 9378f7e commit e962c39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,13 @@ public final class Settings {
*/
public final Setting<Integer> 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<Integer> 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
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/baritone/process/MineProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
*/
public final class MineProcess extends BaritoneProcessHelper implements IMineProcess {

private static final int ORE_LOCATIONS_COUNT = 64;

private BlockOptionalMetaLookup filter;
private List<BlockPos> knownOreLocations;
private List<BlockPos> blacklist; // inaccessible
Expand Down Expand Up @@ -186,7 +184,7 @@ private PathingCommand updateGoal() {
List<BlockPos> locs = knownOreLocations;
if (!locs.isEmpty()) {
CalculationContext context = new CalculationContext(baritone);
List<BlockPos> locs2 = prune(context, new ArrayList<>(locs), filter, ORE_LOCATIONS_COUNT, blacklist, droppedItemsScan());
List<BlockPos> 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;
Expand Down Expand Up @@ -235,7 +233,7 @@ private void rescan(List<BlockPos> already, CalculationContext context) {
return;
}
List<BlockPos> dropped = droppedItemsScan();
List<BlockPos> locs = searchWorld(context, filter, ORE_LOCATIONS_COUNT, already, blacklist, dropped);
List<BlockPos> 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");
Expand Down Expand Up @@ -425,7 +423,7 @@ private boolean addNearby() {
}
}
}
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;
}

Expand Down

0 comments on commit e962c39

Please sign in to comment.