Skip to content

Traits and Machine UI ​

MBD2 21.1.1

A trait is a configurable machine component. Keep three IO systems separate: recipe-handler IO, sided block-capability IO, and automatic world IO.

MBD2 Machine Traits view listing item, fluid, energy and integration traits with the Add Trait control
The Machine Traits view. Optional integration entries appear only when their mod is loaded.

Configure a trait ​

SettingPurpose
Trait nameStable lookup name for KubeJS and generated ui:<name> IDs
Recipe handler IOWhether recipe logic may consume from or produce into the trait
DistinctWhether capability content must be handled without combining across handlers
Slot namesOptional routing names referenced by recipe slotName
Capability IOWhich world-facing sides allow insertion/extraction, relative to machine front
GUI IOWhich actions the machine UI permits
Auto IOPeriodic transfer to/from adjacent block capabilities
Filter/capacity/rateTrait-specific storage constraints

Core traits ​

Trait typeRuntime storageRecipe handlersWorld capability
item_slotItem stack transferitem, item_durabilitySided item handler
fluid_tankFluid storage listfluidSided fluid handler
forge_energy_storageCopiable energy storageforge_energyCapabilities.EnergyStorage.BLOCK
entity_handlerEntity interaction configurationentityBehaviour-oriented; not normal inventory storage

Optional traits appear only with their dependency: chemical_tank, mek_heat_container, pneumatic_pressure_air_handler, pneumatic_heat_exchanger, aura_handler, ars_source_storage, ars_nearby_source, ae2_me_interface, ae2_me_pattern_provider. See Integrations.

Every setting here is overridable per machine

Trait settings are also runtime values: recipe handler IO, distinct, slot names, capability IO, auto IO, capacities and filters can all be overridden on one placed machine by a blueprint or a script, without touching the definition.

Generate and bind UI ​

MBD2 Machine UI editor showing the element hierarchy, canvas, inventory slots, style sheet and add-element controls
The Machine UI canvas; its add button generates widgets from the configured Traits.

Trait definitions implementing IUIProviderTrait create templates using IDs based on ui:<trait-name>. SLOT layouts flow into input/output columns; BAR layouts flow below them. The UI generator can also add recipe progress, fuel progress, recipe-viewer lookup, and player inventory.

Generate after trait names and counts are stable. If you rename a trait, verify all generated widget IDs, recipe slotName/uiName, and scripts.

At runtime, initTraitUI binds the actual trait to matching widgets. Storage remains server-authoritative; controls should send actions or use data bindings rather than directly trusting client-side values.

Cross-part UI ​

A multiblock controller's UI can bind a widget to a trait that lives on one of its parts, and a part's UI can bind to a trait on its controller. Give the element a prefixed ID in the editor:

OnID formBinds to
A controller's UIpart:<traitName>@ui:<widgetId>That trait on any formed part
A part's UIcontroller:<traitName>@ui:<widgetId>That trait on any controller — needs part settings enabled

<widgetId> is the generated widget ID with its ui: prefix dropped, so a part trait named input_items whose first slot is ui:input_items_0 is reached as part:input_items@ui:input_items_0.

At bind time MBD2 finds the trait, rewrites the element's ID back to ui:input_items_0 and runs that trait's initTraitUI. If no part or controller has a trait with that name, or the trait provides no UI, the element is left alone.

For resources rather than widgets, use capability proxying — see Multiblocks.

Adding UI from a blueprint ​

A blueprint can hook the Build UI event and append to the screen the editor authored. The Auto IO panel built-in does exactly that, and it is the pattern for any UI a machine should get without editing its UI tree.

Released under the MIT License.