aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/plugins/movement.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-12-27 22:02:00 -0600
committerGitHub <noreply@github.com>2025-12-27 22:02:00 -0600
commit9513f42e87f64c409cdb2a100500a50e5a713bac (patch)
treebb6aa8b6d50fddf967bcb1f759e023754ea84e49 /azalea-client/src/plugins/movement.rs
parent588902ba4a3965982bdd84d92b20c6f7613f3978 (diff)
downloadazalea-drasl-9513f42e87f64c409cdb2a100500a50e5a713bac.tar.xz
Move Client struct to azalea crate (#297)
* move the Client struct out of azalea-client into azalea * actually add client impls in azalea
Diffstat (limited to 'azalea-client/src/plugins/movement.rs')
-rw-r--r--azalea-client/src/plugins/movement.rs101
1 files changed, 0 insertions, 101 deletions
diff --git a/azalea-client/src/plugins/movement.rs b/azalea-client/src/plugins/movement.rs
index c4409722..c9473ebf 100644
--- a/azalea-client/src/plugins/movement.rs
+++ b/azalea-client/src/plugins/movement.rs
@@ -35,7 +35,6 @@ use bevy_app::{App, Plugin, Update};
use bevy_ecs::prelude::*;
use crate::{
- client::Client,
local_player::{Hunger, InstanceHolder, LocalGameMode},
packet::game::SendGamePacketEvent,
};
@@ -77,55 +76,6 @@ impl Plugin for MovementPlugin {
#[derive(Clone, Debug, Eq, Hash, PartialEq, SystemSet)]
pub struct MoveEventsSystems;
-impl Client {
- /// Set whether we're jumping. This acts as if you held space in
- /// vanilla.
- ///
- /// If you want to jump once, use the `jump` function in `azalea`.
- ///
- /// If you're making a realistic client, calling this function every tick is
- /// recommended.
- pub fn set_jumping(&self, jumping: bool) {
- self.query_self::<&mut Jumping, _>(|mut j| **j = jumping);
- }
-
- /// Returns whether the player will try to jump next tick.
- pub fn jumping(&self) -> bool {
- *self.component::<Jumping>()
- }
-
- pub fn set_crouching(&self, crouching: bool) {
- self.query_self::<&mut PhysicsState, _>(|mut p| p.trying_to_crouch = crouching);
- }
-
- /// Whether the client is currently trying to sneak.
- ///
- /// You may want to check the [`Pose`] instead.
- pub fn crouching(&self) -> bool {
- self.query_self::<&PhysicsState, _>(|p| p.trying_to_crouch)
- }
-
- /// Sets the direction the client is looking.
- ///
- /// `y_rot` is yaw (looking to the side, between -180 to 180), and `x_rot`
- /// is pitch (looking up and down, between -90 to 90).
- ///
- /// You can get these numbers from the vanilla f3 screen.
- pub fn set_direction(&self, y_rot: f32, x_rot: f32) {
- self.query_self::<&mut LookDirection, _>(|mut ld| {
- ld.update(LookDirection::new(y_rot, x_rot));
- });
- }
-
- /// Returns the direction the client is looking.
- ///
- /// See [`Self::set_direction`] for more details.
- pub fn direction(&self) -> (f32, f32) {
- let look_direction: LookDirection = self.component::<LookDirection>();
- (look_direction.y_rot(), look_direction.x_rot())
- }
-}
-
/// A component that contains the look direction that was last sent over the
/// network.
#[derive(Clone, Component, Debug, Default)]
@@ -515,57 +465,6 @@ fn distance_to_unit_square(v: Vec2) -> f32 {
(1. + ratio * ratio).sqrt()
}
-impl Client {
- /// Start walking in the given direction.
- ///
- /// To sprint, use [`Client::sprint`]. To stop walking, call walk with
- /// [`WalkDirection::None`].
- ///
- /// # Example
- ///
- /// ```rust,no_run
- /// # use azalea_client::{Client, WalkDirection};
- /// # use std::time::Duration;
- /// # async fn example(mut bot: Client) {
- /// // walk for one second
- /// bot.walk(WalkDirection::Forward);
- /// tokio::time::sleep(Duration::from_secs(1)).await;
- /// bot.walk(WalkDirection::None);
- /// # }
- /// ```
- pub fn walk(&self, direction: WalkDirection) {
- let mut ecs = self.ecs.lock();
- ecs.write_message(StartWalkEvent {
- entity: self.entity,
- direction,
- });
- }
-
- /// Start sprinting in the given direction.
- ///
- /// o stop moving, call [`bot.walk(WalkDirection::None)`](Self::walk)
- ///
- /// # Example
- ///
- /// ```rust,no_run
- /// # use azalea_client::{Client, WalkDirection, SprintDirection};
- /// # use std::time::Duration;
- /// # async fn example(mut bot: Client) {
- /// // sprint for one second
- /// bot.sprint(SprintDirection::Forward);
- /// tokio::time::sleep(Duration::from_secs(1)).await;
- /// bot.walk(WalkDirection::None);
- /// # }
- /// ```
- pub fn sprint(&self, direction: SprintDirection) {
- let mut ecs = self.ecs.lock();
- ecs.write_message(StartSprintEvent {
- entity: self.entity,
- direction,
- });
- }
-}
-
/// An event sent when the client starts walking.
///
/// This does not get sent for non-local entities.