aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
Diffstat (limited to 'azalea')
-rw-r--r--azalea/examples/testbot.rs37
-rw-r--r--azalea/examples/todo/README.md1
-rw-r--r--[-rwxr-xr-x]azalea/examples/todo/craft_dig_straight_down.rs (renamed from azalea/examples/craft_dig_straight_down.rs)5
-rw-r--r--azalea/examples/todo/mine_a_chunk.rs (renamed from azalea/examples/mine_a_chunk.rs)0
-rw-r--r--[-rwxr-xr-x]azalea/examples/todo/pvp.rs (renamed from azalea/examples/pvp.rs)0
5 files changed, 31 insertions, 12 deletions
diff --git a/azalea/examples/testbot.rs b/azalea/examples/testbot.rs
index 7b7b32b0..a25b28e3 100644
--- a/azalea/examples/testbot.rs
+++ b/azalea/examples/testbot.rs
@@ -52,17 +52,17 @@ async fn main() -> anyhow::Result<()> {
}
loop {
- // let e = SwarmBuilder::new()
- // .add_accounts(accounts.clone())
- // .set_handler(handle)
- // .set_swarm_handler(swarm_handle)
- // .join_delay(Duration::from_millis(1000))
- // .start("localhost")
- // .await;
- let e = azalea::ClientBuilder::new()
+ let e = SwarmBuilder::new()
+ .add_accounts(accounts.clone())
.set_handler(handle)
- .start(Account::offline("bot"), "localhost")
+ .set_swarm_handler(swarm_handle)
+ .join_delay(Duration::from_millis(1000))
+ .start("localhost")
.await;
+ // let e = azalea::ClientBuilder::new()
+ // .set_handler(handle)
+ // .start(Account::offline("bot"), "localhost")
+ // .await;
eprintln!("{e:?}");
}
}
@@ -140,6 +140,25 @@ async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<
"lag" => {
std::thread::sleep(Duration::from_millis(1000));
}
+ "findblock" => {
+ let target_pos = bot.world().read().find_block(
+ bot.component::<Position>(),
+ &azalea_registry::Block::DiamondBlock.into(),
+ );
+ bot.chat(&format!("target_pos: {target_pos:?}",));
+ }
+ "gotoblock" => {
+ let target_pos = bot.world().read().find_block(
+ bot.component::<Position>(),
+ &azalea_registry::Block::DiamondBlock.into(),
+ );
+ if let Some(target_pos) = target_pos {
+ // +1 to stand on top of the block
+ bot.goto(BlockPosGoal::from(target_pos.up(1)));
+ } else {
+ bot.chat("no diamond block found");
+ }
+ }
_ => {}
}
}
diff --git a/azalea/examples/todo/README.md b/azalea/examples/todo/README.md
new file mode 100644
index 00000000..ab31cf22
--- /dev/null
+++ b/azalea/examples/todo/README.md
@@ -0,0 +1 @@
+These examples don't work yet and were only written to help design APIs. They will work in the future (probably with minor changes).
diff --git a/azalea/examples/craft_dig_straight_down.rs b/azalea/examples/todo/craft_dig_straight_down.rs
index 0632776e..4c980ccf 100755..100644
--- a/azalea/examples/craft_dig_straight_down.rs
+++ b/azalea/examples/todo/craft_dig_straight_down.rs
@@ -38,7 +38,7 @@ async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
bot.goto(pathfinder::Goals::NearXZ(5, azalea::BlockXZ(0, 0)))
.await;
let chest = bot
- .open_container(&bot.world().find_one_block(|b| b.id == "minecraft:chest"))
+ .open_container(&bot.world().find_block(azalea_registry::Block::Chest))
.await
.unwrap();
bot.take_amount(&chest, 5, |i| i.id == "#minecraft:planks")
@@ -47,8 +47,7 @@ async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
let crafting_table = bot
.open_crafting_table(
- &bot.world
- .find_one_block(|b| b.id == "minecraft:crafting_table"),
+ &bot.world.find_block(azalea_registry::Block::CraftingTable),
)
.await
.unwrap();
diff --git a/azalea/examples/mine_a_chunk.rs b/azalea/examples/todo/mine_a_chunk.rs
index 74ffacac..74ffacac 100644
--- a/azalea/examples/mine_a_chunk.rs
+++ b/azalea/examples/todo/mine_a_chunk.rs
diff --git a/azalea/examples/pvp.rs b/azalea/examples/todo/pvp.rs
index fb5a768d..fb5a768d 100755..100644
--- a/azalea/examples/pvp.rs
+++ b/azalea/examples/todo/pvp.rs