diff options
| -rw-r--r-- | azalea-client/src/entity_query.rs | 20 | ||||
| -rw-r--r-- | azalea-client/src/plugins/chat/mod.rs | 4 | ||||
| -rw-r--r-- | azalea/examples/echo.rs | 2 | ||||
| -rw-r--r-- | azalea/examples/testbot/commands.rs | 4 |
4 files changed, 14 insertions, 16 deletions
diff --git a/azalea-client/src/entity_query.rs b/azalea-client/src/entity_query.rs index 49119b98..84fcf9e7 100644 --- a/azalea-client/src/entity_query.rs +++ b/azalea-client/src/entity_query.rs @@ -54,7 +54,7 @@ impl Client { /// use bevy_ecs::query::With; /// /// # fn example(mut bot: Client, sender_name: String) { - /// let entity = bot.entity_by::<With<Player>, (&GameProfileComponent,)>( + /// let entity = bot.any_entity_by::<With<Player>, (&GameProfileComponent,)>( /// |(profile,): &(&GameProfileComponent,)| profile.name == sender_name, /// ); /// if let Some(entity) = entity { @@ -86,23 +86,21 @@ impl Client { /// /// # Example /// ``` - /// use azalea_entity::{Position, metadata::Player, LocalEntity}; - /// use bevy_ecs::query::With; + /// use azalea_entity::{LocalEntity, Position, metadata::Player}; + /// use bevy_ecs::query::{With, Without}; /// /// # fn example(mut bot: azalea_client::Client, sender_name: String) { - /// // look at the nearest player - /// if let Some(closest_player) = bot - /// .entities_by::<(With<Player>, Without<LocalEntity>), ()>(|_: &()| true) - /// .first() + /// // get the position of the nearest player + /// if let Some(nearest_player) = + /// bot.nearest_entity_by::<(With<Player>, Without<LocalEntity>), ()>(|_: &()| true) /// { - /// let closest_player_pos = *bot.entity_component::<Position>(*closest_player); - /// bot.look_at(closest_player_pos.up(1.62)); - /// } + /// let nearest_player_pos = *bot.entity_component::<Position>(nearest_player); + /// bot.chat(format!("You are at {nearest_player_pos}")); /// } + /// # } /// ``` /// /// [`Entity`]: bevy_ecs::entity::Entity - /// [`Instance`]: azalea_world::Instance pub fn nearest_entity_by<F: QueryFilter, Q: QueryData>( &self, predicate: impl EntityPredicate<Q, F>, diff --git a/azalea-client/src/plugins/chat/mod.rs b/azalea-client/src/plugins/chat/mod.rs index 856184cc..daeacc2e 100644 --- a/azalea-client/src/plugins/chat/mod.rs +++ b/azalea-client/src/plugins/chat/mod.rs @@ -192,10 +192,10 @@ impl Client { /// # Ok(()) /// # } /// ``` - pub fn chat(&self, content: &str) { + pub fn chat(&self, content: impl Into<String>) { self.ecs.lock().send_event(SendChatEvent { entity: self.entity, - content: content.to_string(), + content: content.into(), }); } } diff --git a/azalea/examples/echo.rs b/azalea/examples/echo.rs index 09c3d5d3..0f59be2a 100644 --- a/azalea/examples/echo.rs +++ b/azalea/examples/echo.rs @@ -25,7 +25,7 @@ async fn handle(bot: Client, event: Event, _state: State) -> anyhow::Result<()> // ignore our own messages return Ok(()); } - bot.chat(&content); + bot.chat(content); } Ok(()) diff --git a/azalea/examples/testbot/commands.rs b/azalea/examples/testbot/commands.rs index 7486780e..1616b82e 100644 --- a/azalea/examples/testbot/commands.rs +++ b/azalea/examples/testbot/commands.rs @@ -23,9 +23,9 @@ impl CommandSource { let message = message.into(); if self.chat.is_whisper() { self.bot - .chat(&format!("/w {} {message}", self.chat.sender().unwrap())); + .chat(format!("/w {} {message}", self.chat.sender().unwrap())); } else { - self.bot.chat(&message); + self.bot.chat(message); } } |
