diff options
Diffstat (limited to 'azalea/src/client_impl')
| -rw-r--r-- | azalea/src/client_impl/entity_query.rs | 4 | ||||
| -rw-r--r-- | azalea/src/client_impl/movement.rs | 15 |
2 files changed, 15 insertions, 4 deletions
diff --git a/azalea/src/client_impl/entity_query.rs b/azalea/src/client_impl/entity_query.rs index 27c3aa9a..df942ef2 100644 --- a/azalea/src/client_impl/entity_query.rs +++ b/azalea/src/client_impl/entity_query.rs @@ -9,7 +9,9 @@ use bevy_ecs::{ query::{QueryData, QueryEntityError, QueryFilter, QueryItem, ROQueryItem}, world::World, }; -use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard}; +use parking_lot::{ + MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLock, RwLockReadGuard, RwLockWriteGuard, +}; use crate::{Client, entity_ref::EntityRef}; diff --git a/azalea/src/client_impl/movement.rs b/azalea/src/client_impl/movement.rs index 905f8b75..9645f09e 100644 --- a/azalea/src/client_impl/movement.rs +++ b/azalea/src/client_impl/movement.rs @@ -1,7 +1,8 @@ use azalea_client::{ - PhysicsState, SprintDirection, StartSprintEvent, StartWalkEvent, WalkDirection, + ClientMovementState, SprintDirection, StartSprintEvent, StartWalkEvent, WalkDirection, }; use azalea_entity::{Jumping, LookDirection}; +use parking_lot::MappedRwLockReadGuard; use crate::Client; @@ -23,14 +24,14 @@ impl Client { } pub fn set_crouching(&self, crouching: bool) { - self.query_self::<&mut PhysicsState, _>(|mut p| p.trying_to_crouch = crouching); + self.query_self::<&mut ClientMovementState, _>(|mut p| p.trying_to_crouch = crouching); } /// Whether the client is currently trying to sneak. /// /// You may want to check the [`Pose`](azalea_entity::Pose) instead. pub fn crouching(&self) -> bool { - self.query_self::<&PhysicsState, _>(|p| p.trying_to_crouch) + self.query_self::<&ClientMovementState, _>(|p| p.trying_to_crouch) } /// Sets the direction the client is looking. @@ -77,6 +78,14 @@ impl Client { }); } + /// Returns the [`ClientMovementState`] data for this client. + /// + /// This includes the direction that we're walking/sprinting in, and whether + /// we're trying to sprint or crouch. + pub fn movement_state(&self) -> ClientMovementState { + self.component::<ClientMovementState>().clone() + } + /// Start sprinting in the given direction. /// /// To stop moving, call [`bot.walk(WalkDirection::None)`](Self::walk). |
