From e8deda5d2e45eb634700614009cbcc5b35949e26 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 25 Jun 2022 17:37:29 -0500 Subject: clippo --- azalea-client/src/client.rs | 6 +++--- azalea-client/src/movement.rs | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'azalea-client/src') diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 9b3f7cdf..e2967a10 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -155,8 +155,8 @@ impl Client { // we got the GameConnection, so the server is now connected :) let client = Client { - game_profile: game_profile.clone(), - conn: conn.clone(), + game_profile, + conn, player: Arc::new(Mutex::new(Player::default())), dimension: Arc::new(Mutex::new(None)), }; @@ -167,7 +167,7 @@ impl Client { // read the error to see where the issue is // you might be able to just drop the lock or put it in its own scope to fix tokio::spawn(Self::protocol_loop(client.clone(), tx.clone())); - tokio::spawn(Self::game_tick_loop(client.clone(), tx.clone())); + tokio::spawn(Self::game_tick_loop(client.clone(), tx)); Ok((client, rx)) } diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs index 5247e0f0..4f99984f 100644 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -5,20 +5,20 @@ use azalea_protocol::packets::game::serverbound_move_player_packet_pos_rot::Serv impl Client { /// Set the client's position to the given coordinates. pub async fn move_to(&mut self, new_pos: EntityPos) -> Result<(), String> { - let mut dimension_lock = self.dimension.lock().unwrap(); - let dimension = dimension_lock.as_mut().unwrap(); + { + let mut dimension_lock = self.dimension.lock().unwrap(); + let dimension = dimension_lock.as_mut().unwrap(); - let player_lock = self.player.lock().unwrap(); + let player_lock = self.player.lock().unwrap(); - let player_id = if let Some(player_lock) = player_lock.entity(dimension) { - player_lock.id - } else { - return Err("Player entity not found".to_string()); - }; + let player_id = if let Some(player_lock) = player_lock.entity(dimension) { + player_lock.id + } else { + return Err("Player entity not found".to_string()); + }; - dimension.move_entity(player_id, new_pos)?; - drop(dimension_lock); - drop(player_lock); + dimension.move_entity(player_id, new_pos)?; + } self.conn .lock() -- cgit v1.2.3