aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-08-12 16:02:42 -0630
committermat <git@matdoes.dev>2025-08-12 16:02:42 -0630
commitf01579f70b4acc045559c1aca82d8d39a1f79f12 (patch)
tree327e52737e4c7254b971bfb1d03db64bebdd120a /azalea-client/src
parent7f4e3c583dd669561e8502822952fc9afe26e005 (diff)
downloadazalea-drasl-f01579f70b4acc045559c1aca82d8d39a1f79f12.tar.xz
Client::chat now takes Into<String> and doc fixes
Diffstat (limited to 'azalea-client/src')
-rw-r--r--azalea-client/src/entity_query.rs20
-rw-r--r--azalea-client/src/plugins/chat/mod.rs4
2 files changed, 11 insertions, 13 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(),
});
}
}