diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 4b44d3e5..b48bf55f 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -61,6 +61,21 @@ public final class Settings { */ public final Setting allowInventory = new Setting<>(false); + /** + * Allow player to decide if to use auto tool or not + */ + public final Setting autoTool = new Setting<>(true); + + /** + * Should movement cost calculation ignore the cost of breaking blocks with current slot, and assume best possible + * item in the hotbar? + * + * Only use this if actually necessary, make sure to put this back to original state (false), or it + * might mess up pathing in some combinations with auto tool setting. (just fall back to original settings if any + * problems occurs) + */ + public final Setting ignoreAutoToolMovementCost = new Setting<>(false); + /** * It doesn't actually take twenty ticks to place a block, this cost is so high * because we want to generally conserve blocks which might be limited. diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 1a3faf57..7ae57ae4 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -432,7 +432,9 @@ public interface MovementHelper extends ActionCosts, Helper { * @param ts previously calculated ToolSet */ static void switchToBestToolFor(IPlayerContext ctx, IBlockState b, ToolSet ts, boolean preferSilkTouch) { - ctx.player().inventory.currentItem = ts.getBestSlot(b.getBlock(), preferSilkTouch); + if (Baritone.settings().autoTool.value) { + ctx.player().inventory.currentItem = ts.getBestSlot(b.getBlock(), preferSilkTouch); + } } static void moveTowards(IPlayerContext ctx, MovementState state, BlockPos pos) { diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index b6446b30..b903bdf3 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -96,12 +96,27 @@ public class ToolSet { } /** - * Calculate which tool on the hotbar is best for mining + * Calculate which tool on the hotbar is best for mining, depending on an override setting, + * related to auto tool movement cost, it will either return current selected slot, or the best slot. * * @param b the blockstate to be mined * @return An int containing the index in the tools array that worked best */ + public int getBestSlot(Block b, boolean preferSilkTouch) { + return getBestSlot(b, preferSilkTouch, false); + } + + public int getBestSlot(Block b, boolean preferSilkTouch, boolean pathingCalculation) { + + /* + If we actually want know what efficiency our held item has instead of the best one + possible, this lets us make pathing depending on the actual tool used (if auto tool is disabled) + */ + if (!Baritone.settings().ignoreAutoToolMovementCost.value && pathingCalculation) { + return player.inventory.currentItem; + } + int best = 0; double highestSpeed = Double.NEGATIVE_INFINITY; int lowestCost = Integer.MIN_VALUE; @@ -137,7 +152,7 @@ public class ToolSet { * @return A double containing the destruction ticks with the best tool */ private double getBestDestructionTime(Block b) { - ItemStack stack = player.inventory.getStackInSlot(getBestSlot(b, false)); + ItemStack stack = player.inventory.getStackInSlot(getBestSlot(b, false, true)); return calculateSpeedVsBlock(stack, b.getDefaultState()) * avoidanceMultiplier(b); }