diff options
| author | mat <git@matdoes.dev> | 2025-06-03 09:52:30 +0930 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-03 09:52:30 +0930 |
| commit | f3a5e91a8ccbcd03a239aa3565dbfddabb26fa76 (patch) | |
| tree | b9f34dda5ba68bbfc4159dd1631455c8dd84e2ad /azalea-client | |
| parent | 7517a207db658c98d5b97b3b3f44df6725c025a2 (diff) | |
| download | azalea-drasl-f3a5e91a8ccbcd03a239aa3565dbfddabb26fa76.tar.xz | |
fix issues when pathfinding to non-full blocks and add Client::view_inventory
Diffstat (limited to 'azalea-client')
| -rw-r--r-- | azalea-client/src/client.rs | 6 | ||||
| -rw-r--r-- | azalea-client/src/plugins/inventory.rs | 3 |
2 files changed, 4 insertions, 5 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 7b63ff12..02625326 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -342,13 +342,13 @@ impl Client { /// ``` /// # use azalea_client::{Client, mining::Mining}; /// # fn example(bot: &Client) { - /// let is_mining = bot.map_get_component::<Mining, _>(|m| m.is_some()); + /// let is_mining = bot.map_get_component::<Mining, _>(|m| m).is_some(); /// # } /// ``` - pub fn map_get_component<T: Component, R>(&self, f: impl FnOnce(Option<&T>) -> R) -> R { + pub fn map_get_component<T: Component, R>(&self, f: impl FnOnce(&T) -> R) -> Option<R> { let mut ecs = self.ecs.lock(); let value = self.query::<Option<&T>>(&mut ecs); - f(value) + value.map(f) } /// Get an `RwLock` with a reference to our (potentially shared) world. diff --git a/azalea-client/src/plugins/inventory.rs b/azalea-client/src/plugins/inventory.rs index 23651db3..a7e45ffb 100644 --- a/azalea-client/src/plugins/inventory.rs +++ b/azalea-client/src/plugins/inventory.rs @@ -95,8 +95,7 @@ impl Client { /// A component present on all local players that have an inventory. #[derive(Component, Debug, Clone)] pub struct Inventory { - /// A component that contains the player's inventory menu. This is - /// guaranteed to be a `Menu::Player`. + /// The player's inventory menu. This is guaranteed to be a `Menu::Player`. /// /// We keep it as a [`Menu`] since `Menu` has some useful functions that /// bare [`azalea_inventory::Player`] doesn't have. |
