diff options
| author | mat <git@matdoes.dev> | 2023-08-25 23:28:19 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-08-25 23:28:19 -0500 |
| commit | 472496b7b808b4c6ac6f8e161a5bc1d08f5b0524 (patch) | |
| tree | b839d9c63829c3e215940f05cdcf0b17cd226300 /azalea-client/src | |
| parent | 2773146fbfd9b61c0ea09210b6d7b9760be5e7dc (diff) | |
| download | azalea-drasl-472496b7b808b4c6ac6f8e161a5bc1d08f5b0524.tar.xz | |
fix all bevy ambiguities
Diffstat (limited to 'azalea-client/src')
| -rw-r--r-- | azalea-client/src/attack.rs | 15 | ||||
| -rw-r--r-- | azalea-client/src/client.rs | 14 | ||||
| -rw-r--r-- | azalea-client/src/events.rs | 2 | ||||
| -rw-r--r-- | azalea-client/src/interact.rs | 10 | ||||
| -rw-r--r-- | azalea-client/src/inventory.rs | 8 | ||||
| -rw-r--r-- | azalea-client/src/mining.rs | 19 | ||||
| -rw-r--r-- | azalea-client/src/movement.rs | 10 | ||||
| -rw-r--r-- | azalea-client/src/packet_handling.rs | 3 |
8 files changed, 58 insertions, 23 deletions
diff --git a/azalea-client/src/attack.rs b/azalea-client/src/attack.rs index 34083ffc..45a4ccaf 100644 --- a/azalea-client/src/attack.rs +++ b/azalea-client/src/attack.rs @@ -1,8 +1,9 @@ use azalea_core::GameMode; use azalea_entity::{ metadata::{ShiftKeyDown, Sprinting}, - Attributes, Physics, + update_bounding_box, Attributes, Physics, }; +use azalea_physics::PhysicsSet; use azalea_protocol::packets::game::serverbound_interact_packet::{ self, ServerboundInteractPacket, }; @@ -14,6 +15,8 @@ use derive_more::{Deref, DerefMut}; use crate::{ interact::SwingArmEvent, local_player::{LocalGameMode, SendPacketEvent}, + movement::walk_listener, + respawn::perform_respawn, Client, }; @@ -21,12 +24,18 @@ pub struct AttackPlugin; impl Plugin for AttackPlugin { fn build(&self, app: &mut App) { app.add_event::<AttackEvent>() - .add_systems(Update, handle_attack_event) + .add_systems( + Update, + handle_attack_event + .before(update_bounding_box) + .before(walk_listener) + .after(perform_respawn), + ) .add_systems( FixedUpdate, ( increment_ticks_since_last_attack, - update_attack_strength_scale, + update_attack_strength_scale.after(PhysicsSet), ) .chain(), ); diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index b44e8b4e..517db4e9 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -25,7 +25,7 @@ use azalea_entity::{ indexing::EntityIdIndex, metadata::Health, EntityPlugin, EntityUpdateSet, EyeHeight, Local, Position, }; -use azalea_physics::{PhysicsPlugin, PhysicsSet}; +use azalea_physics::PhysicsPlugin; use azalea_protocol::{ connect::{Connection, ConnectionError}, packets::{ @@ -48,7 +48,7 @@ use azalea_protocol::{ resolver, ServerAddress, }; use azalea_world::{Instance, InstanceContainer, InstanceName, PartialInstance}; -use bevy_app::{App, FixedUpdate, Main, Plugin, PluginGroup, PluginGroupBuilder, Update}; +use bevy_app::{App, FixedUpdate, Plugin, PluginGroup, PluginGroupBuilder, Update}; use bevy_ecs::{ bundle::Bundle, component::Component, @@ -617,7 +617,7 @@ impl Plugin for AzaleaPlugin { .add_systems( Update, ( - update_in_loaded_chunk.after(PhysicsSet), + update_in_loaded_chunk, // fire the Death event when the player dies. death_event, // add GameProfileComponent when we get an AddPlayerEvent @@ -721,7 +721,13 @@ impl Plugin for TickBroadcastPlugin { pub struct AmbiguityLoggerPlugin; impl Plugin for AmbiguityLoggerPlugin { fn build(&self, app: &mut App) { - app.edit_schedule(Main, |schedule| { + app.edit_schedule(Update, |schedule| { + schedule.set_build_settings(ScheduleBuildSettings { + ambiguity_detection: LogLevel::Warn, + ..Default::default() + }); + }); + app.edit_schedule(FixedUpdate, |schedule| { schedule.set_build_settings(ScheduleBuildSettings { ambiguity_detection: LogLevel::Warn, ..Default::default() diff --git a/azalea-client/src/events.rs b/azalea-client/src/events.rs index d5a32449..0d34d47b 100644 --- a/azalea-client/src/events.rs +++ b/azalea-client/src/events.rs @@ -209,7 +209,7 @@ fn remove_player_listener( } } -fn death_listener(query: Query<&LocalPlayerEvents>, mut events: EventReader<DeathEvent>) { +pub fn death_listener(query: Query<&LocalPlayerEvents>, mut events: EventReader<DeathEvent>) { for event in events.iter() { if let Ok(local_player_events) = query.get(event.entity) { local_player_events diff --git a/azalea-client/src/interact.rs b/azalea-client/src/interact.rs index 3c9428ff..2f7480cb 100644 --- a/azalea-client/src/interact.rs +++ b/azalea-client/src/interact.rs @@ -28,7 +28,7 @@ use log::warn; use crate::{ client::{PermissionLevel, PlayerAbilities}, - inventory::InventoryComponent, + inventory::{InventoryComponent, InventorySet}, local_player::{handle_send_packet_event, LocalGameMode, SendPacketEvent}, Client, LocalPlayer, }; @@ -49,7 +49,9 @@ impl Plugin for InteractPlugin { ) .before(handle_send_packet_event) .chain(), - update_modifiers_for_held_item, + update_modifiers_for_held_item + .after(InventorySet) + .after(crate::movement::walk_listener), ), ); } @@ -151,7 +153,7 @@ pub fn handle_block_interact_event( } #[allow(clippy::type_complexity)] -fn update_hit_result_component( +pub fn update_hit_result_component( mut commands: Commands, mut query: Query<( Entity, @@ -297,7 +299,7 @@ pub fn can_use_game_master_blocks( pub struct SwingArmEvent { pub entity: Entity, } -fn handle_swing_arm_event( +pub fn handle_swing_arm_event( mut events: EventReader<SwingArmEvent>, mut send_packet_events: EventWriter<SendPacketEvent>, ) { diff --git a/azalea-client/src/inventory.rs b/azalea-client/src/inventory.rs index 6f7829de..da5376fc 100644 --- a/azalea-client/src/inventory.rs +++ b/azalea-client/src/inventory.rs @@ -20,7 +20,7 @@ use bevy_ecs::{ entity::Entity, event::EventReader, prelude::{Event, EventWriter}, - schedule::IntoSystemConfigs, + schedule::{IntoSystemConfigs, SystemSet}, system::Query, }; use log::warn; @@ -44,11 +44,15 @@ impl Plugin for InventoryPlugin { handle_container_close_event.before(handle_send_packet_event), handle_client_side_close_container_event, ) - .chain(), + .chain() + .in_set(InventorySet), ); } } +#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)] +pub struct InventorySet; + impl Client { /// Return the menu that is currently open. If no menu is open, this will /// have the player's inventory. diff --git a/azalea-client/src/mining.rs b/azalea-client/src/mining.rs index c087c467..3d43e712 100644 --- a/azalea-client/src/mining.rs +++ b/azalea-client/src/mining.rs @@ -2,6 +2,7 @@ use azalea_block::{Block, BlockState, FluidState}; use azalea_core::{BlockPos, Direction, GameMode}; use azalea_entity::{mining::get_mine_progress, FluidOnEyes, Physics}; use azalea_inventory::ItemSlot; +use azalea_physics::PhysicsSet; use azalea_protocol::packets::game::serverbound_player_action_packet::{ self, ServerboundPlayerActionPacket, }; @@ -16,7 +17,7 @@ use crate::{ can_use_game_master_blocks, check_is_interaction_restricted, CurrentSequenceNumber, HitResultComponent, SwingArmEvent, }, - inventory::InventoryComponent, + inventory::{InventoryComponent, InventorySet}, local_player::{LocalGameMode, SendPacketEvent}, Client, }; @@ -31,7 +32,7 @@ impl Plugin for MinePlugin { .add_event::<StopMiningBlockEvent>() .add_event::<MineBlockProgressEvent>() .add_event::<AttackBlockEvent>() - .add_systems(FixedUpdate, continue_mining_block) + .add_systems(FixedUpdate, continue_mining_block.before(PhysicsSet)) .add_systems( Update, ( @@ -40,11 +41,23 @@ impl Plugin for MinePlugin { handle_finish_mining_block_event, handle_stop_mining_block_event, ) - .chain(), + .chain() + .in_set(MiningSet) + .after(InventorySet) + .before(azalea_entity::update_bounding_box) + .after(azalea_entity::update_fluid_on_eyes) + .after(crate::interact::update_hit_result_component) + .after(crate::attack::handle_attack_event) + .after(crate::interact::handle_block_interact_event) + .before(crate::interact::handle_swing_arm_event) + .before(azalea_physics::handle_force_jump), ); } } +#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)] +pub struct MiningSet; + impl Client { pub fn start_mining(&mut self, position: BlockPos) { self.ecs.lock().send_event(StartMiningBlockEvent { diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs index 919be0e6..b1e58324 100644 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -1,8 +1,8 @@ use crate::client::Client; -use crate::local_player::{update_in_loaded_chunk, LocalPlayer, LocalPlayerInLoadedChunk}; +use crate::local_player::{LocalPlayer, LocalPlayerInLoadedChunk}; use azalea_entity::{metadata::Sprinting, Attributes, Jumping}; use azalea_entity::{LastSentPosition, LookDirection, Physics, Position}; -use azalea_physics::{force_jump_listener, PhysicsSet}; +use azalea_physics::{handle_force_jump, PhysicsSet}; use azalea_protocol::packets::game::serverbound_player_command_packet::ServerboundPlayerCommandPacket; use azalea_protocol::packets::game::{ serverbound_move_player_pos_packet::ServerboundMovePlayerPosPacket, @@ -48,7 +48,7 @@ impl Plugin for PlayerMovePlugin { Update, (sprint_listener, walk_listener) .chain() - .before(force_jump_listener), + .before(handle_force_jump), ) .add_systems( FixedUpdate, @@ -56,7 +56,7 @@ impl Plugin for PlayerMovePlugin { local_player_ai_step .in_set(PhysicsSet) .before(azalea_physics::ai_step), - send_position.after(update_in_loaded_chunk), + send_position.after(PhysicsSet), ) .chain(), ); @@ -120,7 +120,7 @@ pub struct PhysicsState { } #[allow(clippy::type_complexity)] -pub(crate) fn send_position( +pub fn send_position( mut query: Query< ( &MinecraftEntityId, diff --git a/azalea-client/src/packet_handling.rs b/azalea-client/src/packet_handling.rs index 0b6e23b1..605da379 100644 --- a/azalea-client/src/packet_handling.rs +++ b/azalea-client/src/packet_handling.rs @@ -42,6 +42,7 @@ use crate::{ chat::{ChatPacket, ChatReceivedEvent}, client::{PlayerAbilities, TabList}, disconnect::DisconnectEvent, + events::death_listener, inventory::{ ClientSideCloseContainerEvent, InventoryComponent, MenuOpenedEvent, SetContainerContentEvent, @@ -90,7 +91,7 @@ impl Plugin for PacketHandlerPlugin { // we want to index and deindex right after .before(EntityUpdateSet::Deindex), ) - .add_systems(Update, death_event_on_0_health) + .add_systems(Update, death_event_on_0_health.before(death_listener)) .init_resource::<Events<PacketEvent>>() .add_event::<AddPlayerEvent>() .add_event::<RemovePlayerEvent>() |
