diff options
| author | mat <git@matdoes.dev> | 2025-01-29 05:29:20 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-01-29 05:29:20 +0000 |
| commit | 6d8d937d47646a930076c2512fe06055d0ca057f (patch) | |
| tree | a017c7f796212458268a0645e613b9bb87578493 /azalea-client/src/send_client_end.rs | |
| parent | befcec9b3a39fce64b23f31ecb0d56901bc0e1f4 (diff) | |
| download | azalea-drasl-6d8d937d47646a930076c2512fe06055d0ca057f.tar.xz | |
add support for tickend and playerinput
Diffstat (limited to 'azalea-client/src/send_client_end.rs')
| -rw-r--r-- | azalea-client/src/send_client_end.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/azalea-client/src/send_client_end.rs b/azalea-client/src/send_client_end.rs new file mode 100644 index 00000000..cb3d5e74 --- /dev/null +++ b/azalea-client/src/send_client_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_handling::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)); + } +} |
