aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/client.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-04-15 22:04:43 -0430
committermat <git@matdoes.dev>2025-04-15 22:04:43 -0430
commita9820dfd79bf24a0a6fcb2345aad6c79a21585a5 (patch)
treea8e6290707fee0e1b18812aba599da74e7fc6eed /azalea-client/src/client.rs
parent1a0c4e2de9e6d82d5efdfac2bab17a73c79fc466 (diff)
downloadazalea-drasl-a9820dfd79bf24a0a6fcb2345aad6c79a21585a5.tar.xz
make goto async and clean up some examples
Diffstat (limited to 'azalea-client/src/client.rs')
-rw-r--r--azalea-client/src/client.rs42
1 files changed, 3 insertions, 39 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs
index e13368eb..b8688b40 100644
--- a/azalea-client/src/client.rs
+++ b/azalea-client/src/client.rs
@@ -46,19 +46,15 @@ use bevy_ecs::{
component::Component,
entity::Entity,
schedule::{InternedScheduleLabel, IntoSystemConfigs, LogLevel, ScheduleBuildSettings},
- system::{ResMut, Resource},
+ system::Resource,
world::World,
};
use bevy_time::TimePlugin;
-use derive_more::Deref;
use parking_lot::{Mutex, RwLock};
use simdnbt::owned::NbtCompound;
use thiserror::Error;
use tokio::{
- sync::{
- broadcast,
- mpsc::{self, error::TrySendError},
- },
+ sync::mpsc::{self, error::TrySendError},
time,
};
use tracing::{debug, error, info};
@@ -88,6 +84,7 @@ use crate::{
raw_connection::RawConnection,
respawn::RespawnPlugin,
task_pool::TaskPoolPlugin,
+ tick_broadcast::TickBroadcastPlugin,
tick_end::TickEndPlugin,
};
@@ -1006,39 +1003,6 @@ pub async fn tick_run_schedule_loop(run_schedule_sender: mpsc::Sender<()>) {
}
}
-/// A resource that contains a [`broadcast::Sender`] that will be sent every
-/// Minecraft tick.
-///
-/// This is useful for running code every schedule from async user code.
-///
-/// ```
-/// use azalea_client::TickBroadcast;
-/// # async fn example(client: azalea_client::Client) {
-/// let mut receiver = {
-/// let ecs = client.ecs.lock();
-/// let tick_broadcast = ecs.resource::<TickBroadcast>();
-/// tick_broadcast.subscribe()
-/// };
-/// while receiver.recv().await.is_ok() {
-/// // do something
-/// }
-/// # }
-/// ```
-#[derive(Resource, Deref)]
-pub struct TickBroadcast(broadcast::Sender<()>);
-
-pub fn send_tick_broadcast(tick_broadcast: ResMut<TickBroadcast>) {
- let _ = tick_broadcast.0.send(());
-}
-/// A plugin that makes the [`RanScheduleBroadcast`] resource available.
-pub struct TickBroadcastPlugin;
-impl Plugin for TickBroadcastPlugin {
- fn build(&self, app: &mut App) {
- app.insert_resource(TickBroadcast(broadcast::channel(1).0))
- .add_systems(GameTick, send_tick_broadcast);
- }
-}
-
pub struct AmbiguityLoggerPlugin;
impl Plugin for AmbiguityLoggerPlugin {
fn build(&self, app: &mut App) {