From f8872e1cd450cbf205974d6dc9db1e1c6b8d676e Mon Sep 17 00:00:00 2001 From: RealIndrit Date: Fri, 14 Aug 2020 10:14:02 +0200 Subject: [PATCH] Everything can be traced back to getBestSlot(); --- src/main/java/baritone/pathing/movement/MovementHelper.java | 4 +--- src/main/java/baritone/utils/ToolSet.java | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 7ae57ae4..1a3faf57 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -432,9 +432,7 @@ public interface MovementHelper extends ActionCosts, Helper { * @param ts previously calculated ToolSet */ static void switchToBestToolFor(IPlayerContext ctx, IBlockState b, ToolSet ts, boolean preferSilkTouch) { - if (Baritone.settings().autoTool.value) { - ctx.player().inventory.currentItem = ts.getBestSlot(b.getBlock(), preferSilkTouch); - } + 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..101a4294 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -18,6 +18,7 @@ package baritone.utils; import baritone.Baritone; +import baritone.command.argparser.DefaultArgParsers; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.entity.EntityPlayerSP; @@ -102,6 +103,11 @@ public class ToolSet { * @return An int containing the index in the tools array that worked best */ public int getBestSlot(Block b, boolean preferSilkTouch) { + // Make all depending calculation respect auto tool value without doing unecessary calculations... + if (Baritone.settings().autoTool.value) { + return player.inventory.currentItem; + } + int best = 0; double highestSpeed = Double.NEGATIVE_INFINITY; int lowestCost = Integer.MIN_VALUE;