diff options
| author | mat <git@matdoes.dev> | 2025-04-17 10:15:14 -1245 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-04-17 10:15:14 -1245 |
| commit | ad45cf5431939d088b97aa8a368ed910332b53d2 (patch) | |
| tree | 845a607d945e66e84f5677f7289f58d70334677f | |
| parent | 43d7c428e317f503dda899cade9e3ec8024de4de (diff) | |
| download | azalea-drasl-ad45cf5431939d088b97aa8a368ed910332b53d2.tar.xz | |
allow disabling Event::Packet with a crate feature
| -rw-r--r-- | azalea-client/Cargo.toml | 3 | ||||
| -rw-r--r-- | azalea-client/src/plugins/events.rs | 14 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/mod.rs | 2 | ||||
| -rw-r--r-- | azalea/Cargo.toml | 3 |
4 files changed, 12 insertions, 10 deletions
diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml index 6ca17a94..88bf02bc 100644 --- a/azalea-client/Cargo.toml +++ b/azalea-client/Cargo.toml @@ -41,6 +41,7 @@ uuid.workspace = true anyhow.workspace = true [features] -default = ["log"] +default = ["log", "packet-event"] # enables bevy_log::LogPlugin by default log = ["bevy_log"] +packet-event = [] diff --git a/azalea-client/src/plugins/events.rs b/azalea-client/src/plugins/events.rs index 85f50ea5..e92242af 100644 --- a/azalea-client/src/plugins/events.rs +++ b/azalea-client/src/plugins/events.rs @@ -6,9 +6,7 @@ use std::sync::Arc; use azalea_chat::FormattedText; use azalea_core::tick::GameTick; use azalea_entity::{Dead, InLoadedChunk}; -use azalea_protocol::packets::game::{ - ClientboundGamePacket, c_player_combat_kill::ClientboundPlayerCombatKill, -}; +use azalea_protocol::packets::game::c_player_combat_kill::ClientboundPlayerCombatKill; use azalea_world::{InstanceName, MinecraftEntityId}; use bevy_app::{App, Plugin, PreUpdate, Update}; use bevy_ecs::{ @@ -27,8 +25,7 @@ use crate::{ chat::{ChatPacket, ChatReceivedEvent}, disconnect::DisconnectEvent, packet::game::{ - AddPlayerEvent, DeathEvent, KeepAliveEvent, ReceiveGamePacketEvent, RemovePlayerEvent, - UpdatePlayerEvent, + AddPlayerEvent, DeathEvent, KeepAliveEvent, RemovePlayerEvent, UpdatePlayerEvent, }, }; @@ -94,6 +91,7 @@ pub enum Event { Chat(ChatPacket), /// Happens 20 times per second, but only when the world is loaded. Tick, + #[cfg(feature = "packet-event")] /// We received a packet from the server. /// /// ``` @@ -111,7 +109,7 @@ pub enum Event { /// # } /// # } /// ``` - Packet(Arc<ClientboundGamePacket>), + Packet(Arc<azalea_protocol::packets::game::ClientboundGamePacket>), /// A player joined the game (or more specifically, was added to the tab /// list). AddPlayer(PlayerInfo), @@ -146,6 +144,7 @@ impl Plugin for EventsPlugin { chat_listener, login_listener, spawn_listener, + #[cfg(feature = "packet-event")] packet_listener, add_player_listener, update_player_listener, @@ -215,9 +214,10 @@ pub fn tick_listener(query: Query<&LocalPlayerEvents, With<InstanceName>>) { } } +#[cfg(feature = "packet-event")] pub fn packet_listener( query: Query<&LocalPlayerEvents>, - mut events: EventReader<ReceiveGamePacketEvent>, + mut events: EventReader<super::packet::game::ReceiveGamePacketEvent>, ) { for event in events.read() { if let Ok(local_player_events) = query.get(event.entity) { diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index 60531d3b..9afc0e11 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -532,7 +532,7 @@ impl GamePacketHandler<'_> { tab_list.insert(updated_info.profile.uuid, info.clone()); add_player_events.send(AddPlayerEvent { entity: self.player, - info: info.clone(), + info, }); } else if let Some(info) = tab_list.get_mut(&updated_info.profile.uuid) { // `else if` because the block for add_player above diff --git a/azalea/Cargo.toml b/azalea/Cargo.toml index 7ec9635d..0896ab45 100644 --- a/azalea/Cargo.toml +++ b/azalea/Cargo.toml @@ -53,7 +53,7 @@ rand.workspace = true anyhow.workspace = true [features] -default = ["log", "serde"] +default = ["log", "serde", "packet-event"] # enables bevy_log::LogPlugin by default log = ["azalea-client/log"] serde = [ @@ -62,6 +62,7 @@ serde = [ "azalea-registry/serde", "azalea-world/serde", ] +packet-event = ["azalea-client/packet-event"] [[bench]] name = "pathfinder" |
