-
Notifications
You must be signed in to change notification settings - Fork 2
Creating an Event
NanoEvents is a statically registered event framework, so all events need to be declared early on, the way NanoEvents does this is by evt files. EVT files are mostly just property files with 1 level of brackets, they look like this. All white space is removed inside the brackets.
mymod:myevent {
classes = net.mymod.mixin.myevent.*
invoker = net.mymod.invokers.MyEventInvoker
} ...
"depends": { // example
"fabricloader": ">=0.8.2+build.194",
"minecraft": "1.15.2"
}, // example
"custom": {
...
"nano:evt": "events.evt", // this can be an array of strings as well
"nano:lst": "listener.properties" // so can this
...
}
...
}This file needs to be specified in your mod JSON, you can declare multiple files at once, or just one
With nano events, you can specify which package you've put your event mixins in, so if there are no listeners for a given event, NanoEvents won't apply the mixin, further reducing any potential overhead and performance costs. To use this feature, you must specify (net.devtech.nanoevents.plugin.NanoEventMixinPlugin) as your mixin plugin by setting the "plugin" field in your mixin config (your mixin json) to "net.devtech.nanoevents.plugin.NanoEventMixinPlugin" This isn't always desirable, so it's optional. You can also check if there is a listener for an event manually with NanoEventsAPI#isEnabled.
This is the class where the invoker for your event exists.