From d01327862d008dfe3f636aab120e80fe959071c4 Mon Sep 17 00:00:00 2001 From: itspotatotime Date: Wed, 21 Oct 2026 23:29:13 +0300 Subject: [PATCH] fix(client): hide marker stands and read server entity names A marker armor stand has an empty box, so vanilla's shouldRenderAtSqrDistance computes a zero range and the model never draws; Horizon substituted a 4-block range, which turned the stacked marker stands a lobby uses for holograms into a visible tower. Follow vanilla and let the zero edge cull the model. Server NPCs and mobs also carry CustomName, CustomNameVisible and the shared invisible flag in entity data; Horizon only read those for armor stands. Apply them to every mob, keep the styled component for the name tag, and hide the body when the flag is set. Co-Authored-By: cairn-code (DeepSeek V4.1 Flash) --- crates/horizon-client/src/entity_nbt.rs | 1 + .../horizon-client/src/game/armor_stands.rs | 5 +++- crates/horizon-client/src/game/creatures.rs | 4 ++++ crates/horizon-client/src/game/debug_keys.rs | 2 +- crates/horizon-client/src/game/dispenser.rs | 2 ++ crates/horizon-client/src/game/names.rs | 13 ++++++++--- crates/horizon-client/src/game/remote.rs | 23 +++++++++++++++++++ .../src/game/zombie_villagers.rs | 2 ++ crates/horizon-client/src/mobs.rs | 6 +++++ 9 files changed, 53 insertions(+), 5 deletions(-) diff --git a/crates/horizon-client/src/entity_nbt.rs b/crates/horizon-client/src/entity_nbt.rs index 3044e11ff..aaccdd844 100644 --- a/crates/horizon-client/src/entity_nbt.rs +++ b/crates/horizon-client/src/entity_nbt.rs @@ -615,6 +615,7 @@ pub fn mob_from_nbt(tag: &Tag, types: &HashMap>, id: u32) - m.persistent = flag(tag, "PersistenceRequired"); m.extra.pick_up_loot = flag(tag, "CanPickUpLoot"); m.custom_name = custom_name(tag); + m.custom_name_text = tag.get("CustomName").map(name_text); if m.kind.category == "creature" { m.extra.age = number(tag.get("Age")).unwrap_or(0) as i32; m.extra.forced_age = number(tag.get("ForcedAge")).unwrap_or(0) as i32; diff --git a/crates/horizon-client/src/game/armor_stands.rs b/crates/horizon-client/src/game/armor_stands.rs index aa55d83df..018c3d7ab 100644 --- a/crates/horizon-client/src/game/armor_stands.rs +++ b/crates/horizon-client/src/game/armor_stands.rs @@ -432,7 +432,10 @@ impl Game<'_> { (false, false) => (0.5, 1.975), }; let edge = (width + height + width) / 3.0 * 4.0; - let range = if edge == 0.0 { 4.0 } else { edge } * 64.0; + // A marker's empty box gives a range of zero: vanilla's + // `distance < 0` never holds, so marker stands never draw. + let edge = if edge == 1.0 { 4.0 } else { edge }; + let range = edge * 64.0; let dragon = a.equipment[5] .as_ref() .is_some_and(|i| &*i.item == "minecraft:dragon_head"); diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index d36e0adec..98756217f 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2929,6 +2929,10 @@ impl Game<'_> { let scale = f64::from(self.settings.entity_distance); for mob in &self.mobs { let entity_start = out.len(); + // Entity.DATA_SHARED_FLAGS_ID invisible: only the name tag draws. + if mob.invisible { + continue; + } let d = glam::DVec3::new(mob.position.x, mob.position.y, mob.position.z) - camera; // Entity.shouldRenderAtSqrDistance: 64 times the bounding box's // mean edge, scaled by the entity distance option. diff --git a/crates/horizon-client/src/game/debug_keys.rs b/crates/horizon-client/src/game/debug_keys.rs index a2e1b0ce6..553cd0d96 100644 --- a/crates/horizon-client/src/game/debug_keys.rs +++ b/crates/horizon-client/src/game/debug_keys.rs @@ -753,7 +753,7 @@ impl Game<'_> { let lerp = |a: f64, b: f64| a + f64::from(alpha) * (b - a); let lerpf = |a: f32, b: f32| a + alpha * (b - a); for m in &self.mobs { - if m.removed || m.has_effect("minecraft:invisibility") { + if m.removed || m.invisible || m.has_effect("minecraft:invisibility") { continue; } let pos = [ diff --git a/crates/horizon-client/src/game/dispenser.rs b/crates/horizon-client/src/game/dispenser.rs index b4e358d50..61725c6ab 100644 --- a/crates/horizon-client/src/game/dispenser.rs +++ b/crates/horizon-client/src/game/dispenser.rs @@ -1736,7 +1736,9 @@ impl Game<'_> { mob.head_pitch = old.head_pitch; mob.persistent = old.persistent; mob.custom_name = old.custom_name.clone(); + mob.custom_name_text = old.custom_name_text.clone(); mob.name_visible = old.name_visible; + mob.invisible = old.invisible; mob.no_ai = old.no_ai; mob.silent = old.silent; mob.no_gravity = old.no_gravity; diff --git a/crates/horizon-client/src/game/names.rs b/crates/horizon-client/src/game/names.rs index 5a1ea9f68..be829f1bb 100644 --- a/crates/horizon-client/src/game/names.rs +++ b/crates/horizon-client/src/game/names.rs @@ -124,7 +124,7 @@ impl Game<'_> { team, viewer, self.spectator(), - m.has_effect("minecraft:invisibility"), + m.invisible || m.has_effect("minecraft:invisibility"), ); // Entity.isDiscrete: a crouching player. let discrete = player && m.extra.crouching; @@ -144,9 +144,16 @@ impl Game<'_> { continue; } // getDisplayName: the name in the team's prefix, suffix and colour. + let member = if player { + Text::literal(&name) + } else { + m.custom_name_text + .clone() + .unwrap_or_else(|| Text::literal(&name)) + }; let shown = match team { - Some(t) => t.formatted_name(Text::literal(&name)), - None => Text::literal(&name), + Some(t) => t.formatted_name(member), + None => member, }; let mut lines = Vec::new(); // EntityRenderer.extractNameTags: the score shows within the diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 36f4499b5..c3da8b903 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -1709,6 +1709,29 @@ impl Game<'_> { } } C::SetEntityData(p) => { + // Entity.DATA_SHARED_FLAGS_ID, DATA_CUSTOM_NAME and + // DATA_CUSTOM_NAME_VISIBLE: server NPCs and holograms rely on + // these instead of saved NBT. + if let Some(m) = self.mobs.iter_mut().find(|m| m.id == p.id as u32) { + for (index, _, value) in &p.values { + match (index, value) { + (0, Value::Byte(flags)) => m.invisible = flags & 0x20 != 0, + (2, Value::OptText(name)) => { + let text = name.as_ref().map(horizon_client::entity_nbt::name_text); + m.custom_name = + text.as_ref().map(horizon_client::text::Text::plain); + m.custom_name_text = text; + } + (2, Value::Text(name)) => { + let text = horizon_client::entity_nbt::name_text(name); + m.custom_name = Some(text.plain()); + m.custom_name_text = Some(text); + } + (3, Value::Bool(visible)) => m.name_visible = *visible, + _ => {} + } + } + } if let Some(m) = self.mobs.iter_mut().find(|m| m.id == p.id as u32) && m.species() == horizon_client::mobs::Species::Rabbit { diff --git a/crates/horizon-client/src/game/zombie_villagers.rs b/crates/horizon-client/src/game/zombie_villagers.rs index c68c0f1c1..b47e2460c 100644 --- a/crates/horizon-client/src/game/zombie_villagers.rs +++ b/crates/horizon-client/src/game/zombie_villagers.rs @@ -194,7 +194,9 @@ fn carry_over(from: &Mob, to: &mut Mob) { to.fire_ticks = from.fire_ticks; to.persistent = from.persistent; to.custom_name = from.custom_name.clone(); + to.custom_name_text = from.custom_name_text.clone(); to.name_visible = from.name_visible; + to.invisible = from.invisible; to.extra.pick_up_loot = from.extra.pick_up_loot; to.extra.main_hand = from.extra.main_hand.clone(); to.extra.off_hand = from.extra.off_hand.clone(); diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index 3c2b34178..654371a3c 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -807,7 +807,11 @@ pub struct Mob { pub persistent: bool, /// `CustomName` (plain text) and `CustomNameVisible`. pub custom_name: Option, + /// The styled `CustomName`, when it came from a component. + pub custom_name_text: Option, pub name_visible: bool, + /// `Entity.DATA_SHARED_FLAGS_ID` bit 0x20: the model is hidden. + pub invisible: bool, pub random: LegacyRandom, pub ai: Box, pub extra: Extra, @@ -1518,7 +1522,9 @@ impl Mob { last_damage: None, removed: false, custom_name: None, + custom_name_text: None, name_visible: false, + invisible: false, anim: anim::AnimState::default(), rider: None, outbox: Vec::new(),