From 99323463e3ebfd2cd13c70074ffb59588de3afe8 Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 7 Sep 2018 19:00:36 -0500 Subject: [PATCH] Fix improper treatment of unbreakable blocks --- .../java/baritone/pathing/movement/MovementHelper.java | 6 +++++- src/main/java/baritone/utils/ToolSet.java | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 6897d5a4..49fc5968 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -259,7 +259,11 @@ public interface MovementHelper extends ActionCosts, Helper { return COST_INF; } double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table - double result = m / context.getToolSet().getStrVsBlock(state); + double strVsBlock = context.getToolSet().getStrVsBlock(state); + if (strVsBlock < 0) + return COST_INF; + + double result = m / strVsBlock; if (includeFalling) { BlockPos up = position.up(); IBlockState above = BlockStateInterface.get(up); diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 8a97980c..e31fe09e 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -77,7 +77,7 @@ public class ToolSet implements Helper { /** * Calculates how long would it take to mine the specified block given the best tool - * in this toolset is used. + * in this toolset is used. A negative value is returned if the specified block is unbreakable. * * @param state the blockstate to be mined * @return how long it would take in ticks @@ -87,9 +87,8 @@ public class ToolSet implements Helper { ItemStack contents = player().inventory.getStackInSlot(slot); float blockHard = state.getBlockHardness(null, null); - if (blockHard < 0) { - return 0; - } + if (blockHard < 0) + return -1; float speed = contents.getDestroySpeed(state); if (speed > 1) {