diff --git a/src/main/java/baritone/bot/pathing/movement/Movement.java b/src/main/java/baritone/bot/pathing/movement/Movement.java index df24bc12..20ba34e1 100644 --- a/src/main/java/baritone/bot/pathing/movement/Movement.java +++ b/src/main/java/baritone/bot/pathing/movement/Movement.java @@ -55,45 +55,6 @@ public abstract class Movement implements Helper, MovementHelper { return cost; } - public double getTotalHardnessOfBlocksToBreak(ToolSet ts) { - /* - double sum = 0; - HashSet toBreak = new HashSet(); - for (BlockPos positionsToBreak1 : positionsToBreak) { - toBreak.add(positionsToBreak1); - if (this instanceof ActionFall) {//if we are digging straight down, assume we have already broken the sand above us - continue; - } - BlockPos tmp = positionsToBreak1.up(); - while (canFall(tmp)) { - toBreak.add(tmp); - tmp = tmp.up(); - } - } - for (BlockPos pos : toBreak) { - sum += getHardness(ts, Baritone.get(pos), pos); - if (sum >= COST_INF) { - return COST_INF; - } - } - if (!Baritone.allowBreakOrPlace || !Baritone.hasThrowaway) { - for (int i = 0; i < blocksToPlace.length; i++) { - if (!canWalkOn(positionsToPlace[i])) { - return COST_INF; - } - } - }*/ - //^ the above implementation properly deals with falling blocks, TODO integrate - double sum = 0; - for (BlockPos pos : positionsToBreak) { - sum += MovementHelper.getMiningDurationTicks(ts, BlockStateInterface.get(pos), pos); - if (sum >= COST_INF) { - return COST_INF; - } - } - return sum; - } - protected abstract double calculateCost(ToolSet ts); // TODO pass in information like whether it's allowed to place throwaway blocks public double recalculateCost() { diff --git a/src/main/java/baritone/bot/pathing/movement/MovementHelper.java b/src/main/java/baritone/bot/pathing/movement/MovementHelper.java index 09ab12ac..abc8184f 100644 --- a/src/main/java/baritone/bot/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/bot/pathing/movement/MovementHelper.java @@ -82,11 +82,46 @@ public interface MovementHelper extends ActionCosts, Helper { return state.isBlockNormalCube() && !BlockStateInterface.isLava(block); } - - static boolean canFall(BlockPos pos) { - return BlockStateInterface.get(pos).getBlock() instanceof BlockFalling; + static double getTotalHardnessOfBlocksToBreak(ToolSet ts, BlockPos[] positionsToBreak) { + /* + double sum = 0; + HashSet toBreak = new HashSet(); + for (BlockPos positionsToBreak1 : positionsToBreak) { + toBreak.add(positionsToBreak1); + if (this instanceof ActionFall) {//if we are digging straight down, assume we have already broken the sand above us + continue; + } + BlockPos tmp = positionsToBreak1.up(); + while (canFall(tmp)) { + toBreak.add(tmp); + tmp = tmp.up(); + } + } + for (BlockPos pos : toBreak) { + sum += getHardness(ts, Baritone.get(pos), pos); + if (sum >= COST_INF) { + return COST_INF; + } + } + if (!Baritone.allowBreakOrPlace || !Baritone.hasThrowaway) { + for (int i = 0; i < blocksToPlace.length; i++) { + if (!canWalkOn(positionsToPlace[i])) { + return COST_INF; + } + } + }*/ + //^ the above implementation properly deals with falling blocks, TODO integrate + double sum = 0; + for (BlockPos pos : positionsToBreak) { + sum += getMiningDurationTicks(ts, BlockStateInterface.get(pos), pos); + if (sum >= COST_INF) { + return COST_INF; + } + } + return sum; } + static double getMiningDurationTicks(ToolSet ts, IBlockState block, BlockPos position) { if (!block.equals(Blocks.AIR) && !canWalkThrough(position, block)) { if (avoidBreaking(position)) { diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementDescend.java index db5f6d25..107e7730 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementDescend.java @@ -27,7 +27,7 @@ public class MovementDescend extends Movement { if (tmp1 instanceof BlockLadder || tmp1 instanceof BlockVine) { return COST_INF; } - return WALK_ONE_BLOCK_COST * 0.8 + Math.max(FALL_N_BLOCKS_COST[1], WALK_ONE_BLOCK_COST * 0.2) + getTotalHardnessOfBlocksToBreak(ts);//we walk half the block plus 0.3 to get to the edge, then we walk the other 0.2 while simultaneously falling (math.max because of how it's in parallel) + return WALK_ONE_BLOCK_COST * 0.8 + Math.max(FALL_N_BLOCKS_COST[1], WALK_ONE_BLOCK_COST * 0.2) + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak);//we walk half the block plus 0.3 to get to the edge, then we walk the other 0.2 while simultaneously falling (math.max because of how it's in parallel) } @Override diff --git a/src/main/java/baritone/bot/utils/BlockStateInterface.java b/src/main/java/baritone/bot/utils/BlockStateInterface.java index 354c029c..119ddda0 100644 --- a/src/main/java/baritone/bot/utils/BlockStateInterface.java +++ b/src/main/java/baritone/bot/utils/BlockStateInterface.java @@ -1,6 +1,7 @@ package baritone.bot.utils; import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; import net.minecraft.block.BlockLiquid; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -71,4 +72,9 @@ public class BlockStateInterface { return BlockStateInterface.getBlock(pos).equals(Blocks.AIR); } + static boolean canFall(BlockPos pos) { + return BlockStateInterface.get(pos).getBlock() instanceof BlockFalling; + } + + }