aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples/testbot/commands
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-08-14 20:40:13 -0500
committerGitHub <noreply@github.com>2025-08-14 20:40:13 -0500
commite74ed047dbaf3877db4a89a2d589e992abd0bb11 (patch)
tree0a728c8be167a1d59a5492ed9df666f41cf12e57 /azalea/examples/testbot/commands
parent6695132ddb31780786c67b8b9ff5df8ab3891438 (diff)
downloadazalea-drasl-e74ed047dbaf3877db4a89a2d589e992abd0bb11.tar.xz
Sneaking (#237)
* start implementing sneaking * fix horizontal_collision being inverted and cleanup * clippy * change dimensions and eye height based on pose * proper support for automatically crouching in certain cases * fix anticheat issues * add line to changelog and update a comment
Diffstat (limited to 'azalea/examples/testbot/commands')
-rw-r--r--azalea/examples/testbot/commands/debug.rs7
-rw-r--r--azalea/examples/testbot/commands/movement.rs24
2 files changed, 27 insertions, 4 deletions
diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs
index 46f1ed33..b3a8b419 100644
--- a/azalea/examples/testbot/commands/debug.rs
+++ b/azalea/examples/testbot/commands/debug.rs
@@ -205,6 +205,13 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
1
}));
+ commands.register(literal("dimensions").executes(|ctx: &Ctx| {
+ let source = ctx.source.lock();
+ let bot_dimensions = source.bot.dimensions();
+ source.reply(format!("{bot_dimensions:?}"));
+ 1
+ }));
+
commands.register(literal("debugecsleak").executes(|ctx: &Ctx| {
let source = ctx.source.lock();
diff --git a/azalea/examples/testbot/commands/movement.rs b/azalea/examples/testbot/commands/movement.rs
index 89be3d0c..a4ac787a 100644
--- a/azalea/examples/testbot/commands/movement.rs
+++ b/azalea/examples/testbot/commands/movement.rs
@@ -3,10 +3,11 @@ use std::time::Duration;
use azalea::{
BlockPos, SprintDirection, WalkDirection,
brigadier::prelude::*,
- entity::{EyeHeight, Position},
+ entity::Position,
pathfinder::goals::{BlockPosGoal, RadiusGoal, XZGoal},
prelude::*,
};
+use azalea_entity::dimensions::EntityDimensions;
use parking_lot::Mutex;
use super::{CommandSource, Ctx};
@@ -103,8 +104,8 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
};
let eye_height = source
.bot
- .get_entity_component::<EyeHeight>(entity)
- .map(|h| *h)
+ .get_entity_component::<EntityDimensions>(entity)
+ .map(|h| h.eye_height)
.unwrap_or_default();
source.bot.look_at(position.up(eye_height as f64));
1
@@ -155,7 +156,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
tokio::time::sleep(Duration::from_secs_f32(seconds)).await;
bot.walk(WalkDirection::None);
});
- source.reply(format!("ok, spriting for {seconds} seconds"));
+ source.reply(format!("ok, sprinting for {seconds} seconds"));
1
})),
);
@@ -200,6 +201,21 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
})),
);
+ let sneak = |ctx: &Ctx| {
+ let source = ctx.source.lock();
+ source.bot.set_crouching(!source.bot.crouching());
+ source.reply("ok");
+ 1
+ };
+ let sneak_enabled = argument("enabled", bool()).executes(|ctx: &Ctx| {
+ let sneaking = get_bool(ctx, "enabled").unwrap();
+ let source = ctx.source.lock();
+ source.bot.set_crouching(sneaking);
+ 1
+ });
+ commands.register(literal("sneak").executes(sneak).then(sneak_enabled.clone()));
+ commands.register(literal("crouch").executes(sneak).then(sneak_enabled));
+
commands.register(literal("stop").executes(|ctx: &Ctx| {
let source = ctx.source.lock();
source.bot.stop_pathfinding();