aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
authorUbuntu <github@matdoes.dev>2022-12-09 15:13:14 +0000
committerUbuntu <github@matdoes.dev>2022-12-09 15:13:14 +0000
commitca00dbab12ab7de0bba462b9814b9f491b23da69 (patch)
tree560bd906d9ca1fcb822290286e9bf5990826163a /azalea
parentf0097612473d20ebac21e8ae5eba32bf32c2fe42 (diff)
parent70e2dfed16da8d5130460ea15b47701e622f4a9f (diff)
downloadazalea-drasl-ca00dbab12ab7de0bba462b9814b9f491b23da69.tar.xz
Merge branch 'main' of https://github.com/mat-1/azalea into main
Diffstat (limited to 'azalea')
-rw-r--r--azalea/src/pathfinder/moves.rs3
-rw-r--r--azalea/src/pathfinder/mtdstarlite.rs9
-rw-r--r--azalea/src/prelude.rs3
-rw-r--r--azalea/src/start.rs4
-rw-r--r--azalea/src/swarm/chat.rs3
-rw-r--r--azalea/src/swarm/mod.rs10
-rw-r--r--azalea/src/swarm/plugins.rs3
7 files changed, 22 insertions, 13 deletions
diff --git a/azalea/src/pathfinder/moves.rs b/azalea/src/pathfinder/moves.rs
index 63e24412..ac2137d3 100644
--- a/azalea/src/pathfinder/moves.rs
+++ b/azalea/src/pathfinder/moves.rs
@@ -38,7 +38,8 @@ const WALK_ONE_BLOCK_COST: f32 = 1.0;
pub trait Move {
fn cost(&self, world: &World, node: &Node) -> f32;
- /// Returns by how much the entity's position should be changed when this move is executed.
+ /// Returns by how much the entity's position should be changed when this
+ /// move is executed.
fn offset(&self) -> BlockPos;
fn next_node(&self, node: &Node) -> Node {
Node {
diff --git a/azalea/src/pathfinder/mtdstarlite.rs b/azalea/src/pathfinder/mtdstarlite.rs
index ff0fe4cc..50a467df 100644
--- a/azalea/src/pathfinder/mtdstarlite.rs
+++ b/azalea/src/pathfinder/mtdstarlite.rs
@@ -20,7 +20,8 @@ pub struct MTDStarLite<
PredecessorsFn: Fn(&N) -> Vec<Edge<N, W>>,
SuccessFn: Fn(&N) -> bool,
> {
- /// Returns a rough estimate of how close we are to the goal. Lower = closer.
+ /// Returns a rough estimate of how close we are to the goal. Lower =
+ /// closer.
pub heuristic: HeuristicFn,
/// Returns the nodes that can be reached from the given node.
pub successors: SuccessorsFn,
@@ -29,7 +30,8 @@ pub struct MTDStarLite<
/// can be the same as `successors`.
pub predecessors: PredecessorsFn,
/// Returns true if the given node is at the goal.
- /// A simple implementation is to check if the given node is equal to the goal.
+ /// A simple implementation is to check if the given node is equal to the
+ /// goal.
pub success: SuccessFn,
start: N,
@@ -43,7 +45,8 @@ pub struct MTDStarLite<
node_states: HashMap<N, NodeState<N, W>>,
updated_edge_costs: Vec<ChangedEdge<N, W>>,
- /// This only exists so it can be referenced by `state()` when there's no state.
+ /// This only exists so it can be referenced by `state()` when there's no
+ /// state.
default_state: NodeState<N, W>,
}
diff --git a/azalea/src/prelude.rs b/azalea/src/prelude.rs
index 30205e59..bedf724f 100644
--- a/azalea/src/prelude.rs
+++ b/azalea/src/prelude.rs
@@ -1,4 +1,5 @@
-//! The Azalea prelude. Things that are necessary for a bare-bones bot are re-exported here.
+//! The Azalea prelude. Things that are necessary for a bare-bones bot are
+//! re-exported here.
pub use crate::bot::BotTrait;
pub use crate::pathfinder::Trait;
diff --git a/azalea/src/start.rs b/azalea/src/start.rs
index c7d79261..e2374fb8 100644
--- a/azalea/src/start.rs
+++ b/azalea/src/start.rs
@@ -86,8 +86,8 @@ pub enum StartError {
Join(#[from] azalea_client::JoinError),
}
-/// Join a server and start handling events. This function will run forever until
-/// it gets disconnected from the server.
+/// Join a server and start handling events. This function will run forever
+/// until it gets disconnected from the server.
///
/// # Examples
///
diff --git a/azalea/src/swarm/chat.rs b/azalea/src/swarm/chat.rs
index a39632f5..6c51ba33 100644
--- a/azalea/src/swarm/chat.rs
+++ b/azalea/src/swarm/chat.rs
@@ -111,7 +111,8 @@ impl SwarmState {
where
S: Send + Sync + Clone + 'static,
{
- // it should never be locked unless we reused the same plugin for two swarms (bad)
+ // it should never be locked unless we reused the same plugin for two swarms
+ // (bad)
let mut rx = self.rx.lock().await;
while let Some(m) = rx.recv().await {
swarm.swarm_tx.send(SwarmEvent::Chat(m)).unwrap();
diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs
index 4956adde..6fc3e40c 100644
--- a/azalea/src/swarm/mod.rs
+++ b/azalea/src/swarm/mod.rs
@@ -18,8 +18,8 @@ use std::{future::Future, net::SocketAddr, sync::Arc, time::Duration};
use thiserror::Error;
use tokio::sync::mpsc::{self, UnboundedSender};
-/// A helper macro that generates a [`SwarmPlugins`] struct from a list of objects
-/// that implement [`SwarmPlugin`].
+/// A helper macro that generates a [`SwarmPlugins`] struct from a list of
+/// objects that implement [`SwarmPlugin`].
///
/// ```rust,no_run
/// swarm_plugins![azalea_pathfinder::Plugin];
@@ -111,7 +111,8 @@ where
pub swarm_state: SS,
/// The function that's called every time a bot receives an [`Event`].
pub handle: HandleFn<Fut, S>,
- /// The function that's called every time the swarm receives a [`SwarmEvent`].
+ /// The function that's called every time the swarm receives a
+ /// [`SwarmEvent`].
pub swarm_handle: SwarmHandleFn<SwarmFut, S, SS>,
/// How long we should wait between each bot joining the server. Set to
@@ -342,7 +343,8 @@ impl<S> Swarm<S>
where
S: Send + Sync + Clone + 'static,
{
- /// Add a new account to the swarm. You can remove it later by calling [`Client::disconnect`].
+ /// Add a new account to the swarm. You can remove it later by calling
+ /// [`Client::disconnect`].
pub async fn add(&mut self, account: &Account, state: S) -> Result<Client, JoinError> {
let conn = Connection::new(&self.resolved_address).await?;
let (conn, game_profile) = Client::handshake(conn, account, &self.address.clone()).await?;
diff --git a/azalea/src/swarm/plugins.rs b/azalea/src/swarm/plugins.rs
index 0c7cf2ae..f92d40e6 100644
--- a/azalea/src/swarm/plugins.rs
+++ b/azalea/src/swarm/plugins.rs
@@ -13,7 +13,8 @@ type U64Hasher = BuildHasherDefault<NoHashHasher<u64>>;
/// A map of plugin ids to [`SwarmPlugin`] trait objects. The client stores
/// this so we can keep the state for our [`Swarm`] plugins.
///
-/// If you're using azalea, you should generate this from the `swarm_plugins!` macro.
+/// If you're using azalea, you should generate this from the `swarm_plugins!`
+/// macro.
#[derive(Clone, Default)]
pub struct SwarmPlugins<S> {
map: Option<HashMap<TypeId, Box<dyn SwarmPlugin<S>>, U64Hasher>>,