From 65c7e7c28cdd5b9785dbe1bedf0a8b57a46e5a67 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sun, 20 Feb 2022 11:19:05 +0800 Subject: [PATCH] Also make guided waypoints reset when chagned --- .../trait/waypoint/GuidedWaypointProvider.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/GuidedWaypointProvider.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/GuidedWaypointProvider.java index 336e9f1cc..5b0812844 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/GuidedWaypointProvider.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/GuidedWaypointProvider.java @@ -243,6 +243,9 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider { tree.put(new long[] { waypoint.getLocation().getBlockX(), waypoint.getLocation().getBlockY(), waypoint.getLocation().getBlockZ() }, waypoint); } + if (currentGoal != null) { + currentGoal.onProviderChanged(); + } } @Override @@ -262,6 +265,9 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider { @Override public void setPaused(boolean paused) { this.paused = paused; + if (currentGoal != null) { + currentGoal.onProviderChanged(); + } } /** @@ -275,6 +281,15 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider { private class GuidedAIGoal implements Goal { private GuidedPlan plan; + public void onProviderChanged() { + if (plan != null) { + reset(); + if (npc.getNavigator().isNavigating()) { + npc.getNavigator().cancelNavigation(); + } + } + } + @Override public void reset() { plan = null;