From b77d030f718d6a681a09e36d620f1c596cf58a4e Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 4 Oct 2025 16:38:55 -1345 Subject: fix wrong pathfinding when we start calculating a new path and the current executing path is long --- azalea/src/pathfinder/mod.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'azalea') diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index 54fd7a59..d6a16f69 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -285,7 +285,7 @@ pub fn goto_listener( mut events: MessageReader, mut query: Query<( &mut Pathfinder, - Option<&ExecutingPath>, + Option<&mut ExecutingPath>, &Position, &InstanceName, &Inventory, @@ -317,14 +317,19 @@ pub fn goto_listener( pathfinder.opts = Some(event.opts.clone()); pathfinder.is_calculating = true; - let start = if let Some(executing_path) = executing_path - && let Some(final_node) = executing_path.path.back() + let start = if let Some(mut executing_path) = executing_path + && { !executing_path.path.is_empty() } { // if we're currently pathfinding and got a goto event, start a little ahead + + let executing_path_limit = 50; + // truncate the executing path so we can cleanly combine the two paths later + executing_path.path.truncate(executing_path_limit); + executing_path .path - .get(50) - .unwrap_or(final_node) + .back() + .expect("path was just checked to not be empty") .movement .target } else { @@ -1220,7 +1225,7 @@ where // if the node that we're currently executing was obstructed then it's often too // late to change the path, so it's usually better to just ignore this case :/ if i == 0 { - warn!("path obstructed at index 0, ignoring"); + warn!("path obstructed at index 0 ({edge:?}), ignoring"); continue; } -- cgit v1.2.3