diff options
Diffstat (limited to 'azalea/examples/pvp.rs')
| -rw-r--r-- | azalea/examples/pvp.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/azalea/examples/pvp.rs b/azalea/examples/pvp.rs index a2f070f0..8c133576 100644 --- a/azalea/examples/pvp.rs +++ b/azalea/examples/pvp.rs @@ -7,7 +7,7 @@ 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_swarm(azalea::SwarmOptions { @@ -21,24 +21,28 @@ async fn main() { plugins: vec![], handle: Box::new(handle), - swarm_handle: Box::new(handle), + swarm_handle: Box::new(swarm_handle), }) .await .unwrap(); } +#[derive(Default, Clone)] struct State {} + +#[derive(Default, Clone)] struct SwarmState {} -async fn handle(bots: Client, event: Arc<Event>, state: Arc<Mutex<State>>) { - match *event { +async fn handle(bot: Client, event: Event, state: State) {} +async fn swarm_handle(swarm: Swarm, event: Event, state: State) { + match event { Event::Tick => { // choose an arbitrary player within render distance to target - if let Some(target) = bots - .dimension() + if let Some(target) = swarm + .dimension .find_one_entity(|e| e.id == "minecraft:player") { - for bot in bots { + for bot in swarm { bot.tick_goto_goal(pathfinder::Goals::Reach(target.bounding_box)); // if target.bounding_box.distance(bot.eyes) < bot.reach_distance() { if bot.entity.can_reach(target.bounding_box) { |
