From 3f60bdadac1a02e1109148bbbe5a8a3545f13849 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Thu, 17 Apr 2025 16:16:51 -0500 Subject: Move login state to the ECS (#213) * use packet handlers code for login custom_query * initial broken implementation for ecs-only login * fixes * run Update schedule 60 times per second and delete code related to run_schedule_sender * fix tests * fix online-mode * reply to query packets in a separate system and make it easier for plugins to disable individual replies * remove unused imports --- azalea/examples/echo.rs | 2 +- azalea/examples/steal.rs | 2 +- azalea/examples/testbot/commands/debug.rs | 8 +++++++- azalea/examples/testbot/main.rs | 2 +- azalea/examples/todo/craft_dig_straight_down.rs | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) (limited to 'azalea/examples') diff --git a/azalea/examples/echo.rs b/azalea/examples/echo.rs index 01390982..1e773b7d 100644 --- a/azalea/examples/echo.rs +++ b/azalea/examples/echo.rs @@ -20,7 +20,7 @@ pub struct State {} async fn handle(bot: Client, event: Event, _state: State) -> anyhow::Result<()> { if let Event::Chat(m) = event { if let (Some(sender), content) = m.split_sender_and_content() { - if sender == bot.profile.name { + if sender == bot.username() { return Ok(()); // ignore our own messages } bot.chat(&content); diff --git a/azalea/examples/steal.rs b/azalea/examples/steal.rs index 1277fab2..3fa87cc4 100644 --- a/azalea/examples/steal.rs +++ b/azalea/examples/steal.rs @@ -28,7 +28,7 @@ struct State { async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> { if let Event::Chat(m) = event { - if m.sender() == Some(bot.profile.name.clone()) { + if m.sender() == Some(bot.username()) { return Ok(()); }; if m.content() != "go" { diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs index 9de4d97d..3428d117 100644 --- a/azalea/examples/testbot/commands/debug.rs +++ b/azalea/examples/testbot/commands/debug.rs @@ -25,6 +25,12 @@ pub fn register(commands: &mut CommandDispatcher>) { 1 })); + commands.register(literal("disconnect").executes(|ctx: &Ctx| { + let source = ctx.source.lock(); + source.bot.disconnect(); + 1 + })); + commands.register(literal("whereami").executes(|ctx: &Ctx| { let mut source = ctx.source.lock(); let Some(entity) = source.entity() else { @@ -248,7 +254,7 @@ pub fn register(commands: &mut CommandDispatcher>) { } } "bevy_ecs::event::collections::Events" => { - let events = ecs.resource::>(); + let events = ecs.resource::>(); writeln!(report, "- Event count: {}", events.len()).unwrap(); } "bevy_ecs::event::collections::Events" => { diff --git a/azalea/examples/testbot/main.rs b/azalea/examples/testbot/main.rs index 410d1b6d..683a98d7 100644 --- a/azalea/examples/testbot/main.rs +++ b/azalea/examples/testbot/main.rs @@ -134,7 +134,7 @@ async fn handle(bot: Client, event: azalea::Event, state: State) -> anyhow::Resu view_distance: 32, ..Default::default() }) - .await?; + .await; if swarm.args.pathfinder_debug_particles { bot.ecs .lock() diff --git a/azalea/examples/todo/craft_dig_straight_down.rs b/azalea/examples/todo/craft_dig_straight_down.rs index 4f613adf..0dc8e16d 100644 --- a/azalea/examples/todo/craft_dig_straight_down.rs +++ b/azalea/examples/todo/craft_dig_straight_down.rs @@ -24,7 +24,7 @@ async fn main() { async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> { match event { Event::Chat(m) => { - if m.sender() == Some(bot.profile.name) { + if m.sender() == Some(bot.username()) { return Ok(()); }; if m.content() == "go" { -- cgit v1.2.3