add cost verification lookahead
This commit is contained in:
parent
50fd63647b
commit
6dd501a46b
@ -119,6 +119,13 @@ public class Settings {
|
||||
*/
|
||||
public Setting<Boolean> cutoffAtLoadBoundary = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* still be spreading lol
|
||||
*/
|
||||
public Setting<Integer> costVerificationLookahead = new Setting<>(5);
|
||||
|
||||
/**
|
||||
* Static cutoff factor. 0.9 means cut off the last 10% of all paths, regardless of chunk load state
|
||||
*/
|
||||
|
@ -211,6 +211,15 @@ public class PathExecutor implements Helper {
|
||||
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
||||
return true;
|
||||
}
|
||||
for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) {
|
||||
if (path.movements().get(pathPosition + 1).recalculateCost() >= ActionCosts.COST_INF) {
|
||||
displayChatMessageRaw("Something has changed in the world and a future movement has become impossible. Cancelling.");
|
||||
pathPosition = path.length() + 3;
|
||||
failed = true;
|
||||
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (costEstimateIndex == null || costEstimateIndex != pathPosition) {
|
||||
costEstimateIndex = pathPosition;
|
||||
currentMovementInitialCostEstimate = currentCost; // do this only once, when the movement starts
|
||||
|
Loading…
Reference in New Issue
Block a user