BundleEvents
BundleEvents is the static entry point for the bundle lifecycle. Every method takes a callback and returns void; callbacks run inside the bundle's Groovy context.
Registry
| Method | Runs |
|---|---|
registry { it -> ... } | When content registers. The lambda gets a RegistryEvent; call it.items(...), it.blocks(...), it.recipes(...), it.sounds(...), it.particles(...), it.toolMaterials(...), it.menus(...), it.blockEntities(...), it.tags(...). |
Setup
| Method | When |
|---|---|
commonSetup { event -> ... } | FML common setup. |
clientSetup { event -> ... } | FML client setup. |
dedicatedServerSetup { event -> ... } | FML dedicated server setup. Runs only on dedicated servers. |
postInit { event -> ... } | After mod initialization (InterModProcessEvent). |
Runtime
| Method | When |
|---|---|
vanillaGame { event -> ... } | A vanilla game event (block, entity, etc.) is posted on the NeoForge bus. |
dataGen { event -> ... } | During data generation (runs automatically on every startup). The event exposes event.getGenerator() and a convenience event.addProvider(...). |
custom(Class, callback) | Register a callback for a NeoForge Event subclass. The class must extend net.neoforged.neoforge.event.Event. |
Example
BundleEvents.registry {
it.items(gem)
it.blocks(glow)
it.recipes(recipe)
it.sounds(sound)
it.particles(sparkle)
}
BundleEvents.commonSetup { event ->
println "Common setup"
}
BundleEvents.dataGen { event ->
event.addProvider(myDataProvider)
}
Related
- Content registration: Explanation.