diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-08-14 20:40:13 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-14 20:40:13 -0500 |
| commit | e74ed047dbaf3877db4a89a2d589e992abd0bb11 (patch) | |
| tree | 0a728c8be167a1d59a5492ed9df666f41cf12e57 /azalea-client/src/local_player.rs | |
| parent | 6695132ddb31780786c67b8b9ff5df8ab3891438 (diff) | |
| download | azalea-drasl-e74ed047dbaf3877db4a89a2d589e992abd0bb11.tar.xz | |
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
Diffstat (limited to 'azalea-client/src/local_player.rs')
| -rw-r--r-- | azalea-client/src/local_player.rs | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs index 4a937ec7..09232d12 100644 --- a/azalea-client/src/local_player.rs +++ b/azalea-client/src/local_player.rs @@ -5,7 +5,6 @@ use std::{ }; use azalea_core::game_type::GameMode; -use azalea_protocol::packets::game::c_player_abilities::ClientboundPlayerAbilities; use azalea_world::{Instance, PartialInstance}; use bevy_ecs::{component::Component, prelude::*}; use derive_more::{Deref, DerefMut}; @@ -55,34 +54,6 @@ impl From<GameMode> for LocalGameMode { } } -/// A component that contains the abilities the player has, like flying -/// or instantly breaking blocks. This is only present on local players. -#[derive(Clone, Debug, Component, Default)] -pub struct PlayerAbilities { - pub invulnerable: bool, - pub flying: bool, - pub can_fly: bool, - /// Whether the player can instantly break blocks and can duplicate blocks - /// in their inventory. - pub instant_break: bool, - - pub flying_speed: f32, - /// Used for the fov - pub walking_speed: f32, -} -impl From<&ClientboundPlayerAbilities> for PlayerAbilities { - fn from(packet: &ClientboundPlayerAbilities) -> Self { - Self { - invulnerable: packet.flags.invulnerable, - flying: packet.flags.flying, - can_fly: packet.flags.can_fly, - instant_break: packet.flags.instant_break, - flying_speed: packet.flying_speed, - walking_speed: packet.walking_speed, - } - } -} - /// Level must be 0..=4 #[derive(Component, Clone, Default, Deref, DerefMut)] pub struct PermissionLevel(pub u8); @@ -127,6 +98,15 @@ impl Default for Hunger { } } } +impl Hunger { + /// Returns true if we have enough food level to sprint. + /// + /// Note that this doesn't consider our gamemode or passenger status. + pub fn is_enough_to_sprint(&self) -> bool { + // hasEnoughFoodToSprint + self.food >= 6 + } +} impl InstanceHolder { /// Create a new `InstanceHolder` for the given entity. |
