aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-08-04 20:43:10 -0500
committerGitHub <noreply@github.com>2025-08-04 20:43:10 -0500
commit23b7f20a0d88b54d430820baeb4a6da0316a009a (patch)
treef3e780515b3bbb9973d2b94338be6194b5ec0af3 /azalea/examples
parent827d943c3f27c65724ff83689b40c87d1cd1838c (diff)
downloadazalea-drasl-23b7f20a0d88b54d430820baeb4a6da0316a009a.tar.xz
Default components (#232)
* add default components * remove debug prints * clippy * use default components * fix tests
Diffstat (limited to 'azalea/examples')
-rw-r--r--azalea/examples/testbot/commands.rs7
-rw-r--r--azalea/examples/testbot/commands/debug.rs12
2 files changed, 16 insertions, 3 deletions
diff --git a/azalea/examples/testbot/commands.rs b/azalea/examples/testbot/commands.rs
index 79a73bd9..ecd68ade 100644
--- a/azalea/examples/testbot/commands.rs
+++ b/azalea/examples/testbot/commands.rs
@@ -19,12 +19,13 @@ pub struct CommandSource {
}
impl CommandSource {
- pub fn reply(&self, message: &str) {
+ pub fn reply(&self, message: impl Into<String>) {
+ let message = message.into();
if self.chat.is_whisper() {
self.bot
- .chat(&format!("/w {} {}", self.chat.sender().unwrap(), message));
+ .chat(&format!("/w {} {message}", self.chat.sender().unwrap()));
} else {
- self.bot.chat(message);
+ self.bot.chat(&message);
}
}
diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs
index d721fddc..d0d72b40 100644
--- a/azalea/examples/testbot/commands/debug.rs
+++ b/azalea/examples/testbot/commands/debug.rs
@@ -10,10 +10,12 @@ use azalea::{
interact::pick::HitResultComponent,
packet::game,
pathfinder::{ExecutingPath, Pathfinder},
+ prelude::ContainerClientExt,
world::MinecraftEntityId,
};
use azalea_core::hit_result::HitResult;
use azalea_entity::EntityKindComponent;
+use azalea_inventory::components::MaxStackSize;
use azalea_world::InstanceContainer;
use bevy_ecs::event::Events;
use parking_lot::Mutex;
@@ -191,6 +193,16 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
source.reply("Ok!");
1
}));
+ commands.register(literal("maxstacksize").executes(|ctx: &Ctx| {
+ let source = ctx.source.lock();
+ let max_stack_size = source
+ .bot
+ .get_held_item()
+ .get_component::<MaxStackSize>()
+ .map_or(-1, |s| s.count);
+ source.reply(format!("{max_stack_size}"));
+ 1
+ }));
commands.register(literal("debugecsleak").executes(|ctx: &Ctx| {
let source = ctx.source.lock();