From 86dc16c5de5d2368dba8504b86e98b468ee13af1 Mon Sep 17 00:00:00 2001 From: Cheezer <118921295+Cheezer1656@users.noreply.github.com> Date: Fri, 8 May 2026 11:24:08 -0700 Subject: Add SwarmEvent::Tick (#328) --- azalea/src/swarm/events.rs | 11 ++++++++++- azalea/src/swarm/mod.rs | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) 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::() .add_systems(Update, check_ready) + .add_systems(GameTick, send_tick_event) .init_resource::(); } } @@ -40,3 +43,9 @@ fn check_ready( **is_swarm_ready = true; ready_events.write(SwarmReadyEvent); } + +fn send_tick_event(swarm: Option>) { + 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 -- cgit v1.2.3