Fix some issues with Navigator as reported by jrbudda

This commit is contained in:
fullwall 2012-09-09 18:47:25 +08:00
parent f62e536473
commit 338a853b79
4 changed files with 26 additions and 7 deletions

View File

@ -149,12 +149,17 @@ public class CitizensNavigator implements Navigator {
StuckAction action = localParams.stuckAction();
if (action != null) {
boolean shouldContinue = action.run(npc, this);
if (shouldContinue)
if (shouldContinue) {
stationaryTicks = 0;
executing.clearCancelReason();
return;
}
stationaryTicks = 0;
}
Bukkit.getPluginManager().callEvent(new NavigationCancelEvent(this, reason));
}
NavigationCancelEvent event = new NavigationCancelEvent(this, reason);
PathStrategy old = executing;
Bukkit.getPluginManager().callEvent(event);
if (old == executing)
stopNavigating();
}
@ -175,7 +180,10 @@ public class CitizensNavigator implements Navigator {
if (executing.getCancelReason() != null)
stopNavigating(executing.getCancelReason());
else {
Bukkit.getPluginManager().callEvent(new NavigationCompleteEvent(this));
NavigationCompleteEvent event = new NavigationCompleteEvent(this);
PathStrategy old = executing;
Bukkit.getPluginManager().callEvent(event);
if (old == executing)
stopNavigating();
}
}

View File

@ -59,4 +59,9 @@ public class MCNavigationStrategy implements PathStrategy {
navigation.a(parameters.speed());
return navigation.f();
}
@Override
public void clearCancelReason() {
cancelReason = null;
}
}

View File

@ -101,7 +101,11 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
return false;
}
private static final int ATTACK_DELAY_TICKS = 20;
@Override
public void clearCancelReason() {
cancelReason = null;
}
private static final int ATTACK_DELAY_TICKS = 20;
private static final double ATTACK_DISTANCE = 1.75 * 1.75;
}

View File

@ -15,4 +15,6 @@ public interface PathStrategy {
void stop();
boolean update();
void clearCancelReason();
}