From 7405427199e5a994d4a6a706f84434a69cb7a7d9 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 14 Jul 2023 22:20:40 -0500 Subject: Mining (#95) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- azalea/examples/testbot.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'azalea/examples') 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; -- cgit v1.2.3