@@ -70,22 +70,12 @@ class Path extends PathBase {
70
70
private volatile boolean verified ;
71
71
72
72
Path (BetterBlockPos realStart , PathNode start , PathNode end , int numNodes , Goal goal , CalculationContext context ) {
73
- this .start = realStart ;
74
73
this .end = new BetterBlockPos (end .x , end .y , end .z );
75
74
this .numNodes = numNodes ;
76
75
this .movements = new ArrayList <>();
77
76
this .goal = goal ;
78
77
this .context = context ;
79
78
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
-
89
79
PathNode current = end ;
90
80
List <BetterBlockPos > tempPath = new ArrayList <>();
91
81
List <PathNode > tempNodes = new ArrayList <>();
@@ -94,6 +84,22 @@ class Path extends PathBase {
94
84
tempPath .add (new BetterBlockPos (current .x , current .y , current .z ));
95
85
current = current .previous ;
96
86
}
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
+
97
103
// Nodes are traversed last to first so we need to reverse the list
98
104
this .path = Lists .reverse (tempPath );
99
105
this .nodes = Lists .reverse (tempNodes );
0 commit comments