aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-07-14 22:20:40 -0500
committerGitHub <noreply@github.com>2023-07-14 22:20:40 -0500
commit7405427199e5a994d4a6a706f84434a69cb7a7d9 (patch)
treeca537e5d761bc053187d952fced0915c850b92aa /azalea/examples
parentd1afd02aa84e7b4450c1607277f078eb2a0f1bf3 (diff)
downloadazalea-drasl-7405427199e5a994d4a6a706f84434a69cb7a7d9.tar.xz
Mining (#95)
* more mining stuff * initialize azalea-tags crate * more mining stuff 2 * mining in ecs * well technically mining works but no codegen for how long it takes to mine each block yet * rename downloads to __cache__ it was bothering me since it's not *just* downloads * codegen block behavior * fix not sending packet to finish breaking block * mining animation 🎉 * clippy * cleanup, move Client::mine into a client extension * add azalea/src/mining.rs --------- Co-authored-by: mat <git@matdoes.dev>
Diffstat (limited to 'azalea/examples')
-rw-r--r--azalea/examples/testbot.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/azalea/examples/testbot.rs b/azalea/examples/testbot.rs
index 1774d005..d9bd8681 100644
--- a/azalea/examples/testbot.rs
+++ b/azalea/examples/testbot.rs
@@ -89,7 +89,7 @@ async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<
bot.disconnect();
}
let Some(sender) = m.username() else {
- return Ok(())
+ return Ok(());
};
// let mut ecs = bot.ecs.lock();
// let entity = bot
@@ -164,6 +164,21 @@ async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<
bot.chat("no diamond block found");
}
}
+ "mineblock" => {
+ let target_pos = bot
+ .world()
+ .read()
+ .find_block(bot.position(), &azalea::Block::DiamondBlock.into());
+ if let Some(target_pos) = target_pos {
+ // +1 to stand on top of the block
+ bot.chat("ok mining diamond block");
+ bot.look_at(target_pos.center());
+ bot.mine(target_pos).await;
+ bot.chat("finished mining");
+ } else {
+ bot.chat("no diamond block found");
+ }
+ }
"lever" => {
let target_pos = bot
.world()
@@ -171,7 +186,7 @@ async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<
.find_block(bot.position(), &azalea::Block::Lever.into());
let Some(target_pos) = target_pos else {
bot.chat("no lever found");
- return Ok(())
+ return Ok(());
};
bot.goto(BlockPosGoal::from(target_pos));
bot.look_at(target_pos.center());
@@ -188,7 +203,7 @@ async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<
.find_block(bot.position(), &azalea::Block::Chest.into());
let Some(target_pos) = target_pos else {
bot.chat("no chest found");
- return Ok(())
+ return Ok(());
};
bot.look_at(target_pos.center());
let container = bot.open_container(target_pos).await;