From c7b0c51274b5d8548c8a2f829b75dfbec4038be2 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 21 Jun 2022 23:19:31 -0500 Subject: [PATCH] Add move_to --- azalea-client/src/lib.rs | 1 + azalea-client/src/movement.rs | 24 ++++++++++++++++++++++++ bot/src/main.rs | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 azalea-client/src/movement.rs diff --git a/azalea-client/src/lib.rs b/azalea-client/src/lib.rs index 867f05a1..c3c37460 100755 --- a/azalea-client/src/lib.rs +++ b/azalea-client/src/lib.rs @@ -2,6 +2,7 @@ mod account; mod client; +mod movement; pub mod ping; mod player; diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs new file mode 100644 index 00000000..9f5cd27c --- /dev/null +++ b/azalea-client/src/movement.rs @@ -0,0 +1,24 @@ +use azalea_core::EntityPos; +use crate::Client; +use azalea_protocol::packets::game::serverbound_move_player_packet_pos_rot::ServerboundMovePlayerPacketPosRot; + +impl Client { + /// Set the client's position to the given coordinates. + pub async fn move_to(&mut self, pos: &EntityPos) { + self.conn + .lock() + .await + .write( + ServerboundMovePlayerPacketPosRot { + x: pos.x, + y: pos.y, + z: pos.z, + x_rot: 0.0, + y_rot: 0.0, + on_ground: false, + } + .get(), + ) + .await; + } +} diff --git a/bot/src/main.rs b/bot/src/main.rs index 6ff4cc0b..546a9244 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -6,7 +6,7 @@ async fn main() -> Result<(), Box> { println!("Hello, world!"); // let address = "95.111.249.143:10000"; - let address = "localhost:59021"; + let address = "localhost:57172"; // let response = azalea_client::ping::ping_server(&address.try_into().unwrap()) // .await // .unwrap();