EventJS
Forget about restarting Minecraft when developing scripts for KubeJS! EventJS is a groundbreaking addon that turns working with native events into an exciting and productive process.
EventJS Advantages
Your event handlers will execute instantly because EventJS allows refreshing them completely without restarting the game! But that's not all—the mod provides protection against unexpected crashes. If an error appears in your script, it simply won't execute, preventing the entire game client from crashing.
EventJS supports separate scripts for server and client, making it an indispensable tool when working with events specific to each side.
Usage Simplicity
EventJS works completely automatically! After installation, all your Forge events become reloadable without any additional actions. The new functionality perfectly integrates with existing KubeJS approaches.
For more fine-tuning, two main methods are available:
NativeEvents.onEvent(...)— standard connectionNativeEvents.onGenericEvent(...)— for complex universal events
The NativeEvents class is present in all three script types (client, server, startup), allowing full control over which devices will execute your handlers.
Syntax (v1.0.0 - 1.3.0)
NativeEvents.onEvent(eventType, handler)
NativeEvents.onEvent(priority, receiveCancelled, eventType, handler)
NativeEvents.onGenericEvent(genericClassFilter, eventType, handler)
NativeEvents.onGenericEvent(genericClassFilter, priority, receiveCancelled, eventType, handler)
handler— callback function receiving the event:(event) => {...}eventType,genericClassFilter— strings with class name or the class itself loaded viajava(...)orJava.loadClass(...)
let handler: (event: AnyForgeEvent) => void
let eventType: string | Class
let genericClassFilter: string | Class
let priority: $EventPriority | "highest" | "high" | "normal" | "low" | "lowest"
let receiveCancelled: boolean
EventJS 1.4.0 and ProbeJS Compatibility
In the new version, the EventJS author paid special attention to stability when interacting with ProbeJS. Now event classes and universal filters are actively supported only as Class objects loaded through standard KubeJS methods.
let eventType: Class
let genericClassFilter: Class
Minecraft Version Support
- 1.0.0: only for Minecraft 1.16.5
- 1.1.0: support for 1.16.5 and 1.20.1
- 1.2.0: all versions from 1.16 to 1.20
Where does the difference between this addon and KubeJS standard capabilities appear? The answer is simple: KubeJS implemented support for reloadable events only starting from Minecraft version 1.21!
Important note: despite using the same class name NativeEvents, the internal mechanisms of original KubeJS and EventJS differ significantly.