mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
* add configuration state
* start updating to 23w31a
* implement a bit more of 23w31a
* chunk batching
* start adding configuration state
* ioasfhjgsd
* almost works
* configuration state mostly implemented
* handle other packets in configuration state and fix keepalive
* cleanup, fix warnings
* 23w32a
* fix some doctests
* 23w33a
* 23w35a
* 1.20.2-pre2
* fix system conflicts
* 1.20.2-pre4
* make tests compile
* tests pass
* 1.20.2-rc2
* 1.20.2
* Revert "1.20.2"
This reverts commit dd152fd265
.
* didn't mean to commit that code
---------
Co-authored-by: mat <git@matdoes.dev>
73 lines
2 KiB
Rust
73 lines
2 KiB
Rust
//! Steal all the diamonds from all the nearby chests.
|
|
|
|
use azalea::{prelude::*, BlockPos};
|
|
use azalea_inventory::operations::QuickMoveClick;
|
|
use azalea_inventory::ItemSlot;
|
|
use parking_lot::Mutex;
|
|
use std::sync::Arc;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let account = Account::offline("bot");
|
|
// or let bot = Account::microsoft("email").await.unwrap();
|
|
|
|
ClientBuilder::new()
|
|
.set_handler(handle)
|
|
.start(account, "localhost")
|
|
.await
|
|
.unwrap();
|
|
}
|
|
|
|
#[derive(Default, Clone, Component)]
|
|
struct State {
|
|
pub checked_chests: Arc<Mutex<Vec<BlockPos>>>,
|
|
}
|
|
|
|
async fn handle(mut bot: Client, event: Event, state: State) -> anyhow::Result<()> {
|
|
if let Event::Chat(m) = event {
|
|
if m.username() == Some(bot.profile.name.clone()) {
|
|
return Ok(());
|
|
};
|
|
if m.content() != "go" {
|
|
return Ok(());
|
|
}
|
|
{
|
|
state.checked_chests.lock().clear();
|
|
}
|
|
|
|
let chest_block = bot
|
|
.world()
|
|
.read()
|
|
.find_block(bot.position(), &azalea::registry::Block::Chest.into());
|
|
// TODO: update this when find_blocks is implemented
|
|
let Some(chest_block) = chest_block else {
|
|
bot.chat("No chest found");
|
|
return Ok(());
|
|
};
|
|
// bot.goto(BlockPosGoal::from(chest_block));
|
|
let Some(chest) = bot.open_container(chest_block).await else {
|
|
println!("Couldn't open chest");
|
|
return Ok(());
|
|
};
|
|
|
|
println!("Getting contents");
|
|
for (index, slot) in chest
|
|
.contents()
|
|
.expect("we just opened the chest")
|
|
.iter()
|
|
.enumerate()
|
|
{
|
|
println!("Checking slot {index}: {slot:?}");
|
|
if let ItemSlot::Present(item) = slot {
|
|
if item.kind == azalea::registry::Item::Diamond {
|
|
println!("clicking slot ^");
|
|
chest.click(QuickMoveClick::Left { slot: index as u16 });
|
|
}
|
|
}
|
|
}
|
|
|
|
println!("Done");
|
|
}
|
|
|
|
Ok(())
|
|
}
|