From b4d7f0516522c12bbdcb0ccc9802d0bda93772ce Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sat, 19 Sep 2020 00:31:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20two=20NPEs=20in=20estimate?= =?UTF-8?q?dTickToGoal=20apparently=20`ctx.playerFeet()`=20and=20`startPos?= =?UTF-8?q?ition`=20can=20be=20`null`=20before=20pathing=20the=20first=20t?= =?UTF-8?q?ime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/baritone/behavior/PathingBehavior.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index acda243a6..967df1b33 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -378,7 +378,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, } public Optional 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