Cancel navigation on despawn: Navigation isn't carried over so CitizensNavigator would be left in an inconsistent state

This commit is contained in:
fullwall 2013-03-14 23:29:41 +08:00
parent fb32f68856
commit 14ad344f4b
2 changed files with 5 additions and 2 deletions

View File

@ -103,8 +103,11 @@ public class CitizensNavigator implements Navigator, Runnable {
public void run() {
if (!isNavigating())
return;
if (!npc.isSpawned())
if (!npc.isSpawned()) {
if (isNavigating())
stopNavigating(CancelReason.NPC_DESPAWNED);
return;
}
if (updateStationaryStatus())
return;
updatePathfindingRange();

View File

@ -44,7 +44,7 @@ public class WanderWaypointProvider implements WaypointProvider {
@Override
public void onSpawn(NPC npc) {
if (currentGoal == null) {
currentGoal = WanderGoal.createWithNPC(npc);
currentGoal = WanderGoal.createWithNPCAndRange(npc, xrange, yrange);
CitizensAPI.registerEvents(currentGoal);
}
npc.getDefaultGoalController().addGoal(currentGoal, 1);