KubeJS Example Library
Default version Minecraft 1.21.1 / MBD2 21.1.1Copyable script files. Unless a snippet carries a legacy badge, it was executed against MBD2 21.1.1, KubeJS 2101.7.2-build.226 and LDLib2 2.2.39.a — not only read off the source.
| Example | What it teaches | Script stage |
|---|---|---|
| Minimal complete machine | Register a recipe type, a base machine and a recipe | Startup + Server |
| Recipe cookbook | Built-in content, chance, per-tick IO, recipe data | Server |
| Conditions and routing | Conditions, slotName and uiName | Server |
| Machine events | Interaction, states, multiblocks, lifecycle hooks | Server / Client |
| Traits and custom data | Item, fluid and FE access, persistent NBT, runtime values | Server |
| UI behaviour | UIElement queries and server listeners | Server / Client |
| Runtime recipe modification | Upgrades, duration and recipe copies | Server |
| Mod integrations | Create, Mekanism, PNC, Nature's Aura, Ars Nouveau | Server |
| 1.20.1 migration | Map legacy APIs to current ones | Migration |
Debugging order
logs/kubejs/startup.log— registry scripts. A failure here means no recipe schema exists.- Restart.
/reloadcannot recreate registries. logs/kubejs/server.log— recipe and event scripts. The lineAdded N recipes … with X failed recipesis the one to read.
Legacy Discord and old-wiki examples are treated as requirements input only. Methods absent from current source are listed on the migration page, never presented as runnable code.