aboutsummaryrefslogtreecommitdiff
path: root/bot/src/main.rs
blob: 9b2eea1fc30bd1af4a129635f2cefa95c3e227c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use azalea_client::{Account, Client, Event, MoveDirection};
use std::convert::TryInto;

#[tokio::main]
async fn main() {
    env_logger::init();

    let bot = Account::offline("bot");

    let (bot, mut rx) = bot.join(&"localhost".try_into().unwrap()).await.unwrap();

    while let Some(event) = rx.recv().await {
        tokio::spawn(handle_event(event, bot.clone()));
    }
}

async fn handle_event(event: Event, mut bot: Client) -> anyhow::Result<()> {
    match event {
        Event::Login => {
            // tokio::time::sleep(std::time::Duration::from_secs(1)).await;
            // bot.walk(MoveDirection::Forward);

            // loop {
            //     tokio::time::sleep(std::time::Duration::from_secs(2)).await;
            // }
            // bot.walk(MoveDirection::None);
        }
        Event::GameTick => {
            bot.set_jumping(true);
        }
        Event::Packet(_packet) => {}
        _ => {}
    }

    Ok(())
}