From 719379a8a76ab0685f2bd14bebe2f0cd1e97f06b Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Tue, 7 Mar 2023 14:14:36 -0600 Subject: 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 --- azalea-client/src/movement.rs | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'azalea-client/src/movement.rs') 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 for MovePlayerError { } } +pub struct PlayerMovePlugin; + +impl Plugin for PlayerMovePlugin { + fn build(&self, app: &mut App) { + app.add_event::() + .add_event::() + .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. -- cgit v1.2.3