diff options
| author | mat <git@matdoes.dev> | 2024-02-24 06:02:11 -0600 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2024-02-24 06:02:11 -0600 |
| commit | 4eeda83ba4bdb5e20c765a46e43227f4f9b39b69 (patch) | |
| tree | 479d06d13870c17abfda96d704b21cc2eb85488b /azalea-client/src | |
| parent | 64fceff1cc65ee1dd1c72f08004e40179be9f9a4 (diff) | |
| download | azalea-drasl-4eeda83ba4bdb5e20c765a46e43227f4f9b39b69.tar.xz | |
add some more convenience functions
Diffstat (limited to 'azalea-client/src')
| -rw-r--r-- | azalea-client/src/movement.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs index 2f70a40e..ba47b7c8 100644 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -86,9 +86,7 @@ impl Client { /// Returns whether the player will try to jump next tick. pub fn jumping(&self) -> bool { - let mut ecs = self.ecs.lock(); - let jumping_ref = self.query::<&Jumping>(&mut ecs); - **jumping_ref + *self.component::<Jumping>() } /// Sets the direction the client is looking. `y_rot` is yaw (looking to the @@ -101,6 +99,14 @@ impl Client { (look_direction.y_rot, look_direction.x_rot) = (y_rot, x_rot); } + + /// Returns the direction the client is looking. The first value is the y + /// rotation (ie. yaw, looking to the side) and the second value is the x + /// rotation (ie. pitch, looking up and down). + pub fn direction(&self) -> (f32, f32) { + let look_direction = self.component::<LookDirection>(); + (look_direction.y_rot, look_direction.x_rot) + } } /// A component that contains the look direction that was last sent over the |
