sprinting capability. fixes #23
This commit is contained in:
parent
4591895e49
commit
c635ba69fd
@ -31,6 +31,7 @@ import java.util.*;
|
|||||||
public class Settings {
|
public class Settings {
|
||||||
public Setting<Boolean> allowBreak = new Setting<>(true);
|
public Setting<Boolean> allowBreak = new Setting<>(true);
|
||||||
public Setting<Boolean> allowPlaceThrowaway = 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<Double> costHeuristic = new <Double>Setting<Double>(4D);
|
||||||
public Setting<Boolean> chuckCaching = new Setting<>(false);
|
public Setting<Boolean> chuckCaching = new Setting<>(false);
|
||||||
public Setting<Boolean> allowWaterBucketFall = new Setting<>(true);
|
public Setting<Boolean> allowWaterBucketFall = new Setting<>(true);
|
||||||
|
@ -35,15 +35,18 @@ public class CalculationContext implements Helper {
|
|||||||
private final ToolSet toolSet;
|
private final ToolSet toolSet;
|
||||||
private final boolean hasWaterBucket;
|
private final boolean hasWaterBucket;
|
||||||
private final boolean hasThrowaway;
|
private final boolean hasThrowaway;
|
||||||
|
private final boolean canSprint;
|
||||||
|
|
||||||
public CalculationContext() {
|
public CalculationContext() {
|
||||||
this(new ToolSet());
|
this(new ToolSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalculationContext(ToolSet toolSet) {
|
public CalculationContext(ToolSet toolSet) {
|
||||||
|
player().setSprinting(true);
|
||||||
this.toolSet = toolSet;
|
this.toolSet = toolSet;
|
||||||
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether();
|
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.hasThrowaway = Baritone.settings().allowPlaceThrowaway.get() && MovementHelper.throwaway(false);
|
||||||
|
this.canSprint = Baritone.settings().allowSprint.get() && player().getFoodStats().getFoodLevel() > 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolSet getToolSet() {
|
public ToolSet getToolSet() {
|
||||||
@ -57,4 +60,8 @@ public class CalculationContext implements Helper {
|
|||||||
public boolean hasThrowaway() {
|
public boolean hasThrowaway() {
|
||||||
return hasThrowaway;
|
return hasThrowaway;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canSprint() {
|
||||||
|
return canSprint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public class MovementDiagonal extends Movement {
|
|||||||
if (BlockStateInterface.isWater(src) || BlockStateInterface.isWater(dest)) {
|
if (BlockStateInterface.isWater(src) || BlockStateInterface.isWater(dest)) {
|
||||||
multiplier *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST;
|
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
|
// if we aren't edging around anything, and we aren't in water or soul sand
|
||||||
// we can sprint =D
|
// we can sprint =D
|
||||||
multiplier = SPRINT_ONE_BLOCK_COST;
|
multiplier = SPRINT_ONE_BLOCK_COST;
|
||||||
|
@ -77,7 +77,7 @@ public class MovementTraverse extends Movement {
|
|||||||
WC *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST;
|
WC *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canWalkThrough(positionsToBreak[0]) && MovementHelper.canWalkThrough(positionsToBreak[1])) {
|
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
|
// 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
|
// we can sprint =D
|
||||||
WC = SPRINT_ONE_BLOCK_COST;
|
WC = SPRINT_ONE_BLOCK_COST;
|
||||||
|
Loading…
Reference in New Issue
Block a user