aboutsummaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rw-r--r--bot/src/main.rs52
1 files changed, 33 insertions, 19 deletions
diff --git a/bot/src/main.rs b/bot/src/main.rs
index 02f802a5..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() -> Result<(), Box<dyn std::error::Error>> {
println!("Hello, world!");
// let address = "95.111.249.143:10000";
- let address = "localhost:49982";
+ let address = "localhost:65399";
// let response = azalea_client::ping::ping_server(&address.try_into().unwrap())
// .await
// .unwrap();
@@ -20,23 +20,37 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
match e {
// TODO: have a "loaded" or "ready" event that fires when all chunks are loaded
Event::Login => {}
- 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::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();
}
_ => {}
}