mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
change some warnings to debug logs and improve some entity id index code
This commit is contained in:
parent
5721eaf193
commit
a86d011d4a
2 changed files with 22 additions and 19 deletions
|
@ -727,7 +727,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query, entity_kind_query) = system_state.get_mut(ecs);
|
let (mut commands, mut query, entity_kind_query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let entity = entity_id_index.get(&MinecraftEntityId(p.id));
|
let entity = entity_id_index.get(MinecraftEntityId(p.id));
|
||||||
|
|
||||||
let Some(entity) = entity else {
|
let Some(entity) = entity else {
|
||||||
warn!("Server sent an entity data packet for an entity id ({}) that we don't know about", p.id);
|
warn!("Server sent an entity data packet for an entity id ({}) that we don't know about", p.id);
|
||||||
|
@ -773,8 +773,11 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let Some(entity) = entity_id_index.get(&MinecraftEntityId(p.id)) else {
|
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else {
|
||||||
warn!(
|
// note that this log (and some other ones like the one in RemoveEntities)
|
||||||
|
// sometimes happens when killing mobs. it seems to be a vanilla bug, which is
|
||||||
|
// why it's a debug log instead of a warning
|
||||||
|
debug!(
|
||||||
"Got set entity motion packet for unknown entity id {}",
|
"Got set entity motion packet for unknown entity id {}",
|
||||||
p.id
|
p.id
|
||||||
);
|
);
|
||||||
|
@ -839,7 +842,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let Some(entity) = entity_id_index.get(&MinecraftEntityId(p.id)) else {
|
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else {
|
||||||
warn!("Got teleport entity packet for unknown entity id {}", p.id);
|
warn!("Got teleport entity packet for unknown entity id {}", p.id);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@ -885,8 +888,8 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
|
|
||||||
debug!("Got move entity pos packet {p:?}");
|
debug!("Got move entity pos packet {p:?}");
|
||||||
|
|
||||||
let Some(entity) = entity_id_index.get(&MinecraftEntityId(p.entity_id)) else {
|
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.entity_id)) else {
|
||||||
warn!(
|
debug!(
|
||||||
"Got move entity pos packet for unknown entity id {}",
|
"Got move entity pos packet for unknown entity id {}",
|
||||||
p.entity_id
|
p.entity_id
|
||||||
);
|
);
|
||||||
|
@ -926,7 +929,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
|
|
||||||
debug!("Got move entity pos rot packet {p:?}");
|
debug!("Got move entity pos rot packet {p:?}");
|
||||||
|
|
||||||
let entity = entity_id_index.get(&MinecraftEntityId(p.entity_id));
|
let entity = entity_id_index.get(MinecraftEntityId(p.entity_id));
|
||||||
|
|
||||||
if let Some(entity) = entity {
|
if let Some(entity) = entity {
|
||||||
let new_delta = p.delta.clone();
|
let new_delta = p.delta.clone();
|
||||||
|
@ -978,7 +981,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let entity = entity_id_index.get(&MinecraftEntityId(p.entity_id));
|
let entity = entity_id_index.get(MinecraftEntityId(p.entity_id));
|
||||||
|
|
||||||
if let Some(entity) = entity {
|
if let Some(entity) = entity {
|
||||||
let new_look_direction = LookDirection {
|
let new_look_direction = LookDirection {
|
||||||
|
@ -1027,7 +1030,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
ClientboundGamePacket::RemoveEntities(p) => {
|
ClientboundGamePacket::RemoveEntities(p) => {
|
||||||
debug!("Got remove entities packet {:?}", p);
|
debug!("Got remove entities packet {p:?}");
|
||||||
|
|
||||||
let mut system_state: SystemState<(
|
let mut system_state: SystemState<(
|
||||||
Query<&mut EntityIdIndex>,
|
Query<&mut EntityIdIndex>,
|
||||||
|
@ -1041,8 +1044,8 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
};
|
};
|
||||||
|
|
||||||
for &id in &p.entity_ids {
|
for &id in &p.entity_ids {
|
||||||
let Some(entity) = entity_id_index.remove(&MinecraftEntityId(id)) else {
|
let Some(entity) = entity_id_index.remove(MinecraftEntityId(id)) else {
|
||||||
warn!("There is no entity with id {id:?}");
|
debug!("Tried to remove entity with id {id} but it wasn't in the EntityIdIndex");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Ok(mut loaded_by) = entity_query.get_mut(entity) else {
|
let Ok(mut loaded_by) = entity_query.get_mut(entity) else {
|
||||||
|
@ -1480,8 +1483,8 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let Some(entity) = entity_id_index.get(&MinecraftEntityId(p.id)) else {
|
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else {
|
||||||
warn!("Got teleport entity packet for unknown entity id {}", p.id);
|
debug!("Got teleport entity packet for unknown entity id {}", p.id);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -61,20 +61,20 @@ impl EntityUuidIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EntityIdIndex {
|
impl EntityIdIndex {
|
||||||
pub fn get(&self, id: &MinecraftEntityId) -> Option<Entity> {
|
pub fn get(&self, id: MinecraftEntityId) -> Option<Entity> {
|
||||||
self.entity_by_id.get(id).copied()
|
self.entity_by_id.get(&id).copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn contains_key(&self, id: &MinecraftEntityId) -> bool {
|
pub fn contains_key(&self, id: MinecraftEntityId) -> bool {
|
||||||
self.entity_by_id.contains_key(id)
|
self.entity_by_id.contains_key(&id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert(&mut self, id: MinecraftEntityId, entity: Entity) {
|
pub fn insert(&mut self, id: MinecraftEntityId, entity: Entity) {
|
||||||
self.entity_by_id.insert(id, entity);
|
self.entity_by_id.insert(id, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove(&mut self, id: &MinecraftEntityId) -> Option<Entity> {
|
pub fn remove(&mut self, id: MinecraftEntityId) -> Option<Entity> {
|
||||||
self.entity_by_id.remove(id)
|
self.entity_by_id.remove(&id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue