-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanti_afk.rs
44 lines (38 loc) · 1.14 KB
/
anti_afk.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use azalea::{
app::{App, Plugin},
ecs::prelude::*,
interact::{handle_swing_arm_event, SwingArmEvent},
mining::continue_mining_block,
prelude::*,
};
use crate::prelude::*;
/// Automatically swing arm to prevent being kicked.
pub struct AntiAfkPlugin;
impl Plugin for AntiAfkPlugin {
fn build(&self, app: &mut App) {
app.add_systems(
GameTick,
Self::handle_anti_afk
.before(handle_swing_arm_event)
.after(continue_mining_block)
.after(GameTickPlugin::handle_game_ticks),
);
}
}
impl AntiAfkPlugin {
pub fn handle_anti_afk(
query: Query<(Entity, &LocalSettings, &GameTicks)>,
mut swing_arm_events: EventWriter<SwingArmEvent>,
) {
for (entity, local_settings, game_ticks) in query.iter() {
if !local_settings.anti_afk.enabled {
continue;
}
if game_ticks.0 % local_settings.anti_afk.delay_ticks != 0 {
continue;
}
debug!("Anti-Afk Swing Arm Event");
swing_arm_events.send(SwingArmEvent { entity });
}
}
}