aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
Diffstat (limited to 'azalea')
-rw-r--r--azalea/examples/echo.rs2
-rw-r--r--azalea/examples/steal.rs2
-rw-r--r--azalea/examples/testbot/commands/debug.rs8
-rw-r--r--azalea/examples/testbot/main.rs2
-rw-r--r--azalea/examples/todo/craft_dig_straight_down.rs2
-rw-r--r--azalea/src/container.rs7
-rw-r--r--azalea/src/swarm/mod.rs16
7 files changed, 21 insertions, 18 deletions
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<Mutex<CommandSource>>) {
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<Mutex<CommandSource>>) {
}
}
"bevy_ecs::event::collections::Events<azalea_client::packet::game::ReceivePacketEvent>" => {
- let events = ecs.resource::<Events<game::ReceivePacketEvent>>();
+ let events = ecs.resource::<Events<game::ReceiveGamePacketEvent>>();
writeln!(report, "- Event count: {}", events.len()).unwrap();
}
"bevy_ecs::event::collections::Events<azalea_client::chunks::ReceiveChunkEvent>" => {
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" {
diff --git a/azalea/src/container.rs b/azalea/src/container.rs
index 0ce0fc44..0d1cfb16 100644
--- a/azalea/src/container.rs
+++ b/azalea/src/container.rs
@@ -1,7 +1,7 @@
use std::fmt::Debug;
use std::fmt::Formatter;
-use azalea_client::packet::game::ReceivePacketEvent;
+use azalea_client::packet::game::ReceiveGamePacketEvent;
use azalea_client::{
Client,
inventory::{CloseContainerEvent, ContainerClickEvent, Inventory},
@@ -234,7 +234,10 @@ impl ContainerHandle {
#[derive(Component, Debug)]
pub struct WaitingForInventoryOpen;
-fn handle_menu_opened_event(mut commands: Commands, mut events: EventReader<ReceivePacketEvent>) {
+fn handle_menu_opened_event(
+ mut commands: Commands,
+ mut events: EventReader<ReceiveGamePacketEvent>,
+) {
for event in events.read() {
if let ClientboundGamePacket::ContainerSetContent { .. } = event.packet.as_ref() {
commands
diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs
index eb56ae2d..ba8fd7bb 100644
--- a/azalea/src/swarm/mod.rs
+++ b/azalea/src/swarm/mod.rs
@@ -55,8 +55,6 @@ pub struct Swarm {
bots_tx: mpsc::UnboundedSender<(Option<Event>, Client)>,
swarm_tx: mpsc::UnboundedSender<SwarmEvent>,
-
- run_schedule_sender: mpsc::Sender<()>,
}
/// Create a new [`Swarm`].
@@ -396,12 +394,9 @@ where
swarm_tx.send(SwarmEvent::Init).unwrap();
- let (run_schedule_sender, run_schedule_receiver) = mpsc::channel(1);
-
let main_schedule_label = self.app.main().update_schedule.unwrap();
- let ecs_lock =
- start_ecs_runner(self.app, run_schedule_receiver, run_schedule_sender.clone());
+ let ecs_lock = start_ecs_runner(self.app);
let swarm = Swarm {
ecs_lock: ecs_lock.clone(),
@@ -414,8 +409,6 @@ where
bots_tx,
swarm_tx: swarm_tx.clone(),
-
- run_schedule_sender,
};
// run the main schedule so the startup systems run
@@ -495,7 +488,8 @@ where
let Some(first_bot_state) = first_bot.query::<Option<&S>>(&mut ecs).cloned() else {
error!(
"the first bot ({} / {}) is missing the required state component! none of the client handler functions will be called.",
- first_bot.profile.name, first_bot.entity
+ first_bot.username(),
+ first_bot.entity
);
continue;
};
@@ -513,7 +507,8 @@ where
let Some(state) = bot.query::<Option<&S>>(&mut ecs).cloned() else {
error!(
"one of our bots ({} / {}) is missing the required state component! its client handler function will not be called.",
- bot.profile.name, bot.entity
+ bot.username(),
+ bot.entity
);
continue;
};
@@ -665,7 +660,6 @@ impl Swarm {
address: &address,
resolved_address: &resolved_address,
proxy: join_opts.proxy.clone(),
- run_schedule_sender: self.run_schedule_sender.clone(),
event_sender: Some(tx),
})
.await?;