Skip to content

HUD and UI

m4bwav edited this page Oct 28, 2026 · 1 revision

minewright-hud puts information on a Bedrock player's screen from an add-on. Its outcome: on-screen information that works on every platform with the vanilla title and actionbar, plus, only when asked, a JSON UI layer that improves it and can break without making the game unplayable.

Files: skills/minewright-hud/SKILL.md. Tier fast: the move from JSON UI to Ore UI changes screens without notice, so the skill re-checks every three days (Research and freshness).

Layer 1: titles and the actionbar (always)

Stable Script API that works on every platform with no resource pack. From the skill:

player.onScreenDisplay.setTitle("Find: Diamond", {
  subtitle: "30:00", fadeInDuration: 10, stayDuration: 60, fadeOutDuration: 10 }); // ticks
player.onScreenDisplay.setActionBar("Diamond  29:41");
  • The actionbar fades, so the game loop refreshes it every 10 to 20 ticks.
  • setHudVisibility, hideAllExcept and resetHudElementsVisibility with the HudElement enum (stable since 1.11.0) hide or show vanilla HUD parts. The skill always restores them when the round ends.
  • Text must make sense alone: if the JSON UI layer breaks, this is what players see.

Should you add JSON UI?

JSON UI is the resource-pack UI language, and hud_screen.json is still JSON UI in Mojang's current samples (updated for 1.26.50). But the community wiki warns that Ore UI, which resource packs cannot modify, is replacing it, and Mojang has published no timeline. The hotbar selector has already moved, and emojis and custom glyphs do not render on Ore UI screens. So the skill uses JSON UI only for polish, only on the HUD, always over layer 1, and tells you that risk in one line before writing any.

A popup that drops into a timer

The pattern, from wiki.bedrock.dev and Mojang's own item-name popup:

  1. The script sends a title whose text is a short marker prefix plus the texture path, with the readable name in the subtitle: setTitle("gj_item:textures/items/diamond", { subtitle: "Diamond" }).
  2. A hidden data_control in hud_screen.json keeps the last title in a property_bag (the "Preserve Title Texts" pattern), so it stays after the title fades.
  3. A control shows when the preserved string starts with the prefix, strips it, and plays offset and alpha animations.
  4. Strings become numbers with 0 + #str; the older #str * 1 no longer works in some versions.
  5. Change the vanilla file with modifications, not a whole replacement. To hide the vanilla title for marker titles only, replace the title_frame control.
  6. Put the image inside the factory-created hud_title_text, so the animation replays for every title.
  7. A hidden control stops its children's bindings: keep the data_control under an always-visible parent, and switch the image to a transparent texture rather than hiding it.

Steps 5 to 7 came from building the example add-on and have not been seen in the game yet.

Showing an item's picture

No JSON UI control renders an item by id. The options, best first:

  • An image control bound to the vanilla texture path. Build the id-to-path map from item_texture.json in Mojang/bedrock-samples, never by guessing: the keys often differ from item ids (wheat_seeds is seeds_wheat, sugar_cane is reeds, beef is beef_raw, totem_of_undying is totem). Some keys hold several paths, and the compass and clock are animated atlases that look wrong as a still. Pin the map with a unit test against a saved copy, as the example does in test/fixtures/vanilla-item-textures.json.
  • Custom font glyphs. They render inline in titles and chat but are unofficial and fail on Ore UI screens.
  • Text only, which always works.

Forms are dialogs, not a HUD

@minecraft/server-ui (ActionFormData, MessageFormData, ModalFormData) takes over the screen and waits for an answer. It suits settings and confirmations an operator opens, not anything that must stay visible during play.

Verify

Static checks parse ui/*.json like any other pack file. Then it is the game's turn: the vanilla layer alone (resource pack off), then with JSON UI, at the smallest and largest GUI scale, and on a phone screen if players use one. Bedrock Dedicated Server cannot test any of this. Alpha animations stay under three cycles a second.

Clone this wiki locally