diff --git a/src/main/java/baritone/bot/Settings.java b/src/main/java/baritone/bot/Settings.java index 96a1c822..d226763c 100644 --- a/src/main/java/baritone/bot/Settings.java +++ b/src/main/java/baritone/bot/Settings.java @@ -31,6 +31,7 @@ import java.util.*; public class Settings { public Setting allowBreak = new Setting<>(true); public Setting allowPlaceThrowaway = new Setting<>(true); + public Setting allowSprint = new Setting<>(true); public Setting costHeuristic = new Setting(4D); public Setting chuckCaching = new Setting<>(false); public Setting allowWaterBucketFall = new Setting<>(true); diff --git a/src/main/java/baritone/bot/pathing/movement/CalculationContext.java b/src/main/java/baritone/bot/pathing/movement/CalculationContext.java index 92a9de9f..88a419bf 100644 --- a/src/main/java/baritone/bot/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/bot/pathing/movement/CalculationContext.java @@ -35,15 +35,18 @@ public class CalculationContext implements Helper { private final ToolSet toolSet; private final boolean hasWaterBucket; private final boolean hasThrowaway; + private final boolean canSprint; public CalculationContext() { this(new ToolSet()); } public CalculationContext(ToolSet toolSet) { + player().setSprinting(true); this.toolSet = toolSet; this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether(); this.hasThrowaway = Baritone.settings().allowPlaceThrowaway.get() && MovementHelper.throwaway(false); + this.canSprint = Baritone.settings().allowSprint.get() && player().getFoodStats().getFoodLevel() > 6; } public ToolSet getToolSet() { @@ -57,4 +60,8 @@ public class CalculationContext implements Helper { public boolean hasThrowaway() { return hasThrowaway; } + + public boolean canSprint() { + return canSprint; + } } diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementDiagonal.java index 776f2037..c7a045f2 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementDiagonal.java @@ -116,7 +116,7 @@ public class MovementDiagonal extends Movement { if (BlockStateInterface.isWater(src) || BlockStateInterface.isWater(dest)) { multiplier *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST; } - if (multiplier == WALK_ONE_BLOCK_COST) { + if (multiplier == WALK_ONE_BLOCK_COST && context.canSprint()) { // if we aren't edging around anything, and we aren't in water or soul sand // we can sprint =D multiplier = SPRINT_ONE_BLOCK_COST; diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java index 09c0ddef..cd8d56d5 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java @@ -77,7 +77,7 @@ public class MovementTraverse extends Movement { WC *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST; } if (MovementHelper.canWalkThrough(positionsToBreak[0]) && MovementHelper.canWalkThrough(positionsToBreak[1])) { - if (WC == WALK_ONE_BLOCK_COST) { + if (WC == WALK_ONE_BLOCK_COST && context.canSprint()) { // if there's nothing in the way, and this isn't water or soul sand, and we aren't sneak placing // we can sprint =D WC = SPRINT_ONE_BLOCK_COST;