aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples
diff options
context:
space:
mode:
Diffstat (limited to 'azalea/examples')
-rw-r--r--azalea/examples/testbot/commands.rs2
-rw-r--r--azalea/examples/testbot/killaura.rs4
-rw-r--r--azalea/examples/testbot/main.rs4
3 files changed, 6 insertions, 4 deletions
diff --git a/azalea/examples/testbot/commands.rs b/azalea/examples/testbot/commands.rs
index e8a9855f..03705617 100644
--- a/azalea/examples/testbot/commands.rs
+++ b/azalea/examples/testbot/commands.rs
@@ -37,6 +37,8 @@ impl CommandSource {
.any_entity_by::<&GameProfileComponent, With<Player>>(
|profile: &GameProfileComponent| profile.name == username,
)
+ .ok()
+ .flatten()
}
}
diff --git a/azalea/examples/testbot/killaura.rs b/azalea/examples/testbot/killaura.rs
index 136ae7dd..37f65ab2 100644
--- a/azalea/examples/testbot/killaura.rs
+++ b/azalea/examples/testbot/killaura.rs
@@ -13,7 +13,7 @@ pub fn tick(bot: Client, state: State) -> eyre::Result<()> {
if bot.has_attack_cooldown() {
return Ok(());
}
- let bot_position = bot.eye_position();
+ let bot_position = bot.eye_position()?;
let nearest_entity = bot.nearest_entity_by::<&Position, (
With<AbstractMonster>,
@@ -22,7 +22,7 @@ pub fn tick(bot: Client, state: State) -> eyre::Result<()> {
)>(|position: &Position| {
let distance = bot_position.distance_to(**position);
distance < 4.
- });
+ })?;
if let Some(nearest_entity) = nearest_entity {
println!("attacking {nearest_entity:?}");
diff --git a/azalea/examples/testbot/main.rs b/azalea/examples/testbot/main.rs
index 034a80ad..806780b7 100644
--- a/azalea/examples/testbot/main.rs
+++ b/azalea/examples/testbot/main.rs
@@ -189,10 +189,10 @@ async fn handle(bot: Client, event: azalea::Event, state: State) -> eyre::Result
if let Some(following) = &*state.following_entity.lock()
&& following.is_alive()
{
- let goal = RadiusGoal::new(following.position(), 3.);
+ let goal = RadiusGoal::new(following.position()?, 3.);
if bot.is_calculating_path() {
// keep waiting
- } else if !goal.success(bot.position().into()) || bot.is_executing_path() {
+ } else if !goal.success(bot.position()?.into()) || bot.is_executing_path() {
bot.start_goto_with_opts(
goal,
PathfinderOpts::new()