From 7a43e0e0330fa3d5644f353d5363d20a55a29660 Mon Sep 17 00:00:00 2001 From: iam4722202468 Date: Wed, 7 Feb 2024 17:15:16 -0500 Subject: [PATCH] fix once and for all --- .../minestom/server/entity/pathfinding/Navigator.java | 11 +++++------ .../net/minestom/server/entity/pathfinding/PNode.java | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/minestom/server/entity/pathfinding/Navigator.java b/src/main/java/net/minestom/server/entity/pathfinding/Navigator.java index 51145b0eb0d..39338b98e90 100644 --- a/src/main/java/net/minestom/server/entity/pathfinding/Navigator.java +++ b/src/main/java/net/minestom/server/entity/pathfinding/Navigator.java @@ -19,9 +19,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.sql.SQLOutput; import java.util.List; -import java.util.function.Consumer; // TODO all pathfinding requests could be processed in another thread @@ -238,16 +236,17 @@ public synchronized void tick() { // drawPath(path); moveTowards(currentTarget, movementSpeed, path.capabilities(), nextIsRepath ? currentTarget : nextTarget); + if (entity.getPosition().sameBlock(currentTarget)) { + path.next(); + return; + } + if ((path.getCurrentType() == PNode.NodeType.JUMP) && entity.isOnGround() && path.capabilities().canJump() ) { jump(4f); } - - if (entity.getPosition().sameBlock(currentTarget) && entity.isOnGround()) { - path.next(); - } } /** diff --git a/src/main/java/net/minestom/server/entity/pathfinding/PNode.java b/src/main/java/net/minestom/server/entity/pathfinding/PNode.java index cd99366c554..bdf61f68c6a 100644 --- a/src/main/java/net/minestom/server/entity/pathfinding/PNode.java +++ b/src/main/java/net/minestom/server/entity/pathfinding/PNode.java @@ -347,6 +347,8 @@ private PNode newNode(double cost, Pos point, Point goal) { } static Pos gravitySnap(Instance instance, Point point, BoundingBox boundingBox, double maxFall) { + point = new Pos(point.blockX() + 0.5, point.blockY(), point.blockZ() + 0.5); + Chunk c = instance.getChunkAt(point); if (c == null) return null;