aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/bot.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-07-09 19:11:29 -0500
committerGitHub <noreply@github.com>2023-07-09 19:11:29 -0500
commitd1afd02aa84e7b4450c1607277f078eb2a0f1bf3 (patch)
treeefea9bb7ef7f2064f7c963fd88f394fecec6231b /azalea/src/bot.rs
parentea8a8fccb6eb39c97f6cb69e11db5f7d0886172e (diff)
downloadazalea-drasl-d1afd02aa84e7b4450c1607277f078eb2a0f1bf3.tar.xz
Update to Bevy 0.11 (#94)
* update to bevy 0.11 * clippy --------- Co-authored-by: mat <git@matdoes.dev>
Diffstat (limited to 'azalea/src/bot.rs')
-rw-r--r--azalea/src/bot.rs29
1 files changed, 17 insertions, 12 deletions
diff --git a/azalea/src/bot.rs b/azalea/src/bot.rs
index 13b33bb0..47c825ca 100644
--- a/azalea/src/bot.rs
+++ b/azalea/src/bot.rs
@@ -1,4 +1,4 @@
-use crate::app::{App, CoreSchedule, IntoSystemAppConfig, Plugin, PluginGroup, PluginGroupBuilder};
+use crate::app::{App, Plugin, PluginGroup, PluginGroupBuilder};
use crate::auto_respawn::AutoRespawnPlugin;
use crate::container::ContainerPlugin;
use crate::ecs::{
@@ -6,13 +6,15 @@ use crate::ecs::{
entity::Entity,
event::EventReader,
query::{With, Without},
- schedule::IntoSystemConfig,
system::{Commands, Query},
};
use azalea_core::Vec3;
use azalea_physics::{force_jump_listener, PhysicsSet};
use azalea_world::entity::{clamp_look_direction, EyeHeight, LookDirection};
use azalea_world::entity::{metadata::Player, Jumping, Local, Position};
+use bevy_app::{FixedUpdate, Update};
+use bevy_ecs::prelude::Event;
+use bevy_ecs::schedule::IntoSystemConfigs;
use std::f64::consts::PI;
use crate::pathfinder::PathfinderPlugin;
@@ -23,16 +25,17 @@ impl Plugin for BotPlugin {
fn build(&self, app: &mut App) {
app.add_event::<LookAtEvent>()
.add_event::<JumpEvent>()
- .add_systems((
- insert_bot,
- look_at_listener
- .before(force_jump_listener)
- .before(clamp_look_direction),
- jump_listener,
- stop_jumping
- .in_schedule(CoreSchedule::FixedUpdate)
- .after(PhysicsSet),
- ));
+ .add_systems(
+ Update,
+ (
+ insert_bot,
+ look_at_listener
+ .before(force_jump_listener)
+ .before(clamp_look_direction),
+ jump_listener,
+ ),
+ )
+ .add_systems(FixedUpdate, stop_jumping.after(PhysicsSet));
}
}
@@ -85,6 +88,7 @@ impl BotClientExt for azalea_client::Client {
}
/// Event to jump once.
+#[derive(Event)]
pub struct JumpEvent(pub Entity);
fn jump_listener(mut query: Query<(&mut Jumping, &mut Bot)>, mut events: EventReader<JumpEvent>) {
@@ -97,6 +101,7 @@ fn jump_listener(mut query: Query<(&mut Jumping, &mut Bot)>, mut events: EventRe
}
/// Make an entity look towards a certain position in the world.
+#[derive(Event)]
pub struct LookAtEvent {
pub entity: Entity,
/// The position we want the entity to be looking at.