blacklistClosestOnFailure
This commit is contained in:
parent
6b7aca3081
commit
7cfa837604
@ -485,10 +485,12 @@ public final class Settings {
|
|||||||
public final Setting<Boolean> sprintInWater = new Setting<>(true);
|
public final Setting<Boolean> sprintInWater = new Setting<>(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When GetToBlockProcess fails to calculate a path, instead of just giving up, mark the closest instances
|
* When GetToBlockProcess or MineProcess fails to calculate a path, instead of just giving up, mark the closest instance
|
||||||
* of that block as "unreachable" and go towards the next closest
|
* of that block as "unreachable" and go towards the next closest. GetToBlock expands this seaarch to the whole "vein"; MineProcess does not.
|
||||||
|
* This is because MineProcess finds individual impossible blocks (like one block in a vein that has gravel on top then lava, so it can't break)
|
||||||
|
* Whereas GetToBlock should blacklist the whole "vein" if it can't get to any of them.
|
||||||
*/
|
*/
|
||||||
public final Setting<Boolean> blacklistOnGetToBlockFailure = new Setting<>(true);
|
public final Setting<Boolean> blacklistClosestOnFailure = new Setting<>(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 😎 Render cached chunks as semitransparent. Doesn't work with OptiFine 😭 Rarely randomly crashes, see <a href="https://github.com/cabaletta/baritone/issues/327">this issue</a>.
|
* 😎 Render cached chunks as semitransparent. Doesn't work with OptiFine 😭 Rarely randomly crashes, see <a href="https://github.com/cabaletta/baritone/issues/327">this issue</a>.
|
||||||
|
@ -83,7 +83,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
}
|
}
|
||||||
Goal goal = new GoalComposite(knownLocations.stream().map(this::createGoal).toArray(Goal[]::new));
|
Goal goal = new GoalComposite(knownLocations.stream().map(this::createGoal).toArray(Goal[]::new));
|
||||||
if (calcFailed) {
|
if (calcFailed) {
|
||||||
if (Baritone.settings().blacklistOnGetToBlockFailure.value) {
|
if (Baritone.settings().blacklistClosestOnFailure.value) {
|
||||||
logDirect("Unable to find any path to " + gettingTo + ", blacklisting presumably unreachable closest instances");
|
logDirect("Unable to find any path to " + gettingTo + ", blacklisting presumably unreachable closest instances");
|
||||||
blacklistClosest();
|
blacklistClosest();
|
||||||
return onTick(false, isSafeToCancel); // gamer moment
|
return onTick(false, isSafeToCancel); // gamer moment
|
||||||
@ -168,7 +168,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void rescan(List<BlockPos> known, CalculationContext context) {
|
private synchronized void rescan(List<BlockPos> known, CalculationContext context) {
|
||||||
List<BlockPos> positions = MineProcess.searchWorld(context, Collections.singletonList(gettingTo), 64, known);
|
List<BlockPos> positions = MineProcess.searchWorld(context, Collections.singletonList(gettingTo), 64, known, blacklist);
|
||||||
positions.removeIf(blacklist::contains);
|
positions.removeIf(blacklist::contains);
|
||||||
knownLocations = positions;
|
knownLocations = positions;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
|
|
||||||
private List<Block> mining;
|
private List<Block> mining;
|
||||||
private List<BlockPos> knownOreLocations;
|
private List<BlockPos> knownOreLocations;
|
||||||
|
private List<BlockPos> blacklist; // inaccessible
|
||||||
private BlockPos branchPoint;
|
private BlockPos branchPoint;
|
||||||
private GoalRunAway branchPointRunaway;
|
private GoalRunAway branchPointRunaway;
|
||||||
private int desiredQuantity;
|
private int desiredQuantity;
|
||||||
@ -80,6 +81,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (calcFailed && !knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) {
|
||||||
|
knownOreLocations.stream().sorted(Comparator.comparingDouble(ctx.player()::getDistanceSq)).findFirst().ifPresent(blacklist::add);
|
||||||
|
knownOreLocations.removeIf(blacklist::contains);
|
||||||
|
calcFailed = false; // 😎
|
||||||
|
}
|
||||||
if (calcFailed) {
|
if (calcFailed) {
|
||||||
logDirect("Unable to find any path to " + mining + ", canceling Mine");
|
logDirect("Unable to find any path to " + mining + ", canceling Mine");
|
||||||
cancel();
|
cancel();
|
||||||
@ -118,7 +124,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
boolean legit = Baritone.settings().legitMine.value;
|
boolean legit = Baritone.settings().legitMine.value;
|
||||||
List<BlockPos> locs = knownOreLocations;
|
List<BlockPos> locs = knownOreLocations;
|
||||||
if (!locs.isEmpty()) {
|
if (!locs.isEmpty()) {
|
||||||
List<BlockPos> locs2 = prune(new CalculationContext(baritone), new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT);
|
List<BlockPos> locs2 = prune(new CalculationContext(baritone), new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT, blacklist);
|
||||||
// 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
|
// 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(ctx, loc, locs2)).toArray(Goal[]::new));
|
Goal goal = new GoalComposite(locs2.stream().map(loc -> coalesce(ctx, loc, locs2)).toArray(Goal[]::new));
|
||||||
knownOreLocations = locs2;
|
knownOreLocations = locs2;
|
||||||
@ -160,10 +166,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
if (Baritone.settings().legitMine.value) {
|
if (Baritone.settings().legitMine.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<BlockPos> locs = searchWorld(context, mining, ORE_LOCATIONS_COUNT, already);
|
List<BlockPos> locs = searchWorld(context, mining, ORE_LOCATIONS_COUNT, already, blacklist);
|
||||||
locs.addAll(droppedItemsScan(mining, ctx.world()));
|
locs.addAll(droppedItemsScan(mining, ctx.world()));
|
||||||
if (locs.isEmpty()) {
|
if (locs.isEmpty()) {
|
||||||
logDebug("No locations for " + mining + " known, cancelling");
|
logDirect("No locations for " + mining + " known, cancelling");
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -204,7 +210,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<BlockPos> searchWorld(CalculationContext ctx, List<Block> mining, int max, List<BlockPos> alreadyKnown) {
|
public static List<BlockPos> searchWorld(CalculationContext ctx, List<Block> mining, int max, List<BlockPos> alreadyKnown, List<BlockPos> blacklist) {
|
||||||
List<BlockPos> locs = new ArrayList<>();
|
List<BlockPos> locs = new ArrayList<>();
|
||||||
List<Block> uninteresting = new ArrayList<>();
|
List<Block> uninteresting = new ArrayList<>();
|
||||||
//long b = System.currentTimeMillis();
|
//long b = System.currentTimeMillis();
|
||||||
@ -216,6 +222,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
uninteresting.add(m);
|
uninteresting.add(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
locs = prune(ctx, locs, mining, max, blacklist);
|
||||||
//System.out.println("Scan of cached chunks took " + (System.currentTimeMillis() - b) + "ms");
|
//System.out.println("Scan of cached chunks took " + (System.currentTimeMillis() - b) + "ms");
|
||||||
if (locs.isEmpty()) {
|
if (locs.isEmpty()) {
|
||||||
uninteresting = mining;
|
uninteresting = mining;
|
||||||
@ -226,7 +233,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
|
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
|
||||||
}
|
}
|
||||||
locs.addAll(alreadyKnown);
|
locs.addAll(alreadyKnown);
|
||||||
return prune(ctx, locs, mining, max);
|
return prune(ctx, locs, mining, max, blacklist);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addNearby() {
|
private void addNearby() {
|
||||||
@ -249,10 +256,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, mining, ORE_LOCATIONS_COUNT);
|
knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, mining, ORE_LOCATIONS_COUNT, blacklist);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<BlockPos> prune(CalculationContext ctx, List<BlockPos> locs2, List<Block> mining, int max) {
|
private static List<BlockPos> prune(CalculationContext ctx, List<BlockPos> locs2, List<Block> mining, int max, List<BlockPos> blacklist) {
|
||||||
List<BlockPos> dropped = droppedItemsScan(mining, ctx.world);
|
List<BlockPos> dropped = droppedItemsScan(mining, ctx.world);
|
||||||
dropped.removeIf(drop -> {
|
dropped.removeIf(drop -> {
|
||||||
for (BlockPos pos : locs2) {
|
for (BlockPos pos : locs2) {
|
||||||
@ -272,6 +279,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
// remove any that are implausible to mine (encased in bedrock, or touching lava)
|
// remove any that are implausible to mine (encased in bedrock, or touching lava)
|
||||||
.filter(pos -> MineProcess.plausibleToBreak(ctx.bsi, pos))
|
.filter(pos -> MineProcess.plausibleToBreak(ctx.bsi, pos))
|
||||||
|
|
||||||
|
.filter(pos -> !blacklist.contains(pos))
|
||||||
|
|
||||||
.sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().playerFeet()::distanceSq))
|
.sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().playerFeet()::distanceSq))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
@ -300,6 +309,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks);
|
this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks);
|
||||||
this.desiredQuantity = quantity;
|
this.desiredQuantity = quantity;
|
||||||
this.knownOreLocations = new ArrayList<>();
|
this.knownOreLocations = new ArrayList<>();
|
||||||
|
this.blacklist = new ArrayList<>();
|
||||||
this.branchPoint = null;
|
this.branchPoint = null;
|
||||||
this.branchPointRunaway = null;
|
this.branchPointRunaway = null;
|
||||||
if (mining != null) {
|
if (mining != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user