Package net.neoforged.fml.common
Annotation Interface EventBusSubscriber
Annotate a class which will be subscribed to an Event Bus at mod construction time.
Annotated classes will be scanned for static methods that have the SubscribeEvent
annotation.
For example:
@EventBusSubscriber
public class MyEventHandler {
@SubscribeEvent
private static void onSomeEvent(SomeEvent event) {
// SomeEvent handler here
}
@SubscribeEvent
private static void onAnotherEvent(AnotherEvent event) {
// AnotherEvent handler here
}
}
Event subscribers for events inheriting from IModBusEvent
will be registered to the mod's event bus
,
while the rest will be registered to the NeoForge#EVENT_BUS
.
By default, the subscribers will be registered on both physical sides. This can be customised using value()
.
- See Also:
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
net.neoforged.api.distmarker.Dist[] valueSpecify targets to load this event subscriber on. Can be used to avoid loading Client specific events on a dedicated server, for example.- Returns:
- an array of Dist to load this event subscriber on
- Default:
{CLIENT, DEDICATED_SERVER}
-
modid
String modidOptional value, only necessary for mod jars that contain multiple mods.- Returns:
- the mod id whose mod bus events to subscribe to
- Default:
""
-