diff options
| author | mat <git@matdoes.dev> | 2025-10-12 23:01:54 +0300 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-10-12 23:01:54 +0300 |
| commit | ee2575794e91b9457a74a95daf1dcc707058cd58 (patch) | |
| tree | df725850ef18ded5ce3f6552e17095d0f704ae84 /azalea-client | |
| parent | 1a1402954b07cd77615d0afc026c73b008787f51 (diff) | |
| download | azalea-drasl-ee2575794e91b9457a74a95daf1dcc707058cd58.tar.xz | |
upgrade deps and clean up lots of doc comments
Diffstat (limited to 'azalea-client')
| -rw-r--r-- | azalea-client/src/account.rs | 43 | ||||
| -rw-r--r-- | azalea-client/src/client.rs | 13 | ||||
| -rw-r--r-- | azalea-client/src/entity_query.rs | 13 | ||||
| -rw-r--r-- | azalea-client/src/local_player.rs | 19 | ||||
| -rw-r--r-- | azalea-client/src/player.rs | 10 | ||||
| -rw-r--r-- | azalea-client/src/plugins/attack.rs | 5 | ||||
| -rw-r--r-- | azalea-client/src/plugins/auto_reconnect.rs | 13 | ||||
| -rw-r--r-- | azalea-client/src/plugins/chat/mod.rs | 35 | ||||
| -rw-r--r-- | azalea-client/src/plugins/client_information.rs | 10 | ||||
| -rw-r--r-- | azalea-client/src/plugins/connection.rs | 19 | ||||
| -rw-r--r-- | azalea-client/src/plugins/events.rs | 15 | ||||
| -rw-r--r-- | azalea-client/src/plugins/interact/mod.rs | 11 | ||||
| -rw-r--r-- | azalea-client/src/plugins/inventory.rs | 57 | ||||
| -rw-r--r-- | azalea-client/src/plugins/join.rs | 5 | ||||
| -rw-r--r-- | azalea-client/src/plugins/mining.rs | 19 | ||||
| -rw-r--r-- | azalea-client/src/plugins/movement.rs | 64 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/events.rs | 19 | ||||
| -rw-r--r-- | azalea-client/src/plugins/task_pool.rs | 18 |
18 files changed, 225 insertions, 163 deletions
diff --git a/azalea-client/src/account.rs b/azalea-client/src/account.rs index bda69558..ab8e8e65 100644 --- a/azalea-client/src/account.rs +++ b/azalea-client/src/account.rs @@ -37,8 +37,9 @@ use uuid::Uuid; pub struct Account { /// The Minecraft username of the account. pub username: String, - /// The access token for authentication. You can obtain one of these - /// manually from azalea-auth. + /// The access token for authentication. + /// + /// You can obtain one of these manually from azalea-auth. /// /// This is an `Arc<Mutex>` so it can be modified by [`Self::refresh`]. pub access_token: Option<Arc<Mutex<String>>>, @@ -46,8 +47,10 @@ pub struct Account { pub uuid: Option<Uuid>, /// The parameters (i.e. email) that were passed for creating this - /// [`Account`]. This is used for automatic reauthentication when we get - /// "Invalid Session" errors. If you don't need that feature (like in + /// [`Account`]. + /// + /// This is used for automatic reauthentication when we get "Invalid + /// Session" errors. If you don't need that feature (like in /// offline mode), then you can set this to `AuthOpts::default()`. pub account_opts: AccountOpts, @@ -74,8 +77,9 @@ pub enum AccountOpts { impl Account { /// An offline account does not authenticate with Microsoft's servers, and - /// as such can only join offline mode servers. This is useful for testing - /// in LAN worlds. + /// as such can only join offline mode servers. + /// + /// This is useful for testing in LAN worlds. pub fn offline(username: &str) -> Self { Self { username: username.to_string(), @@ -89,19 +93,20 @@ impl Account { } /// This will create an online-mode account by authenticating with - /// Microsoft's servers. Note that the email given is actually only used as - /// a key for the cache, but it's recommended to use the real email to - /// avoid confusion. - pub async fn microsoft(email: &str) -> Result<Self, azalea_auth::AuthError> { - Self::microsoft_with_custom_client_id_and_scope(email, None, None).await + /// Microsoft's servers. + /// + /// The cache key is used for avoiding having to log in every time. This is + /// typically set to the account email, but it can be any string. + pub async fn microsoft(cache_key: &str) -> Result<Self, azalea_auth::AuthError> { + Self::microsoft_with_custom_client_id_and_scope(cache_key, None, None).await } - /// Similar to [`Account::microsoft`] but you can use your - /// own `client_id` and `scope`. + /// Similar to [`Account::microsoft`] but you can use your own `client_id` + /// and `scope`. /// /// Pass `None` if you want to use default ones. pub async fn microsoft_with_custom_client_id_and_scope( - email: &str, + cache_key: &str, client_id: Option<&str>, scope: Option<&str>, ) -> Result<Self, azalea_auth::AuthError> { @@ -112,7 +117,7 @@ impl Account { ) }); let auth_result = azalea_auth::auth( - email, + cache_key, azalea_auth::AuthOpts { cache_file: Some(minecraft_dir.join("azalea-auth.json")), client_id, @@ -126,7 +131,7 @@ impl Account { access_token: Some(Arc::new(Mutex::new(auth_result.access_token))), uuid: Some(auth_result.profile.id), account_opts: AccountOpts::Microsoft { - email: email.to_string(), + email: cache_key.to_string(), }, // we don't do chat signing by default unless the user asks for it certs: Arc::new(Mutex::new(None)), @@ -235,8 +240,10 @@ impl Account { } } - /// Get the UUID of this account. This will generate an offline-mode UUID - /// by making a hash with the username if the `uuid` field is None. + /// Get the UUID of this account. + /// + /// If the `uuid` field is None, the UUID will be determined by using + /// Minecraft's offline-mode UUIDv3 algorithm. pub fn uuid_or_offline(&self) -> Uuid { self.uuid .unwrap_or_else(|| azalea_auth::offline::generate_uuid(&self.username)) diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index cf07f8b2..6957619e 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -78,9 +78,11 @@ pub struct Client { /// The entity for this client in the ECS. pub entity: Entity, - /// The entity component system. You probably don't need to access this - /// directly. Note that if you're using a shared world (i.e. a swarm), this - /// will contain all entities in all worlds. + /// A mutually exclusive reference to the entity component system (ECS). + /// + /// You probably don't need to access this directly. Note that if you're + /// using a shared world (i.e. a swarm), the ECS will contain all entities + /// in all instances/dimensions. pub ecs: Arc<Mutex<World>>, } @@ -524,8 +526,9 @@ pub struct LocalPlayerBundle { } /// A bundle for the components that are present on a local player that is -/// currently in the `game` protocol state. If you want to filter for this, use -/// [`InGameState`]. +/// currently in the `game` protocol state. +/// +/// If you want to filter for this, use [`InGameState`]. #[derive(Bundle, Default)] pub struct JoinedClientBundle { // note that InstanceHolder isn't here because it's set slightly before we fully join the world diff --git a/azalea-client/src/entity_query.rs b/azalea-client/src/entity_query.rs index a1d761e3..6945549d 100644 --- a/azalea-client/src/entity_query.rs +++ b/azalea-client/src/entity_query.rs @@ -175,8 +175,10 @@ impl Client { predicate.find_all_sorted(self.ecs.clone(), &instance_name, (&position).into()) } - /// Get a component from an entity. Note that this will return an owned type - /// (i.e. not a reference) so it may be expensive for larger types. + /// Get a component from an entity. + /// + /// Note that this will return an owned type (i.e. not a reference) so it + /// may be expensive for larger types. /// /// If you're trying to get a component for this client, use /// [`Self::component`]. @@ -192,9 +194,10 @@ impl Client { components.clone() } - /// Get a component from an entity, if it exists. This is similar to - /// [`Self::entity_component`] but returns an `Option` instead of panicking - /// if the component isn't present. + /// Get a component from an entity, if it exists. + /// + /// This is similar to [`Self::entity_component`] but returns an `Option` + /// instead of panicking if the component isn't present. pub fn get_entity_component<Q: Component + Clone>(&self, entity: Entity) -> Option<Q> { let mut ecs = self.ecs.lock(); let mut q = ecs.query::<&Q>(); diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs index 20da4c80..4bc69995 100644 --- a/azalea-client/src/local_player.rs +++ b/azalea-client/src/local_player.rs @@ -26,11 +26,12 @@ use crate::{ClientInformation, events::Event as AzaleaEvent, player::PlayerInfo} /// [`InstanceName`]: azalea_world::InstanceName #[derive(Component, Clone)] pub struct InstanceHolder { - /// The partial instance is the world this client currently has loaded. It - /// has a limited render distance. + /// The partial instance is the world this client currently has loaded. + /// + /// It has a limited render distance. pub partial_instance: Arc<RwLock<PartialInstance>>, - /// The world is the combined [`PartialInstance`]s of all clients in the - /// same world. + /// The combined [`PartialInstance`]s of all clients in the same instance + /// (aka world/dimension). /// /// This is only relevant if you're using a shared world (i.e. a /// swarm). @@ -81,11 +82,13 @@ pub struct TabList(HashMap<Uuid, PlayerInfo>); #[derive(Component, Clone)] pub struct Hunger { - /// The main hunger bar. Goes from 0 to 20. + /// The main hunger bar. This is typically in the range `0..=20`. pub food: u32, - /// The amount of saturation the player has. This isn't shown in normal - /// vanilla clients but it's a separate counter that makes it so your hunger - /// only starts decreasing when this is 0. + /// The amount of saturation the player has. + /// + /// This isn't displayed in the vanilla Minecraft GUI, but it's used + /// internally by the game. It's a decrementing counter, and the player's + /// [`Hunger::food`] only starts decreasing when this reaches 0. pub saturation: f32, } diff --git a/azalea-client/src/player.rs b/azalea-client/src/player.rs index 46596e48..9a2e7a1c 100644 --- a/azalea-client/src/player.rs +++ b/azalea-client/src/player.rs @@ -22,12 +22,14 @@ pub struct PlayerInfo { pub uuid: Uuid, /// The current gamemode of the player, like survival or creative. pub gamemode: GameMode, - /// The player's latency in milliseconds. The bars in the tab screen depend - /// on this. + /// The player's latency in milliseconds. + /// + /// The bars in the tab screen depend on this. pub latency: i32, /// The player's display name in the tab list, but only if it's different - /// from the player's normal username. Use `player_info.profile.name` to get - /// the player's actual username. + /// from the player's normal username. + /// + /// Use [`GameProfile::name`] to get the player's actual username. pub display_name: Option<Box<FormattedText>>, } diff --git a/azalea-client/src/plugins/attack.rs b/azalea-client/src/plugins/attack.rs index 0e7cfeb8..7550ed19 100644 --- a/azalea-client/src/plugins/attack.rs +++ b/azalea-client/src/plugins/attack.rs @@ -43,7 +43,10 @@ impl Plugin for AttackPlugin { } impl Client { - /// Attack the entity with the given id. + /// Attack an entity in the world. + /// + /// This doesn't automatically look at the entity or perform any + /// range/visibility checks, so it might trigger anticheats. pub fn attack(&self, entity: Entity) { self.ecs.lock().write_message(AttackEvent { entity: self.entity, diff --git a/azalea-client/src/plugins/auto_reconnect.rs b/azalea-client/src/plugins/auto_reconnect.rs index bff72e5a..fd24f12c 100644 --- a/azalea-client/src/plugins/auto_reconnect.rs +++ b/azalea-client/src/plugins/auto_reconnect.rs @@ -14,14 +14,17 @@ use super::{ }; use crate::Account; -/// The default delay that Azalea will use for reconnecting our clients. See -/// [`AutoReconnectPlugin`] for more information. +/// The default delay that Azalea will use for reconnecting our clients. +/// +/// See [`AutoReconnectPlugin`] for more information. pub const DEFAULT_RECONNECT_DELAY: Duration = Duration::from_secs(5); /// A default plugin that makes clients automatically rejoin the server when -/// they're disconnected. The reconnect delay is configurable globally or -/// per-client with the [`AutoReconnectDelay`] resource/component. Auto -/// reconnecting can be disabled by removing the resource from the ECS. +/// they're disconnected. +/// +/// The reconnect delay is configurable globally or per-client with the +/// [`AutoReconnectDelay`] resource/component. Auto reconnecting can be disabled +/// by removing the resource from the ECS. /// /// The delay defaults to [`DEFAULT_RECONNECT_DELAY`]. pub struct AutoReconnectPlugin; diff --git a/azalea-client/src/plugins/chat/mod.rs b/azalea-client/src/plugins/chat/mod.rs index 098b6543..e0a41d49 100644 --- a/azalea-client/src/plugins/chat/mod.rs +++ b/azalea-client/src/plugins/chat/mod.rs @@ -131,9 +131,11 @@ impl ChatPacket { self.split_sender_and_content().0 } - /// Get the UUID of the sender of the message. If it's not a - /// player-sent chat message, this will be None (this is sometimes the case - /// when a server uses a plugin to modify chat messages). + /// Get the UUID of the sender of the message. + /// + /// If it's not a player-sent chat message, this will be None (this is + /// sometimes the case when a server uses a plugin to modify chat + /// messages). pub fn sender_uuid(&self) -> Option<Uuid> { match self { ChatPacket::System(_) => None, @@ -142,14 +144,16 @@ impl ChatPacket { } } - /// Get the content part of the message as a string. This does not preserve - /// formatting codes. If it's not a player-sent chat message or the sender - /// couldn't be determined, this will contain the entire message. + /// Get the content part of the message as a string. + /// + /// This does not preserve formatting codes. If it's not a player-sent chat + /// message or the sender couldn't be determined, this will contain the + /// entire message. pub fn content(&self) -> String { self.split_sender_and_content().1 } - /// Create a new Chat from a string. This is meant to be used as a + /// Create a new `ChatPacket` from a string. This is meant to be used as a /// convenience function for testing. pub fn new(message: &str) -> Self { ChatPacket::System(Arc::new(ClientboundSystemChat { @@ -159,8 +163,9 @@ impl ChatPacket { } /// Whether this message is an incoming whisper message (i.e. someone else - /// dm'd the bot with /msg). It works by checking the translation key, so it - /// won't work on servers that use their own whisper system. + /// messaged the bot with /msg). + /// + /// This is not guaranteed to work correctly on custom servers. pub fn is_whisper(&self) -> bool { match self { ChatPacket::System(p) => { @@ -183,11 +188,13 @@ impl ChatPacket { } impl Client { - /// Send a chat message to the server. This only sends the chat packet and - /// not the command packet, which means on some servers you can use this to - /// send chat messages that start with a `/`. The [`Client::chat`] function - /// handles checking whether the message is a command and using the - /// proper packet for you, so you should use that instead. + /// Send a chat message to the server. + /// + /// This only sends the chat packet and not the command packet, which means + /// on some servers you can use this to send chat messages that start + /// with a `/`. The [`Client::chat`] function handles checking whether + /// the message is a command and using the proper packet for you, so you + /// should use that instead. pub fn write_chat_packet(&self, message: &str) { self.ecs.lock().write_message(SendChatKindEvent { entity: self.entity, diff --git a/azalea-client/src/plugins/client_information.rs b/azalea-client/src/plugins/client_information.rs index 499b8ab5..98f69a2d 100644 --- a/azalea-client/src/plugins/client_information.rs +++ b/azalea-client/src/plugins/client_information.rs @@ -45,8 +45,9 @@ pub fn send_client_information( impl Client { /// Tell the server we changed our game options (i.e. render distance, main - /// hand). If this is not set before the login packet, the default will - /// be sent. + /// hand). + /// + /// If this is not set before the login packet, the default will be sent. /// /// ```rust,no_run /// # use azalea_client::{Client, ClientInformation}; @@ -54,12 +55,11 @@ impl Client { /// bot.set_client_information(ClientInformation { /// view_distance: 2, /// ..Default::default() - /// }) - /// .await; + /// }); /// # Ok(()) /// # } /// ``` - pub async fn set_client_information(&self, client_information: ClientInformation) { + pub fn set_client_information(&self, client_information: ClientInformation) { self.query_self::<&mut ClientInformation, _>(|mut ci| { *ci = client_information.clone(); }); diff --git a/azalea-client/src/plugins/connection.rs b/azalea-client/src/plugins/connection.rs index 5d9cde18..dc14545a 100644 --- a/azalea-client/src/plugins/connection.rs +++ b/azalea-client/src/plugins/connection.rs @@ -182,9 +182,10 @@ pub struct RawConnection { pub(crate) is_alive: bool, /// This exists for internal testing purposes and probably shouldn't be used - /// for normal bots. It's basically a way to make our client think it - /// received a packet from the server without needing to interact with the - /// network. + /// for normal bots. + /// + /// It's basically a way to make our client think it received a packet from + /// the server without needing to interact with the network. pub injected_clientbound_packets: Vec<Box<[u8]>>, } impl RawConnection { @@ -305,9 +306,10 @@ pub struct NetworkConnection { pub enc_cipher: Option<Aes128CfbEnc>, pub writer_task: bevy_tasks::Task<()>, - /// A queue of raw TCP packets to send. These will not be modified further, - /// they should already be serialized and encrypted and everything before - /// being added here. + /// A queue of raw TCP packets to send. + /// + /// These will not be modified further, they should already be serialized + /// and compressed and encrypted before being added here. network_packet_writer_tx: mpsc::UnboundedSender<Box<[u8]>>, } impl NetworkConnection { @@ -344,8 +346,9 @@ impl NetworkConnection { trace!("Set compression threshold to {threshold:?}"); self.reader.compression_threshold = threshold; } - /// Set the encryption key that is used to encrypt and decrypt packets. It's - /// the same for both reading and writing. + /// Set the encryption key that is used to encrypt and decrypt packets. + /// + /// The same key is used for both reading and writing. pub fn set_encryption_key(&mut self, key: [u8; 16]) { trace!("Enabled protocol encryption"); let (enc_cipher, dec_cipher) = azalea_crypto::create_cipher(&key); diff --git a/azalea-client/src/plugins/events.rs b/azalea-client/src/plugins/events.rs index bc8a7a98..e8d99e7c 100644 --- a/azalea-client/src/plugins/events.rs +++ b/azalea-client/src/plugins/events.rs @@ -54,12 +54,16 @@ use crate::{ #[non_exhaustive] pub enum Event { /// Happens right after the bot switches into the Game state, but before - /// it's actually spawned. This can be useful for setting the client - /// information with `Client::set_client_information`, so the packet - /// doesn't have to be sent twice. + /// it's actually spawned. + /// + /// This can be useful for setting the client information with + /// [`Client::set_client_information`], so the packet doesn't have to be + /// sent twice. /// /// You may want to use [`Event::Spawn`] instead to wait for the bot to be /// in the world. + /// + /// [`Client::set_client_information`]: crate::Client::set_client_information Init, /// Fired when we receive a login packet, which is after [`Event::Init`] but /// before [`Event::Spawn`]. You usually want [`Event::Spawn`] instead. @@ -123,8 +127,9 @@ pub enum Event { } /// A component that contains an event sender for events that are only -/// received by local players. The receiver for this is returned by -/// [`Client::start_client`]. +/// received by local players. +/// +/// The receiver for this is returned by [`Client::start_client`]. /// /// [`Client::start_client`]: crate::Client::start_client #[derive(Component, Deref, DerefMut)] diff --git a/azalea-client/src/plugins/interact/mod.rs b/azalea-client/src/plugins/interact/mod.rs index 52862a38..09a8afc9 100644 --- a/azalea-client/src/plugins/interact/mod.rs +++ b/azalea-client/src/plugins/interact/mod.rs @@ -363,8 +363,9 @@ pub fn handle_start_use_item_queued( } } -/// Whether we can't interact with the block, based on your gamemode. If -/// this is false, then we can interact with the block. +/// Whether we can't interact with the block, based on your gamemode. +/// +/// If this is false, then we can interact with the block. /// /// Passing the inventory, block position, and instance is necessary for the /// adventure mode check. @@ -427,8 +428,10 @@ pub fn can_use_game_master_blocks( abilities.instant_break && **permission_level >= 2 } -/// Swing your arm. This is purely a visual effect and won't interact with -/// anything in the world. +/// Swing your arm. +/// +/// This is purely a visual effect and won't interact with anything in the +/// world. #[derive(EntityEvent, Clone, Debug)] pub struct SwingArmEvent { pub entity: Entity, diff --git a/azalea-client/src/plugins/inventory.rs b/azalea-client/src/plugins/inventory.rs index a805ae9b..c167917b 100644 --- a/azalea-client/src/plugins/inventory.rs +++ b/azalea-client/src/plugins/inventory.rs @@ -47,8 +47,8 @@ impl Plugin for InventoryPlugin { pub struct InventorySystems; impl Client { - /// Return the menu that is currently open. If no menu is open, this will - /// have the player's inventory. + /// Return the menu that is currently open, or the player's inventory if no + /// menu is open. pub fn menu(&self) -> Menu { self.query_self::<&Inventory, _>(|inv| inv.menu().clone()) } @@ -95,26 +95,29 @@ pub struct Inventory { /// bare [`azalea_inventory::Player`] doesn't have. pub inventory_menu: azalea_inventory::Menu, - /// The ID of the container that's currently open. Its value is not - /// guaranteed to be anything specific, and may change every time you open a - /// container (unless it's 0, in which case it means that no container is - /// open). + /// The ID of the container that's currently open. + /// + /// Its value is not guaranteed to be anything specific, and it may change + /// every time you open a container (unless it's 0, in which case it + /// means that no container is open). pub id: i32, - /// The current container menu that the player has open. If no container is - /// open, this will be `None`. + /// The current container menu that the player has open, or `None` if no + /// container is open. pub container_menu: Option<azalea_inventory::Menu>, - /// The custom name of the menu that's currently open. This is Some when - /// `container_menu` is Some. + /// The custom name of the menu that's currently open. + /// + /// This can only be `Some` when `container_menu` is `Some`. pub container_menu_title: Option<FormattedText>, - /// The item that is currently held by the cursor. `Slot::Empty` if nothing - /// is currently being held. + /// The item that is currently held by the cursor, or `Slot::Empty` if + /// nothing is currently being held. /// /// This is different from [`Self::selected_hotbar_slot`], which is the /// item that's selected in the hotbar. pub carried: ItemStack, - /// An identifier used by the server to track client inventory desyncs. This - /// is sent on every container click, and it's only ever updated when the - /// server sends a new container update. + /// An identifier used by the server to track client inventory desyncs. + /// + /// This is sent on every container click, and it's only ever updated when + /// the server sends a new container update. pub state_id: u32, pub quick_craft_status: QuickCraftStatusKind, @@ -124,7 +127,7 @@ pub struct Inventory { pub quick_craft_slots: HashSet<u16>, /// The index of the item in the hotbar that's currently being held by the - /// player. This MUST be in the range 0..9 (not including 9). + /// player. This must be in the range 0..=8. /// /// In a vanilla client this is changed by pressing the number keys or using /// the scroll wheel. @@ -132,9 +135,10 @@ pub struct Inventory { } impl Inventory { - /// Returns a reference to the currently active menu. If a container is open - /// it'll return [`Self::container_menu`], otherwise - /// [`Self::inventory_menu`]. + /// Returns a reference to the currently active menu. + /// + /// If a container is open then it'll return [`Self::container_menu`], + /// otherwise [`Self::inventory_menu`]. /// /// Use [`Self::menu_mut`] if you need a mutable reference. pub fn menu(&self) -> &azalea_inventory::Menu { @@ -144,9 +148,10 @@ impl Inventory { } } - /// Returns a mutable reference to the currently active menu. If a container - /// is open it'll return [`Self::container_menu`], otherwise - /// [`Self::inventory_menu`]. + /// Returns a mutable reference to the currently active menu. + /// + /// If a container is open then it'll return [`Self::container_menu`], + /// otherwise [`Self::inventory_menu`]. /// /// Use [`Self::menu`] if you don't need a mutable reference. pub fn menu_mut(&mut self) -> &mut azalea_inventory::Menu { @@ -743,8 +748,10 @@ fn handle_menu_opened_trigger(event: On<MenuOpenedEvent>, mut query: Query<&mut #[derive(EntityEvent)] pub struct CloseContainerEvent { pub entity: Entity, - /// The ID of the container to close. 0 for the player's inventory. If this - /// is not the same as the currently open inventory, nothing will happen. + /// The ID of the container to close. 0 for the player's inventory. + /// + /// If this is not the same as the currently open inventory, nothing will + /// happen. pub id: i32, } fn handle_container_close_event( @@ -772,7 +779,7 @@ fn handle_container_close_event( }); } -/// A Bevy trigger that's fired when our client closed a container. +/// A Bevy event that's fired when our client closed a container. /// /// This can also be triggered directly to close a container silently without /// sending any packets to the server. You probably don't want that though, and diff --git a/azalea-client/src/plugins/join.rs b/azalea-client/src/plugins/join.rs index b9878370..a8f6e3c5 100644 --- a/azalea-client/src/plugins/join.rs +++ b/azalea-client/src/plugins/join.rs @@ -57,8 +57,9 @@ pub struct StartJoinServerEvent { pub start_join_callback_tx: Option<mpsc::UnboundedSender<Entity>>, } -/// Options for how the connection to the server will be made. These are -/// persisted on reconnects. +/// Options for how the connection to the server will be made. +/// +/// These are persisted on reconnects. /// /// This is inserted as a component on clients to make auto-reconnecting work. #[derive(Debug, Clone, Component)] diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs index fda54521..101cd4df 100644 --- a/azalea-client/src/plugins/mining.rs +++ b/azalea-client/src/plugins/mining.rs @@ -147,8 +147,9 @@ fn handle_auto_mine( } } -/// Information about the block we're currently mining. This is only present if -/// we're currently mining a block. +/// Information about the block we're currently mining. +/// +/// This is only present if we're currently mining a block. #[derive(Component, Debug, Clone)] pub struct Mining { pub pos: BlockPos, @@ -441,8 +442,9 @@ pub struct MineBundle { #[derive(Component, Debug, Default, Deref, DerefMut, Clone)] pub struct MineDelay(pub u32); -/// A component that stores the progress of the current mining operation. This -/// is a value between 0 and 1. +/// A component that stores the progress of the current mining operation. +/// +/// This is a value between 0 and 1. #[derive(Component, Debug, Default, Deref, DerefMut, Clone)] pub struct MineProgress(pub f32); @@ -457,8 +459,9 @@ impl MineProgress { } /// A component that stores the number of ticks that we've been mining the same -/// block for. This is a float even though it should only ever be a round -/// number. +/// block for. +/// +/// This is a float despite the fact that it should only ever be a round number. #[derive(Component, Clone, Debug, Default, Deref, DerefMut)] pub struct MineTicks(pub f32); @@ -466,8 +469,8 @@ pub struct MineTicks(pub f32); #[derive(Component, Clone, Debug, Default, Deref, DerefMut)] pub struct MineBlockPos(pub Option<BlockPos>); -/// A component that contains the item we're currently using to mine. If we're -/// not mining anything, it'll be [`ItemStack::Empty`]. +/// A component that contains the item we're currently using to mine, or +/// [`ItemStack::Empty`] if nothing is being mined. #[derive(Component, Clone, Debug, Default, Deref, DerefMut)] pub struct MineItem(pub ItemStack); diff --git a/azalea-client/src/plugins/movement.rs b/azalea-client/src/plugins/movement.rs index 2ee5c379..adbaa01d 100644 --- a/azalea-client/src/plugins/movement.rs +++ b/azalea-client/src/plugins/movement.rs @@ -100,7 +100,9 @@ pub struct MoveEventsSystems; impl Client { /// Set whether we're jumping. This acts as if you held space in - /// vanilla. If you want to jump once, use the `jump` function. + /// vanilla. + /// + /// If you want to jump once, use the `jump` function in `azalea`. /// /// If you're making a realistic client, calling this function every tick is /// recommended. @@ -124,19 +126,21 @@ impl Client { self.query_self::<&PhysicsState, _>(|p| p.trying_to_crouch) } - /// Sets the direction the client is looking. `y_rot` is yaw (looking to the - /// side), `x_rot` is pitch (looking up and down). You can get these - /// numbers from the vanilla f3 screen. - /// `y_rot` goes from -180 to 180, and `x_rot` goes from -90 to 90. + /// Sets the direction the client is looking. + /// + /// `y_rot` is yaw (looking to the side, between -180 to 180), and `x_rot` + /// is pitch (looking up and down, between -90 to 90). + /// + /// You can get these numbers from the vanilla f3 screen. pub fn set_direction(&self, y_rot: f32, x_rot: f32) { self.query_self::<&mut LookDirection, _>(|mut ld| { ld.update(LookDirection::new(y_rot, x_rot)); }); } - /// Returns the direction the client is looking. The first value is the y - /// rotation (ie. yaw, looking to the side) and the second value is the x - /// rotation (ie. pitch, looking up and down). + /// Returns the direction the client is looking. + /// + /// See [`Self::set_direction`] for more details. pub fn direction(&self) -> (f32, f32) { let look_direction: LookDirection = self.component::<LookDirection>(); (look_direction.y_rot(), look_direction.x_rot()) @@ -350,8 +354,9 @@ pub(crate) fn tick_controls(mut query: Query<&mut PhysicsState>) { } } -/// Makes the bot do one physics tick. Note that this is already handled -/// automatically by the client. +/// Makes the bot do one physics tick. +/// +/// This is handled automatically by the client. #[allow(clippy::type_complexity)] pub fn local_player_ai_step( mut query: Query< @@ -532,17 +537,18 @@ fn distance_to_unit_square(v: Vec2) -> f32 { } impl Client { - /// Start walking in the given direction. To sprint, use - /// [`Client::sprint`]. To stop walking, call walk with - /// `WalkDirection::None`. + /// Start walking in the given direction. /// - /// # Examples + /// To sprint, use [`Client::sprint`]. To stop walking, call walk with + /// [`WalkDirection::None`]. + /// + /// # Example /// - /// Walk for 1 second /// ```rust,no_run /// # use azalea_client::{Client, WalkDirection}; /// # use std::time::Duration; /// # async fn example(mut bot: Client) { + /// // walk for one second /// bot.walk(WalkDirection::Forward); /// tokio::time::sleep(Duration::from_secs(1)).await; /// bot.walk(WalkDirection::None); @@ -556,16 +562,17 @@ impl Client { }); } - /// Start sprinting in the given direction. To stop moving, call - /// [`bot.walk(WalkDirection::None)`](Self::walk) + /// Start sprinting in the given direction. + /// + /// o stop moving, call [`bot.walk(WalkDirection::None)`](Self::walk) /// - /// # Examples + /// # Example /// - /// Sprint for 1 second /// ```rust,no_run /// # use azalea_client::{Client, WalkDirection, SprintDirection}; /// # use std::time::Duration; /// # async fn example(mut bot: Client) { + /// // sprint for one second /// bot.sprint(SprintDirection::Forward); /// tokio::time::sleep(Duration::from_secs(1)).await; /// bot.walk(WalkDirection::None); @@ -580,8 +587,9 @@ impl Client { } } -/// An event sent when the client starts walking. This does not get sent for -/// non-local entities. +/// An event sent when the client starts walking. +/// +/// This does not get sent for non-local entities. /// /// To stop walking or sprinting, send this event with `WalkDirection::None`. #[derive(Message, Debug)] @@ -606,8 +614,9 @@ pub fn handle_walk( } } -/// An event sent when the client starts sprinting. This does not get sent for -/// non-local entities. +/// An event sent when the client starts sprinting. +/// +/// This does not get sent for non-local entities. #[derive(Message)] pub struct StartSprintEvent { pub entity: Entity, @@ -662,10 +671,11 @@ fn has_enough_impulse_to_start_sprinting(physics_state: &PhysicsState) -> bool { // } } -/// An event sent by the server that sets or adds to our velocity. Usually -/// `KnockbackKind::Set` is used for normal knockback and `KnockbackKind::Add` -/// is used for explosions, but some servers (notably Hypixel) use explosions -/// for knockback. +/// An event sent by the server that sets or adds to our velocity. +/// +/// Usually `KnockbackKind::Set` is used for normal knockback and +/// `KnockbackKind::Add` is used for explosions, but some servers (notably +/// Hypixel) use explosions for knockback. #[derive(Message)] pub struct KnockbackEvent { pub entity: Entity, diff --git a/azalea-client/src/plugins/packet/game/events.rs b/azalea-client/src/plugins/packet/game/events.rs index cb9a5e07..7c773b44 100644 --- a/azalea-client/src/plugins/packet/game/events.rs +++ b/azalea-client/src/plugins/packet/game/events.rs @@ -102,9 +102,10 @@ pub struct UpdatePlayerEvent { pub info: PlayerInfo, } -/// Event for when an entity dies. dies. If it's a local player and there's a -/// reason in the death screen, the [`ClientboundPlayerCombatKill`] will -/// be included. +/// Event for when an entity dies. +/// +/// If it's a local player and there's a reason in the death screen, the +/// [`ClientboundPlayerCombatKill`] will be included. #[derive(Message, Debug, Clone)] pub struct DeathEvent { pub entity: Entity, @@ -116,16 +117,20 @@ pub struct DeathEvent { #[derive(Message, Debug, Clone)] pub struct KeepAliveEvent { pub entity: Entity, - /// The ID of the keepalive. This is an arbitrary number, but vanilla - /// servers use the time to generate this. + /// The ID of the keepalive. + /// + /// This is an arbitrary number, but vanilla servers use the current time to + /// generate this. pub id: u64, } #[derive(Message, Debug, Clone)] pub struct ResourcePackEvent { pub entity: Entity, - /// The random ID for this request to download the resource pack. The packet - /// for replying to a resource pack push must contain the same ID. + /// The random ID for this request to download the resource pack. + /// + /// The packet for replying to a resource pack push must contain the same + /// ID. pub id: Uuid, pub url: String, pub hash: String, diff --git a/azalea-client/src/plugins/task_pool.rs b/azalea-client/src/plugins/task_pool.rs index 56ebc7cf..5e9031d7 100644 --- a/azalea-client/src/plugins/task_pool.rs +++ b/azalea-client/src/plugins/task_pool.rs @@ -34,8 +34,9 @@ fn tick_global_task_pools(_main_thread_marker: Option<NonSend<NonSendMarker>>) { tick_global_task_pools_on_main_thread(); } -/// Helper for configuring and creating the default task pools. For end-users -/// who want full control, set up [`TaskPoolPlugin`] +/// Helper for configuring and creating the default task pools. +/// +/// For end-users who want full control, set up [`TaskPoolPlugin`] #[derive(Clone, Resource)] pub struct TaskPoolOptions { /// If the number of physical cores is less than min_total_threads, force @@ -85,15 +86,6 @@ impl Default for TaskPoolOptions { } impl TaskPoolOptions { - // /// Create a configuration that forces using the given number of threads. - // pub fn with_num_threads(thread_count: usize) -> Self { - // TaskPoolOptions { - // min_total_threads: thread_count, - // max_total_threads: thread_count, - // ..Default::default() - // } - // } - /// Inserts the default thread pools into the given resource map based on /// the configured values pub fn create_default_pools(&self) { @@ -160,7 +152,9 @@ pub struct TaskPoolThreadAssignmentPolicy { /// Under no circumstance use more than this many threads for this pool pub max_threads: usize, /// Target using this percentage of total cores, clamped by min_threads and - /// max_threads. It is permitted to use 1.0 to try to use all remaining + /// max_threads. + /// + /// It is permitted to use 1.0 to try to use all remaining /// threads pub percent: f32, } |
