diff options
Diffstat (limited to 'bot')
| -rwxr-xr-x | bot/Cargo.toml | 2 | ||||
| -rw-r--r-- | bot/src/main.rs | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/bot/Cargo.toml b/bot/Cargo.toml index fa0b0c67..b51e6705 100755 --- a/bot/Cargo.toml +++ b/bot/Cargo.toml @@ -6,9 +6,11 @@ version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow = "1.0.65" azalea-client = {path = "../azalea-client"} azalea-core = {path = "../azalea-core"} azalea-physics = {path = "../azalea-physics"} azalea-protocol = {path = "../azalea-protocol"} +env_logger = "0.9.1" tokio = "1.19.2" uuid = "1.1.2" diff --git a/bot/src/main.rs b/bot/src/main.rs index 5423e017..92c1bc91 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -1,8 +1,11 @@ use azalea_client::{Account, Client, Event, MoveDirection}; +use azalea_protocol::packets::game::ClientboundGamePacket; 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(); @@ -12,7 +15,7 @@ async fn main() { } } -async fn handle_event(event: Event, mut bot: Client) { +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; @@ -22,6 +25,15 @@ async fn handle_event(event: Event, mut bot: Client) { // } // bot.walk(MoveDirection::None); } + Event::Packet(packet) => { + if let ClientboundGamePacket::SetHealth(_) = *packet { + println!("got set health"); + bot.shutdown().await?; + panic!(); + } + } _ => {} } + + Ok(()) } |
