mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-26 11:07:59 +01:00
Make NavigatorParameters#run run consistently
This commit is contained in:
parent
676590f5fe
commit
5bf9fdc6c9
@ -136,7 +136,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
}
|
||||
Location loc = npc.getEntity().getLocation(NPC_LOCATION);
|
||||
/* 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();
|
||||
@ -176,7 +176,6 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
npc.getEntity().setVelocity(dir);
|
||||
Util.faceLocation(npc.getEntity(), dest);
|
||||
}
|
||||
params.run();
|
||||
plan.run(npc);
|
||||
return false;
|
||||
}
|
||||
|
@ -161,8 +161,8 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
if (!isNavigating() || !npc.isSpawned() || isPaused())
|
||||
return;
|
||||
Location npcLoc = npc.getStoredLocation();
|
||||
if (!npcLoc.getWorld().equals(getTargetAsLocation().getWorld())
|
||||
|| Math.pow(localParams.range(), 2) < npc.getStoredLocation().distanceSquared(getTargetAsLocation())) {
|
||||
Location targetLoc = getTargetAsLocation();
|
||||
if (!npcLoc.getWorld().equals(targetLoc.getWorld()) || localParams.range() < npcLoc.distance(targetLoc)) {
|
||||
stopNavigating(CancelReason.STUCK);
|
||||
return;
|
||||
}
|
||||
@ -170,6 +170,9 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
return;
|
||||
updatePathfindingRange();
|
||||
boolean finished = executing.update();
|
||||
if (!finished) {
|
||||
localParams.run();
|
||||
}
|
||||
if (localParams.lookAtFunction() != null) {
|
||||
Util.faceLocation(npc.getEntity(), localParams.lookAtFunction().apply(this), true, true);
|
||||
Entity entity = npc.getEntity().getPassenger();
|
||||
@ -182,9 +185,9 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
}
|
||||
}
|
||||
if (localParams.destinationTeleportMargin() > 0
|
||||
&& npcLoc.distance(getTargetAsLocation()) < localParams.destinationTeleportMargin()) {
|
||||
&& npcLoc.distance(targetLoc) < localParams.destinationTeleportMargin()) {
|
||||
// TODO: easing?
|
||||
npc.teleport(getTargetAsLocation(), TeleportCause.PLUGIN);
|
||||
npc.teleport(targetLoc, TeleportCause.PLUGIN);
|
||||
finished = true;
|
||||
}
|
||||
if (!finished) {
|
||||
|
@ -181,7 +181,6 @@ public class FlyingAStarNavigationStrategy extends AbstractPathStrategy {
|
||||
NMS.setVerticalMovement(npc.getEntity(), 0.5);
|
||||
Util.faceLocation(npc.getEntity(), centeredDest.toLocation(npc.getEntity().getWorld()));
|
||||
}
|
||||
parameters.run();
|
||||
plan.run(npc);
|
||||
return false;
|
||||
}
|
||||
|
@ -76,7 +76,6 @@ public class MCNavigationStrategy extends AbstractPathStrategy {
|
||||
if (getCancelReason() != null)
|
||||
return true;
|
||||
boolean wasFinished = navigator.update();
|
||||
parameters.run();
|
||||
Location loc = handle.getLocation(HANDLE_LOCATION);
|
||||
double dX = target.getX() - loc.getX();
|
||||
double dZ = target.getZ() - loc.getZ();
|
||||
|
@ -120,7 +120,6 @@ public class StraightLineNavigationStrategy extends AbstractPathStrategy {
|
||||
Util.faceLocation(npc.getEntity(), destLoc);
|
||||
npc.getEntity().setVelocity(dir);
|
||||
}
|
||||
params.run();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user