🔨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

View File

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