aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-02-24 04:24:52 +0000
committermat <git@matdoes.dev>2025-02-24 04:24:52 +0000
commit7d6cacc79baadc53c7ac9eee735af311423634ad (patch)
tree973830546f327cc3fdbdfefcb474daa38c9f8d59
parentcfe6bea25a619846bbd5e23022ae572ea487563d (diff)
downloadazalea-drasl-7d6cacc79baadc53c7ac9eee735af311423634ad.tar.xz
fix send_receivepacketevent running outside of game state
-rw-r--r--azalea-client/src/client.rs8
-rw-r--r--azalea-client/src/plugins/packet/game/events.rs5
-rw-r--r--azalea-client/src/plugins/packet/game/mod.rs4
-rw-r--r--azalea-entity/src/lib.rs2
4 files changed, 13 insertions, 6 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs
index 5863690e..ae94c773 100644
--- a/azalea-client/src/client.rs
+++ b/azalea-client/src/client.rs
@@ -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;
diff --git a/azalea-client/src/plugins/packet/game/events.rs b/azalea-client/src/plugins/packet/game/events.rs
index 19f2a571..9e7f88fa 100644
--- a/azalea-client/src/plugins/packet/game/events.rs
+++ b/azalea-client/src/plugins/packet/game/events.rs
@@ -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
diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs
index 2826295d..c3381e59 100644
--- a/azalea-client/src/plugins/packet/game/mod.rs
+++ b/azalea-client/src/plugins/packet/game/mod.rs
@@ -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}");
}
diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs
index 770afc50..49e42017 100644
--- a/azalea-entity/src/lib.rs
+++ b/azalea-entity/src/lib.rs
@@ -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;