aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/pathfinder
diff options
context:
space:
mode:
Diffstat (limited to 'azalea/src/pathfinder')
-rw-r--r--azalea/src/pathfinder/astar.rs7
-rw-r--r--azalea/src/pathfinder/goto_event.rs6
-rw-r--r--azalea/src/pathfinder/mod.rs14
-rw-r--r--azalea/src/pathfinder/moves/mod.rs5
-rw-r--r--azalea/src/pathfinder/world.rs21
5 files changed, 33 insertions, 20 deletions
diff --git a/azalea/src/pathfinder/astar.rs b/azalea/src/pathfinder/astar.rs
index b2559c1f..d2a57b38 100644
--- a/azalea/src/pathfinder/astar.rs
+++ b/azalea/src/pathfinder/astar.rs
@@ -312,9 +312,10 @@ impl PartialOrd for WeightedNode {
/// [`PathfinderOpts::max_timeout`]: super::goto_event::PathfinderOpts::max_timeout
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum PathfinderTimeout {
- /// Time out after a certain duration has passed. This is a good default so
- /// you don't waste too much time calculating a path if you're on a slow
- /// computer.
+ /// Time out after a certain duration has passed.
+ ///
+ /// This is a good default so you don't waste too much time calculating a
+ /// path if you're on a slow computer.
Time(Duration),
/// Time out after this many nodes have been considered.
///
diff --git a/azalea/src/pathfinder/goto_event.rs b/azalea/src/pathfinder/goto_event.rs
index 379c61d0..e4f934f2 100644
--- a/azalea/src/pathfinder/goto_event.rs
+++ b/azalea/src/pathfinder/goto_event.rs
@@ -106,8 +106,10 @@ impl PathfinderOpts {
self
}
/// The absolute maximum amount of time that the pathfinder function can
- /// take to find a path. If it takes this long, it means no usable path was
- /// found (so it might be impossible).
+ /// take to find a path.
+ ///
+ /// If it takes this long, it means no usable path was found (so it might be
+ /// impossible).
///
/// Defaults to `PathfinderTimeout::Time(Duration::from_secs(5))`.
pub fn max_timeout(mut self, max_timeout: PathfinderTimeout) -> Self {
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index 6d78b043..c001f838 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -917,7 +917,7 @@ pub fn check_for_path_obstruction(
}
}
-/// update the given [`ExecutingPath`] to recalculate the path of the nodes in
+/// Update the given [`ExecutingPath`] to recalculate the path of the nodes in
/// the given index range.
///
/// You should avoid making the range too large, since the timeout for the A*
@@ -1153,9 +1153,11 @@ pub fn recalculate_if_has_goal_but_no_path(
#[derive(Message)]
pub struct StopPathfindingEvent {
pub entity: Entity,
- /// If false, then let the current movement finish before stopping. If true,
- /// then stop moving immediately. This might cause the bot to fall if it was
- /// in the middle of parkouring.
+ /// Whether we should stop moving immediately without waiting for the
+ /// current movement to finish.
+ ///
+ /// This is usually set to false, since it might cause the bot to fall if it
+ /// was in the middle of parkouring.
pub force: bool,
}
@@ -1210,7 +1212,9 @@ pub fn stop_pathfinding_on_instance_change(
}
/// Checks whether the path has been obstructed, and returns Some(index) if it
-/// has been. The index is of the first obstructed node.
+/// has been.
+///
+/// The index is of the first obstructed node.
pub fn check_path_obstructed<SuccessorsFn>(
origin: BlockPos,
mut current_position: RelBlockPos,
diff --git a/azalea/src/pathfinder/moves/mod.rs b/azalea/src/pathfinder/moves/mod.rs
index 39ef786b..bb2354bf 100644
--- a/azalea/src/pathfinder/moves/mod.rs
+++ b/azalea/src/pathfinder/moves/mod.rs
@@ -137,8 +137,9 @@ impl ExecuteCtx<'_, '_, '_, '_, '_, '_, '_, '_> {
true
}
- /// Mine the block at the given position. Returns whether the block is being
- /// mined.
+ /// Mine the block at the given position.
+ ///
+ /// Returns whether the block is being mined.
pub fn mine(&mut self, block: BlockPos) -> bool {
let block_state = self
.instance
diff --git a/azalea/src/pathfinder/world.rs b/azalea/src/pathfinder/world.rs
index 318ed55e..0f1a8305 100644
--- a/azalea/src/pathfinder/world.rs
+++ b/azalea/src/pathfinder/world.rs
@@ -17,8 +17,9 @@ use super::{mining::MiningCache, rel_block_pos::RelBlockPos};
/// An efficient representation of the world used for the pathfinder.
pub struct CachedWorld {
- /// The origin that the [`RelBlockPos`] types will be relative to. This is
- /// for an optimization that reduces the size of the block positions
+ /// The origin that the [`RelBlockPos`] types will be relative to.
+ ///
+ /// This is for an optimization that reduces the size of the block positions
/// that are used by the pathfinder.
origin: BlockPos,
@@ -247,8 +248,9 @@ impl CachedWorld {
passable
}
- /// Get the block state at the given position. This is relatively slow, so
- /// you should avoid it whenever possible.
+ /// Get the block state at the given position.
+ ///
+ /// This is relatively slow, so you should avoid it whenever possible.
pub fn get_block_state(&self, pos: RelBlockPos) -> BlockState {
self.get_block_state_at_pos(pos.apply(self.origin))
}
@@ -304,8 +306,9 @@ impl CachedWorld {
solid
}
- /// Returns how much it costs to break this block. Returns 0 if the block is
- /// already passable.
+ /// Returns how much it costs to break this block.
+ ///
+ /// Returns 0 if the block is already passable.
pub fn cost_for_breaking_block(&self, pos: RelBlockPos, mining_cache: &MiningCache) -> f32 {
// SAFETY: pathfinding is single-threaded
let cached_mining_costs = unsafe { &mut *self.cached_mining_costs.get() };
@@ -478,8 +481,10 @@ impl CachedWorld {
+ self.cost_for_breaking_block(pos.up(1), mining_cache)
}
- /// Whether we can stand in this position. Checks if the block below is
- /// solid, and that the two blocks above that are passable.
+ /// Whether we can stand in this position.
+ ///
+ /// Checks if the block below is solid, and that the two blocks above that
+ /// are passable.
pub fn is_standable(&self, pos: RelBlockPos) -> bool {
self.is_standable_at_block_pos(pos.apply(self.origin))
}