diff options
Diffstat (limited to 'bot/src/main.rs')
| -rw-r--r-- | bot/src/main.rs | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/bot/src/main.rs b/bot/src/main.rs index 9b2eea1f..0a291fd8 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -1,35 +1,31 @@ -use azalea_client::{Account, Client, Event, MoveDirection}; -use std::convert::TryInto; +use azalea::prelude::*; +use azalea::{Account, Client, Event}; +use parking_lot::Mutex; +use std::sync::Arc; + +#[derive(Default)] +struct State {} #[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(); + let account = Account::offline("bot"); - while let Some(event) = rx.recv().await { - tokio::spawn(handle_event(event, bot.clone())); - } + azalea::start(azalea::Options { + account, + address: "localhost", + state: Arc::new(Mutex::new(State::default())), + plugins: vec![], + handle, + }) + .await + .unwrap(); } -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) => {} - _ => {} +async fn handle(bot: Client, event: Arc<Event>, _state: Arc<Mutex<State>>) -> anyhow::Result<()> { + if let Event::Tick = *event { + bot.jump(); } Ok(()) |
