Skip to content

Commit

Permalink
Reached and prevent too long underwaterpathing
Browse files Browse the repository at this point in the history
  • Loading branch information
Raycoms committed Aug 21, 2024
1 parent 223e9ca commit 954fa56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,11 @@ protected void followThePath()
boolean isTracking = PathfindingUtils.trackingMap.containsValue(ourEntity.getUUID());

HashSet<BlockPos> reached = null;
if (isTracking)
{
reached = new HashSet<>();
}

// Look at multiple points, incase we're too fast
for (int i = this.path.getNextNodeIndex(); i < Math.min(this.path.getNodeCount(), this.path.getNextNodeIndex() + 4); i++)
{
Expand All @@ -979,17 +984,13 @@ protected void followThePath()

if (isTracking)
{
if (reached == null)
{
reached = new HashSet<>();
}
final Node point = path.getNode(i);
reached.add(new BlockPos(point.x, point.y, point.z));
}
}
}

if (isTracking && reached != null)
if (isTracking)
{
PathfindingUtils.syncDebugReachedPositions(reached, ourEntity);
reached.clear();
Expand Down Expand Up @@ -1033,7 +1034,7 @@ else if (isTracking)
}
}

if (isTracking && reached != null)
if (isTracking)
{
PathfindingUtils.syncDebugReachedPositions(reached, ourEntity);
reached.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected Path search()
@Override
protected double computeHeuristic(final int x, final int y, final int z)
{
return BlockPosUtil.dist(preferredDirection, x, y, z) * 2;
return BlockPosUtil.dist(preferredDirection, x, y, z) * 2 / (y / 10.0);
}

/**
Expand Down

0 comments on commit 954fa56

Please sign in to comment.