From 0ef05bb0d0cebb35dec5fa814d6d43d41e96ed89 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 15 Jul 2022 04:21:32 -0700 Subject: [PATCH] Add client velocity --- src/client.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client.rs b/src/client.rs index 9a3ba3b..f27e95f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -346,6 +346,13 @@ impl Client { } } + pub fn set_velocity(&mut self, velocity: impl Into>) { + self.send_packet(SetEntityMotion { + entity_id: VarInt(0), + velocity: velocity_to_packet_units(velocity.into()), + }); + } + /// Gets this client's yaw. pub fn yaw(&self) -> f32 { self.yaw @@ -1081,6 +1088,8 @@ impl Client { ) } + // Teleport the player. + // // This is done after the chunks are loaded so that the "downloading terrain" // screen is closed at the appropriate time. if self.flags.teleported_this_tick() { @@ -1096,6 +1105,7 @@ impl Client { }); } + // Send chat messages. for msg in self.msgs_to_send.drain(..) { send_packet( &mut self.send, @@ -1262,8 +1272,8 @@ impl Client { }, ); } - // Don't bother sending animations since it shouldn't be visible to - // the client. + // Don't bother sending animations for self since it shouldn't have + // any effect. } self.old_position = self.new_position;