fix cost cache overwrite in path executor
This commit is contained in:
parent
c63ccc3dcb
commit
f75188b24d
@ -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.
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user