Skip to content

MBD2 KubeJS ​

Current docs Minecraft 1.21.1 / MBD2 21.1.1Script runtime KubeJS 2101.7.2-build.226

MBD2 adds recipe schemas, registry events, targeted machine events, and a client renderer hook to KubeJS.

MBD2 Recipe Viewer UI editor showing the template a KubeJS-authored recipe is displayed with in JEI, REI or EMI
KubeJS supplies recipe data; the editor-authored Recipe Viewer UI controls how it is presented.

Script placement ​

FolderMBD2 APIUse it for
startup_scriptsMBDRegistryEvents.machine, MBDRegistryEvents.recipeTypeRegistering recipe types and base machine definitions
server_scriptsServerEvents.recipes, MBDMachineEvents.*, MBDRecipeTypeEvents.onTransferProxyRecipeRecipes and machine behaviour
client_scriptsMBDMachineEvents.onClientTick / onCustomDataUpdate / onCustomKeyframe, MBDRecipeTypeEvents.onRecipeUI, MBDClientEvents.registerCustomRenderersVisuals only

Every MBDMachineEvents and MBDRecipeTypeEvents subscription is targeted: the first argument is the machine-definition ID or recipe-type ID.

Registry changes need a full restart; /reload rebuilds recipes only.

Global bindings ​

BindingIs
MBDRegistriesThe MBD2 registries — RECIPE_CAPABILITIES, RECIPE_TYPES, MACHINE_DEFINITIONS, …
IOIO.IN, IO.OUT, IO.BOTH, IO.NONE
CapabilityIO, ContentModifier, MachineState, ConfigBlockPropertiesMBD2 config types
UIEvents, HoverTooltips, DataBindingBuilder, …LDLib2 UI types; see its own documentation

Every com.lowdragmc.mbd2 and com.lowdragmc.lowdraglib2 class is also reachable through Java.loadClass(...).

Pages ​

PageCovers
Registry eventsCreating recipe types and base machine definitions at startup
RecipesThe full recipe builder
TraitsReaching a machine's storage from an event
EventsEvery machine and recipe-type event, and what each one can change
UI behaviourAttaching server behaviour to an editor-authored machine UI
Script renderersDrawing a machine from a client script
Dynamic recipe modificationRewriting the selected recipe at runtime
Proxy recipe typesFiltering recipes imported from another recipe type
Example libraryCopyable scripts

Machine authoring boundary

KubeJS registration creates only a bare single or multiblock definition. It does not expose the editor's states, traits, renderers, UI, recipe logic or multiblock patterns. Author those in an MBD2 editor project, then script recipes and behaviour against it.

Do not mix UI generations

MBDMachineEvents.onUI still exists, but wrapper.event.ui is an LDLib2 2.x UI, not the 1.20.1 WidgetGroup. Legacy getFirstWidgetById and setOnPressCallback examples do not run. See UI behaviour.

Blueprints do the same jobs

Everything on the events page is also available as a blueprint node graph, authored in the editor and shipped inside the machine. Use KubeJS when the pack owns the behaviour, a blueprint when the machine does.

Released under the MIT License.