diff options
| author | mat <git@matdoes.dev> | 2025-06-03 22:01:50 +0330 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-03 22:01:50 +0330 |
| commit | f311ac27d47c43eb4c33d760f3e1d1f2b8008a4f (patch) | |
| tree | 0528f06cda48a5e3062d9348604ff2c01ed30cfa /azalea-client/src/plugins/loading.rs | |
| parent | 415c0d873e7e793bbc8304247b828355d3ea8118 (diff) | |
| download | azalea-drasl-f311ac27d47c43eb4c33d760f3e1d1f2b8008a4f.tar.xz | |
send ServerboundPlayerLoaded on join and respawn
Diffstat (limited to 'azalea-client/src/plugins/loading.rs')
| -rw-r--r-- | azalea-client/src/plugins/loading.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/azalea-client/src/plugins/loading.rs b/azalea-client/src/plugins/loading.rs new file mode 100644 index 00000000..33290f39 --- /dev/null +++ b/azalea-client/src/plugins/loading.rs @@ -0,0 +1,40 @@ +use azalea_core::tick::GameTick; +use azalea_entity::InLoadedChunk; +use azalea_physics::PhysicsSet; +use azalea_protocol::packets::game::ServerboundPlayerLoaded; +use bevy_app::{App, Plugin}; +use bevy_ecs::prelude::*; + +use crate::{mining::MiningSet, packet::game::SendPacketEvent}; + +pub struct PlayerLoadedPlugin; +impl Plugin for PlayerLoadedPlugin { + fn build(&self, app: &mut App) { + app.add_systems( + GameTick, + player_loaded_packet + .after(PhysicsSet) + .after(MiningSet) + .after(crate::movement::send_position), + ); + } +} + +// this component is removed on respawn or disconnect +// (notably, it's not removed on login) + +// mojmap interchangably calls it 'has client loaded' and 'has player loaded', i +// prefer the client one because it makes it clear that the component is only +// present on our own clients + +#[derive(Component)] +pub struct HasClientLoaded; +pub fn player_loaded_packet( + mut commands: Commands, + query: Query<Entity, (With<InLoadedChunk>, Without<HasClientLoaded>)>, +) { + for entity in query.iter() { + commands.trigger(SendPacketEvent::new(entity, ServerboundPlayerLoaded)); + commands.entity(entity).insert(HasClientLoaded); + } +} |
