aboutsummaryrefslogtreecommitdiff
path: root/bot/src
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2022-06-25 05:09:26 +0000
committerGitHub <noreply@github.com>2022-06-25 05:09:26 +0000
commit7d3e57763e32ac9cf94180b1c714704cfbc3034d (patch)
tree2dcfe72bf09a42f6614f9dc988dc0254162ea0bf /bot/src
parent69c47eda4c496b13dadd80976bffd2fab7ea5894 (diff)
parentca7067e173129f3044ebc8c77634f06da29a086e (diff)
downloadazalea-drasl-7d3e57763e32ac9cf94180b1c714704cfbc3034d.tar.xz
Merge pull request #10 from mat-1/azalea-entity
azalea-entity
Diffstat (limited to 'bot/src')
-rw-r--r--bot/src/main.rs54
1 files changed, 38 insertions, 16 deletions
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(())
}