mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
fix send_receivepacketevent running outside of game state
This commit is contained in:
parent
cfe6bea25a
commit
7d6cacc79b
4 changed files with 13 additions and 6 deletions
|
@ -815,11 +815,17 @@ pub struct JoinedClientBundle {
|
||||||
|
|
||||||
pub mining: mining::MineBundle,
|
pub mining: mining::MineBundle,
|
||||||
pub attack: attack::AttackBundle,
|
pub attack: attack::AttackBundle,
|
||||||
|
|
||||||
|
pub in_game_state: InGameState,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A marker component for local players that are currently in the
|
||||||
|
/// `game` state.
|
||||||
|
#[derive(Component, Clone, Debug, Default)]
|
||||||
|
pub struct InGameState;
|
||||||
/// A marker component for local players that are currently in the
|
/// A marker component for local players that are currently in the
|
||||||
/// `configuration` state.
|
/// `configuration` state.
|
||||||
#[derive(Component, Clone, Debug)]
|
#[derive(Component, Clone, Debug, Default)]
|
||||||
pub struct InConfigState;
|
pub struct InConfigState;
|
||||||
|
|
||||||
pub struct AzaleaPlugin;
|
pub struct AzaleaPlugin;
|
||||||
|
|
|
@ -5,7 +5,6 @@ use std::{
|
||||||
|
|
||||||
use azalea_chat::FormattedText;
|
use azalea_chat::FormattedText;
|
||||||
use azalea_core::resource_location::ResourceLocation;
|
use azalea_core::resource_location::ResourceLocation;
|
||||||
use azalea_entity::LocalEntity;
|
|
||||||
use azalea_protocol::{
|
use azalea_protocol::{
|
||||||
packets::{
|
packets::{
|
||||||
Packet,
|
Packet,
|
||||||
|
@ -19,7 +18,7 @@ use parking_lot::RwLock;
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{PlayerInfo, raw_connection::RawConnection};
|
use crate::{PlayerInfo, client::InGameState, raw_connection::RawConnection};
|
||||||
|
|
||||||
/// An event that's sent when we receive a packet.
|
/// An event that's sent when we receive a packet.
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -77,7 +76,7 @@ pub fn handle_outgoing_packets(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_receivepacketevent(
|
pub fn send_receivepacketevent(
|
||||||
query: Query<(Entity, &RawConnection), With<LocalEntity>>,
|
query: Query<(Entity, &RawConnection), With<InGameState>>,
|
||||||
mut packet_events: ResMut<Events<ReceivePacketEvent>>,
|
mut packet_events: ResMut<Events<ReceivePacketEvent>>,
|
||||||
) {
|
) {
|
||||||
// we manually clear and send the events at the beginning of each update
|
// we manually clear and send the events at the beginning of each update
|
||||||
|
|
|
@ -749,7 +749,7 @@ impl GamePacketHandler<'_> {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let entity_kind = *entity_kind;
|
let entity_kind = **entity_kind;
|
||||||
|
|
||||||
debug!("Got set entity data packet {p:?} for entity of kind {entity_kind:?}");
|
debug!("Got set entity data packet {p:?} for entity of kind {entity_kind:?}");
|
||||||
|
|
||||||
|
@ -766,7 +766,7 @@ impl GamePacketHandler<'_> {
|
||||||
let mut commands = commands_system_state.get_mut(world);
|
let mut commands = commands_system_state.get_mut(world);
|
||||||
let mut entity_commands = commands.entity(entity_id);
|
let mut entity_commands = commands.entity(entity_id);
|
||||||
if let Err(e) =
|
if let Err(e) =
|
||||||
apply_metadata(&mut entity_commands, *entity_kind, packed_items)
|
apply_metadata(&mut entity_commands, entity_kind, packed_items)
|
||||||
{
|
{
|
||||||
warn!("{e}");
|
warn!("{e}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -482,6 +482,8 @@ impl EntityBundle {
|
||||||
/// be updated by other clients.
|
/// be updated by other clients.
|
||||||
///
|
///
|
||||||
/// If this is for a client then all of our clients will have this.
|
/// If this is for a client then all of our clients will have this.
|
||||||
|
///
|
||||||
|
/// This component is not removed from clients when they disconnect.
|
||||||
#[derive(Component, Clone, Debug, Default)]
|
#[derive(Component, Clone, Debug, Default)]
|
||||||
pub struct LocalEntity;
|
pub struct LocalEntity;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue