From 5f6a5ea4030386286d83b2b95532b1b73bfb3d32 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 26 Aug 2018 08:31:03 -0700 Subject: [PATCH] extend MovementFall breakability one more, fixes #97 --- .../pathing/movement/MovementHelper.java | 18 +++++++++--------- .../movement/movements/MovementFall.java | 13 ++++++++----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index fd033b78..93bd34fb 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -304,22 +304,22 @@ public interface MovementHelper extends ActionCosts, Helper { static Movement generateMovementFallOrDescend(BlockPos pos, BlockPos dest, CalculationContext calcContext) { // A //SA - // B + // A // B // C // D - //if S is where you start, both of B need to be air for a movementfall + //if S is where you start, B needs to be air for a movementfall //A is plausibly breakable by either descend or fall //C, D, etc determine the length of the fall - for (int i = 1; i < 3; i++) { - if (!canWalkThrough(dest.down(i))) { - //if any of these two (B in the diagram) aren't air - //have to do a descend, because fall is impossible - //this doesn't guarantee descend is possible, it just guarantees fall is impossible - return new MovementDescend(pos, dest.down()); // standard move out by 1 and descend by 1 - } + if (!canWalkThrough(dest.down(2))) { + //if B in the diagram aren't air + //have to do a descend, because fall is impossible + + //this doesn't guarantee descend is possible, it just guarantees fall is impossible + return new MovementDescend(pos, dest.down()); // standard move out by 1 and descend by 1 } + // we're clear for a fall 2 // let's see how far we can fall for (int fallHeight = 3; true; fallHeight++) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 5c40c706..04e42938 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -56,14 +56,17 @@ public class MovementFall extends Movement { } placeBucketCost = context.placeBlockCost(); } - double frontTwo = MovementHelper.getMiningDurationTicks(context, positionsToBreak[0]) + MovementHelper.getMiningDurationTicks(context, positionsToBreak[1]); - if (frontTwo >= COST_INF) { - return COST_INF; + double frontThree = 0; + for (int i = 0; i < 3; i++) { + frontThree += MovementHelper.getMiningDurationTicks(context, positionsToBreak[i]); + if (frontThree >= COST_INF) { + return COST_INF; + } } if (BlockStateInterface.get(positionsToBreak[0].up()).getBlock() instanceof BlockFalling) { return COST_INF; } - for (int i = 2; i < positionsToBreak.length; i++) { + for (int i = 3; i < positionsToBreak.length; i++) { // TODO is this the right check here? // MiningDurationTicks is all right, but shouldn't it be canWalkThrough instead? // Lilypads (i think?) are 0 ticks to mine, but they definitely cause fall damage @@ -74,7 +77,7 @@ public class MovementFall extends Movement { return COST_INF; } } - return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + placeBucketCost + frontTwo; + return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + placeBucketCost + frontThree; } @Override