diff options
| author | mat <git@matdoes.dev> | 2025-04-05 00:50:39 +0330 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-04-05 00:50:39 +0330 |
| commit | f250978cdd789d8ceb10cb225970a408933f508b (patch) | |
| tree | 5cc543750b69b68056fa36249147d7dba584afc8 /azalea-client/src/plugins/interact.rs | |
| parent | 5fd57fd630bea256639332f117848d6f1fcfd132 (diff) | |
| download | azalea-drasl-f250978cdd789d8ceb10cb225970a408933f508b.tar.xz | |
send attack packets at the end of the tick
Diffstat (limited to 'azalea-client/src/plugins/interact.rs')
| -rw-r--r-- | azalea-client/src/plugins/interact.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/azalea-client/src/plugins/interact.rs b/azalea-client/src/plugins/interact.rs index f9513183..f7239c17 100644 --- a/azalea-client/src/plugins/interact.rs +++ b/azalea-client/src/plugins/interact.rs @@ -23,6 +23,7 @@ use bevy_ecs::{ component::Component, entity::Entity, event::{Event, EventReader}, + observer::Trigger, query::{Changed, With}, schedule::IntoSystemConfigs, system::{Commands, Query, Res}, @@ -64,7 +65,8 @@ impl Plugin for InteractPlugin { .after(InventorySet) .after(MoveEventsSet), ), - ); + ) + .add_observer(handle_swing_arm_trigger); } } @@ -295,18 +297,21 @@ pub fn can_use_game_master_blocks( /// Swing your arm. This is purely a visual effect and won't interact with /// anything in the world. -#[derive(Event)] +#[derive(Event, Clone, Debug)] pub struct SwingArmEvent { pub entity: Entity, } +pub fn handle_swing_arm_trigger(trigger: Trigger<SwingArmEvent>, mut commands: Commands) { + commands.trigger(SendPacketEvent::new( + trigger.event().entity, + ServerboundSwing { + hand: InteractionHand::MainHand, + }, + )); +} pub fn handle_swing_arm_event(mut events: EventReader<SwingArmEvent>, mut commands: Commands) { for event in events.read() { - commands.trigger(SendPacketEvent::new( - event.entity, - ServerboundSwing { - hand: InteractionHand::MainHand, - }, - )); + commands.trigger(event.clone()); } } |
