diff options
| author | mat <git@matdoes.dev> | 2025-09-29 02:01:50 +0700 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-09-29 02:01:50 +0700 |
| commit | a80d8d1b242430c4a251876fa67bfd26af7a0de9 (patch) | |
| tree | e683100c2f68fed0729dbaa12e7ef189189350be /azalea-client/src/plugins | |
| parent | 2c8b7c5c2c9297273abfba8f7743f1bc25f166b1 (diff) | |
| download | azalea-drasl-a80d8d1b242430c4a251876fa67bfd26af7a0de9.tar.xz | |
rename SendPacketEvent to SendGamePacketEvent and PingEvent to GamePingEvent
Diffstat (limited to 'azalea-client/src/plugins')
| -rw-r--r-- | azalea-client/src/plugins/attack.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/plugins/chat/handler.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/plugins/chat_signing.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/plugins/chunks.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/plugins/connection.rs | 6 | ||||
| -rw-r--r-- | azalea-client/src/plugins/interact/mod.rs | 12 | ||||
| -rw-r--r-- | azalea-client/src/plugins/inventory.rs | 8 | ||||
| -rw-r--r-- | azalea-client/src/plugins/loading.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/plugins/mining.rs | 14 | ||||
| -rw-r--r-- | azalea-client/src/plugins/movement.rs | 8 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/events.rs | 10 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/mod.rs | 10 | ||||
| -rw-r--r-- | azalea-client/src/plugins/pong.rs | 8 | ||||
| -rw-r--r-- | azalea-client/src/plugins/respawn.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/plugins/tick_end.rs | 4 |
15 files changed, 52 insertions, 52 deletions
diff --git a/azalea-client/src/plugins/attack.rs b/azalea-client/src/plugins/attack.rs index 47e45896..26b5f34d 100644 --- a/azalea-client/src/plugins/attack.rs +++ b/azalea-client/src/plugins/attack.rs @@ -10,7 +10,7 @@ use bevy_ecs::prelude::*; use derive_more::{Deref, DerefMut}; use tracing::warn; -use super::packet::game::SendPacketEvent; +use super::packet::game::SendGamePacketEvent; use crate::{ Client, interact::SwingArmEvent, local_player::LocalGameMode, movement::MoveEventsSet, respawn::perform_respawn, @@ -121,7 +121,7 @@ pub fn handle_attack_queued( commands.entity(client_entity).remove::<AttackQueued>(); - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( client_entity, ServerboundInteract { entity_id: target_entity_id, diff --git a/azalea-client/src/plugins/chat/handler.rs b/azalea-client/src/plugins/chat/handler.rs index d71bcbd1..5a2a065c 100644 --- a/azalea-client/src/plugins/chat/handler.rs +++ b/azalea-client/src/plugins/chat/handler.rs @@ -8,7 +8,7 @@ use azalea_protocol::packets::{ use bevy_ecs::prelude::*; use super::ChatKind; -use crate::{Account, chat_signing::ChatSigningSession, packet::game::SendPacketEvent}; +use crate::{Account, chat_signing::ChatSigningSession, packet::game::SendGamePacketEvent}; /// Send a chat packet to the server of a specific kind (chat message or /// command). Usually you just want [`SendChatEvent`] instead. @@ -81,7 +81,7 @@ pub fn handle_send_chat_kind_event( } }; - commands.trigger(SendPacketEvent::new(event.entity, packet)); + commands.trigger(SendGamePacketEvent::new(event.entity, packet)); } } diff --git a/azalea-client/src/plugins/chat_signing.rs b/azalea-client/src/plugins/chat_signing.rs index 8961430e..5c805f01 100644 --- a/azalea-client/src/plugins/chat_signing.rs +++ b/azalea-client/src/plugins/chat_signing.rs @@ -12,7 +12,7 @@ use chrono::Utc; use tracing::{debug, error}; use uuid::Uuid; -use super::{chat, login::IsAuthenticated, packet::game::SendPacketEvent}; +use super::{chat, login::IsAuthenticated, packet::game::SendGamePacketEvent}; use crate::{Account, InGameState}; pub struct ChatSigningPlugin; @@ -169,7 +169,7 @@ pub fn handle_queued_certs_to_send( debug!("Sending chat signing certs to server"); - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundChatSessionUpdate { chat_session }, )); diff --git a/azalea-client/src/plugins/chunks.rs b/azalea-client/src/plugins/chunks.rs index f8d2c523..6d0877cd 100644 --- a/azalea-client/src/plugins/chunks.rs +++ b/azalea-client/src/plugins/chunks.rs @@ -17,7 +17,7 @@ use bevy_ecs::prelude::*; use tracing::{error, trace}; use crate::{ - inventory::InventorySet, local_player::InstanceHolder, packet::game::SendPacketEvent, + inventory::InventorySet, local_player::InstanceHolder, packet::game::SendGamePacketEvent, respawn::perform_respawn, }; @@ -150,7 +150,7 @@ pub fn handle_chunk_batch_finished_event( if let Ok(mut chunk_batch_info) = query.get_mut(event.entity) { chunk_batch_info.batch_finished(event.batch_size); let desired_chunks_per_tick = chunk_batch_info.desired_chunks_per_tick(); - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( event.entity, ServerboundChunkBatchReceived { desired_chunks_per_tick, diff --git a/azalea-client/src/plugins/connection.rs b/azalea-client/src/plugins/connection.rs index 54966703..5d9cde18 100644 --- a/azalea-client/src/plugins/connection.rs +++ b/azalea-client/src/plugins/connection.rs @@ -171,7 +171,7 @@ pub struct RawConnection { /// handlers or at all times during tests. /// /// You shouldn't rely on this. Instead, use the events for sending packets - /// like [`SendPacketEvent`](crate::packet::game::SendPacketEvent) / + /// like [`SendGamePacketEvent`](crate::packet::game::SendGamePacketEvent) / /// [`SendConfigPacketEvent`](crate::packet::config::SendConfigPacketEvent) /// / [`SendLoginPacketEvent`](crate::packet::login::SendLoginPacketEvent). /// @@ -227,10 +227,10 @@ impl RawConnection { /// Write a packet to the server without emitting any events. /// - /// This is called by the handlers for [`SendPacketEvent`], + /// This is called by the handlers for [`SendGamePacketEvent`], /// [`SendConfigPacketEvent`], and [`SendLoginPacketEvent`]. /// - /// [`SendPacketEvent`]: crate::packet::game::SendPacketEvent + /// [`SendGamePacketEvent`]: crate::packet::game::SendGamePacketEvent /// [`SendConfigPacketEvent`]: crate::packet::config::SendConfigPacketEvent /// [`SendLoginPacketEvent`]: crate::packet::login::SendLoginPacketEvent pub fn write<P: ProtocolPacket + Debug>( diff --git a/azalea-client/src/plugins/interact/mod.rs b/azalea-client/src/plugins/interact/mod.rs index b5defdf0..27dba1d4 100644 --- a/azalea-client/src/plugins/interact/mod.rs +++ b/azalea-client/src/plugins/interact/mod.rs @@ -40,7 +40,7 @@ use crate::{ inventory::{Inventory, InventorySet}, local_player::{LocalGameMode, PermissionLevel}, movement::MoveEventsSet, - packet::game::SendPacketEvent, + packet::game::SendGamePacketEvent, respawn::perform_respawn, }; @@ -302,7 +302,7 @@ pub fn handle_start_use_item_queued( HitResult::Block(r) => { let seq = prediction_handler.start_predicting(); if r.miss { - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundUseItem { hand: start_use_item.hand, @@ -312,7 +312,7 @@ pub fn handle_start_use_item_queued( }, )); } else { - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundUseItemOn { hand: start_use_item.hand, @@ -342,7 +342,7 @@ pub fn handle_start_use_item_queued( }, using_secondary_action: physics_state.trying_to_crouch, }; - commands.trigger(SendPacketEvent::new(entity, interact.clone())); + commands.trigger(SendGamePacketEvent::new(entity, interact.clone())); // TODO: this is true if the interaction failed, which i think can only happen // in certain cases when interacting with armor stands let consumes_action = false; @@ -352,7 +352,7 @@ pub fn handle_start_use_item_queued( interact.action = s_interact::ActionType::Interact { hand: InteractionHand::MainHand, }; - commands.trigger(SendPacketEvent::new(entity, interact)); + commands.trigger(SendGamePacketEvent::new(entity, interact)); } } } @@ -430,7 +430,7 @@ pub struct SwingArmEvent { pub entity: Entity, } pub fn handle_swing_arm_trigger(swing_arm: On<SwingArmEvent>, mut commands: Commands) { - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( swing_arm.entity, ServerboundSwing { hand: InteractionHand::MainHand, diff --git a/azalea-client/src/plugins/inventory.rs b/azalea-client/src/plugins/inventory.rs index 448f9e95..6902430e 100644 --- a/azalea-client/src/plugins/inventory.rs +++ b/azalea-client/src/plugins/inventory.rs @@ -23,7 +23,7 @@ use bevy_ecs::prelude::*; use indexmap::IndexMap; use tracing::{error, warn}; -use crate::{Client, packet::game::SendPacketEvent, respawn::perform_respawn}; +use crate::{Client, packet::game::SendGamePacketEvent, respawn::perform_respawn}; pub struct InventoryPlugin; impl Plugin for InventoryPlugin { @@ -764,7 +764,7 @@ fn handle_container_close_event( return; } - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundContainerClose { container_id: inventory.id, @@ -873,7 +873,7 @@ pub fn handle_container_click_event( } } - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundContainerClick { container_id: container_click.window_id, @@ -969,7 +969,7 @@ pub fn ensure_has_sent_carried_item( continue; } - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundSetCarriedItem { slot: inventory.selected_hotbar_slot as u16, diff --git a/azalea-client/src/plugins/loading.rs b/azalea-client/src/plugins/loading.rs index 86c2b2de..45735f3b 100644 --- a/azalea-client/src/plugins/loading.rs +++ b/azalea-client/src/plugins/loading.rs @@ -5,7 +5,7 @@ use azalea_protocol::packets::game::ServerboundPlayerLoaded; use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use crate::{mining::MiningSet, packet::game::SendPacketEvent}; +use crate::{mining::MiningSet, packet::game::SendGamePacketEvent}; pub struct PlayerLoadedPlugin; impl Plugin for PlayerLoadedPlugin { @@ -45,7 +45,7 @@ pub fn player_loaded_packet( >, ) { for entity in query.iter() { - commands.trigger(SendPacketEvent::new(entity, ServerboundPlayerLoaded)); + commands.trigger(SendGamePacketEvent::new(entity, ServerboundPlayerLoaded)); commands.entity(entity).insert(HasClientLoaded); } } diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs index b4f8adbe..499ae71f 100644 --- a/azalea-client/src/plugins/mining.rs +++ b/azalea-client/src/plugins/mining.rs @@ -19,7 +19,7 @@ use crate::{ inventory::{Inventory, InventorySet}, local_player::{InstanceHolder, LocalGameMode, PermissionLevel}, movement::MoveEventsSet, - packet::game::SendPacketEvent, + packet::game::SendGamePacketEvent, }; /// A plugin that allows clients to break blocks in the world. @@ -258,7 +258,7 @@ pub fn handle_mining_queued( if game_mode.current == GameMode::Creative { // In creative mode, first send START_DESTROY_BLOCK packet then immediately // finish mining - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundPlayerAction { action: s_player_action::Action::StartDestroyBlock, @@ -283,7 +283,7 @@ pub fn handle_mining_queued( { if mining.is_some() { // send a packet to stop mining since we just changed target - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundPlayerAction { action: s_player_action::Action::AbortDestroyBlock, @@ -347,7 +347,7 @@ pub fn handle_mining_queued( }); } - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundPlayerAction { action: s_player_action::Action::StartDestroyBlock, @@ -525,7 +525,7 @@ pub fn handle_stop_mining_block_event( let mine_block_pos = mine_block_pos.expect("IsMining is true so MineBlockPos must be present"); - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( event.entity, ServerboundPlayerAction { action: s_player_action::Action::AbortDestroyBlock, @@ -589,7 +589,7 @@ pub fn continue_mining_block( if game_mode.current == GameMode::Creative { // TODO: worldborder check **mine_delay = 5; - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundPlayerAction { action: s_player_action::Action::StartDestroyBlock, @@ -645,7 +645,7 @@ pub fn continue_mining_block( entity, position: mining.pos, }); - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundPlayerAction { action: s_player_action::Action::StopDestroyBlock, diff --git a/azalea-client/src/plugins/movement.rs b/azalea-client/src/plugins/movement.rs index c76158c5..4559be20 100644 --- a/azalea-client/src/plugins/movement.rs +++ b/azalea-client/src/plugins/movement.rs @@ -40,7 +40,7 @@ use thiserror::Error; use crate::{ client::Client, local_player::{Hunger, InstanceHolder, LocalGameMode}, - packet::game::SendPacketEvent, + packet::game::SendGamePacketEvent, }; #[derive(Error, Debug)] @@ -251,7 +251,7 @@ pub fn send_position( }; if let Some(packet) = packet { - commands.trigger(SendPacketEvent { + commands.trigger(SendGamePacketEvent { sent_by: entity, packet, }); @@ -283,7 +283,7 @@ pub fn send_player_input_packet( let last_sent_input = last_sent_input.cloned().unwrap_or_default(); if input != last_sent_input.0 { - commands.trigger(SendPacketEvent { + commands.trigger(SendGamePacketEvent { sent_by: entity, packet: input.clone().into_variant(), }); @@ -304,7 +304,7 @@ pub fn send_sprinting_if_needed( } else { azalea_protocol::packets::game::s_player_command::Action::StopSprinting }; - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( entity, ServerboundPlayerCommand { id: *minecraft_entity_id, diff --git a/azalea-client/src/plugins/packet/game/events.rs b/azalea-client/src/plugins/packet/game/events.rs index 4ae51734..cb9a5e07 100644 --- a/azalea-client/src/plugins/packet/game/events.rs +++ b/azalea-client/src/plugins/packet/game/events.rs @@ -18,7 +18,7 @@ use crate::{client::InGameState, connection::RawConnection, player::PlayerInfo}; /// ``` /// # use azalea_client::packet::game::ReceiveGamePacketEvent; /// # use azalea_protocol::packets::game::ClientboundGamePacket; -/// # use bevy_ecs::event::MessageReader; +/// # use bevy_ecs::message::MessageReader; /// /// fn handle_packets(mut events: MessageReader<ReceiveGamePacketEvent>) { /// for ReceiveGamePacketEvent { entity, packet } in events.read() { @@ -41,12 +41,12 @@ pub struct ReceiveGamePacketEvent { /// An event for sending a packet to the server while we're in the `game` state. #[derive(EntityEvent, Clone, Debug)] -pub struct SendPacketEvent { +pub struct SendGamePacketEvent { #[event_target] pub sent_by: Entity, pub packet: ServerboundGamePacket, } -impl SendPacketEvent { +impl SendGamePacketEvent { pub fn new(sent_by: Entity, packet: impl Packet<ServerboundGamePacket>) -> Self { let packet = packet.into_variant(); Self { sent_by, packet } @@ -54,7 +54,7 @@ impl SendPacketEvent { } pub fn handle_outgoing_packets_observer( - trigger: On<SendPacketEvent>, + trigger: On<SendGamePacketEvent>, mut query: Query<(&mut RawConnection, Option<&InGameState>)>, ) { let event = trigger.event(); @@ -152,7 +152,7 @@ pub struct InstanceLoadedEvent { /// [`ClientboundPing`]: azalea_protocol::packets::game::ClientboundPing /// [`ConfigPingEvent`]: crate::packet::config::ConfigPingEvent #[derive(EntityEvent, Debug, Clone)] -pub struct PingEvent { +pub struct GamePingEvent { pub entity: Entity, pub packet: azalea_protocol::packets::game::ClientboundPing, } diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index dbdc8e26..ed45ab61 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -420,11 +420,11 @@ impl GamePacketHandler<'_> { physics.set_old_pos(*position); // send the relevant packets - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( self.player, ServerboundAcceptTeleportation { id: p.id }, )); - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( self.player, ServerboundMovePlayerPosRot { pos: **position, @@ -964,7 +964,7 @@ impl GamePacketHandler<'_> { entity: self.player, id: p.id, }); - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( self.player, ServerboundKeepAlive { id: p.id }, )); @@ -1278,7 +1278,7 @@ impl GamePacketHandler<'_> { debug!("Got ping packet {p:?}"); as_system::<Commands>(self.ecs, |mut commands| { - commands.trigger(PingEvent { + commands.trigger(GamePingEvent { entity: self.player, packet: p.clone(), }); @@ -1443,7 +1443,7 @@ impl GamePacketHandler<'_> { }; raw_conn.state = ConnectionProtocol::Configuration; - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( self.player, ServerboundConfigurationAcknowledged, )); diff --git a/azalea-client/src/plugins/pong.rs b/azalea-client/src/plugins/pong.rs index f268a836..6370a932 100644 --- a/azalea-client/src/plugins/pong.rs +++ b/azalea-client/src/plugins/pong.rs @@ -4,9 +4,9 @@ use bevy_ecs::prelude::*; use super::packet::{ config::{ConfigPingEvent, SendConfigPacketEvent}, - game::PingEvent, + game::GamePingEvent, }; -use crate::packet::game::SendPacketEvent; +use crate::packet::game::SendGamePacketEvent; /// A plugin that replies to [`ClientboundPing`] packets with /// [`ServerboundPong`]. @@ -23,8 +23,8 @@ impl Plugin for PongPlugin { } } -pub fn reply_to_game_ping(ping: On<PingEvent>, mut commands: Commands) { - commands.trigger(SendPacketEvent::new( +pub fn reply_to_game_ping(ping: On<GamePingEvent>, mut commands: Commands) { + commands.trigger(SendGamePacketEvent::new( ping.entity, game::ServerboundPong { id: ping.packet.id }, )); diff --git a/azalea-client/src/plugins/respawn.rs b/azalea-client/src/plugins/respawn.rs index ecc773c4..7c16b0e2 100644 --- a/azalea-client/src/plugins/respawn.rs +++ b/azalea-client/src/plugins/respawn.rs @@ -2,7 +2,7 @@ use azalea_protocol::packets::game::s_client_command::{self, ServerboundClientCo use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; -use crate::packet::game::SendPacketEvent; +use crate::packet::game::SendGamePacketEvent; /// Tell the server that we're respawning. #[derive(Message, Debug, Clone)] @@ -21,7 +21,7 @@ impl Plugin for RespawnPlugin { pub fn perform_respawn(mut events: MessageReader<PerformRespawnEvent>, mut commands: Commands) { for event in events.read() { - commands.trigger(SendPacketEvent::new( + commands.trigger(SendGamePacketEvent::new( event.entity, ServerboundClientCommand { action: s_client_command::Action::PerformRespawn, diff --git a/azalea-client/src/plugins/tick_end.rs b/azalea-client/src/plugins/tick_end.rs index 6ad924ee..daa78454 100644 --- a/azalea-client/src/plugins/tick_end.rs +++ b/azalea-client/src/plugins/tick_end.rs @@ -8,7 +8,7 @@ use azalea_world::InstanceName; use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use crate::{mining::MiningSet, packet::game::SendPacketEvent}; +use crate::{mining::MiningSet, packet::game::SendGamePacketEvent}; /// A plugin that makes clients send a [`ServerboundClientTickEnd`] packet every /// tick. @@ -31,6 +31,6 @@ pub fn game_tick_packet( mut commands: Commands, ) { for entity in query.iter() { - commands.trigger(SendPacketEvent::new(entity, ServerboundClientTickEnd)); + commands.trigger(SendGamePacketEvent::new(entity, ServerboundClientTickEnd)); } } |
