aboutsummaryrefslogtreecommitdiff
path: root/azalea/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2026-03-30 10:02:22 +0600
committermat <git@matdoes.dev>2026-05-07 08:05:58 -1200
commit4af9762854aad30b7fdc40640618e465197f2148 (patch)
treeb3f00274ed277ed4a1fb6363b1f11e9f430c7535 /azalea/src
parentddef37118448b639ff56b86ae339e8913cb4ed11 (diff)
downloadazalea-drasl-4af9762854aad30b7fdc40640618e465197f2148.tar.xz
rename PhysicsState to ClientMovementState and add utility functions for it
Diffstat (limited to 'azalea/src')
-rw-r--r--azalea/src/client_impl/entity_query.rs4
-rw-r--r--azalea/src/client_impl/movement.rs15
-rw-r--r--azalea/src/pathfinder/execute/simulation.rs6
-rw-r--r--azalea/src/pathfinder/moves/mod.rs4
-rw-r--r--azalea/src/pathfinder/simulation.rs6
5 files changed, 23 insertions, 12 deletions
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(),