aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/pathfinder
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-07-15 16:35:23 -0500
committermat <git@matdoes.dev>2023-07-15 16:35:23 -0500
commita839c6a923a737fab61536cec0258fdd83106368 (patch)
tree8dfdb984da72dd60ad77a5f171e7db4efd296103 /azalea/src/pathfinder
parentcde7e35046b726b07bf3e067c080b85a12b2fd74 (diff)
downloadazalea-drasl-a839c6a923a737fab61536cec0258fdd83106368.tar.xz
fix brigadier booleans
Diffstat (limited to 'azalea/src/pathfinder')
-rw-r--r--azalea/src/pathfinder/goals.rs30
-rw-r--r--azalea/src/pathfinder/mod.rs30
2 files changed, 32 insertions, 28 deletions
diff --git a/azalea/src/pathfinder/goals.rs b/azalea/src/pathfinder/goals.rs
new file mode 100644
index 00000000..95f1b74f
--- /dev/null
+++ b/azalea/src/pathfinder/goals.rs
@@ -0,0 +1,30 @@
+use azalea_core::BlockPos;
+
+use super::{Goal, Node, VerticalVel};
+
+pub struct BlockPosGoal {
+ pub pos: BlockPos,
+}
+impl Goal for BlockPosGoal {
+ fn heuristic(&self, n: &Node) -> f32 {
+ let dx = (self.pos.x - n.pos.x) as f32;
+ let dy = (self.pos.y - n.pos.y) as f32;
+ let dz = (self.pos.z - n.pos.z) as f32;
+ dx * dx + dy * dy + dz * dz
+ }
+ fn success(&self, n: &Node) -> bool {
+ n.pos == self.pos
+ }
+ fn goal_node(&self) -> Node {
+ Node {
+ pos: self.pos,
+ vertical_vel: VerticalVel::None,
+ }
+ }
+}
+
+impl From<BlockPos> for BlockPosGoal {
+ fn from(pos: BlockPos) -> Self {
+ Self { pos }
+ }
+}
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index f4e4d599..27314d07 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -1,4 +1,5 @@
mod astar;
+pub mod goals;
mod moves;
use crate::bot::{JumpEvent, LookAtEvent};
@@ -75,7 +76,7 @@ pub trait PathfinderClientExt {
impl PathfinderClientExt for azalea_client::Client {
/// ```
/// # use azalea::prelude::*;
- /// # use azalea::{BlockPos, pathfinder::BlockPosGoal};
+ /// # use azalea::{BlockPos, pathfinder::goals::BlockPosGoal};
/// # fn example(bot: &Client) {
/// bot.goto(BlockPosGoal::from(BlockPos::new(0, 70, 0)));
/// # }
@@ -320,30 +321,3 @@ impl Node {
}
}
}
-
-pub struct BlockPosGoal {
- pub pos: BlockPos,
-}
-impl Goal for BlockPosGoal {
- fn heuristic(&self, n: &Node) -> f32 {
- let dx = (self.pos.x - n.pos.x) as f32;
- let dy = (self.pos.y - n.pos.y) as f32;
- let dz = (self.pos.z - n.pos.z) as f32;
- dx * dx + dy * dy + dz * dz
- }
- fn success(&self, n: &Node) -> bool {
- n.pos == self.pos
- }
- fn goal_node(&self) -> Node {
- Node {
- pos: self.pos,
- vertical_vel: VerticalVel::None,
- }
- }
-}
-
-impl From<BlockPos> for BlockPosGoal {
- fn from(pos: BlockPos) -> Self {
- Self { pos }
- }
-}