From 072f5ce2ee412f735e9b2ec70c29126695dc15b0 Mon Sep 17 00:00:00 2001 From: rdbtCVS <87152661+rdbtCVS@users.noreply.github.com> Date: Sun, 25 Oct 2026 22:43:07 +0000 Subject: [PATCH] Fix custom item names above targeted item frames Show the framed item's custom name through the existing world name-label renderer, matching vanilla's HUD and crosshair conditions. Extend the LAN frame check for normal and glow frames. Co-Authored-By: Codex --- crates/horizon-client/src/game/names.rs | 36 +++++++++++++++++++++++++ tools/lan_e2e.py | 17 ++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/names.rs b/crates/horizon-client/src/game/names.rs index 7655fb489..d5e8446c3 100644 --- a/crates/horizon-client/src/game/names.rs +++ b/crates/horizon-client/src/game/names.rs @@ -240,6 +240,42 @@ impl Game<'_> { discrete: false, }); } + // ItemFrameRenderer.shouldShowName/getNameTag: only the targeted + // frame's custom-named item, with the HUD visible (also glow frames). + if !self.ui.hide_gui + && let Some((i, distance)) = self.frame_hit() + && self.before_block(distance) + && self.mob_hit().is_none_or(|(_, d)| d > distance) + && let Some(name) = self.item_frames[i] + .item + .as_ref() + .and_then(|item| item.custom_name()) + { + let frame = &self.item_frames[i]; + let (lo, hi) = frame.bounds(); + let center = glam::DVec3::from_array(std::array::from_fn(|a| (lo[a] + hi[a]) / 2.0)); + if center.distance_squared(camera) < 64.0 * 64.0 { + // NAME_TAG is at the entity height (0.5), then the name + // submitter lifts it 0.5. ItemFrameRenderer offsets rendering + // 0.3 toward its facing and -0.25 vertically. + let step = frame.step(); + tags.push(NameTag { + at: center + + glam::DVec3::new( + f64::from(step[0] as f32 * 0.3), + 0.75, + f64::from(step[2] as f32 * 0.3), + ), + lines: vec![(Text::literal(name).resolve_legacy(), 0.0)], + light: self.world.light( + center.x.floor() as i32, + center.y.floor() as i32, + center.z.floor() as i32, + ), + discrete: false, + }); + } + } tags } /// `SubmitNodeCollection.submitNameTag`: a discrete name is drawn once, diff --git a/tools/lan_e2e.py b/tools/lan_e2e.py index 0ec7218d8..df78489f9 100755 --- a/tools/lan_e2e.py +++ b/tools/lan_e2e.py @@ -3762,17 +3762,21 @@ def check_frames(host, guest, out): # Within a survival player's 3 blocks of reach: a frame on a wall, an armor stand beside it. player('command', command=f'fill {x - 2} {y} {z + 1} {x + 2} {y + 2} {z + 2} minecraft:air') player('command', command=f'fill {x - 2} {y} {z + 3} {x + 2} {y + 2} {z + 3} minecraft:stone') - player('command', command=f'summon minecraft:item_frame {x + 0.5} {y + 1.5} {z + 2.97} ' + frame_kind = 'item_frame' if label == 'host' else 'glow_item_frame' + player('command', command=f'summon minecraft:{frame_kind} {x + 0.5} {y + 1.5} {z + 2.97} ' f'{{block_pos:[I;{x},{y + 1},{z + 2}],Facing:2b}}') player('command', command=f'summon minecraft:armor_stand {x - 1.5} {y} {z + 1.5}') player('command', command='clear @s') - player('command', command='item replace entity @s weapon.mainhand with minecraft:diamond') + frame_name = f'{label} framed diamond' + player('command', command='item replace entity @s weapon.mainhand with ' + f"minecraft:diamond[minecraft:custom_name='{frame_name}']") player.wait(30) try: frame = [o for o in player('status')['objects'] if o['kind'].endswith('item_frame') and o['position'] == [x, y + 1, z + 2]] assert frame, f'the {label} sees no item frame at {[x, y + 1, z + 2]}' player.raw('look-at', f'{x + 0.5:.2f}', f'{y + 1.5:.2f}', f'{z + 2.95:.2f}') + assert frame_name not in (player('status').get('name_tags') or []), 'empty frame name visible' player.raw('mouse', 'right', 'click') player.wait(10) player.raw('mouse', 'right', 'click') @@ -3780,6 +3784,15 @@ def check_frames(host, guest, out): frame = [o for o in player('status')['objects'] if o['id'] == frame[0]['id']][0] assert frame['item'] == 'minecraft:diamond', f'the {label}\'s frame holds {frame["item"]}' assert frame['rotation'] == 1, f'the {label}\'s frame turned to {frame["rotation"]}' + assert frame_name in (player('status').get('name_tags') or []), \ + f"the {label}'s targeted frame has no item name" + player.shot(out, f'{label}-framed-item-name') + player.raw('key', 'f1', 'tap') + player.wait(2) + assert frame_name not in (player('status').get('name_tags') or []), 'F1 left the frame name visible' + player.raw('key', 'f1', 'tap') + player.raw('look-at', f'{x + 2:.2f}', f'{y + 1.5:.2f}', f'{z + 2.95:.2f}') + assert frame_name not in (player('status').get('name_tags') or []), 'untargeted frame name visible' theirs = [o for o in other('status')['objects'] if o['kind'].endswith('item_frame') and o['position'] == [x, y + 1, z + 2]] assert theirs and theirs[0]['item'] == 'minecraft:diamond' and theirs[0]['rotation'] == 1, \