max fall height even with bucket, fixes #57

This commit is contained in:
Leijurv 2018-08-21 17:16:00 -07:00
parent 4c0d581d7f
commit 9f12a0ab6f
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
4 changed files with 24 additions and 8 deletions

View File

@ -133,7 +133,13 @@ public class Settings {
* 3 won't deal any damage. But if you just want to get down the mountain quickly and you have
* Feather Falling IV, you might set it a bit higher, like 4 or 5.
*/
public Setting<Integer> maxFallHeight = new Setting<>(3);
public Setting<Integer> maxFallHeightNoWater = new Setting<>(3);
/**
* How far are you allowed to fall onto solid ground (with a water bucket)?
* It's not that reliable, so I've set it below what would kill an unarmored player (23)
*/
public Setting<Integer> maxFallHeightBucket = new Setting<>(20);
/**
* If your goal is a GoalBlock in an unloaded chunk, assume it's far enough away that the Y coord

View File

@ -38,7 +38,8 @@ public class CalculationContext implements Helper {
private final boolean canSprint;
private final double placeBlockCost;
private final boolean allowBreak;
private final int maxFallHeight;
private final int maxFallHeightNoWater;
private final int maxFallHeightBucket;
public CalculationContext() {
this(new ToolSet());
@ -52,7 +53,8 @@ public class CalculationContext implements Helper {
this.canSprint = Baritone.settings().allowSprint.get() && player().getFoodStats().getFoodLevel() > 6;
this.placeBlockCost = Baritone.settings().blockPlacementPenalty.get();
this.allowBreak = Baritone.settings().allowBreak.get();
this.maxFallHeight = Baritone.settings().maxFallHeight.get();
this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.get();
this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.get();
// why cache these things here, why not let the movements just get directly from settings?
// because if some movements are calculated one way and others are calculated another way,
// then you get a wildly inconsistent path that isn't optimal for either scenario.
@ -82,7 +84,12 @@ public class CalculationContext implements Helper {
return allowBreak;
}
public int maxFallHeight(){
return maxFallHeight;
public int maxFallHeightNoWater() {
return maxFallHeightNoWater;
}
public int maxFallHeightBucket() {
return maxFallHeightBucket;
}
}

View File

@ -299,7 +299,7 @@ public interface MovementHelper extends ActionCosts, Helper {
continue;
}
if (canWalkOn(onto, ontoBlock)) {
if (calcContext.hasWaterBucket() || fallHeight <= 4) {
if ((calcContext.hasWaterBucket() && fallHeight <= calcContext.maxFallHeightBucket() + 1) || fallHeight <= calcContext.maxFallHeightNoWater() + 1) {
// fallHeight = 4 means onto.up() is 3 blocks down, which is the max
return new MovementFall(pos, onto.up());
} else {

View File

@ -52,10 +52,13 @@ public class MovementFall extends Movement {
return COST_INF;
}
double placeBucketCost = 0.0;
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > context.maxFallHeight()) {
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > context.maxFallHeightNoWater()) {
if (!context.hasWaterBucket()) {
return COST_INF;
}
if (src.getY() - dest.getY() > context.maxFallHeightBucket()) {
return COST_INF;
}
placeBucketCost = context.placeBlockCost();
}
double frontTwo = MovementHelper.getMiningDurationTicks(context, positionsToBreak[0]) + MovementHelper.getMiningDurationTicks(context, positionsToBreak[1]);
@ -89,7 +92,7 @@ public class MovementFall extends Movement {
}
BlockPos playerFeet = playerFeet();
Optional<Rotation> targetRotation = Optional.empty();
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeight.get() && !playerFeet.equals(dest)) {
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) {
if (!player().inventory.hasItemStack(STACK_BUCKET_WATER) || world().provider.isNether()) { // TODO check if water bucket is on hotbar or main inventory
state.setStatus(MovementStatus.UNREACHABLE);
return state;