diff options
| author | mat <git@matdoes.dev> | 2023-07-15 16:35:23 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-07-15 16:35:23 -0500 |
| commit | a839c6a923a737fab61536cec0258fdd83106368 (patch) | |
| tree | 8dfdb984da72dd60ad77a5f171e7db4efd296103 /azalea-client/src | |
| parent | cde7e35046b726b07bf3e067c080b85a12b2fd74 (diff) | |
| download | azalea-drasl-a839c6a923a737fab61536cec0258fdd83106368.tar.xz | |
fix brigadier booleans
Diffstat (limited to 'azalea-client/src')
| -rw-r--r-- | azalea-client/src/client.rs | 11 | ||||
| -rw-r--r-- | azalea-client/src/events.rs | 12 | ||||
| -rw-r--r-- | azalea-client/src/packet_handling.rs | 2 |
3 files changed, 20 insertions, 5 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index f7fcb16c..a7cceaed 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -21,7 +21,7 @@ use crate::{ use azalea_auth::{game_profile::GameProfile, sessionserver::ClientSessionServerError}; use azalea_chat::FormattedText; use azalea_core::Vec3; -use azalea_entity::{metadata::Health, EntityPlugin, EntityUpdateSet, Local, Position}; +use azalea_entity::{metadata::Health, EntityPlugin, EntityUpdateSet, EyeHeight, Local, Position}; use azalea_physics::{PhysicsPlugin, PhysicsSet}; use azalea_protocol::{ connect::{Connection, ConnectionError}, @@ -550,6 +550,15 @@ impl Client { pub fn position(&self) -> Vec3 { Vec3::from(&self.component::<Position>()) } + + /// Get the position of this client's eyes. + /// + /// This is a shortcut for + /// `bot.position().up(bot.component::<EyeHeight>())`. + pub fn eye_position(&self) -> Vec3 { + self.position().up((*self.component::<EyeHeight>()) as f64) + } + /// Get the health of this client. /// /// This is a shortcut for `*bot.component::<Health>()`. diff --git a/azalea-client/src/events.rs b/azalea-client/src/events.rs index 900f559f..b581fcee 100644 --- a/azalea-client/src/events.rs +++ b/azalea-client/src/events.rs @@ -6,9 +6,14 @@ use std::sync::Arc; use azalea_protocol::packets::game::{ clientbound_player_combat_kill_packet::ClientboundPlayerCombatKillPacket, ClientboundGamePacket, }; -use azalea_world::MinecraftEntityId; +use azalea_world::{InstanceName, MinecraftEntityId}; use bevy_app::{App, FixedUpdate, Plugin, Update}; -use bevy_ecs::{component::Component, event::EventReader, query::Added, system::Query}; +use bevy_ecs::{ + component::Component, + event::EventReader, + query::{Added, With}, + system::Query, +}; use derive_more::{Deref, DerefMut}; use tokio::sync::mpsc; @@ -143,7 +148,8 @@ fn chat_listener(query: Query<&LocalPlayerEvents>, mut events: EventReader<ChatR } } -fn tick_listener(query: Query<&LocalPlayerEvents>) { +// only tick if we're in a world +fn tick_listener(query: Query<&LocalPlayerEvents, With<InstanceName>>) { for local_player_events in &query { local_player_events.send(Event::Tick).unwrap(); } diff --git a/azalea-client/src/packet_handling.rs b/azalea-client/src/packet_handling.rs index b4f4e045..70bf2778 100644 --- a/azalea-client/src/packet_handling.rs +++ b/azalea-client/src/packet_handling.rs @@ -327,7 +327,7 @@ fn process_packet_events(ecs: &mut World) { debug!("Got update tags packet"); } ClientboundGamePacket::Disconnect(p) => { - debug!("Got disconnect packet {:?}", p); + warn!("Got disconnect packet {:?}", p); let mut system_state: SystemState<EventWriter<DisconnectEvent>> = SystemState::new(ecs); let mut disconnect_events = system_state.get_mut(ecs); |
