From 974150613a3bb63135bf27a7659881211f51c1f0 Mon Sep 17 00:00:00 2001 From: ghostly_zsh Date: Sun, 23 Mar 2025 17:30:26 -0500 Subject: [PATCH] fixed player ghost bug --- crates/client/src/networking/mod.rs | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crates/client/src/networking/mod.rs b/crates/client/src/networking/mod.rs index fe15e304a8cf1941284b32d973187cb1c5abb2da..105699501538a4bbd692bee4eedb25bbf09af8e4 100644 --- a/crates/client/src/networking/mod.rs +++ b/crates/client/src/networking/mod.rs @@ -145,6 +145,36 @@ pub fn process_packets( *amount = *m_amount; *max = *m_max; } + PlayerLeave { id } => { + let mut part_query = world.query_filtered::<(Entity, &ServerId), With>(); + let mut entity_to_remove = None; + for (entity, server_id) in part_query.iter_mut(world) { + if server_id.0 == *id { + entity_to_remove = Some(entity); + } + } + match entity_to_remove { + Some(entity) => { + world.despawn(entity); + } + None => {} + } + } + DespawnPart { id } => { + let mut part_query = world.query_filtered::<(Entity, &ServerId), With>(); + let mut entity_to_remove = None; + for (entity, server_id) in part_query.iter_mut(world) { + if server_id.0 == *id { + entity_to_remove = Some(entity); + } + } + match entity_to_remove { + Some(entity) => { + world.despawn(entity); + } + None => {} + } + } _ => {} } }