Skip to content

Fix: handle object components in dialog button labels#6502

Open
andreiusq wants to merge 1 commit into
GeyserMC:masterfrom
andreiusq:fix/dialog-object-component
Open

Fix: handle object components in dialog button labels#6502
andreiusq wants to merge 1 commit into
GeyserMC:masterfrom
andreiusq:fix/dialog-object-component

Conversation

@andreiusq

@andreiusq andreiusq commented Jul 2, 2026

Copy link
Copy Markdown

AI usage: I used an AI assistant (Claude Code) to help investigate the bug and write the fix and tests, and to draft this description. I tested the change in-game myself and understand how it works.

Dialog buttons whose label contains an object component (an atlas sprite or a player head) show up blank on Bedrock and log Expected tag to be a literal string... on every send.

Fixes #6499

Why it happens

componentFromNbtTag only handled text and translate components. An object component left the built component null, so the code skipped the block that appends extra. That matters because the client normalizes an array label like [<sprite>, " Hello world"] into the sprite component with the text moved into its extra, so skipping extra dropped the whole label, not just the sprite.

What changed

  • An unrecognized component now falls back to an empty base and still gets its style and extra applied, so the text around an object component survives. This also helps signs, dialog titles/bodies and inputs, which go through the same method.
  • The error log is kept for genuinely unknown component types, but skipped for object components since we expect to run into those.
  • Bedrock can't render a sprite inside text, but a SimpleForm button can show an image next to its label, so the first sprite in a button label is turned into the button icon (NoticeDialog and the SimpleForm path of DialogWithButtons).

On the sprite -> texture mapping

There's no Java-sprite to Bedrock-texture table in the mappings, so this is best effort: item/x maps to textures/items/x and block/x to textures/blocks/x, with only the vanilla minecraft:items/minecraft:blocks atlases handled. Leaf names don't always match between editions (e.g. cooked_beef vs beef_cooked), so a sprite we can't line up resolves to no icon rather than a wrong one. Text always renders regardless. Happy to drop the icon part and keep just the text fix if you'd prefer to wait on a proper mapping.

Testing

Tested in-game on Paper with a Bedrock client using the /dialog show command from the issue: the button now renders its text (and the barrier icon, since that texture name matches). Also added unit tests to MessageTranslatorTest: objectComponentKeepsSurroundingText (text survives for both the normalized and plain-list forms) and spriteMapsToBedrockTexturePath (the mapping). Full :core:test passes.

A dialog button whose label contains an "object" component (an atlas
sprite or a player head) showed up blank on Bedrock and spammed
"Expected tag to be a literal string..." in the console.

componentFromNbtTag only handled text and translate components. An
object component left the built component null, so the code skipped the
block that appends "extra" - which is where the rest of the label ends
up once the client normalizes [<sprite>, " text"] into the sprite with
the text moved into extra. That meant the whole label was dropped, not
just the sprite.

An unrecognized component now falls back to an empty base and still gets
its style and extra applied, so the surrounding text survives. The error
is still logged for genuinely unknown component types, just skipped for
object components since we expect those.

Bedrock can't draw a sprite inside text, but a SimpleForm button can show
an image next to its label, so the first sprite in a button label is now
used as the button icon. The atlas sprite is mapped to the matching
vanilla Bedrock texture path (item/x -> textures/items/x, block/x ->
textures/blocks/x). Leaf names don't always line up between Java and
Bedrock, so an unknown sprite resolves to no icon instead of a wrong one.
@retracdev

Copy link
Copy Markdown

Thank you for solving my issue. I look forward to it being patch in an upcoming Geyser update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants