Skip to content

Commit

Permalink
Prevent entities from pathfinding too far (ldtteam#9629)
Browse files Browse the repository at this point in the history
Prevent entities from pathfinding too far
  • Loading branch information
someaddons authored Dec 18, 2023
1 parent b6987ad commit 49966e0
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ public PathResult<AbstractPathJob> moveToXYZ(final double x, final double y, fin
@NotNull final BlockPos start = AbstractPathJob.prepareStart(ourEntity);
desiredPos = new BlockPos(newX, newY, newZ);

if (start.distSqr(desiredPos) > 500 * 500)
{
Log.getLogger()
.error(
"Entity: " + ourEntity.getDisplayName().getString() + " is trying to walk too far! distance:" + Math.sqrt(start.distSqr(desiredPos)) + " from:" + start + " to:"
+ desiredPos, new Exception());
return null;
}

return setPathJob(
new PathJobMoveToLocation(CompatibilityUtils.getWorldFromEntity(ourEntity),
start,
Expand Down

0 comments on commit 49966e0

Please sign in to comment.