azalea_client/plugins/
respawn.rs1use azalea_protocol::packets::game::s_client_command::{self, ServerboundClientCommand};
2use bevy_app::{App, Plugin, Update};
3use bevy_ecs::prelude::*;
4
5use crate::packet::game::SendPacketEvent;
6
7#[derive(Event, Debug, Clone)]
9pub struct PerformRespawnEvent {
10 pub entity: Entity,
11}
12
13pub struct RespawnPlugin;
15impl Plugin for RespawnPlugin {
16 fn build(&self, app: &mut App) {
17 app.add_event::<PerformRespawnEvent>()
18 .add_systems(Update, perform_respawn);
19 }
20}
21
22pub fn perform_respawn(mut events: EventReader<PerformRespawnEvent>, mut commands: Commands) {
23 for event in events.read() {
24 commands.trigger(SendPacketEvent::new(
25 event.entity,
26 ServerboundClientCommand {
27 action: s_client_command::Action::PerformRespawn,
28 },
29 ));
30 }
31}