From e74ed047dbaf3877db4a89a2d589e992abd0bb11 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Thu, 14 Aug 2025 20:40:13 -0500 Subject: Sneaking (#237) * start implementing sneaking * fix horizontal_collision being inverted and cleanup * clippy * change dimensions and eye height based on pose * proper support for automatically crouching in certain cases * fix anticheat issues * add line to changelog and update a comment --- azalea-client/src/client.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'azalea-client/src/client.rs') diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 9481ba2d..be9c8e99 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -14,10 +14,12 @@ use azalea_core::{ tick::GameTick, }; use azalea_entity::{ - EntityUpdateSet, EyeHeight, Position, + EntityUpdateSet, PlayerAbilities, Position, + dimensions::EntityDimensions, indexing::{EntityIdIndex, EntityUuidIndex}, metadata::Health, }; +use azalea_physics::local_player::PhysicsState; use azalea_protocol::{ ServerAddress, common::client_information::ClientInformation, @@ -55,9 +57,9 @@ use crate::{ interact::BlockStatePredictionHandler, inventory::Inventory, join::{ConnectOpts, StartJoinServerEvent}, - local_player::{Hunger, InstanceHolder, PermissionLevel, PlayerAbilities, TabList}, + local_player::{Hunger, InstanceHolder, PermissionLevel, TabList}, mining::{self}, - movement::{LastSentLookDirection, PhysicsState}, + movement::LastSentLookDirection, packet::game::SendPacketEvent, player::{GameProfileComponent, PlayerInfo, retroactively_add_game_profile_component}, }; @@ -427,12 +429,21 @@ impl Client { ) } + /// Get the bounding box dimensions for our client, which contains our + /// width, height, and eye height. + /// + /// This is a shortcut for + /// `self.component::()`. + pub fn dimensions(&self) -> EntityDimensions { + self.component::() + } + /// Get the position of this client's eyes. /// /// This is a shortcut for - /// `bot.position().up(bot.component::())`. + /// `bot.position().up(bot.dimensions().eye_height)`. pub fn eye_position(&self) -> Vec3 { - self.position().up((*self.component::()) as f64) + self.position().up(self.dimensions().eye_height as f64) } /// Get the health of this client. -- cgit v1.2.3