From 4eeda83ba4bdb5e20c765a46e43227f4f9b39b69 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 24 Feb 2024 06:02:11 -0600 Subject: add some more convenience functions --- azalea-client/src/movement.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'azalea-client/src') 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::() } /// 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::(); + (look_direction.y_rot, look_direction.x_rot) + } } /// A component that contains the look direction that was last sent over the -- cgit v1.2.3