diff options
| author | mat <git@matdoes.dev> | 2023-08-25 02:34:31 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-08-25 02:34:31 -0500 |
| commit | d5465cd28e43d48b3e913fdb1161eb907e4d80d0 (patch) | |
| tree | b0962ac1bd09b434c67296c038ef3b26245ce6d7 /azalea-client/src/movement.rs | |
| parent | 9c31f8033f006d5f505ce97e359638d6c1136859 (diff) | |
| download | azalea-drasl-d5465cd28e43d48b3e913fdb1161eb907e4d80d0.tar.xz | |
add basic pathfinding test
Diffstat (limited to 'azalea-client/src/movement.rs')
| -rw-r--r-- | azalea-client/src/movement.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs index 0bda9b15..ad26f49c 100644 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -1,7 +1,5 @@ use crate::client::Client; -use crate::local_player::{ - update_in_loaded_chunk, LocalPlayer, LocalPlayerInLoadedChunk, PhysicsState, -}; +use crate::local_player::{update_in_loaded_chunk, LocalPlayer, LocalPlayerInLoadedChunk}; use azalea_entity::{metadata::Sprinting, Attributes, Jumping}; use azalea_entity::{LastSentPosition, LookDirection, Physics, Position}; use azalea_physics::{force_jump_listener, PhysicsSet}; @@ -102,6 +100,23 @@ pub struct LastSentLookDirection { pub y_rot: f32, } +/// Component for entities that can move and sprint. Usually only in +/// [`LocalPlayer`] entities. +#[derive(Default, Component, Clone)] +pub struct PhysicsState { + /// Minecraft only sends a movement packet either after 20 ticks or if the + /// player moved enough. This is that tick counter. + pub position_remainder: u32, + pub was_sprinting: bool, + // Whether we're going to try to start sprinting this tick. Equivalent to + // holding down ctrl for a tick. + pub trying_to_sprint: bool, + + pub move_direction: WalkDirection, + pub forward_impulse: f32, + pub left_impulse: f32, +} + #[allow(clippy::type_complexity)] pub(crate) fn send_position( mut query: Query< |
