Add null checks

This commit is contained in:
fullwall 2022-02-21 17:36:57 +08:00
parent 897c511757
commit 89e06a3e67
2 changed files with 6 additions and 3 deletions

View File

@ -151,8 +151,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
destVector.setZ(vector.getZ() + targetFace.getModZ());
}
}*/
Location dest = Util.getCenterLocation(
new Location(loc.getWorld(), vector.getX(), vector.getY(), vector.getZ()).getBlock());
Location dest = Util.getCenterLocation(vector.toLocation(loc.getWorld()).getBlock());
double dX = dest.getX() - loc.getX();
double dZ = dest.getZ() - loc.getZ();
double dY = dest.getY() - loc.getY();

View File

@ -154,6 +154,8 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
@Override
public Location getCurrentDestination() {
if (strategy == null)
return null;
return strategy.getCurrentDestination();
}
@ -221,6 +223,8 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
@Override
public Location getCurrentDestination() {
if (active == null)
return null;
return active.getCurrentDestination();
}