aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples/mine_a_chunk.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea/examples/mine_a_chunk.rs')
-rw-r--r--azalea/examples/mine_a_chunk.rs43
1 files changed, 22 insertions, 21 deletions
diff --git a/azalea/examples/mine_a_chunk.rs b/azalea/examples/mine_a_chunk.rs
index bc576513..5f1dabe1 100644
--- a/azalea/examples/mine_a_chunk.rs
+++ b/azalea/examples/mine_a_chunk.rs
@@ -1,4 +1,4 @@
-use azalea::{pathfinder, Account, Accounts, Client, Event};
+use azalea::{pathfinder, Account, Accounts, Client, Event, Swarm};
use parking_lot::Mutex;
use std::sync::Arc;
@@ -7,31 +7,31 @@ async fn main() {
let accounts = Accounts::new();
for i in 0..10 {
- accounts.add(Account::offline(format!("bot{}", i)));
+ accounts.add(Account::offline(&format!("bot{}", i)));
}
- azalea::start_group(azalea::GroupOptions {
+ azalea::start_swarm(azalea::SwarmOptions {
accounts,
address: "localhost",
- group_state: Arc::new(Mutex::new(State::default())),
+ swarm_state: Arc::new(Mutex::new(State::default())),
state: State::default(),
- group_plugins: vec![Arc::new(pathfinder::Plugin::default())],
+ swarm_plugins: vec![Arc::new(pathfinder::Plugin::default())],
plugins: vec![],
handle: Box::new(handle),
- group_handle: Box::new(handle),
+ swarm_handle: Box::new(swarm_handle),
})
.await
.unwrap();
}
-#[derive(Default)]
+#[derive(Default, Clone)]
struct State {}
-#[derive(Default)]
-struct GroupState {}
+#[derive(Default, Clone)]
+struct SwarmState {}
async fn handle(bot: Client, event: Arc<Event>, state: Arc<Mutex<State>>) -> anyhow::Result<()> {
match event {
@@ -41,26 +41,27 @@ async fn handle(bot: Client, event: Arc<Event>, state: Arc<Mutex<State>>) -> any
Ok(())
}
-async fn group_handle(
- bots: Swarm,
+async fn swarm_handle(
+ swarm: Swarm,
event: Arc<Event>,
- state: Arc<Mutex<GroupState>>,
+ state: Arc<Mutex<SwarmState>>,
) -> anyhow::Result<()> {
match *event {
Event::Login => {
- bots.goto(azalea::BlockPos::new(0, 70, 0)).await;
+ swarm.goto(azalea::BlockPos::new(0, 70, 0)).await;
// or bots.goto_goal(pathfinder::Goals::Goto(azalea::BlockPos(0, 70, 0))).await;
// destroy the blocks in this area and then leave
- bots.fill(
- azalea::Selection::Range(
- azalea::BlockPos::new(0, 0, 0),
- azalea::BlockPos::new(16, 255, 16),
- ),
- azalea::block::Air,
- )
- .await;
+ swarm
+ .fill(
+ azalea::Selection::Range(
+ azalea::BlockPos::new(0, 0, 0),
+ azalea::BlockPos::new(16, 255, 16),
+ ),
+ azalea::block::Air,
+ )
+ .await;
}
_ => {}
}