mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-11 09:51:35 +01:00
fix pathfinding repathNode issue (#2330)
This commit is contained in:
parent
d47db68950
commit
0651c4e401
@ -35,7 +35,7 @@ public final class Navigator {
|
||||
|
||||
private double minimumDistance;
|
||||
|
||||
NodeGenerator nodeGenerator = new GroundNodeGenerator();
|
||||
NodeGenerator nodeGenerator = new GroundNodeGenerator();
|
||||
private NodeFollower nodeFollower;
|
||||
|
||||
public Navigator(@NotNull Entity entity) {
|
||||
|
@ -16,7 +16,6 @@ import java.util.concurrent.Executors;
|
||||
|
||||
public class PathGenerator {
|
||||
private static final ExecutorService pool = Executors.newWorkStealingPool();
|
||||
private static final PNode repathNode = new PNode(0, 0, 0, 0, 0, PNode.NodeType.REPATH, null);
|
||||
private static final Comparator<PNode> pNodeComparator = (s1, s2) -> (int) (((s1.g() + s1.h()) - (s2.g() + s2.h())) * 1000);
|
||||
|
||||
public static @NotNull PPath generate(@NotNull Instance instance, @NotNull Pos orgStart, @NotNull Point orgTarget, double closeDistance, double maxDistance, double pathVariance, @NotNull BoundingBox boundingBox, boolean isOnGround, @NotNull NodeGenerator generator, @Nullable Runnable onComplete) {
|
||||
@ -34,6 +33,10 @@ public class PathGenerator {
|
||||
return path;
|
||||
}
|
||||
|
||||
private static PNode buildRepathNode(PNode parent) {
|
||||
return new PNode(0, 0, 0, 0, 0, PNode.NodeType.REPATH, parent);
|
||||
}
|
||||
|
||||
private static void computePath(Instance instance, Point start, Point target, double closeDistance, double maxDistance, double pathVariance, BoundingBox boundingBox, PPath path, NodeGenerator generator) {
|
||||
double closestDistance = Double.MAX_VALUE;
|
||||
double straightDistance = generator.heuristic(start, target);
|
||||
@ -93,8 +96,7 @@ public class PathGenerator {
|
||||
current = closestFoundNodes.get(0);
|
||||
|
||||
if (!open.isEmpty()) {
|
||||
repathNode.setParent(current);
|
||||
current = repathNode;
|
||||
current = buildRepathNode(current);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user