blob: e8ff5f95e0b30d0d66ea0c5795ad3a89c432ac6d (
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
37
38
39
40
41
|
use azalea_client::{Account, Event};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Hello, world!");
// let address = "95.111.249.143:10000";
let address = "localhost:61146";
// let response = azalea_client::ping::ping_server(&address.try_into().unwrap())
// .await
// .unwrap();
// println!("{}", response.description.to_ansi(None));
let account = Account::offline("bot");
let mut client = account.join(&address.try_into().unwrap()).await.unwrap();
println!("connected");
while let Some(e) = &client.next().await {
match e {
// TODO: have a "loaded" or "ready" event that fires when all chunks are loaded
Event::Login => {}
Event::Chat(_p) => {
let state = client.state.lock().unwrap();
let world = state.world.as_ref().unwrap();
println!("{:#?}", world);
// world.get_block_state(state.player.entity.pos);
// println!("{}", p.message.to_ansi(None));
// if p.message.to_ansi(None) == "<py5> ok" {
// let state = client.state.lock();
// let world = state.world.as_ref().unwrap();
// let c = world.get_block_state(&BlockPos::new(5, 78, -2)).unwrap();
// println!("block state: {:?}", c);
// }
}
}
}
println!("done");
Ok(())
}
|