From 5f8afb17fc92b9d163dcf4505592c98dbd6572b4 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 28 Oct 2026 11:26:00 +0300 Subject: [PATCH] Name tags: copy a custom name only inside the tag's range name_tags cloned every named mob's custom name each frame and dropped the tag afterwards when the mob was beyond 64 blocks. Test the distance first, so the copy happens only for a mob the frame can show. Co-Authored-By: Hermes Agent (Nous Research) --- crates/horizon-client/src/game/names.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/game/names.rs b/crates/horizon-client/src/game/names.rs index 3ecd2d245..a41d7e1ed 100644 --- a/crates/horizon-client/src/game/names.rs +++ b/crates/horizon-client/src/game/names.rs @@ -81,10 +81,13 @@ impl Game<'_> { let viewer = self.player_team(); let mut tags = Vec::new(); let players = self.other_players(); - let named = self - .mobs - .iter() - .filter_map(|m| Some((m, m.custom_name.clone()?, false))); + let named = self.mobs.iter().filter_map(|m| { + let name = m.custom_name.as_ref()?; + // The tag's 64 block distance is measured to the entity: copy the + // name only for a mob the frame can show it on. + let at = glam::DVec3::new(m.position.x, m.position.y, m.position.z); + (at.distance_squared(camera) < 64.0 * 64.0).then(|| (m, name.clone(), false)) + }); let players = players.into_iter().map(|(m, name)| (m, name, true)); // Who is riding whom: asked once per tag below, and rescanning every mob // for each tag made this quadratic in the number of loaded mobs.