Skip to content

Commit 9de3074

Browse files
authored
Merge pull request cabaletta#4662 from ZacSharp/pr/1.19.4/mine/fixCanWalkThroughButAvoidBreaking
Fix `MineProcess` stalling on blocks which are `canWalkThrough` but shouldn't be broken
2 parents 37a95ae + b8ac867 commit 9de3074

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/main/java/baritone/process/MineProcess.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
7777
int curr = ctx.player().getInventory().items.stream()
7878
.filter(stack -> filter.has(stack))
7979
.mapToInt(ItemStack::getCount).sum();
80-
System.out.println("Currently have " + curr + " valid items");
8180
if (curr >= desiredQuantity) {
8281
logDirect("Have " + curr + " valid items");
8382
cancel();
@@ -119,7 +118,7 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
119118
.filter(pos -> pos.getX() == ctx.playerFeet().getX() && pos.getZ() == ctx.playerFeet().getZ())
120119
.filter(pos -> pos.getY() >= ctx.playerFeet().getY())
121120
.filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof AirBlock)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =(
122-
.min(Comparator.comparingDouble(ctx.playerFeet()::distSqr));
121+
.min(Comparator.comparingDouble(ctx.playerFeet().above()::distSqr));
123122
baritone.getInputOverrideHandler().clearAllKeys();
124123
if (shaft.isPresent() && ctx.player().isOnGround()) {
125124
BlockPos pos = shaft.get();
@@ -486,7 +485,11 @@ public static boolean isNextToAir(CalculationContext ctx, BlockPos pos) {
486485

487486

488487
public static boolean plausibleToBreak(CalculationContext ctx, BlockPos pos) {
489-
if (MovementHelper.getMiningDurationTicks(ctx, pos.getX(), pos.getY(), pos.getZ(), ctx.bsi.get0(pos), true) >= COST_INF) {
488+
BlockState state = ctx.bsi.get0(pos);
489+
if (MovementHelper.getMiningDurationTicks(ctx, pos.getX(), pos.getY(), pos.getZ(), state, true) >= COST_INF) {
490+
return false;
491+
}
492+
if (MovementHelper.avoidBreaking(ctx.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
490493
return false;
491494
}
492495

0 commit comments

Comments
 (0)