Skip to content

Java Extensions ​

MBD2 21.1.1

Use Java when a pack needs a new storage model, recipe content type, condition, machine subclass, or external-mod capability. MBD2 separates the editor-facing definition from the runtime object, and separates recipe content from the trait that handles it.

MBD2 Add Trait registry containing built-in and Java-provided integration Trait definition types
Successfully registered Java TraitDefinitionTypes become editor entries; recipe capabilities and conditions follow their own registries.

Choose an extension point ​

RequirementImplementRegistration
Load an editor-authored machine from your mod JARMBDRegistryEvent.Machine listenerNeoForge mod event bus
Add a new machine project/definition familyMachineDefinitionType<T> and definition subclass@LDLRegister static field
Add storage, behavior, or a block capabilityTraitDefinition + TraitTraitDefinitionType static field
Add a recipe content domainRecipeCapability<T> + IContentSerializer<T>RecipeCapability static field
Let a trait consume/produce that contentIRecipeHandlerTrait<T> or RecipeHandlerTrait<T>Returned by the runtime trait
Add an environmental/runtime prerequisiteRecipeConditionAnnotation on the condition class
Add a blueprint nodeA KilaGraph Node subclass@NodeAttribute(graphTypes = MachineBlueprintGraph.class)

Start with Gradle dependency setup, then read registration and lifecycle. After the workspace resolves MBD2 and LDLib2, follow the complete custom capability, custom trait, and custom condition tutorials.

Before writing Java

Blueprints reach every machine event, every trait handler and the whole recipe object without a mod. Reach for Java when you need a new kind of thing — a storage model, a content type, a condition — not a new behaviour built from the existing ones.

API level

These pages describe MBD2 21.1.1. The registries are frozen after MBD2's construction work; do not register these objects from common setup, server start, or a KubeJS server script.

Released under the MIT License.