aboutsummaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rwxr-xr-xbot/Cargo.toml1
-rw-r--r--bot/src/main.rs54
2 files changed, 39 insertions, 16 deletions
diff --git a/bot/Cargo.toml b/bot/Cargo.toml
index 1a6a44a3..974d6f61 100755
--- a/bot/Cargo.toml
+++ b/bot/Cargo.toml
@@ -10,3 +10,4 @@ azalea-client = {path = "../azalea-client"}
azalea-core = {path = "../azalea-core"}
azalea-protocol = {path = "../azalea-protocol"}
tokio = "1.19.2"
+uuid = "1.1.2"
diff --git a/bot/src/main.rs b/bot/src/main.rs
index e2e87456..2976920b 100644
--- a/bot/src/main.rs
+++ b/bot/src/main.rs
@@ -1,12 +1,12 @@
use azalea_client::{Account, Event};
-use azalea_core::BlockPos;
+use azalea_core::PositionXYZ;
#[tokio::main]
-async fn 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 address = "localhost:65399";
// let response = azalea_client::ping::ping_server(&address.try_into().unwrap())
// .await
// .unwrap();
@@ -16,25 +16,47 @@ async fn main() {
let mut client = account.join(&address.try_into().unwrap()).await.unwrap();
println!("connected");
- while let Some(e) = client.next().await {
+ 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().await;
- let world = state.world.as_ref().unwrap();
- // println!("{:?}", state.player.entity);
- // 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().await;
- // let world = state.world.as_ref().unwrap();
- // let c = world.get_block_state(&BlockPos::new(5, 78, -2)).unwrap();
- // println!("block state: {:?}", c);
- // }
+ // Event::GameTick => {
+ // let world = client.world();
+ // if let Some(b) = world.find_one_entity(|e| {
+ // e.uuid == uuid::uuid!("6536bfed-8695-48fd-83a1-ecd24cf2a0fd")
+ // }) {
+ // // let world = state.world.as_ref().unwrap();
+ // // world.
+ // println!("{:?}", b);
+ // }
+ // // 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);
+ // // }
+ // }
+ Event::Chat(msg) => {
+ let new_pos = {
+ let state_lock = client.state.lock().unwrap();
+ let world = state_lock.world.as_ref().unwrap();
+ let player = &state_lock.player;
+ let entity = player
+ .entity(&world)
+ .expect("Player entity is not in world");
+ entity.pos().add_y(0.5)
+ };
+
+ println!("{:?}", new_pos);
+ client.move_to(new_pos).await.unwrap();
}
+ _ => {}
}
}
println!("done");
+
+ Ok(())
}