From 4b442e064a36d1c1a621d808e3644771350f464d Mon Sep 17 00:00:00 2001 From: someaddons <38401808+someaddons@users.noreply.github.com> Date: Wed, 15 Jan 2025 18:19:22 +0100 Subject: [PATCH] Fix unstuck npe (#10597) --- .../entity/pathfinding/navigation/PathingStuckHandler.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/PathingStuckHandler.java b/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/PathingStuckHandler.java index 00244a91bcf..001bd1ec06a 100644 --- a/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/PathingStuckHandler.java +++ b/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/PathingStuckHandler.java @@ -527,7 +527,9 @@ private void placeLeaves(final NAV navigator) final Level world = navigator.getOurEntity().level(); final Mob entity = navigator.getOurEntity(); - final Direction badFacing = BlockPosUtil.getFacing(BlockPos.containing(entity.position()), navigator.getSafeDestination()).getOpposite(); + final Direction badFacing = navigator.getSafeDestination() == null + ? entity.getDirection().getOpposite() + : BlockPosUtil.getFacing(BlockPos.containing(entity.position()), navigator.getSafeDestination()).getOpposite(); for (final Direction dir : HORIZONTAL_DIRS) { @@ -573,7 +575,8 @@ private void breakBlocks(final NAV navigator) final Level world = navigator.getOurEntity().level(); final Mob entity = navigator.getOurEntity(); - final Direction facing = BlockPosUtil.getFacing(BlockPos.containing(entity.position()), navigator.getSafeDestination()); + final Direction facing = + navigator.getSafeDestination() == null ? entity.getDirection() : BlockPosUtil.getFacing(BlockPos.containing(entity.position()), navigator.getSafeDestination()); if (breakBlocksAhead(world, entity.blockPosition(), facing) && entity.getHealth() >= entity.getMaxHealth() / 3) {