aboutsummaryrefslogtreecommitdiff
path: root/examples/craft_dig_straight_down.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-14 20:50:20 -0500
committermat <github@matdoes.dev>2022-05-14 20:50:20 -0500
commit5c1712c8404e52f893e3fc10f79a337933865123 (patch)
treea515b76d77fdf710314f07d70ec639f4a6dded6a /examples/craft_dig_straight_down.rs
parent4000a9d29cbd286517e00db88a27aeddc1967557 (diff)
downloadazalea-drasl-5c1712c8404e52f893e3fc10f79a337933865123.tar.xz
move examples into examples directory
Diffstat (limited to 'examples/craft_dig_straight_down.rs')
-rw-r--r--examples/craft_dig_straight_down.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/craft_dig_straight_down.rs b/examples/craft_dig_straight_down.rs
new file mode 100644
index 00000000..79985672
--- /dev/null
+++ b/examples/craft_dig_straight_down.rs
@@ -0,0 +1,37 @@
+use azalea::{Bot, Event};
+
+let bot = Bot::offline("bot");
+// or let bot = azalea::Bot::microsoft("access token").await;
+
+bot.join("localhost".try_into().unwrap()).await.unwrap();
+
+loop {
+ match bot.next().await {
+ Event::Message(m) {
+ if m.username == bot.username { return };
+ if m.message = "go" {
+ bot.goto_goal(
+ pathfinder::Goals::NearXZ(5, azalea::BlockXZ(0, 0))
+ ).await;
+ let chest = bot.open_chest(&bot.world.find_one_block(|b| b.id == "minecraft:chest")).await.unwrap();
+ bot.take_amount(&chest, 3, |i| i.id == "#minecraft:planks").await;
+ // when rust adds async drop this won't be necessary
+ chest.close().await;
+
+ let crafting_table = bot.open_crafting_table(&bot.world.find_one_block(|b| b.id == "minecraft:crafting_table")).await.unwrap();
+ bot.craft(&crafting_table, &bot.recipe_for("minecraft:sticks")).await?;
+ let pickaxe = bot.craft(&crafting_table, &bot.recipe_for("minecraft:wooden_pickaxe")).await?;
+ crafting_table.close().await;
+
+ bot.hold(&pickaxe);
+ loop {
+ if let Err(e) = bot.dig(bot.feet_coords().down(1)).await {
+ println!("{:?}", e);
+ break;
+ }
+ }
+ }
+ },
+ _ => {}
+ }
+}