1
0
mirror of https://github.com/cabaletta/baritone synced 2024-12-24 16:02:38 +00:00

fix cost cache overwrite in path executor

This commit is contained in:
Leijurv 2018-09-02 14:12:33 -07:00
parent c63ccc3dcb
commit f75188b24d
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 7 additions and 2 deletions

View File

@ -100,6 +100,10 @@ public abstract class Movement implements Helper, MovementHelper {
return getCost(null);
}
public double calculateCostWithoutCaching() {
return calculateCost0(new CalculationContext());
}
/**
* Handles the execution of the latest Movement
* State, and offers a Status to the calling class.

View File

@ -219,9 +219,10 @@ public class PathExecutor implements Helper {
Movement movement = path.movements().get(pathPosition);
if (costEstimateIndex == null || costEstimateIndex != pathPosition) {
costEstimateIndex = pathPosition;
currentMovementInitialCostEstimate = movement.getCost(null); // do this only once, when the movement starts
// do this only once, when the movement starts, and deliberately get the cost as cached when this path was calculated, not the cost as it is right now
currentMovementInitialCostEstimate = movement.getCost(null);
for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) {
if (path.movements().get(pathPosition + i).recalculateCost() >= ActionCosts.COST_INF) {
if (path.movements().get(pathPosition + i).calculateCostWithoutCaching() >= ActionCosts.COST_INF) {
displayChatMessageRaw("Something has changed in the world and a future movement has become impossible. Cancelling.");
pathPosition = path.length() + 3;
failed = true;