Recipe Registration
This section explains how to register custom machine recipes into UtilityCraft using ScriptEvents.
UtilityCraft allows external addons to inject recipes dynamically at runtime.
Recipes are transmitted using a serialized JSON payload and processed internally after the world has fully loaded.
How It Works
Recipe registration follows a structured communication flow:
- Wait for
worldLoad. - Create a JavaScript object containing the recipe definition.
- Convert the object into a string using
JSON.stringify. - Send the string through a ScriptEvent.
- UtilityCraft receives the event.
- UtilityCraft parses the string using
JSON.parse. - The recipe is validated and registered internally.
This system ensures:
- Cross-addon compatibility
- Namespace isolation
- Runtime safety
- No hard dependencies between packs
Why ScriptEvents?
ScriptEvents are used because:
- They allow inter-addon communication.
- They avoid direct imports between packs.
- They are stable across modular ecosystems.
- They prevent circular dependency issues.
The sending addon does not need access to UtilityCraft’s internal code — only the event contract.
Basic Registration Flow
Wait for World Load
Recipes must only be registered after the world is ready.
world.afterEvents.worldLoad.subscribe(() => {
system.sendScriptEvent("utilitycraft:register_crusher_recipe", JSON.stringify(myRecipes));
});