1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

fix an error in set_entity_data

This commit is contained in:
mat 2025-02-24 04:14:54 +00:00
parent 172e0ce079
commit 9e061be903
2 changed files with 11 additions and 5 deletions

View file

@ -742,9 +742,13 @@ impl GamePacketHandler<'_> {
return; return;
}; };
let entity_kind = *entity_kind_query let Ok(entity_kind) = entity_kind_query.get(entity) else {
.get(entity) debug!(
.expect("EntityKind component should always be present for entities"); "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:?}"); debug!("Got set entity data packet {p:?} for entity of kind {entity_kind:?}");

View file

@ -488,7 +488,9 @@ where
} }
if let Some(handler) = &self.handler { if let Some(handler) = &self.handler {
let Some(first_bot_state) = first_bot.get_component::<S>() else { let ecs_mutex = first_bot.ecs.clone();
let mut ecs = ecs_mutex.lock();
let Some(first_bot_state) = first_bot.query::<Option<&S>>(&mut ecs).cloned() else {
error!( error!(
"the first bot ({} / {}) is missing the required state component! none of the client handler functions will be called.", "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 first_bot.profile.name, first_bot.entity
@ -506,7 +508,7 @@ where
let state = match states.entry(bot.entity) { let state = match states.entry(bot.entity) {
hash_map::Entry::Occupied(e) => e.into_mut(), hash_map::Entry::Occupied(e) => e.into_mut(),
hash_map::Entry::Vacant(e) => { hash_map::Entry::Vacant(e) => {
let Some(state) = bot.get_component::<S>() else { let Some(state) = bot.query::<Option<&S>>(&mut ecs).cloned() else {
error!( error!(
"one of our bots ({} / {}) is missing the required state component! its client handler function will not be called.", "one of our bots ({} / {}) is missing the required state component! its client handler function will not be called.",
bot.profile.name, bot.entity bot.profile.name, bot.entity