aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/pathfinder/world.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-10-12 23:01:54 +0300
committermat <git@matdoes.dev>2025-10-12 23:01:54 +0300
commitee2575794e91b9457a74a95daf1dcc707058cd58 (patch)
treedf725850ef18ded5ce3f6552e17095d0f704ae84 /azalea/src/pathfinder/world.rs
parent1a1402954b07cd77615d0afc026c73b008787f51 (diff)
downloadazalea-drasl-ee2575794e91b9457a74a95daf1dcc707058cd58.tar.xz
upgrade deps and clean up lots of doc comments
Diffstat (limited to 'azalea/src/pathfinder/world.rs')
-rw-r--r--azalea/src/pathfinder/world.rs21
1 files changed, 13 insertions, 8 deletions
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))
}