diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-02-22 21:45:26 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-22 21:45:26 -0600 |
| commit | e21e1b97bf9337e9f4747cd1b545b1b3a03e2ce7 (patch) | |
| tree | add6f8bfce40d0c07845d8aa4c9945a0b918444c /azalea-client/src/plugins/tick_end.rs | |
| parent | f8130c3c92946d2293634ba4e252d6bc93026c3c (diff) | |
| download | azalea-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/plugins/tick_end.rs')
| -rw-r--r-- | azalea-client/src/plugins/tick_end.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/azalea-client/src/plugins/tick_end.rs b/azalea-client/src/plugins/tick_end.rs new file mode 100644 index 00000000..c7737eb1 --- /dev/null +++ b/azalea-client/src/plugins/tick_end.rs @@ -0,0 +1,36 @@ +//! Clients send a [`ServerboundClientTickEnd`] packet every tick. + +use azalea_core::tick::GameTick; +use azalea_entity::LocalEntity; +use azalea_physics::PhysicsSet; +use azalea_protocol::packets::game::ServerboundClientTickEnd; +use azalea_world::InstanceName; +use bevy_app::{App, Plugin}; +use bevy_ecs::prelude::*; + +use crate::{mining::MiningSet, packet::game::SendPacketEvent}; + +/// A plugin that makes clients send a [`ServerboundClientTickEnd`] packet every +/// tick. +pub struct TickEndPlugin; +impl Plugin for TickEndPlugin { + fn build(&self, app: &mut App) { + app.add_systems( + GameTick, + // this has to happen after every other event that might send packets + game_tick_packet + .after(PhysicsSet) + .after(MiningSet) + .after(crate::movement::send_position), + ); + } +} + +pub fn game_tick_packet( + query: Query<Entity, (With<LocalEntity>, With<InstanceName>)>, + mut send_packets: EventWriter<SendPacketEvent>, +) { + for entity in query.iter() { + send_packets.send(SendPacketEvent::new(entity, ServerboundClientTickEnd)); + } +} |
