1
2
Fork 0
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:
mat 2025-02-24 04:24:52 +00:00
parent cfe6bea25a
commit 7d6cacc79b
4 changed files with 13 additions and 6 deletions

View file

@ -815,11 +815,17 @@ pub struct JoinedClientBundle {
pub mining: mining::MineBundle,
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
/// `configuration` state.
#[derive(Component, Clone, Debug)]
#[derive(Component, Clone, Debug, Default)]
pub struct InConfigState;
pub struct AzaleaPlugin;

View file

@ -5,7 +5,6 @@ use std::{
use azalea_chat::FormattedText;
use azalea_core::resource_location::ResourceLocation;
use azalea_entity::LocalEntity;
use azalea_protocol::{
packets::{
Packet,
@ -19,7 +18,7 @@ use parking_lot::RwLock;
use tracing::{debug, error};
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.
/// ```
@ -77,7 +76,7 @@ pub fn handle_outgoing_packets(
}
pub fn send_receivepacketevent(
query: Query<(Entity, &RawConnection), With<LocalEntity>>,
query: Query<(Entity, &RawConnection), With<InGameState>>,
mut packet_events: ResMut<Events<ReceivePacketEvent>>,
) {
// we manually clear and send the events at the beginning of each update

View file

@ -749,7 +749,7 @@ impl GamePacketHandler<'_> {
);
return;
};
let entity_kind = *entity_kind;
let entity_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 entity_commands = commands.entity(entity_id);
if let Err(e) =
apply_metadata(&mut entity_commands, *entity_kind, packed_items)
apply_metadata(&mut entity_commands, entity_kind, packed_items)
{
warn!("{e}");
}

View file

@ -482,6 +482,8 @@ impl EntityBundle {
/// be updated by other clients.
///
/// 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)]
pub struct LocalEntity;