diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2023-03-07 14:14:36 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-07 14:14:36 -0600 |
| commit | 719379a8a76ab0685f2bd14bebe2f0cd1e97f06b (patch) | |
| tree | ce5d6c62bc36fb1d1ec31083bc8e81a0109c12df /azalea-client/src/movement.rs | |
| parent | bf4ff517890cad3ff4e36b4b78959504192e5374 (diff) | |
| download | azalea-drasl-719379a8a76ab0685f2bd14bebe2f0cd1e97f06b.tar.xz | |
Bevy 0.10 (#79)
* replace 0.9.1 with 0.10.0
* start migrating to bevy .10
* well it compiles
* doesn't immediately panic
* remove unused imports
* fmt
* delete azalea-ecs
* make RelativeEntityUpdate an EntityCommand
* fix a doc test
* explain what FixedUpdate does
Diffstat (limited to 'azalea-client/src/movement.rs')
| -rw-r--r-- | azalea-client/src/movement.rs | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs index f379501c..f6123c70 100644 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -1,7 +1,8 @@ use crate::client::Client; -use crate::local_player::{LocalPlayer, LocalPlayerInLoadedChunk, PhysicsState}; -use azalea_ecs::entity::Entity; -use azalea_ecs::{event::EventReader, query::With, system::Query}; +use crate::local_player::{ + update_in_loaded_chunk, LocalPlayer, LocalPlayerInLoadedChunk, PhysicsState, +}; +use azalea_physics::{force_jump_listener, PhysicsSet}; use azalea_protocol::packets::game::serverbound_player_command_packet::ServerboundPlayerCommandPacket; use azalea_protocol::packets::game::{ serverbound_move_player_pos_packet::ServerboundMovePlayerPosPacket, @@ -13,6 +14,14 @@ use azalea_world::{ entity::{self, metadata::Sprinting, Attributes, Jumping, MinecraftEntityId}, MoveEntityError, }; +use bevy_app::{App, CoreSchedule, IntoSystemAppConfigs, Plugin}; +use bevy_ecs::{ + entity::Entity, + event::EventReader, + query::With, + schedule::{IntoSystemConfig, IntoSystemConfigs}, + system::Query, +}; use std::backtrace::Backtrace; use thiserror::Error; @@ -34,6 +43,28 @@ impl From<MoveEntityError> for MovePlayerError { } } +pub struct PlayerMovePlugin; + +impl Plugin for PlayerMovePlugin { + fn build(&self, app: &mut App) { + app.add_event::<StartWalkEvent>() + .add_event::<StartSprintEvent>() + .add_systems( + (sprint_listener, walk_listener) + .chain() + .before(force_jump_listener), + ) + .add_systems( + ( + local_player_ai_step.in_set(PhysicsSet), + send_position.after(update_in_loaded_chunk), + ) + .chain() + .in_schedule(CoreSchedule::FixedUpdate), + ); + } +} + impl Client { /// Set whether we're jumping. This acts as if you held space in /// vanilla. If you want to jump once, use the `jump` function. |
