Skip to main content

Machine UI

In this section you will replace the template's temporary crusher interface with a small addon-owned UI. The finished screen displays the machine name, live status, energy, input, progress, output, and the standard information tab.

The UI reuses UtilityCraft's shared controls:

{
"input@uc.input_slot": {
"collection_index": 3
}
}

uc is the namespace defined by UtilityCraft/RP/ui/ui_core.json. Your addon references that namespace directly; it does not copy or modify the file.

Do not copy UI Core

Keep ui_core.json, its shared textures, and its uc namespace inside UtilityCraft. Your extension owns only its UI layout, routing, localization, block textures, and scripts.

Before you start

Complete Your First Machine first. This tutorial expects the Example Thermal Crusher to use the following helper-entity indices:

IndexContentWritten byDisplayed with
0Energy display itemmachine.displayEnergy()uc.energy_bar
1Status label itemmachine.setLabel()uc.text_label
2Progress frame itemmachine.displayProgress()uc.progress_display
3Recipe inputPlayer or item IOuc.input_slot
4Recipe outputMachine scriptuc.output_slot
5–8Reserved for upgradesLater tutorialuc.upgrades_tab
9–14Reserved for six item-IO buttonsLater tutorialuc.io_tab

The indices are a contract. If the script writes progress to slot 2, the UI must also read progress from collection_index: 2.

What belongs to each layer

LayerResponsibility
Helper entityProvides the container_items collection and inventory slots.
Machine scriptWrites energy, labels, progress, outputs, upgrades, and IO button states.
Addon JSON UIChooses which collection indices to display and where to place them.
UtilityCraft UI CoreSupplies reusable controls such as slots, bars, screens, and tabs.
Language fileSupplies the entity title and the information-tab description.

JSON UI does not process recipes, consume energy, move items, or calculate progress. It renders the values already owned by the machine runtime.

Files used

FilePurpose
RP/ui/first_machine_ui.jsonNew addon-owned machine layout.
RP/ui/_ui_defs.jsonLoads the new UI file.
RP/ui/chest_screen.jsonRoutes the helper entity's title to the new layout.
RP/texts/en_US.langProvides the entity name and information text.
BP/scripts/examples/machines/thermalCrusher.jsContinues to update energy, label, and progress slots.

Tutorial order

  1. Create the UI file
  2. Display input and output
  3. Add a progress bar
  4. Add labels
  5. Add Info, IO, and Upgrades tabs

The pages are cumulative. Each page replaces or extends the UI created on the previous one.

For every shared control and exposed variable, see the UtilityCraft Machine UI Core reference.

Start with Create the UI file.