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/src/plugins/inventory.rs | |
| parent | 1a1402954b07cd77615d0afc026c73b008787f51 (diff) | |
| download | azalea-drasl-ee2575794e91b9457a74a95daf1dcc707058cd58.tar.xz | |
upgrade deps and clean up lots of doc comments
Diffstat (limited to 'azalea-client/src/plugins/inventory.rs')
| -rw-r--r-- | azalea-client/src/plugins/inventory.rs | 57 |
1 files changed, 32 insertions, 25 deletions
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 |
