Skip to content

Commit f8c36ab

Browse files
committed
Fix player.pathTo for moving paths
1 parent 8834b7c commit f8c36ab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/net/earthcomputer/clientcommands/script/ScriptPlayer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ public void onBlockChange(BlockPos pos, BlockState oldState, BlockState newState
255255
return false;
256256
path[0].setCurrentNodeIndex(path[0].getCurrentNodeIndex() + 1);
257257
if (movingTarget || needsRecalc[0]) {
258-
BlockPos lastTargetPos = target.get();
259-
targetPos[0] = target.get();
260-
if (!lastTargetPos.equals(targetPos[0]) || needsRecalc[0]) {
258+
BlockPos newTargetPos = target.get();
259+
if (!newTargetPos.equals(targetPos[0]) || needsRecalc[0]) {
260+
targetPos[0] = newTargetPos;
261261
needsRecalc[0] = false;
262262
path[0] = PlayerPathfinder.findPathToAny(ImmutableSet.of(targetPos[0]), javaHints);
263263
}
@@ -267,7 +267,7 @@ public void onBlockChange(BlockPos pos, BlockState oldState, BlockState newState
267267
IBlockChangeListener.LISTENERS.remove(blockChangeListener);
268268
}
269269

270-
return path[0] != null;
270+
return path[0] != null && path[0].getEnd() != null && path[0].getEnd().getPos().equals(targetPos[0]);
271271
}
272272

273273
public void setYaw(float yaw) {

0 commit comments

Comments
 (0)