aboutsummaryrefslogtreecommitdiff
path: root/azalea/src
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
parentcde7e35046b726b07bf3e067c080b85a12b2fd74 (diff)
downloadazalea-drasl-a839c6a923a737fab61536cec0258fdd83106368.tar.xz
fix brigadier booleans
Diffstat (limited to 'azalea/src')
-rw-r--r--azalea/src/bot.rs7
-rw-r--r--azalea/src/lib.rs4
-rw-r--r--azalea/src/pathfinder/goals.rs30
-rw-r--r--azalea/src/pathfinder/mod.rs30
4 files changed, 38 insertions, 33 deletions
diff --git a/azalea/src/bot.rs b/azalea/src/bot.rs
index 71d96c4d..1624db78 100644
--- a/azalea/src/bot.rs
+++ b/azalea/src/bot.rs
@@ -99,11 +99,12 @@ impl BotClientExt for azalea_client::Client {
/// ```
/// # use azalea::prelude::*;
- /// # async fn example(mut bot: azalea::Client) {
- /// let mut ticks = self.get_tick_broadcaster();
+ /// # use azalea::container::WaitingForInventoryOpen;
+ /// # async fn example(bot: &mut azalea::Client) {
+ /// let mut ticks = bot.get_tick_broadcaster();
/// while ticks.recv().await.is_ok() {
/// let ecs = bot.ecs.lock();
- /// if ecs.get::<WaitingForInventoryOpen>(self.entity).is_none() {
+ /// if ecs.get::<WaitingForInventoryOpen>(bot.entity).is_none() {
/// break;
/// }
/// }
diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs
index 0aff2a56..f564cd9b 100644
--- a/azalea/src/lib.rs
+++ b/azalea/src/lib.rs
@@ -5,7 +5,7 @@
mod auto_respawn;
mod bot;
-mod container;
+pub mod container;
pub mod pathfinder;
pub mod prelude;
pub mod swarm;
@@ -20,7 +20,7 @@ pub use azalea_core::{BlockPos, Vec3};
pub use azalea_entity as entity;
pub use azalea_protocol as protocol;
pub use azalea_registry::{Block, EntityKind, Item};
-pub use azalea_world::Instance;
+pub use azalea_world as world;
pub use bot::DefaultBotPlugins;
use ecs::component::Component;
use futures::Future;
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 }
- }
-}