From 38553b33248f0146ec18cb56bc62f3b8515ea46a Mon Sep 17 00:00:00 2001 From: Babbaj Date: Tue, 18 Jul 2023 14:52:09 -0400 Subject: [PATCH] behavior can't be null in onTick --- .../java/baritone/process/ElytraProcess.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/baritone/process/ElytraProcess.java b/src/main/java/baritone/process/ElytraProcess.java index 6738cab55..eb3c1bdd8 100644 --- a/src/main/java/baritone/process/ElytraProcess.java +++ b/src/main/java/baritone/process/ElytraProcess.java @@ -78,14 +78,13 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro @Override public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { final long seedSetting = Baritone.settings().elytraNetherSeed.value; - if (this.behavior != null && seedSetting != behavior.context.getSeed()) { + if (seedSetting != behavior.context.getSeed()) { logDirect("Nether seed changed, recalculating path"); this.resetState(); } - if (this.behavior != null) { - this.behavior.onTick(); - } + this.behavior.onTick(); + if (calcFailed) { onLostControl(); logDirect("Failed to get to jump off spot, canceling"); @@ -199,8 +198,10 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro public void onLostControl() { this.goal = null; this.state = State.START_FLYING; // TODO: null state? - if (this.behavior != null) this.behavior.destroy(); - this.behavior = null; + if (this.behavior != null) { + this.behavior.destroy(); + this.behavior = null; + } } @Override @@ -210,7 +211,9 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro @Override public void repackChunks() { - this.behavior.repackChunks(); + if (this.behavior != null) { + this.behavior.repackChunks(); + } } @Override @@ -260,12 +263,10 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro @Override public void onWorldEvent(WorldEvent event) { - if (event.getWorld() != null && event.getState() == EventState.POST) { + if (event.getWorld() != null && event.getState() == EventState.POST && this.behavior != null) { // Exiting the world, just destroy - if (this.behavior != null) { - this.behavior.destroy(); - this.behavior = new LegacyElytraBehavior(baritone, this); - } + this.behavior.destroy(); + this.behavior = new LegacyElytraBehavior(baritone, this); } }