aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-04-04 16:05:06 -0430
committermat <git@matdoes.dev>2025-04-04 16:05:06 -0430
commit5fd57fd630bea256639332f117848d6f1fcfd132 (patch)
tree83e21595e69e24b3b1e8790dc630b79cf14a1777 /azalea/examples
parente99ae608b67ad3ff105666e619d04ca9385488e1 (diff)
downloadazalea-drasl-5fd57fd630bea256639332f117848d6f1fcfd132.tar.xz
don't require mut for functions in Client and add some more convenience functions
Diffstat (limited to 'azalea/examples')
-rw-r--r--azalea/examples/steal.rs2
-rw-r--r--azalea/examples/testbot/commands/movement.rs18
-rw-r--r--azalea/examples/testbot/killaura.rs2
3 files changed, 11 insertions, 11 deletions
diff --git a/azalea/examples/steal.rs b/azalea/examples/steal.rs
index 21eea424..464d94f8 100644
--- a/azalea/examples/steal.rs
+++ b/azalea/examples/steal.rs
@@ -24,7 +24,7 @@ struct State {
pub checked_chests: Arc<Mutex<Vec<BlockPos>>>,
}
-async fn handle(mut bot: Client, event: Event, state: State) -> anyhow::Result<()> {
+async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
if let Event::Chat(m) = event {
if m.sender() == Some(bot.profile.name.clone()) {
return Ok(());
diff --git a/azalea/examples/testbot/commands/movement.rs b/azalea/examples/testbot/commands/movement.rs
index a8511cc5..114c3c31 100644
--- a/azalea/examples/testbot/commands/movement.rs
+++ b/azalea/examples/testbot/commands/movement.rs
@@ -115,7 +115,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
get_integer(ctx, "z").unwrap(),
);
println!("{:?}", pos);
- let mut source = ctx.source.lock();
+ let source = ctx.source.lock();
source.bot.look_at(pos.center());
1
}),
@@ -126,7 +126,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
literal("walk").then(argument("seconds", float()).executes(|ctx: &Ctx| {
let mut seconds = get_float(ctx, "seconds").unwrap();
let source = ctx.source.lock();
- let mut bot = source.bot.clone();
+ let bot = source.bot.clone();
if seconds < 0. {
bot.walk(WalkDirection::Backward);
@@ -147,7 +147,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
literal("sprint").then(argument("seconds", float()).executes(|ctx: &Ctx| {
let seconds = get_float(ctx, "seconds").unwrap();
let source = ctx.source.lock();
- let mut bot = source.bot.clone();
+ let bot = source.bot.clone();
bot.sprint(SprintDirection::Forward);
tokio::spawn(async move {
tokio::time::sleep(Duration::from_secs_f32(seconds)).await;
@@ -159,25 +159,25 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
);
commands.register(literal("north").executes(|ctx: &Ctx| {
- let mut source = ctx.source.lock();
+ let source = ctx.source.lock();
source.bot.set_direction(180., 0.);
source.reply("ok");
1
}));
commands.register(literal("south").executes(|ctx: &Ctx| {
- let mut source = ctx.source.lock();
+ let source = ctx.source.lock();
source.bot.set_direction(0., 0.);
source.reply("ok");
1
}));
commands.register(literal("east").executes(|ctx: &Ctx| {
- let mut source = ctx.source.lock();
+ let source = ctx.source.lock();
source.bot.set_direction(-90., 0.);
source.reply("ok");
1
}));
commands.register(literal("west").executes(|ctx: &Ctx| {
- let mut source = ctx.source.lock();
+ let source = ctx.source.lock();
source.bot.set_direction(90., 0.);
source.reply("ok");
1
@@ -185,14 +185,14 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
commands.register(
literal("jump")
.executes(|ctx: &Ctx| {
- let mut source = ctx.source.lock();
+ let source = ctx.source.lock();
source.bot.jump();
source.reply("ok");
1
})
.then(argument("enabled", bool()).executes(|ctx: &Ctx| {
let jumping = get_bool(ctx, "enabled").unwrap();
- let mut source = ctx.source.lock();
+ let source = ctx.source.lock();
source.bot.set_jumping(jumping);
1
})),
diff --git a/azalea/examples/testbot/killaura.rs b/azalea/examples/testbot/killaura.rs
index e98fe6ec..b47ac0df 100644
--- a/azalea/examples/testbot/killaura.rs
+++ b/azalea/examples/testbot/killaura.rs
@@ -7,7 +7,7 @@ use azalea::{
use crate::State;
-pub fn tick(mut bot: Client, state: State) -> anyhow::Result<()> {
+pub fn tick(bot: Client, state: State) -> anyhow::Result<()> {
if !state.killaura {
return Ok(());
}