mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-28 05:35:45 +01:00
Fix some issues with Navigator as reported by jrbudda
This commit is contained in:
parent
f62e536473
commit
338a853b79
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -59,4 +59,9 @@ public class MCNavigationStrategy implements PathStrategy {
|
||||
navigation.a(parameters.speed());
|
||||
return navigation.f();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCancelReason() {
|
||||
cancelReason = null;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
@ -15,4 +15,6 @@ public interface PathStrategy {
|
||||
void stop();
|
||||
|
||||
boolean update();
|
||||
|
||||
void clearCancelReason();
|
||||
}
|
Loading…
Reference in New Issue
Block a user