Everything can be traced back to getBestSlot();

This commit is contained in:
RealIndrit 2020-08-14 10:14:02 +02:00
parent 2ed3e10833
commit f8872e1cd4
2 changed files with 7 additions and 3 deletions

View File

@ -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) {

View File

@ -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;