From cabdb60370178d6d298a1159f69cb8918660010b Mon Sep 17 00:00:00 2001 From: Felix Cravic Date: Sun, 29 Nov 2020 17:27:24 +0100 Subject: [PATCH] Fix pathfinding NPE --- .../java/net/minestom/server/entity/EntityCreature.java | 4 +++- .../server/entity/pathfinding/PFPathingEntity.java | 9 +++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/minestom/server/entity/EntityCreature.java b/src/main/java/net/minestom/server/entity/EntityCreature.java index 7f7770a18..567ddb0e2 100644 --- a/src/main/java/net/minestom/server/entity/EntityCreature.java +++ b/src/main/java/net/minestom/server/entity/EntityCreature.java @@ -137,7 +137,9 @@ public abstract class EntityCreature extends LivingEntity { if (path != null) { final float speed = getAttributeValue(Attributes.MOVEMENT_SPEED); final Position targetPosition = pathingEntity.getTargetPosition(); - moveTowards(targetPosition, speed); + if (targetPosition != null) { + moveTowards(targetPosition, speed); + } } else { if (pathPosition != null) { this.pathPosition = null; diff --git a/src/main/java/net/minestom/server/entity/pathfinding/PFPathingEntity.java b/src/main/java/net/minestom/server/entity/pathfinding/PFPathingEntity.java index cd5923203..4ffa8b9e2 100644 --- a/src/main/java/net/minestom/server/entity/pathfinding/PFPathingEntity.java +++ b/src/main/java/net/minestom/server/entity/pathfinding/PFPathingEntity.java @@ -188,12 +188,9 @@ public class PFPathingEntity implements IPathingEntity { final float z = (float) position.z; this.targetPosition = new Position(x, y, z); - // Jump for non-flying entities - if (!avian) { - final float entityY = entity.getPosition().getY(); - if (entityY < y) { - entity.jump(1); - } + final float entityY = entity.getPosition().getY(); + if (entityY < y) { + entity.jump(1); } }