Check world in navigator

This commit is contained in:
fullwall 2017-02-05 21:37:39 +08:00
parent 49c6d3cbed
commit 2c8ac01aea
2 changed files with 8 additions and 5 deletions

View File

@ -153,7 +153,8 @@ public class CitizensNavigator implements Navigator, Runnable {
updateMountedStatus();
if (!isNavigating() || !npc.isSpawned() || paused)
return;
if (Math.pow(localParams.range(), 2) < npc.getStoredLocation().distanceSquared(getTargetAsLocation())) {
if (!npc.getStoredLocation().getWorld().equals(getTargetAsLocation().getWorld())
|| Math.pow(localParams.range(), 2) < npc.getStoredLocation().distanceSquared(getTargetAsLocation())) {
stopNavigating(CancelReason.STUCK);
return;
}

View File

@ -36,9 +36,9 @@ public class Poses extends Trait {
}
private void assumePose(float yaw, float pitch) {
if (!npc.isSpawned())
if (!npc.isSpawned()) {
npc.spawn(npc.getTrait(CurrentLocation.class).getLocation());
}
Util.assumePose(npc.getEntity(), yaw, pitch);
}
@ -66,9 +66,11 @@ public class Poses extends Trait {
}
public Pose getPose(String name) {
for (Pose pose : poses.values())
if (pose.getName().equalsIgnoreCase(name))
for (Pose pose : poses.values()) {
if (pose.getName().equalsIgnoreCase(name)) {
return pose;
}
}
return null;
}