sprinting capability. fixes #23

This commit is contained in:
Leijurv 2018-08-17 10:52:58 -07:00
parent 4591895e49
commit c635ba69fd
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
4 changed files with 10 additions and 2 deletions

View File

@ -31,6 +31,7 @@ import java.util.*;
public class Settings {
public Setting<Boolean> allowBreak = new Setting<>(true);
public Setting<Boolean> allowPlaceThrowaway = new Setting<>(true);
public Setting<Boolean> allowSprint = new Setting<>(true);
public Setting<Double> costHeuristic = new <Double>Setting<Double>(4D);
public Setting<Boolean> chuckCaching = new Setting<>(false);
public Setting<Boolean> allowWaterBucketFall = new Setting<>(true);

View File

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

View File

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

View File

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