By opening this merge request, you agree to release your code and all other changes under the GPL 3 license and to abide by the terms set by this license.
Migrations have been added if applicable
Significant changes of this merge request have been added to the changelog.
We had an unnecessary unwrap_or_else() preceded by a question mark operator, which means that the or_else clause could never be called.
We had a random chance of restarting the route to avoid getting the chaser stuck. This didn't work properly because the rerouting code was only triggered if
self.route.is_none() or if the target moved significantly, and the random chance branch only set
None. This change sets
self.route = None to trigger rerouting.
When a chaser's route finishes calculating, the chaser may already be a few blocks away from the starting position, thanks to movement inertia. The path finding code finds the point along the route closest to the chaser's position.
This calculation only considered the xy coordinates when finding the closest point. This caused issues whenever the calculated route goes below the chaser's position (for example, when the chaser is on top of a bridge and the route circled around to go under the bridge). In this case, there was a chance that the closest point was the one below the bridge. This caused the chaser to try to move directly to a directly inaccessible block.
The fix was to remove the xy() filter so that the closest point algorithm also considered the z coordinate.