aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-01-13 06:10:55 +0000
committermat <git@matdoes.dev>2025-01-13 06:11:14 +0000
commita86d011d4ae869128dd404535f8d377c3a5e4c18 (patch)
tree63ce8c6519d7a4db1ec4cac9c4b34b0ada905676
parent5721eaf193977ce0d7c2fee9504b8ad057d1c1a2 (diff)
downloadazalea-drasl-a86d011d4ae869128dd404535f8d377c3a5e4c18.tar.xz
change some warnings to debug logs and improve some entity id index code
-rw-r--r--azalea-client/src/packet_handling/game.rs29
-rw-r--r--azalea-entity/src/plugin/indexing.rs12
2 files changed, 22 insertions, 19 deletions
diff --git a/azalea-client/src/packet_handling/game.rs b/azalea-client/src/packet_handling/game.rs
index 0d5a6afe..4d1d9e10 100644
--- a/azalea-client/src/packet_handling/game.rs
+++ b/azalea-client/src/packet_handling/game.rs
@@ -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;
};
diff --git a/azalea-entity/src/plugin/indexing.rs b/azalea-entity/src/plugin/indexing.rs
index c4879c4f..f1105d89 100644
--- a/azalea-entity/src/plugin/indexing.rs
+++ b/azalea-entity/src/plugin/indexing.rs
@@ -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)
}
}