added maxCostIncrease, fixes #154

This commit is contained in:
Leijurv 2018-09-11 15:50:46 -07:00
parent e6c574063e
commit 1bf34d42e2
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 13 additions and 0 deletions

View File

@ -144,6 +144,12 @@ public class Settings {
*/ */
public Setting<Boolean> cutoffAtLoadBoundary = new Setting<>(false); public Setting<Boolean> cutoffAtLoadBoundary = new Setting<>(false);
/**
* If a movement's cost increases by more than this amount between calculation and execution (due to changes
* in the environment / world), cancel and recalculate
*/
public Setting<Double> maxCostIncrease = new Setting<>(10D);
/** /**
* Stop 5 movements before anything that made the path COST_INF. * Stop 5 movements before anything that made the path COST_INF.
* For example, if lava has spread across the path, don't walk right up to it then recalculate, it might * For example, if lava has spread across the path, don't walk right up to it then recalculate, it might

View File

@ -236,6 +236,13 @@ public class PathExecutor implements Helper {
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
return true; return true;
} }
if (currentCost - currentMovementInitialCostEstimate > Baritone.settings().maxCostIncrease.get()) {
logDebug("Original cost " + currentMovementInitialCostEstimate + " current cost " + currentCost + ". Cancelling.");
pathPosition = path.length() + 3;
failed = true;
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
return true;
}
player().capabilities.allowFlying = false; player().capabilities.allowFlying = false;
MovementState.MovementStatus movementStatus = movement.update(); MovementState.MovementStatus movementStatus = movement.update();
if (movementStatus == UNREACHABLE || movementStatus == FAILED) { if (movementStatus == UNREACHABLE || movementStatus == FAILED) {