aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/packet_handling/mod.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-02-22 21:45:26 -0600
committerGitHub <noreply@github.com>2025-02-22 21:45:26 -0600
commite21e1b97bf9337e9f4747cd1b545b1b3a03e2ce7 (patch)
treeadd6f8bfce40d0c07845d8aa4c9945a0b918444c /azalea-client/src/packet_handling/mod.rs
parentf8130c3c92946d2293634ba4e252d6bc93026c3c (diff)
downloadazalea-drasl-e21e1b97bf9337e9f4747cd1b545b1b3a03e2ce7.tar.xz
Refactor azalea-client (#205)
* start organizing packet_handling more by moving packet handlers into their own functions * finish writing all the handler functions for packets * use macro for generating match statement for packet handler functions * fix set_entity_data * update config state to also use handler functions * organize az-client file structure by moving things into plugins directory * fix merge issues
Diffstat (limited to 'azalea-client/src/packet_handling/mod.rs')
-rw-r--r--azalea-client/src/packet_handling/mod.rs78
1 files changed, 0 insertions, 78 deletions
diff --git a/azalea-client/src/packet_handling/mod.rs b/azalea-client/src/packet_handling/mod.rs
deleted file mode 100644
index 908f368e..00000000
--- a/azalea-client/src/packet_handling/mod.rs
+++ /dev/null
@@ -1,78 +0,0 @@
-use azalea_entity::{EntityUpdateSet, metadata::Health};
-use bevy_app::{App, First, Plugin, PreUpdate, Update};
-use bevy_ecs::prelude::*;
-
-use self::{
- game::{
- AddPlayerEvent, DeathEvent, InstanceLoadedEvent, KeepAliveEvent, RemovePlayerEvent,
- ResourcePackEvent, UpdatePlayerEvent,
- },
- login::{LoginPacketEvent, SendLoginPacketEvent},
-};
-use crate::{chat::ChatReceivedEvent, events::death_listener};
-
-pub mod configuration;
-pub mod game;
-pub mod login;
-
-pub struct PacketHandlerPlugin;
-
-pub fn death_event_on_0_health(
- query: Query<(Entity, &Health), Changed<Health>>,
- mut death_events: EventWriter<DeathEvent>,
-) {
- for (entity, health) in query.iter() {
- if **health == 0. {
- death_events.send(DeathEvent {
- entity,
- packet: None,
- });
- }
- }
-}
-
-impl Plugin for PacketHandlerPlugin {
- fn build(&self, app: &mut App) {
- app.add_systems(
- First,
- (game::send_packet_events, configuration::send_packet_events),
- )
- .add_systems(
- PreUpdate,
- (
- game::process_packet_events
- // we want to index and deindex right after
- .before(EntityUpdateSet::Deindex),
- configuration::process_packet_events,
- login::handle_send_packet_event,
- login::process_packet_events,
- ),
- )
- .add_systems(
- Update,
- (
- (
- configuration::handle_send_packet_event,
- game::handle_send_packet_event,
- )
- .chain(),
- death_event_on_0_health.before(death_listener),
- ),
- )
- // we do this instead of add_event so we can handle the events ourselves
- .init_resource::<Events<game::PacketEvent>>()
- .init_resource::<Events<configuration::ConfigurationEvent>>()
- .add_event::<game::SendPacketEvent>()
- .add_event::<configuration::SendConfigurationEvent>()
- .add_event::<AddPlayerEvent>()
- .add_event::<RemovePlayerEvent>()
- .add_event::<UpdatePlayerEvent>()
- .add_event::<ChatReceivedEvent>()
- .add_event::<DeathEvent>()
- .add_event::<KeepAliveEvent>()
- .add_event::<ResourcePackEvent>()
- .add_event::<InstanceLoadedEvent>()
- .add_event::<LoginPacketEvent>()
- .add_event::<SendLoginPacketEvent>();
- }
-}