diff options
| author | mat <git@matdoes.dev> | 2024-12-24 08:48:36 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2024-12-24 08:48:36 +0000 |
| commit | f03e0c22355778a9863cccb5a59d852278d60701 (patch) | |
| tree | f02e7ca3d1e975d486071934a6322d372b7c9a02 /azalea/examples | |
| parent | de5a53ce08de5b9d77bce99dd9ecde3171ebd74e (diff) | |
| download | azalea-drasl-f03e0c22355778a9863cccb5a59d852278d60701.tar.xz | |
fix parsing Dust particle and treat waterlogged blocks as liquid in pathfinder
Diffstat (limited to 'azalea/examples')
| -rw-r--r-- | azalea/examples/testbot/commands/debug.rs | 15 | ||||
| -rw-r--r-- | azalea/examples/testbot/main.rs | 30 |
2 files changed, 36 insertions, 9 deletions
diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs index ae0808cb..ab323b2f 100644 --- a/azalea/examples/testbot/commands/debug.rs +++ b/azalea/examples/testbot/commands/debug.rs @@ -5,6 +5,7 @@ use azalea::{ entity::{LookDirection, Position}, interact::HitResultComponent, world::MinecraftEntityId, + BlockPos, }; use parking_lot::Mutex; @@ -102,4 +103,18 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { 1 })); + + commands.register(literal("getblock").then(argument("x", integer()).then( + argument("y", integer()).then(argument("z", integer()).executes(|ctx: &Ctx| { + let source = ctx.source.lock(); + let x = get_integer(ctx, "x").unwrap(); + let y = get_integer(ctx, "y").unwrap(); + let z = get_integer(ctx, "z").unwrap(); + println!("getblock xyz {x} {y} {z}"); + let block_pos = BlockPos::new(x, y, z); + let block = source.bot.world().read().get_block_state(&block_pos); + source.reply(&format!("Block at {block_pos:?} is {block:?}")); + 1 + })), + ))); } diff --git a/azalea/examples/testbot/main.rs b/azalea/examples/testbot/main.rs index 81cd2bb8..3d9f999e 100644 --- a/azalea/examples/testbot/main.rs +++ b/azalea/examples/testbot/main.rs @@ -1,13 +1,24 @@ //! A relatively simple bot for demonstrating some of Azalea's capabilities. //! -//! Usage: +//! ## Usage +//! //! - Modify the consts below if necessary. -//! - Run `cargo r --example testbot -- --owner <owner> --name <username/email> -//! --address <address>`. +//! - Run `cargo r --example testbot -- [arguments]`. (see below) //! - Commands are prefixed with `!` in chat. You can send them either in public //! chat or as a /msg. //! - Some commands to try are `!goto`, `!killaura true`, `!down`. Check the //! `commands` directory to see all of them. +//! +//! ### Arguments +//! +//! - `--owner` or `-O`: The username of the player who owns the bot. The bot +//! will ignore commands from other players. +//! - `--name` or `-N`: The username or email of the bot. +//! - `--address` or `-A`: The address of the server to join. +//! - `--pathfinder-debug-particles` or `-P`: Whether the bot should run +//! /particle a ton of times to show where it's pathfinding to. You should +//! only have this on if the bot has operator permissions, otherwise it'll +//! just spam the server console unnecessarily. #![feature(async_closure)] #![feature(trivial_bounds)] @@ -28,11 +39,6 @@ use azalea::ClientInformation; use commands::{register_commands, CommandSource}; use parking_lot::Mutex; -/// Whether the bot should run /particle a ton of times to show where it's -/// pathfinding to. You should only have this on if the bot has operator -/// permissions, otherwise it'll just spam the server console unnecessarily. -const PATHFINDER_DEBUG_PARTICLES: bool = false; - #[tokio::main] async fn main() { let args = parse_args(); @@ -121,7 +127,7 @@ async fn handle(bot: Client, event: azalea::Event, state: State) -> anyhow::Resu ..Default::default() }) .await?; - if PATHFINDER_DEBUG_PARTICLES { + if state.args.pathfinder_debug_particles { bot.ecs .lock() .entity_mut(bot.entity) @@ -208,12 +214,14 @@ pub struct Args { pub owner: String, pub name: String, pub address: String, + pub pathfinder_debug_particles: bool, } fn parse_args() -> Args { let mut owner_username = None; let mut bot_username = None; let mut address = None; + let mut pathfinder_debug_particles = false; let mut args = env::args().skip(1); while let Some(arg) = args.next() { @@ -227,6 +235,9 @@ fn parse_args() -> Args { "--address" | "-A" => { address = args.next(); } + "--pathfinder-debug-particles" | "-P" => { + pathfinder_debug_particles = true; + } _ => { eprintln!("Unknown argument: {}", arg); process::exit(1); @@ -238,5 +249,6 @@ fn parse_args() -> Args { owner: owner_username.unwrap_or_else(|| "admin".to_string()), name: bot_username.unwrap_or_else(|| "azalea".to_string()), address: address.unwrap_or_else(|| "localhost".to_string()), + pathfinder_debug_particles, } } |
