This commit is contained in:
fullwall 2024-06-18 01:58:12 +08:00
parent 6d1aad513e
commit f86b387c82

View File

@ -82,7 +82,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
CancelReason reason = planner.tick(Setting.ASTAR_ITERATIONS_PER_TICK.asInt(), CancelReason reason = planner.tick(Setting.ASTAR_ITERATIONS_PER_TICK.asInt(),
Setting.MAXIMUM_ASTAR_ITERATIONS.asInt()); Setting.MAXIMUM_ASTAR_ITERATIONS.asInt());
plan = planner.plan; plan = planner.plan;
if (reason == null || plan == null) if (reason == null && plan == null)
return false; return false;
setCancelReason(reason); setCancelReason(reason);
planner = null; planner = null;
@ -93,18 +93,18 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
vector = plan.getCurrentVector(); vector = plan.getCurrentVector();
} }
Location loc = npc.getEntity().getLocation(); Location loc = npc.getEntity().getLocation();
Location dest = Util.getCenterLocation(vector.toLocation(loc.getWorld()).getBlock());
/* 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 = loc.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();
if (door.isOpen()) { if (door.isOpen()) {
BlockFace targetFace = door.getFacing().getOppositeFace(); BlockFace targetFace = door.getFacing().getOppositeFace();
destVector.setX(vector.getX() + targetFace.getModX()); dest.setX(vector.getX() + targetFace.getModX());
destVector.setZ(vector.getZ() + targetFace.getModZ()); dest.setZ(vector.getZ() + targetFace.getModZ());
} }
}*/ }*/
Location dest = Util.getCenterLocation(vector.toLocation(loc.getWorld()).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();