Fix: handle object components in dialog button labels#6502
Open
andreiusq wants to merge 1 commit into
Open
Conversation
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.
|
Thank you for solving my issue. I look forward to it being patch in an upcoming Geyser update. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dialog buttons whose label contains an
objectcomponent (an atlas sprite or a player head) show up blank on Bedrock and logExpected tag to be a literal string...on every send.Fixes #6499
Why it happens
componentFromNbtTagonly handled text and translate components. An object component left the built componentnull, so the code skipped the block that appendsextra. That matters because the client normalizes an array label like[<sprite>, " Hello world"]into the sprite component with the text moved into itsextra, so skippingextradropped the whole label, not just the sprite.What changed
extraapplied, so the text around an object component survives. This also helps signs, dialog titles/bodies and inputs, which go through the same method.objectcomponents since we expect to run into those.NoticeDialogand the SimpleForm path ofDialogWithButtons).On the sprite -> texture mapping
There's no Java-sprite to Bedrock-texture table in the mappings, so this is best effort:
item/xmaps totextures/items/xandblock/xtotextures/blocks/x, with only the vanillaminecraft:items/minecraft:blocksatlases handled. Leaf names don't always match between editions (e.g.cooked_beefvsbeef_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 showcommand from the issue: the button now renders its text (and the barrier icon, since that texture name matches). Also added unit tests toMessageTranslatorTest:objectComponentKeepsSurroundingText(text survives for both the normalized and plain-list forms) andspriteMapsToBedrockTexturePath(the mapping). Full:core:testpasses.