diff options
| author | mat <git@matdoes.dev> | 2026-03-30 10:02:22 +0600 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-05-07 08:05:58 -1200 |
| commit | 4af9762854aad30b7fdc40640618e465197f2148 (patch) | |
| tree | b3f00274ed277ed4a1fb6363b1f11e9f430c7535 | |
| parent | ddef37118448b639ff56b86ae339e8913cb4ed11 (diff) | |
| download | azalea-drasl-4af9762854aad30b7fdc40640618e465197f2148.tar.xz | |
rename PhysicsState to ClientMovementState and add utility functions for it
| -rw-r--r-- | azalea-client/src/client.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/lib.rs | 5 | ||||
| -rw-r--r-- | azalea-client/src/plugins/interact/mod.rs | 6 | ||||
| -rw-r--r-- | azalea-client/src/plugins/movement.rs | 30 | ||||
| -rw-r--r-- | azalea-client/tests/simulation/correct_sneak_movement.rs | 4 | ||||
| -rw-r--r-- | azalea-client/tests/simulation/correct_sprint_sneak_movement.rs | 4 | ||||
| -rw-r--r-- | azalea-physics/src/client_movement.rs | 181 | ||||
| -rw-r--r-- | azalea-physics/src/collision/mod.rs | 4 | ||||
| -rw-r--r-- | azalea-physics/src/lib.rs | 2 | ||||
| -rw-r--r-- | azalea-physics/src/local_player.rs | 69 | ||||
| -rw-r--r-- | azalea-physics/src/travel.rs | 4 | ||||
| -rw-r--r-- | azalea/src/client_impl/entity_query.rs | 4 | ||||
| -rw-r--r-- | azalea/src/client_impl/movement.rs | 15 | ||||
| -rw-r--r-- | azalea/src/pathfinder/execute/simulation.rs | 6 | ||||
| -rw-r--r-- | azalea/src/pathfinder/moves/mod.rs | 4 | ||||
| -rw-r--r-- | azalea/src/pathfinder/simulation.rs | 6 |
16 files changed, 242 insertions, 106 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index b9a4e824..e86e428a 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -10,7 +10,7 @@ use azalea_core::tick::GameTick; use azalea_entity::{ EntityUpdateSystems, PlayerAbilities, indexing::EntityIdIndex, inventory::Inventory, }; -use azalea_physics::local_player::PhysicsState; +use azalea_physics::client_movement::ClientMovementState; use azalea_world::Worlds; use bevy_app::{App, AppExit, Plugin, PluginsState, SubApp, Update}; use bevy_ecs::{ @@ -56,7 +56,7 @@ pub struct LocalPlayerBundle { #[derive(Bundle, Default)] pub struct JoinedClientBundle { // note that WorldHolder isn't here because it's set slightly before we fully join the world - pub physics_state: PhysicsState, + pub physics_state: ClientMovementState, pub inventory: Inventory, pub tab_list: TabList, pub block_state_prediction_handler: BlockStatePredictionHandler, diff --git a/azalea-client/src/lib.rs b/azalea-client/src/lib.rs index fbe88bf7..da4d3884 100644 --- a/azalea-client/src/lib.rs +++ b/azalea-client/src/lib.rs @@ -15,7 +15,10 @@ pub mod test_utils; #[deprecated = "moved to `account::Account`."] pub type Account = account::Account; -pub use azalea_physics::local_player::{PhysicsState, SprintDirection, WalkDirection}; +pub use azalea_physics::client_movement::{ClientMovementState, SprintDirection, WalkDirection}; +#[deprecated = "renamed to `ClientMovementState`."] +pub type PhysicsState = ClientMovementState; + pub use azalea_protocol::common::client_information::ClientInformation; // Re-export bevy-tasks so plugins can make sure that they're using the same // version. diff --git a/azalea-client/src/plugins/interact/mod.rs b/azalea-client/src/plugins/interact/mod.rs index 0eb43818..3db026b9 100644 --- a/azalea-client/src/plugins/interact/mod.rs +++ b/azalea-client/src/plugins/interact/mod.rs @@ -22,8 +22,8 @@ use azalea_entity::{ }; use azalea_inventory::{ItemStack, ItemStackData, components}; use azalea_physics::{ - PhysicsSystems, collision::entity_collisions::update_last_bounding_box, - local_player::PhysicsState, + PhysicsSystems, client_movement::ClientMovementState, + collision::entity_collisions::update_last_bounding_box, }; use azalea_protocol::packets::game::{ ServerboundInteract, ServerboundUseItem, s_interact::InteractionHand, @@ -312,7 +312,7 @@ pub struct EntityInteractEvent { pub fn handle_entity_interact( trigger: On<EntityInteractEvent>, mut commands: Commands, - client_query: Query<(&PhysicsState, &EntityIdIndex, &HitResultComponent)>, + client_query: Query<(&ClientMovementState, &EntityIdIndex, &HitResultComponent)>, target_query: Query<&Position>, ) { let Some((physics_state, entity_id_index, hit_result)) = client_query.get(trigger.client).ok() diff --git a/azalea-client/src/plugins/movement.rs b/azalea-client/src/plugins/movement.rs index 6e2da752..dfd1f4b2 100644 --- a/azalea-client/src/plugins/movement.rs +++ b/azalea-client/src/plugins/movement.rs @@ -13,8 +13,8 @@ use azalea_entity::{ }; use azalea_physics::{ PhysicsSystems, ai_step, + client_movement::{ClientMovementState, SprintDirection, WalkDirection}, collision::entity_collisions::{AabbQuery, CollidableEntityQuery, update_last_bounding_box}, - local_player::{PhysicsState, SprintDirection, WalkDirection}, travel::{no_collision, travel}, }; use azalea_protocol::{ @@ -92,7 +92,7 @@ pub fn send_position( Entity, &Position, &LookDirection, - &mut PhysicsState, + &mut ClientMovementState, &mut LastSentPosition, &mut Physics, &mut LastSentLookDirection, @@ -196,7 +196,12 @@ pub fn send_position( #[derive(Clone, Component, Debug, Default, Eq, PartialEq)] pub struct LastSentInput(pub ServerboundPlayerInput); pub fn send_player_input_packet( - mut query: Query<(Entity, &PhysicsState, &Jumping, Option<&LastSentInput>)>, + mut query: Query<( + Entity, + &ClientMovementState, + &Jumping, + Option<&LastSentInput>, + )>, mut commands: Commands, ) { for (entity, physics_state, jumping, last_sent_input) in query.iter_mut() { @@ -227,7 +232,12 @@ pub fn send_player_input_packet( } pub fn send_sprinting_if_needed( - mut query: Query<(Entity, &MinecraftEntityId, &Sprinting, &mut PhysicsState)>, + mut query: Query<( + Entity, + &MinecraftEntityId, + &Sprinting, + &mut ClientMovementState, + )>, mut commands: Commands, ) { for (entity, minecraft_entity_id, sprinting, mut physics_state) in query.iter_mut() { @@ -253,7 +263,7 @@ pub fn send_sprinting_if_needed( /// Updates the [`PhysicsState::move_vector`] based on the /// [`PhysicsState::move_direction`]. -pub(crate) fn tick_controls(mut query: Query<&mut PhysicsState>) { +pub(crate) fn tick_controls(mut query: Query<&mut ClientMovementState>) { for mut physics_state in query.iter_mut() { let mut forward_impulse: f32 = 0.; let mut left_impulse: f32 = 0.; @@ -292,7 +302,7 @@ pub fn local_player_ai_step( mut query: Query< ( Entity, - &PhysicsState, + &ClientMovementState, &PlayerAbilities, &metadata::Swimming, &metadata::SleepingPos, @@ -481,7 +491,7 @@ pub struct StartWalkEvent { /// [`StartWalkEvent`]. pub fn handle_walk( mut events: MessageReader<StartWalkEvent>, - mut query: Query<(&mut PhysicsState, &mut Sprinting, &mut Attributes)>, + mut query: Query<(&mut ClientMovementState, &mut Sprinting, &mut Attributes)>, ) { for event in events.read() { if let Ok((mut physics_state, mut sprinting, mut attributes)) = query.get_mut(event.entity) @@ -504,7 +514,7 @@ pub struct StartSprintEvent { /// The system that makes the player start sprinting when they receive a /// [`StartSprintEvent`]. pub fn handle_sprint( - mut query: Query<&mut PhysicsState>, + mut query: Query<&mut ClientMovementState>, mut events: MessageReader<StartSprintEvent>, ) { for event in events.read() { @@ -542,7 +552,7 @@ fn set_sprinting( } // Whether the player is moving fast enough to be able to start sprinting. -fn has_enough_impulse_to_start_sprinting(physics_state: &PhysicsState) -> bool { +fn has_enough_impulse_to_start_sprinting(physics_state: &ClientMovementState) -> bool { // if self.underwater() { // self.has_forward_impulse() // } else { @@ -585,7 +595,7 @@ pub fn update_pose( Entity, &mut Pose, &Physics, - &PhysicsState, + &ClientMovementState, &LocalGameMode, &WorldHolder, &Position, diff --git a/azalea-client/tests/simulation/correct_sneak_movement.rs b/azalea-client/tests/simulation/correct_sneak_movement.rs index 73abb26f..e283301e 100644 --- a/azalea-client/tests/simulation/correct_sneak_movement.rs +++ b/azalea-client/tests/simulation/correct_sneak_movement.rs @@ -1,4 +1,4 @@ -use azalea_client::{PhysicsState, StartWalkEvent, WalkDirection, test_utils::prelude::*}; +use azalea_client::{ClientMovementState, StartWalkEvent, WalkDirection, test_utils::prelude::*}; use azalea_core::position::{BlockPos, ChunkPos, Vec3}; use azalea_entity::LookDirection; use azalea_protocol::{ @@ -49,7 +49,7 @@ fn test_correct_sneak_movement() { simulation.tick(); sent_packets.clear(); - simulation.with_component_mut::<PhysicsState>(|p| p.trying_to_crouch = true); + simulation.with_component_mut::<ClientMovementState>(|p| p.trying_to_crouch = true); simulation.tick(); sent_packets.expect("PlayerInput", |p| { matches!( diff --git a/azalea-client/tests/simulation/correct_sprint_sneak_movement.rs b/azalea-client/tests/simulation/correct_sprint_sneak_movement.rs index a96c7024..eed7aa07 100644 --- a/azalea-client/tests/simulation/correct_sprint_sneak_movement.rs +++ b/azalea-client/tests/simulation/correct_sprint_sneak_movement.rs @@ -1,4 +1,4 @@ -use azalea_client::{PhysicsState, SprintDirection, StartSprintEvent, test_utils::prelude::*}; +use azalea_client::{ClientMovementState, SprintDirection, StartSprintEvent, test_utils::prelude::*}; use azalea_core::position::{BlockPos, ChunkPos, Vec3}; use azalea_entity::LookDirection; use azalea_protocol::{ @@ -85,7 +85,7 @@ fn test_correct_sprint_sneak_movement() { }); sent_packets.expect_tick_end(); sent_packets.expect_empty(); - simulation.with_component_mut::<PhysicsState>(|p| p.trying_to_crouch = true); + simulation.with_component_mut::<ClientMovementState>(|p| p.trying_to_crouch = true); simulation.tick(); sent_packets.expect("PlayerInput", |p| { diff --git a/azalea-physics/src/client_movement.rs b/azalea-physics/src/client_movement.rs new file mode 100644 index 00000000..a3bddb34 --- /dev/null +++ b/azalea-physics/src/client_movement.rs @@ -0,0 +1,181 @@ +use azalea_core::position::Vec2; +use bevy_ecs::component::Component; + +/// Component for entities that can move and sprint. +/// +/// Usually only present for [`LocalEntity`]s. +/// +/// [`LocalEntity`]: azalea_entity::LocalEntity +#[derive(Clone, Component, Default)] +pub struct ClientMovementState { + /// 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, + + /// Whether our player is currently trying to sneak. + /// + /// This is distinct from + /// [`AbstractEntityShiftKeyDown`](azalea_entity::metadata::AbstractEntityShiftKeyDown), + /// which is a metadata value that is controlled by the server and affects + /// how the nametags of other entities are displayed. + /// + /// To check whether we're actually sneaking, you can check the + /// [`Crouching`](azalea_entity::Crouching) or [`Pose`](azalea_entity::Pose) + /// components. + pub trying_to_crouch: bool, + + pub move_direction: WalkDirection, + pub move_vector: Vec2, +} + +/// A direction that a player can walk in, including none. +/// +/// Superset of [`SprintDirection`]. +/// +/// This can be freely converted to and from [`DirectionStates`]. +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub enum WalkDirection { + #[default] + None, + Forward, + Backward, + Left, + Right, + ForwardRight, + ForwardLeft, + BackwardRight, + BackwardLeft, +} +impl WalkDirection { + /// Returns true if the direction is forward, forward-right, or + /// forward-left. + pub fn forward(self) -> bool { + DirectionStates::from(self).forward + } + /// Returns true if the direction is backward, backward-right, or + /// backward-left. + pub fn backward(self) -> bool { + DirectionStates::from(self).backward + } + /// Returns true if the direction is left, forward-left, or backward-left. + pub fn left(self) -> bool { + DirectionStates::from(self).left + } + /// Returns true if the direction is right, forward-right, or + /// backward-right. + pub fn right(self) -> bool { + DirectionStates::from(self).right + } + + pub fn set_forward(&mut self, value: bool) { + let mut d = DirectionStates::from(*self); + d.forward = value; + *self = d.into(); + } + pub fn set_backward(&mut self, value: bool) { + let mut d = DirectionStates::from(*self); + d.backward = value; + *self = d.into(); + } + pub fn set_left(&mut self, value: bool) { + let mut d = DirectionStates::from(*self); + d.left = value; + *self = d.into(); + } + pub fn set_right(&mut self, value: bool) { + let mut d = DirectionStates::from(*self); + d.right = value; + *self = d.into(); + } +} +/// A struct containing fields for each direction. +/// +/// This can be freely converted to and from a [`WalkDirection`], and may +/// simplify certain movement direction checks. +#[derive(Default)] +pub struct DirectionStates { + pub forward: bool, + pub backward: bool, + pub left: bool, + pub right: bool, +} +impl From<WalkDirection> for DirectionStates { + fn from(d: WalkDirection) -> Self { + let mut s = Self::default(); + match d { + WalkDirection::None => {} + WalkDirection::Forward => s.forward = true, + WalkDirection::Backward => s.backward = true, + WalkDirection::Left => s.left = true, + WalkDirection::Right => s.right = true, + WalkDirection::ForwardRight => { + s.forward = true; + s.right = true + } + WalkDirection::ForwardLeft => { + s.forward = true; + s.left = true + } + WalkDirection::BackwardRight => { + s.backward = true; + s.right = true + } + WalkDirection::BackwardLeft => { + s.forward = true; + s.left = true + } + }; + s + } +} +impl From<DirectionStates> for WalkDirection { + fn from(d: DirectionStates) -> Self { + let left = d.left && !d.right; + let right = d.right && !d.left; + + if d.forward && !d.backward { + if right { + return Self::ForwardRight; + } else if left { + return Self::ForwardLeft; + } + return Self::Forward; + } else if d.backward && !d.forward { + if right { + return Self::BackwardRight; + } else if left { + return Self::BackwardLeft; + } + return Self::Backward; + } + if right { + return Self::Right; + } else if left { + return Self::Left; + } + return Self::None; + } +} + +/// The directions that a player can sprint in. It's a subset of +/// [`WalkDirection`]. +#[derive(Clone, Copy, Debug)] +pub enum SprintDirection { + Forward, + ForwardRight, + ForwardLeft, +} + +impl From<SprintDirection> for WalkDirection { + fn from(d: SprintDirection) -> Self { + match d { + SprintDirection::Forward => WalkDirection::Forward, + SprintDirection::ForwardRight => WalkDirection::ForwardRight, + SprintDirection::ForwardLeft => WalkDirection::ForwardLeft, + } + } +} diff --git a/azalea-physics/src/collision/mod.rs b/azalea-physics/src/collision/mod.rs index 430b91ad..6dfe2e00 100644 --- a/azalea-physics/src/collision/mod.rs +++ b/azalea-physics/src/collision/mod.rs @@ -29,7 +29,7 @@ use tracing::warn; use self::world_collisions::get_block_collisions; use crate::{ - collision::entity_collisions::AabbQuery, local_player::PhysicsState, travel::no_collision, + client_movement::ClientMovementState, collision::entity_collisions::AabbQuery, travel::no_collision, }; #[derive(Clone, Copy, Debug, Eq, PartialEq)] @@ -116,7 +116,7 @@ pub struct MoveCtx<'world, 'state, 'a, 'b> { pub source_entity: Entity, pub aabb_query: &'a AabbQuery<'world, 'state, 'b>, pub collidable_entity_query: &'a CollidableEntityQuery<'world, 'state>, - pub physics_state: Option<&'a PhysicsState>, + pub physics_state: Option<&'a ClientMovementState>, pub attributes: &'a Attributes, pub abilities: Option<&'a PlayerAbilities>, diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs index 491bda0e..8b0443ce 100644 --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -1,10 +1,10 @@ #![doc = include_str!("../README.md")] #![feature(trait_alias)] +pub mod client_movement; pub mod clip; pub mod collision; pub mod fluids; -pub mod local_player; pub mod travel; use std::collections::HashSet; diff --git a/azalea-physics/src/local_player.rs b/azalea-physics/src/local_player.rs deleted file mode 100644 index 75bbbfb9..00000000 --- a/azalea-physics/src/local_player.rs +++ /dev/null @@ -1,69 +0,0 @@ -use azalea_core::position::Vec2; -use bevy_ecs::component::Component; - -/// Component for entities that can move and sprint. -/// -/// Usually only present for [`LocalEntity`]s. -/// -/// [`LocalEntity`]: azalea_entity::LocalEntity -#[derive(Clone, Component, Default)] -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, - - /// Whether our player is currently trying to sneak. - /// - /// This is distinct from - /// [`AbstractEntityShiftKeyDown`](azalea_entity::metadata::AbstractEntityShiftKeyDown), - /// which is a metadata value that is controlled by the server and affects - /// how the nametags of other entities are displayed. - /// - /// To check whether we're actually sneaking, you can check the - /// [`Crouching`](azalea_entity::Crouching) or [`Pose`](azalea_entity::Pose) - /// components. - pub trying_to_crouch: bool, - - pub move_direction: WalkDirection, - pub move_vector: Vec2, -} - -/// A direction that a player can walk in, including none. -/// -/// Superset of [`SprintDirection`]. -#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] -pub enum WalkDirection { - #[default] - None, - Forward, - Backward, - Left, - Right, - ForwardRight, - ForwardLeft, - BackwardRight, - BackwardLeft, -} - -/// The directions that a player can sprint in. It's a subset of -/// [`WalkDirection`]. -#[derive(Clone, Copy, Debug)] -pub enum SprintDirection { - Forward, - ForwardRight, - ForwardLeft, -} - -impl From<SprintDirection> for WalkDirection { - fn from(d: SprintDirection) -> Self { - match d { - SprintDirection::Forward => WalkDirection::Forward, - SprintDirection::ForwardRight => WalkDirection::ForwardRight, - SprintDirection::ForwardLeft => WalkDirection::ForwardLeft, - } - } -} diff --git a/azalea-physics/src/travel.rs b/azalea-physics/src/travel.rs index 257e2924..c6bc321b 100644 --- a/azalea-physics/src/travel.rs +++ b/azalea-physics/src/travel.rs @@ -11,6 +11,7 @@ use azalea_world::{World, WorldName, Worlds}; use bevy_ecs::prelude::*; use crate::{ + client_movement::ClientMovementState, collision::{ MoveCtx, MoverType, Shapes, entity_collisions::{AabbQuery, CollidableEntityQuery, get_entity_collisions}, @@ -18,7 +19,6 @@ use crate::{ world_collisions::{get_block_and_liquid_collisions, get_block_collisions}, }, get_block_pos_below_that_affects_movement, handle_relative_friction_and_calculate_movement, - local_player::PhysicsState, }; /// Move the entity with the given acceleration while handling friction, @@ -32,7 +32,7 @@ pub fn travel( &WorldName, &OnClimbable, &Jumping, - Option<&PhysicsState>, + Option<&ClientMovementState>, Option<&Sprinting>, Option<&Pose>, Option<&PlayerAbilities>, diff --git a/azalea/src/client_impl/entity_query.rs b/azalea/src/client_impl/entity_query.rs index 27c3aa9a..df942ef2 100644 --- a/azalea/src/client_impl/entity_query.rs +++ b/azalea/src/client_impl/entity_query.rs @@ -9,7 +9,9 @@ use bevy_ecs::{ query::{QueryData, QueryEntityError, QueryFilter, QueryItem, ROQueryItem}, world::World, }; -use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard}; +use parking_lot::{ + MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLock, RwLockReadGuard, RwLockWriteGuard, +}; use crate::{Client, entity_ref::EntityRef}; diff --git a/azalea/src/client_impl/movement.rs b/azalea/src/client_impl/movement.rs index 905f8b75..9645f09e 100644 --- a/azalea/src/client_impl/movement.rs +++ b/azalea/src/client_impl/movement.rs @@ -1,7 +1,8 @@ use azalea_client::{ - PhysicsState, SprintDirection, StartSprintEvent, StartWalkEvent, WalkDirection, + ClientMovementState, SprintDirection, StartSprintEvent, StartWalkEvent, WalkDirection, }; use azalea_entity::{Jumping, LookDirection}; +use parking_lot::MappedRwLockReadGuard; use crate::Client; @@ -23,14 +24,14 @@ impl Client { } pub fn set_crouching(&self, crouching: bool) { - self.query_self::<&mut PhysicsState, _>(|mut p| p.trying_to_crouch = crouching); + self.query_self::<&mut ClientMovementState, _>(|mut p| p.trying_to_crouch = crouching); } /// Whether the client is currently trying to sneak. /// /// You may want to check the [`Pose`](azalea_entity::Pose) instead. pub fn crouching(&self) -> bool { - self.query_self::<&PhysicsState, _>(|p| p.trying_to_crouch) + self.query_self::<&ClientMovementState, _>(|p| p.trying_to_crouch) } /// Sets the direction the client is looking. @@ -77,6 +78,14 @@ impl Client { }); } + /// Returns the [`ClientMovementState`] data for this client. + /// + /// This includes the direction that we're walking/sprinting in, and whether + /// we're trying to sprint or crouch. + pub fn movement_state(&self) -> ClientMovementState { + self.component::<ClientMovementState>().clone() + } + /// Start sprinting in the given direction. /// /// To stop moving, call [`bot.walk(WalkDirection::None)`](Self::walk). diff --git a/azalea/src/pathfinder/execute/simulation.rs b/azalea/src/pathfinder/execute/simulation.rs index 1b010cca..6a79d077 100644 --- a/azalea/src/pathfinder/execute/simulation.rs +++ b/azalea/src/pathfinder/execute/simulation.rs @@ -6,7 +6,7 @@ use std::{borrow::Cow, time::Instant}; use azalea_client::{ - PhysicsState, SprintDirection, StartSprintEvent, StartWalkEvent, + ClientMovementState, SprintDirection, StartSprintEvent, StartWalkEvent, local_player::WorldHolder, mining::{Mining, MiningSystems, StartMiningBlockEvent}, }; @@ -107,7 +107,7 @@ pub fn tick_execute_path( &mut LookDirection, &Position, &Physics, - &PhysicsState, + &ClientMovementState, Option<&Mining>, &WorldHolder, &Attributes, @@ -398,7 +398,7 @@ fn run_one_simulation( direction: SprintDirection::Forward, }); } else if ecs - .get::<PhysicsState>(sim.entity) + .get::<ClientMovementState>(sim.entity) .map(|p| p.was_sprinting) .unwrap_or_default() { diff --git a/azalea/src/pathfinder/moves/mod.rs b/azalea/src/pathfinder/moves/mod.rs index 4e621a10..c0a85fe6 100644 --- a/azalea/src/pathfinder/moves/mod.rs +++ b/azalea/src/pathfinder/moves/mod.rs @@ -9,7 +9,7 @@ use std::{ use azalea_block::BlockState; use azalea_client::{ - PhysicsState, SprintDirection, StartSprintEvent, StartWalkEvent, WalkDirection, + ClientMovementState, SprintDirection, StartSprintEvent, StartWalkEvent, WalkDirection, inventory::SetSelectedHotbarSlotEvent, mining::StartMiningBlockEvent, }; use azalea_core::position::{BlockPos, Vec3}; @@ -134,7 +134,7 @@ impl ExecuteCtx<'_, '_, '_, '_, '_, '_, '_, '_> { self.commands .entity(self.entity) .queue(move |mut entity: EntityWorldMut<'_>| { - if let Some(mut physics_state) = entity.get_mut::<PhysicsState>() { + if let Some(mut physics_state) = entity.get_mut::<ClientMovementState>() { physics_state.trying_to_crouch = sneaking; } }); diff --git a/azalea/src/pathfinder/simulation.rs b/azalea/src/pathfinder/simulation.rs index 82d93370..89fefaa9 100644 --- a/azalea/src/pathfinder/simulation.rs +++ b/azalea/src/pathfinder/simulation.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use azalea_client::{ - PhysicsState, interact::BlockStatePredictionHandler, local_player::LocalGameMode, + ClientMovementState, interact::BlockStatePredictionHandler, local_player::LocalGameMode, mining::MineBundle, }; use azalea_core::{ @@ -24,7 +24,7 @@ use uuid::Uuid; pub struct SimulatedPlayerBundle { pub position: Position, pub physics: Physics, - pub physics_state: PhysicsState, + pub physics_state: ClientMovementState, pub look_direction: LookDirection, pub attributes: Attributes, pub inventory: Inventory, @@ -37,7 +37,7 @@ impl SimulatedPlayerBundle { SimulatedPlayerBundle { position: Position::new(position), physics: Physics::new(&dimensions, position), - physics_state: PhysicsState::default(), + physics_state: ClientMovementState::default(), look_direction: LookDirection::default(), attributes: Attributes::new(EntityKind::Player), inventory: Inventory::default(), |
