diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index 5f3e125f..f3670c71 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -742,9 +742,13 @@ impl GamePacketHandler<'_> { return; }; - let entity_kind = *entity_kind_query - .get(entity) - .expect("EntityKind component should always be present for entities"); + let Ok(entity_kind) = entity_kind_query.get(entity) else { + debug!( + "Server sent an entity data packet for an entity id ({}) that we have indexed as {entity} but they don't have EntityKind. Maybe a second local client that just disconnected?", + p.id + ); + return; + }; debug!("Got set entity data packet {p:?} for entity of kind {entity_kind:?}"); diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index a9b2512b..04bc94dc 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -488,7 +488,9 @@ where } if let Some(handler) = &self.handler { - let Some(first_bot_state) = first_bot.get_component::() else { + let ecs_mutex = first_bot.ecs.clone(); + let mut ecs = ecs_mutex.lock(); + let Some(first_bot_state) = first_bot.query::>(&mut ecs).cloned() else { error!( "the first bot ({} / {}) is missing the required state component! none of the client handler functions will be called.", first_bot.profile.name, first_bot.entity @@ -506,7 +508,7 @@ where let state = match states.entry(bot.entity) { hash_map::Entry::Occupied(e) => e.into_mut(), hash_map::Entry::Vacant(e) => { - let Some(state) = bot.get_component::() else { + let Some(state) = bot.query::>(&mut ecs).cloned() else { error!( "one of our bots ({} / {}) is missing the required state component! its client handler function will not be called.", bot.profile.name, bot.entity