From 1b576eca2850e080f1c84d4c078bee4f9d20bfb5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 19:58:03 -0700 Subject: [PATCH] MovementDescend --- .../movement/movements/MovementDescend.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 85f7f110..dc0f2e0a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -45,14 +45,18 @@ public class MovementDescend extends Movement { @Override protected double calculateCost(CalculationContext context) { - Block fromDown = BlockStateInterface.get(src.down()).getBlock(); + return cost(context, src.x, src.y, src.z, dest.x, dest.z); + } + + public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { + Block fromDown = BlockStateInterface.get(x, y - 1, z).getBlock(); if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { return COST_INF; } - if (!MovementHelper.canWalkOn(positionToPlace)) { + if (!MovementHelper.canWalkOn(destX, y - 2, destZ)) { return COST_INF; } - Block tmp1 = BlockStateInterface.get(dest).getBlock(); + Block tmp1 = BlockStateInterface.get(destX, y - 1, destZ).getBlock(); if (tmp1 == Blocks.LADDER || tmp1 == Blocks.VINE) { return COST_INF; } @@ -62,7 +66,17 @@ public class MovementDescend extends Movement { // use this ratio to apply the soul sand speed penalty to our 0.8 block distance walk = WALK_ONE_OVER_SOUL_SAND_COST; } - return walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST) + getTotalHardnessOfBlocksToBreak(context); + double totalCost = walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST); + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y - 1, destZ, false); + if (totalCost >= COST_INF) { + return COST_INF; + } + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y, destZ, false); + if (totalCost >= COST_INF) { + return COST_INF; + } + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, true); // only the top block in the 3 we need to mine needs to consider the falling blocks above + return totalCost; } @Override