mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-11 09:51:34 +01:00
Fix stationary ticks
This commit is contained in:
parent
7377093c6a
commit
fcf8bf1f88
@ -133,12 +133,14 @@ public class CitizensNavigator implements Navigator {
|
|||||||
executing.stop();
|
executing.stop();
|
||||||
executing = null;
|
executing = null;
|
||||||
localParams = defaultParams;
|
localParams = defaultParams;
|
||||||
|
stationaryTicks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchStrategyTo(PathStrategy newStrategy) {
|
private void switchStrategyTo(PathStrategy newStrategy) {
|
||||||
if (executing != null)
|
if (executing != null)
|
||||||
Bukkit.getPluginManager().callEvent(new NavigationReplaceEvent(this));
|
Bukkit.getPluginManager().callEvent(new NavigationReplaceEvent(this));
|
||||||
executing = newStrategy;
|
executing = newStrategy;
|
||||||
|
stationaryTicks = 0;
|
||||||
Bukkit.getPluginManager().callEvent(new NavigationBeginEvent(this));
|
Bukkit.getPluginManager().callEvent(new NavigationBeginEvent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,16 +163,19 @@ public class CitizensNavigator implements Navigator {
|
|||||||
return false;
|
return false;
|
||||||
EntityLiving handle = npc.getHandle();
|
EntityLiving handle = npc.getHandle();
|
||||||
if ((int) handle.lastX == (int) handle.locX && (int) handle.lastY == (int) handle.locY
|
if ((int) handle.lastX == (int) handle.locX && (int) handle.lastY == (int) handle.locY
|
||||||
&& (int) handle.lastZ == (int) handle.locZ
|
&& (int) handle.lastZ == (int) handle.locZ) {
|
||||||
&& ++stationaryTicks >= localParams.stationaryTicks()) {
|
if (++stationaryTicks >= localParams.stationaryTicks()) {
|
||||||
StuckAction action = localParams.stuckAction();
|
StuckAction action = localParams.stuckAction();
|
||||||
if (action != null)
|
if (action != null)
|
||||||
action.run(npc, this);
|
action.run(npc, this);
|
||||||
Bukkit.getPluginManager().callEvent(new NavigationCancelEvent(this, CancelReason.STUCK));
|
Bukkit.getPluginManager().callEvent(new NavigationCancelEvent(this, CancelReason.STUCK));
|
||||||
stopNavigating();
|
stopNavigating();
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
stationaryTicks = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static int UNINITIALISED_SPEED = Integer.MIN_VALUE;
|
private static int UNINITIALISED_SPEED = Integer.MIN_VALUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user