mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-28 21:55:29 +01:00
Ensure new pathfinder iterates for the max iterations per tick
This commit is contained in:
parent
5e9f04f141
commit
6d1aad513e
@ -50,6 +50,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
this.params = params;
|
||||
destination = dest;
|
||||
this.npc = npc;
|
||||
planner = new AStarPlanner(params, npc.getEntity().getLocation(), destination);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,20 +78,15 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
if (plan == null) {
|
||||
if (planner == null) {
|
||||
planner = new AStarPlanner(params, npc.getEntity().getLocation(), destination);
|
||||
}
|
||||
if (planner != null) {
|
||||
CancelReason reason = planner.tick(Setting.ASTAR_ITERATIONS_PER_TICK.asInt(),
|
||||
Setting.MAXIMUM_ASTAR_ITERATIONS.asInt());
|
||||
if (reason != null) {
|
||||
setCancelReason(reason);
|
||||
}
|
||||
plan = planner.plan;
|
||||
if (plan != null) {
|
||||
if (reason == null || plan == null)
|
||||
return false;
|
||||
setCancelReason(reason);
|
||||
planner = null;
|
||||
}
|
||||
}
|
||||
if (getCancelReason() != null || plan == null || plan.isComplete())
|
||||
return true;
|
||||
if (vector == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user