aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/pathfinder/mod.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-12-11 00:15:37 -0600
committermat <github@matdoes.dev>2022-12-11 00:15:37 -0600
commit37b9f10b3bcc74b48df2c6843a5286a7d41e2414 (patch)
tree6a995f7ad3f3309e57c276e10dc7e655dae9c5bb /azalea/src/pathfinder/mod.rs
parent2d6737b247b74e964fd734d5ab4828a3193c296f (diff)
downloadazalea-drasl-37b9f10b3bcc74b48df2c6843a5286a7d41e2414.tar.xz
make entities have a reference to WeakWorlds instead
... and other exciting bug fixes
Diffstat (limited to 'azalea/src/pathfinder/mod.rs')
-rw-r--r--azalea/src/pathfinder/mod.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index 8a9d7540..a1619c41 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -6,7 +6,7 @@ use crate::{Client, Event};
use async_trait::async_trait;
use azalea_core::{BlockPos, CardinalDirection};
use azalea_world::entity::EntityData;
-use log::debug;
+use log::{debug, error};
use mtdstarlite::Edge;
pub use mtdstarlite::MTDStarLite;
use parking_lot::Mutex;
@@ -80,7 +80,7 @@ impl Trait for azalea_client::Client {
let successors = |node: &Node| {
let mut edges = Vec::new();
- let world = self.world.read();
+ let world = &self.world.read().shared;
for possible_move in possible_moves.iter() {
edges.push(Edge {
target: possible_move.next_node(node),
@@ -111,7 +111,11 @@ impl Trait for azalea_client::Client {
.expect("Pathfinder plugin not installed!")
.clone();
// convert the Option<Vec<Node>> to a VecDeque<Node>
- *state.path.lock() = p.expect("no path").into_iter().collect();
+ if let Some(p) = p {
+ *state.path.lock() = p.into_iter().collect();
+ } else {
+ error!("no path found");
+ }
}
}