Skip to content

Commit

Permalink
Fix unstuck npe
Browse files Browse the repository at this point in the history
  • Loading branch information
someaddons committed Jan 15, 2025
1 parent 6758621 commit 8c00c39
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 8c00c39

Please sign in to comment.