🐛 fix two NPEs in estimatedTickToGoal

apparently `ctx.playerFeet()` and `startPosition` can be `null` before pathing the first time
This commit is contained in:
ZacSharp 2020-09-19 00:31:58 +02:00
parent 46a12754e9
commit b4d7f05165
No known key found for this signature in database
GPG Key ID: 9453647B005083A3
1 changed files with 2 additions and 2 deletions

View File

@ -378,7 +378,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
}
public Optional<Double> estimatedTicksToGoal() {
if (goal == null) {
BetterBlockPos currentPos = ctx.playerFeet();
if (goal == null || currentPos == null || startPosition == null) {
return Optional.empty();
}
if (goal.isInGoal(ctx.playerFeet())) {
@ -388,7 +389,6 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
if (ticksElapsedSoFar == 0) {
return Optional.empty();
}
BetterBlockPos currentPos = ctx.playerFeet();
double current = goal.heuristic(currentPos.x, currentPos.y, currentPos.z);
double start = goal.heuristic(startPosition.x, startPosition.y, startPosition.z);
if (current == start) {//can't check above because current and start can be equal even if currentPos and startPosition are not