🔨move ETA reset to it's own function

This commit is contained in:
ZacSharp 2020-09-18 23:16:56 +02:00
parent 7255ccbdaa
commit 411b2a0acc
No known key found for this signature in database
GPG Key ID: 9453647B005083A3
1 changed files with 14 additions and 2 deletions

View File

@ -391,6 +391,19 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
return Optional.of(eta);
}
private void resetEstimatedTicksToGoal() {
resetEstimatedTicksToGoal(expectedSegmentStart);
}
private void resetEstimatedTicksToGoal(BlockPos start) {
resetEstimatedTicksToGoal(new BetterBlockPos(start));
}
private void resetEstimatedTicksToGoal(BetterBlockPos start) {
ticksElapsedSoFar = 0;
startPosition = start;
}
/**
* See issue #209
*
@ -487,8 +500,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
if (executor.get().getPath().positions().contains(expectedSegmentStart)) {
queuePathEvent(PathEvent.CALC_FINISHED_NOW_EXECUTING);
current = executor.get();
ticksElapsedSoFar = 0;
startPosition = expectedSegmentStart;
resetEstimatedTicksToGoal(start);
} else {
logDebug("Warning: discarding orphan path segment with incorrect start");
}