@@ -70,22 +70,12 @@ class Path extends PathBase {
7070 private volatile boolean verified ;
7171
7272 Path (BetterBlockPos realStart , PathNode start , PathNode end , int numNodes , Goal goal , CalculationContext context ) {
73- this .start = realStart ;
7473 this .end = new BetterBlockPos (end .x , end .y , end .z );
7574 this .numNodes = numNodes ;
7675 this .movements = new ArrayList <>();
7776 this .goal = goal ;
7877 this .context = context ;
7978
80- // If the position the player is at is different from the position we told A* to start from
81- // see PathingBehavior#createPathfinder and https://github.com/cabaletta/baritone/pull/4519
82- var startNodePos = new BetterBlockPos (start .x , start .y , start .z );
83- if (!realStart .equals (startNodePos )) {
84- PathNode fakeNode = new PathNode (realStart .x , realStart .y , realStart .z , goal );
85- fakeNode .cost = 0 ;
86- start .previous = fakeNode ;
87- }
88-
8979 PathNode current = end ;
9080 List <BetterBlockPos > tempPath = new ArrayList <>();
9181 List <PathNode > tempNodes = new ArrayList <>();
@@ -94,6 +84,22 @@ class Path extends PathBase {
9484 tempPath .add (new BetterBlockPos (current .x , current .y , current .z ));
9585 current = current .previous ;
9686 }
87+
88+ // If the position the player is at is different from the position we told A* to start from,
89+ // and A* gave us no movements, then add a fake node that will allow a movement to be created
90+ // that gets us to the single position in the path.
91+ // See PathingBehavior#createPathfinder and https://github.com/cabaletta/baritone/pull/4519
92+ var startNodePos = new BetterBlockPos (start .x , start .y , start .z );
93+ if (!realStart .equals (startNodePos ) && start .equals (end )) {
94+ this .start = realStart ;
95+ PathNode fakeNode = new PathNode (realStart .x , realStart .y , realStart .z , goal );
96+ fakeNode .cost = 0 ;
97+ tempNodes .add (fakeNode );
98+ tempPath .add (realStart );
99+ } else {
100+ this .start = startNodePos ;
101+ }
102+
97103 // Nodes are traversed last to first so we need to reverse the list
98104 this .path = Lists .reverse (tempPath );
99105 this .nodes = Lists .reverse (tempNodes );
0 commit comments