Skip to content

Commit

Permalink
fix path reaching value (#9840)
Browse files Browse the repository at this point in the history
Fix the finalized path not getting the correct reached flag, as the result returns it only when its processed
  • Loading branch information
someaddons authored Mar 14, 2024
1 parent 34155ca commit 8db2a17
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public abstract class AbstractPathJob implements Callable<Path>, IPathJob
*/
private PathingOptions pathingOptions = new PathingOptions();

/**
* Whether the path reached its destination
*/
private boolean reachesDestination = false;

/**
* AbstractPathJob constructor.
*
Expand Down Expand Up @@ -262,8 +267,6 @@ protected Path search()
// breakpoint at which we start scoring potential ending points
final double heuristicCutoff = bestNode.getHeuristic() > 0 ? bestNode.getHeuristic() / 3 : 200;

boolean isAtDestination = false;

while (!nodesToVisit.isEmpty())
{
if (Thread.currentThread().isInterrupted())
Expand All @@ -281,7 +284,7 @@ protected Path search()
break;
}

if (isAtDestination && extraNodes > 0)
if (reachesDestination && extraNodes > 0)
{
extraNodes--;
if (extraNodes == 0)
Expand All @@ -293,9 +296,9 @@ protected Path search()
handleDebugOptions(node);
node.setVisited();

if (!isAtDestination && isAtDestination(node))
if (!reachesDestination && isAtDestination(node))
{
isAtDestination = true;
reachesDestination = true;
bestNode = node;
bestNodeEndScore = getEndNodeScore(node);
result.setPathReachesDestination(true);
Expand All @@ -318,7 +321,7 @@ protected Path search()
final double nodeEndSCore = getEndNodeScore(node);
if (nodeEndSCore < bestNodeEndScore)
{
if (!isAtDestination || isAtDestination(node))
if (!reachesDestination || isAtDestination(node))
{
bestNode = node;
bestNodeEndScore = nodeEndSCore;
Expand Down Expand Up @@ -804,7 +807,7 @@ else if (p.isOnRails() && points.length > pathLength + 1)

doDebugPrinting(points);

return new Path(Arrays.asList(points), new BlockPos(targetNode.x, targetNode.y, targetNode.z), result.isPathReachingDestination());
return new Path(Arrays.asList(points), new BlockPos(targetNode.x, targetNode.y, targetNode.z), reachesDestination);
}

/**
Expand Down

0 comments on commit 8db2a17

Please # to comment.