Skip to content

Commit

Permalink
Also make guided waypoints reset when chagned
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Feb 20, 2022
1 parent b56a1f8 commit 65c7e7c
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -243,6 +243,9 @@ private void rebuildTree() {
tree.put(new long[] { waypoint.getLocation().getBlockX(), waypoint.getLocation().getBlockY(),
waypoint.getLocation().getBlockZ() }, waypoint);
}
if (currentGoal != null) {
currentGoal.onProviderChanged();
}
}

@Override
Expand All @@ -262,6 +265,9 @@ public void save(DataKey key) {
@Override
public void setPaused(boolean paused) {
this.paused = paused;
if (currentGoal != null) {
currentGoal.onProviderChanged();
}
}

/**
Expand All @@ -275,6 +281,15 @@ public Iterable<Waypoint> waypoints() {
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;
Expand Down

0 comments on commit 65c7e7c

Please sign in to comment.