mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-26 11:07:59 +01:00
Add null checks
This commit is contained in:
parent
897c511757
commit
89e06a3e67
@ -141,7 +141,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
}
|
}
|
||||||
Location loc = npc.getEntity().getLocation(NPC_LOCATION);
|
Location loc = npc.getEntity().getLocation(NPC_LOCATION);
|
||||||
/* Proper door movement - gets stuck on corners at times
|
/* Proper door movement - gets stuck on corners at times
|
||||||
|
|
||||||
Block block = currLoc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
Block block = currLoc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||||
if (MinecraftBlockExaminer.isDoor(block.getType())) {
|
if (MinecraftBlockExaminer.isDoor(block.getType())) {
|
||||||
Door door = (Door) block.getState().getData();
|
Door door = (Door) block.getState().getData();
|
||||||
@ -151,8 +151,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
destVector.setZ(vector.getZ() + targetFace.getModZ());
|
destVector.setZ(vector.getZ() + targetFace.getModZ());
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
Location dest = Util.getCenterLocation(
|
Location dest = Util.getCenterLocation(vector.toLocation(loc.getWorld()).getBlock());
|
||||||
new Location(loc.getWorld(), vector.getX(), vector.getY(), vector.getZ()).getBlock());
|
|
||||||
double dX = dest.getX() - loc.getX();
|
double dX = dest.getX() - loc.getX();
|
||||||
double dZ = dest.getZ() - loc.getZ();
|
double dZ = dest.getZ() - loc.getZ();
|
||||||
double dY = dest.getY() - loc.getY();
|
double dY = dest.getY() - loc.getY();
|
||||||
|
@ -154,6 +154,8 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getCurrentDestination() {
|
public Location getCurrentDestination() {
|
||||||
|
if (strategy == null)
|
||||||
|
return null;
|
||||||
return strategy.getCurrentDestination();
|
return strategy.getCurrentDestination();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,6 +223,8 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getCurrentDestination() {
|
public Location getCurrentDestination() {
|
||||||
|
if (active == null)
|
||||||
|
return null;
|
||||||
return active.getCurrentDestination();
|
return active.getCurrentDestination();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user