Repository: cabaletta/baritone (language: java)

Issue:
Baritone can't mine flowers next to the world boarder
## Some information
Operating system:
Java version: Runtime 21.0.1
Minecraft version: 1.21.3
Baritone version: 1.11.1 (latest)
Other mods (if used): Plenty honestly. It's a lot of fps improvement mods and other client side mods. I don't think this issue is relating to any mod interference but I'll write them here if you need me to.

## Exception, error or logs

## How to reproduce
For some reason Britone is unable to mine flowers next to the world boarder. It paths to the flower just fine, but it doesn't break it when it arrives. I have to break it manually.

The flower must be next to the world boarder, not in it or past it. However if the flower is only 1 block away or more. It can mine it just fine.

## Modified settings
It's also alot. I'll add them if I need to.

## Final checklist
- [x] I know how to properly use check boxes 
- [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
- [ ] I have included logs, exceptions and / or steps to reproduce the issue.
- [x] I have not used any OwO's or UwU's in this issue.


Discussion / hints:
If I'm correct about the reason for this, this should happen with anything Baritone can walk through. Other blocks will be ignored when next to or outside the world border.

Firstly, for `canWalkThrough` blocks just walking into them won't do the trick. Path execution will walk into them and that's it (honestly I was surprised mining them works anyway). However, there's a second mechanism by which `MineProcess` can break blocks:
If a target block is in the same xz column as the player and at or above foot height and breaking it won't trigger falling blocks or risk unblocking liquids, then `MineProcess` will break it.

The check for falling blocks/liquids happens in `MovementHelper.avoidBreaking`, which also returns true right next to the world border. Normally that's not a problem since `MovementHelper.getMiningDurationTicks`  reports any such block as being unbreakable and `MineProcess` will completely ignore inbreakable blocks.
However, if a block is `canWalkThrough` there is no reason for movements to break it, so `getMiningDurationTicks` shortcuts and returns 0, making `MineProcess` include it in the pathfinder goal even though it won't be able to break the block.

(I'll hopefully have a fix tomorrow; should be as simple as explicitly checking `avoidBreaking`)

Fix patch:
diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java
index d1bec672f..ff905c02f 100644
--- a/src/main/java/baritone/process/MineProcess.java
+++ b/src/main/java/baritone/process/MineProcess.java
@@ -77,7 +77,6 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
             int curr = ctx.player().getInventory().items.stream()
                     .filter(stack -> filter.has(stack))
                     .mapToInt(ItemStack::getCount).sum();
-            System.out.println("Currently have " + curr + " valid items");
             if (curr >= desiredQuantity) {
                 logDirect("Have " + curr + " valid items");
                 cancel();
@@ -119,7 +118,7 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
                 .filter(pos -> pos.getX() == ctx.playerFeet().getX() && pos.getZ() == ctx.playerFeet().getZ())
                 .filter(pos -> pos.getY() >= ctx.playerFeet().getY())
                 .filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof AirBlock)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =(
-                .min(Comparator.comparingDouble(ctx.playerFeet()::distSqr));
+                .min(Comparator.comparingDouble(ctx.playerFeet().above()::distSqr));
         baritone.getInputOverrideHandler().clearAllKeys();
         if (shaft.isPresent() && ctx.player().isOnGround()) {
             BlockPos pos = shaft.get();
@@ -486,7 +485,11 @@ public static boolean isNextToAir(CalculationContext ctx, BlockPos pos) {
 
 
     public static boolean plausibleToBreak(CalculationContext ctx, BlockPos pos) {
-        if (MovementHelper.getMiningDurationTicks(ctx, pos.getX(), pos.getY(), pos.getZ(), ctx.bsi.get0(pos), true) >= COST_INF) {
+        BlockState state = ctx.bsi.get0(pos);
+        if (MovementHelper.getMiningDurationTicks(ctx, pos.getX(), pos.getY(), pos.getZ(), state, true) >= COST_INF) {
+            return false;
+        }
+        if (MovementHelper.avoidBreaking(ctx.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
             return false;
         }
 


Test patch: