diff options
| author | Cheezer <118921295+Cheezer1656@users.noreply.github.com> | 2026-05-08 11:24:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-08 13:24:08 -0500 |
| commit | 86dc16c5de5d2368dba8504b86e98b468ee13af1 (patch) | |
| tree | a1eeded9e5c72dc9a3a9a07a546677c288ec54a8 | |
| parent | c963b0a5fbe57423ccda0c3b2bfe108439dd895c (diff) | |
| download | azalea-drasl-86dc16c5de5d2368dba8504b86e98b468ee13af1.tar.xz | |
Add SwarmEvent::Tick (#328)
| -rw-r--r-- | azalea/src/swarm/events.rs | 11 | ||||
| -rw-r--r-- | azalea/src/swarm/mod.rs | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/azalea/src/swarm/events.rs b/azalea/src/swarm/events.rs index 83817c86..e5f7f6e0 100644 --- a/azalea/src/swarm/events.rs +++ b/azalea/src/swarm/events.rs @@ -1,14 +1,17 @@ use azalea_client::local_player::WorldHolder; -use azalea_core::entity_id::MinecraftEntityId; +use azalea_core::{entity_id::MinecraftEntityId, tick::GameTick}; use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; use derive_more::{Deref, DerefMut}; +use crate::swarm::{Swarm, SwarmEvent}; + pub struct SwarmPlugin; impl Plugin for SwarmPlugin { fn build(&self, app: &mut App) { app.add_message::<SwarmReadyEvent>() .add_systems(Update, check_ready) + .add_systems(GameTick, send_tick_event) .init_resource::<IsSwarmReady>(); } } @@ -40,3 +43,9 @@ fn check_ready( **is_swarm_ready = true; ready_events.write(SwarmReadyEvent); } + +fn send_tick_event(swarm: Option<Res<Swarm>>) { + if let Some(swarm) = swarm { + swarm.swarm_tx.send(SwarmEvent::Tick).unwrap(); + } +} diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index 69f2b3e5..4599675c 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -66,6 +66,8 @@ pub enum SwarmEvent { /// This is only fired once, and it's guaranteed to be the first event to /// fire. Init, + /// This is fired every Minecraft tick (in the [`GameTick`] schedule). + Tick, /// A bot got disconnected from the server. /// /// If you'd like to implement special auto-reconnect behavior beyond what's |
