Skip to content

fix: delegate null-cost research lore to addon unlock-instructions in ItemButton#799

Open
KevinWoodWL wants to merge 1 commit into
pylonmc:masterfrom
KevinWoodWL:fix/item-button-null-cost-research
Open

fix: delegate null-cost research lore to addon unlock-instructions in ItemButton#799
KevinWoodWL wants to merge 1 commit into
pylonmc:masterfrom
KevinWoodWL:fix/item-button-null-cost-research

Conversation

@KevinWoodWL
Copy link
Copy Markdown

Problem

ItemButton.getItemProvider renders guide.button.item.not-researched for researches whose cost == null (custom unlock flow, no research points). That key is a YAML section in the lang file (it has no-research-cost, enough-points, not-enough-points children), not a string. RebarTranslator reads it via ConfigAdapter.STRING which calls toString() on the MemorySection, so the player sees:

MemorySection[path='guide.button.item.not-researched',root='YamlConfiguration']

This appears on item buttons in the main guide page, recipe detail pages, and vanilla crafting pages — anywhere ItemButton is used to display a locked item.

Fix

ResearchButton already handles cost == null correctly by delegating to <namespace>.researches.<key>.unlock-instructions, letting the addon describe its own unlock flow. This PR aligns ItemButton with the same behaviour.

// before
Component.translatable("rebar.guide.button.item.not-researched")

// after
Component.translatable(
    "${research.key.namespace}.researches.${research.key.key}.unlock-instructions"
)

Addons that use null-cost researches can now provide a meaningful lore line on item buttons (e.g. "Requires 80 Material discipline points — unlock via Science Interface") rather than seeing garbled text.

Reproduce

  1. Register a Research with cost = null and add an item to its unlocks set.
  2. Open the Rebar guide while the research is not yet unlocked.
  3. Any ItemButton showing that item displays MemorySection[...] as the first lore line.

… ItemButton

ItemButton rendered `guide.button.item.not-researched` (a YAML section, not a
string) for researches with cost == null, causing RebarTranslator to call
toString() on the MemorySection and display garbled text in the guide.

ResearchButton already handles this case correctly by delegating to the addon's
`<namespace>.researches.<key>.unlock-instructions` key. Align ItemButton with
the same behaviour: addons can now describe their custom unlock flow on item
buttons (main guide page, recipe detail pages, vanilla crafting pages) as well
as on the research node itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant