Fix inconsistency in canNavigate where flyable/living status was not respected

This commit is contained in:
fullwall 2024-04-21 23:24:28 +08:00
parent 59531a9bc8
commit 77d34b53e6

View File

@ -31,6 +31,7 @@ import net.citizensnpcs.api.ai.event.NavigationReplaceEvent;
import net.citizensnpcs.api.ai.event.NavigationStuckEvent;
import net.citizensnpcs.api.ai.event.NavigatorCallback;
import net.citizensnpcs.api.astar.pathfinder.DoorExaminer;
import net.citizensnpcs.api.astar.pathfinder.FlyingBlockExaminer;
import net.citizensnpcs.api.astar.pathfinder.MinecraftBlockExaminer;
import net.citizensnpcs.api.astar.pathfinder.SwimmingExaminer;
import net.citizensnpcs.api.npc.NPC;
@ -93,7 +94,10 @@ public class CitizensNavigator implements Navigator, Runnable {
@Override
public boolean canNavigateTo(Location dest, NavigatorParameters params) {
if (defaultParams.useNewPathfinder()) {
if (defaultParams.useNewPathfinder() || !(npc.getEntity() instanceof LivingEntity)) {
if (npc.isFlyable()) {
params.examiner(new FlyingBlockExaminer());
}
AStarPlanner planner = new AStarPlanner(params, npc.getStoredLocation(), dest);
planner.tick(Setting.MAXIMUM_ASTAR_ITERATIONS.asInt(), Setting.MAXIMUM_ASTAR_ITERATIONS.asInt());
return planner.plan != null;