From a3e5714e91fb53143bdbebcf43db67115304d1dd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 28 Aug 2018 15:01:24 -0700 Subject: [PATCH] collect canPlaceAgainst into one place --- src/main/java/baritone/pathing/movement/MovementHelper.java | 6 ++++++ .../baritone/pathing/movement/movements/MovementAscend.java | 4 ++-- .../pathing/movement/movements/MovementTraverse.java | 5 ++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 72fc9f5b..142f5d98 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -224,6 +224,12 @@ public interface MovementHelper extends ActionCosts, Helper { return BlockStateInterface.get(pos).getBlock() instanceof BlockFalling; } + static boolean canPlaceAgainst(BlockPos pos) { + IBlockState state = BlockStateInterface.get(pos); + // TODO isBlockNormalCube isn't the best check for whether or not we can place a block against it. e.g. glass isn't normalCube but we can place against it + return state.isBlockNormalCube(); + } + static double getMiningDurationTicks(CalculationContext context, BlockPos position, boolean includeFalling) { IBlockState state = BlockStateInterface.get(position); return getMiningDurationTicks(context, position, state, includeFalling); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 5afa8243..af29a887 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -69,7 +69,7 @@ public class MovementAscend extends Movement { if (against1.equals(src)) { continue; } - if (BlockStateInterface.get(against1).isBlockNormalCube()) { + if (MovementHelper.canPlaceAgainst(against1)) { return JUMP_ONE_BLOCK_COST + WALK_ONE_BLOCK_COST + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context); } } @@ -129,7 +129,7 @@ public class MovementAscend extends Movement { if (anAgainst.equals(src)) { continue; } - if (BlockStateInterface.get(anAgainst).isBlockNormalCube()) { + if (MovementHelper.canPlaceAgainst(anAgainst)) { if (!MovementHelper.throwaway(true)) {//get ready to place a throwaway block return state.setStatus(MovementStatus.UNREACHABLE); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 7a45c8bc..b1eac4e9 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -103,8 +103,7 @@ public class MovementTraverse extends Movement { continue; } against1 = against1.down(); - // TODO isBlockNormalCube isn't the best check for whether or not we can place a block against it. e.g. glass isn't normalCube but we can place against it - if (BlockStateInterface.get(against1).isBlockNormalCube()) { + if (MovementHelper.canPlaceAgainst(against1)) { return WC + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context); } } @@ -201,7 +200,7 @@ public class MovementTraverse extends Movement { continue; } against1 = against1.down(); - if (BlockStateInterface.get(against1).isBlockNormalCube()) { + if (MovementHelper.canPlaceAgainst(against1)) { if (!MovementHelper.throwaway(true)) { // get ready to place a throwaway block displayChatMessageRaw("bb pls get me some blocks. dirt or cobble"); return state.setStatus(MovementState.MovementStatus.UNREACHABLE);