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 (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 {
|
||||
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 (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||
|
||||
let Some(entity) = entity_id_index.get(&MinecraftEntityId(p.id)) else {
|
||||
warn!(
|
||||
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else {
|
||||
// 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 {}",
|
||||
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 (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);
|
||||
continue;
|
||||
};
|
||||
|
@ -885,8 +888,8 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
debug!("Got move entity pos packet {p:?}");
|
||||
|
||||
let Some(entity) = entity_id_index.get(&MinecraftEntityId(p.entity_id)) else {
|
||||
warn!(
|
||||
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.entity_id)) else {
|
||||
debug!(
|
||||
"Got move entity pos packet for unknown 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:?}");
|
||||
|
||||
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 {
|
||||
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 (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 {
|
||||
let new_look_direction = LookDirection {
|
||||
|
@ -1027,7 +1030,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
));
|
||||
}
|
||||
ClientboundGamePacket::RemoveEntities(p) => {
|
||||
debug!("Got remove entities packet {:?}", p);
|
||||
debug!("Got remove entities packet {p:?}");
|
||||
|
||||
let mut system_state: SystemState<(
|
||||
Query<&mut EntityIdIndex>,
|
||||
|
@ -1041,8 +1044,8 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
};
|
||||
|
||||
for &id in &p.entity_ids {
|
||||
let Some(entity) = entity_id_index.remove(&MinecraftEntityId(id)) else {
|
||||
warn!("There is no entity with id {id:?}");
|
||||
let Some(entity) = entity_id_index.remove(MinecraftEntityId(id)) else {
|
||||
debug!("Tried to remove entity with id {id} but it wasn't in the EntityIdIndex");
|
||||
continue;
|
||||
};
|
||||
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 (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||
|
||||
let Some(entity) = entity_id_index.get(&MinecraftEntityId(p.id)) else {
|
||||
warn!("Got teleport entity packet for unknown entity id {}", p.id);
|
||||
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else {
|
||||
debug!("Got teleport entity packet for unknown entity id {}", p.id);
|
||||
continue;
|
||||
};
|
||||
|
||||
|
|
|
@ -61,20 +61,20 @@ impl EntityUuidIndex {
|
|||
}
|
||||
|
||||
impl EntityIdIndex {
|
||||
pub fn get(&self, id: &MinecraftEntityId) -> Option<Entity> {
|
||||
self.entity_by_id.get(id).copied()
|
||||
pub fn get(&self, id: MinecraftEntityId) -> Option<Entity> {
|
||||
self.entity_by_id.get(&id).copied()
|
||||
}
|
||||
|
||||
pub fn contains_key(&self, id: &MinecraftEntityId) -> bool {
|
||||
self.entity_by_id.contains_key(id)
|
||||
pub fn contains_key(&self, id: MinecraftEntityId) -> bool {
|
||||
self.entity_by_id.contains_key(&id)
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, id: MinecraftEntityId, entity: Entity) {
|
||||
self.entity_by_id.insert(id, entity);
|
||||
}
|
||||
|
||||
pub fn remove(&mut self, id: &MinecraftEntityId) -> Option<Entity> {
|
||||
self.entity_by_id.remove(id)
|
||||
pub fn remove(&mut self, id: MinecraftEntityId) -> Option<Entity> {
|
||||
self.entity_by_id.remove(&id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue