diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-07-07 05:58:44 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-07 05:58:44 +0000 |
| commit | 31e5629ce1c8267802bbcb9d03b60a299d474e59 (patch) | |
| tree | 5968b48af9b0c30149e908b043966c41dda0a61d /azalea-client/src/movement.rs | |
| parent | 27edd4f578e7b64fdaacefa26f691e2148707a8c (diff) | |
| parent | 37d854c799236650da3deb025d8b32693531a27f (diff) | |
| download | azalea-drasl-31e5629ce1c8267802bbcb9d03b60a299d474e59.tar.xz | |
Merge branch 'main' into 1.19.1
Diffstat (limited to 'azalea-client/src/movement.rs')
| -rw-r--r-- | azalea-client/src/movement.rs | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs index f74d48df..4f99984f 100644 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -5,24 +5,21 @@ 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> { - println!("obtaining lock on state"); - let mut state_lock = self.state.lock().unwrap(); - println!("obtained lock on state"); + { + let mut dimension_lock = self.dimension.lock().unwrap(); + let dimension = dimension_lock.as_mut().unwrap(); - let world = state_lock.world.as_ref().unwrap(); + let player_lock = self.player.lock().unwrap(); - let player = &state_lock.player; - let player_id = if let Some(player) = player.entity(world) { - player.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()); + }; - let world = state_lock.world.as_mut().unwrap(); - world.move_entity(player_id, new_pos)?; - drop(state_lock); + dimension.move_entity(player_id, new_pos)?; + } - println!("obtaining lock on conn"); self.conn .lock() .await @@ -38,7 +35,6 @@ impl Client { .get(), ) .await; - println!("obtained lock on conn"); Ok(()) } |
