mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 03:55:30 +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,19 +78,14 @@ 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) {
|
||||
planner = null;
|
||||
}
|
||||
if (reason == null || plan == null)
|
||||
return false;
|
||||
setCancelReason(reason);
|
||||
planner = null;
|
||||
}
|
||||
if (getCancelReason() != null || plan == null || plan.isComplete())
|
||||
return true;
|
||||
@ -98,7 +94,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
}
|
||||
Location loc = npc.getEntity().getLocation();
|
||||
/* Proper door movement - gets stuck on corners at times
|
||||
|
||||
|
||||
Block block = currLoc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
if (MinecraftBlockExaminer.isDoor(block.getType())) {
|
||||
Door door = (Door) block.getState().getData();
|
||||
|
Loading…
Reference in New Issue
Block a user