From 75efbc83fdc4a47f880e95259a339d41839af01a Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 19 Mar 2025 21:35:47 +0000 Subject: make SendPacketEvent a bevy trigger --- azalea-client/src/plugins/mining.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'azalea-client/src/plugins/mining.rs') diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs index beb380b7..d4a6f2a0 100644 --- a/azalea-client/src/plugins/mining.rs +++ b/azalea-client/src/plugins/mining.rs @@ -186,7 +186,7 @@ pub struct StartMiningBlockWithDirectionEvent { fn handle_start_mining_block_with_direction_event( mut events: EventReader, mut finish_mining_events: EventWriter, - mut send_packet_events: EventWriter, + mut commands: Commands, mut attack_block_events: EventWriter, mut mine_block_progress_events: EventWriter, mut query: Query<( @@ -204,7 +204,6 @@ fn handle_start_mining_block_with_direction_event( &mut MineBlockPos, )>, instances: Res, - mut commands: Commands, ) { for event in events.read() { let ( @@ -252,7 +251,7 @@ fn handle_start_mining_block_with_direction_event( { if mining.is_some() { // send a packet to stop mining since we just changed target - send_packet_events.send(SendPacketEvent::new( + commands.trigger(SendPacketEvent::new( event.entity, ServerboundPlayerAction { action: s_player_action::Action::AbortDestroyBlock, @@ -324,7 +323,7 @@ fn handle_start_mining_block_with_direction_event( }); } - send_packet_events.send(SendPacketEvent::new( + commands.trigger(SendPacketEvent::new( event.entity, ServerboundPlayerAction { action: s_player_action::Action::StartDestroyBlock, @@ -483,17 +482,16 @@ pub struct StopMiningBlockEvent { } pub fn handle_stop_mining_block_event( mut events: EventReader, - mut send_packet_events: EventWriter, + mut commands: Commands, mut mine_block_progress_events: EventWriter, mut query: Query<(&mut Mining, &MineBlockPos, &mut MineProgress)>, - mut commands: Commands, ) { for event in events.read() { let (mut _mining, mine_block_pos, mut mine_progress) = query.get_mut(event.entity).unwrap(); let mine_block_pos = mine_block_pos.expect("IsMining is true so MineBlockPos must be present"); - send_packet_events.send(SendPacketEvent::new( + commands.trigger(SendPacketEvent::new( event.entity, ServerboundPlayerAction { action: s_player_action::Action::AbortDestroyBlock, @@ -529,13 +527,12 @@ pub fn continue_mining_block( &mut MineTicks, &mut CurrentSequenceNumber, )>, - mut send_packet_events: EventWriter, + mut commands: Commands, mut mine_block_progress_events: EventWriter, mut finish_mining_events: EventWriter, mut start_mining_events: EventWriter, mut swing_arm_events: EventWriter, instances: Res, - mut commands: Commands, ) { for ( entity, @@ -566,7 +563,7 @@ pub fn continue_mining_block( position: mining.pos, }); *sequence_number += 1; - send_packet_events.send(SendPacketEvent::new( + commands.trigger(SendPacketEvent::new( entity, ServerboundPlayerAction { action: s_player_action::Action::StartDestroyBlock, @@ -611,7 +608,7 @@ pub fn continue_mining_block( entity, position: mining.pos, }); - send_packet_events.send(SendPacketEvent::new( + commands.trigger(SendPacketEvent::new( entity, ServerboundPlayerAction { action: s_player_action::Action::StopDestroyBlock, -- cgit v1.2.3