mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-01 14:08:08 +01:00
Cancel navigation on despawn: Navigation isn't carried over so CitizensNavigator would be left in an inconsistent state
This commit is contained in:
parent
5f093276f1
commit
aa022f8fae
@ -103,8 +103,11 @@ public class CitizensNavigator implements Navigator, Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (!isNavigating())
|
if (!isNavigating())
|
||||||
return;
|
return;
|
||||||
if (!npc.isSpawned())
|
if (!npc.isSpawned()) {
|
||||||
|
if (isNavigating())
|
||||||
|
stopNavigating(CancelReason.NPC_DESPAWNED);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (updateStationaryStatus())
|
if (updateStationaryStatus())
|
||||||
return;
|
return;
|
||||||
updatePathfindingRange();
|
updatePathfindingRange();
|
||||||
|
@ -44,7 +44,7 @@ public class WanderWaypointProvider implements WaypointProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void onSpawn(NPC npc) {
|
public void onSpawn(NPC npc) {
|
||||||
if (currentGoal == null) {
|
if (currentGoal == null) {
|
||||||
currentGoal = WanderGoal.createWithNPC(npc);
|
currentGoal = WanderGoal.createWithNPCAndRange(npc, xrange, yrange);
|
||||||
CitizensAPI.registerEvents(currentGoal);
|
CitizensAPI.registerEvents(currentGoal);
|
||||||
}
|
}
|
||||||
npc.getDefaultGoalController().addGoal(currentGoal, 1);
|
npc.getDefaultGoalController().addGoal(currentGoal, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user