EventJS

Quick rating

EventJS

No reviews yet

Reloadable sided native event for KubeJS

No Theme
No Genre
QoL & Tweaks
Mod Addon
Mod Loaders
Forge
NeoForge
Minecraft

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

Compatibility

Supported Environments

Dev Environment
Client Required
Server Required

About

Project Details

Type
Mod
License
GNU General Public License v3.0 or later
Latest Version
EventJS-1.20.1-1.4.3.jar
Authors
CurseForge
Modrinth

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

CurseForge ID
Modrinth ID

Resources

External Links

Source Issues Wiki Discord

About

Description

EventJS

is a KubeJS addon that adds reloadable native events for KubeJS.

With EventJS, you can

  • refresh your native event listeners without restarting the whole game or store the handler within a global['someId'], which is both simpler and more performant.
  • add/remove native event listeners as you like without relaunching, which was impossible in KubeJS for 1.16-1.20
  • prevent your game from crashing if something goes wrong in your native event listener
  • add event listener only in server/client side

Usage

By default, EventJS will replace the original native event listening method to make it reloadable. So you actually don't need to learn anything new in order to use EventJS, just install it and you Forge event listening is reloadable now.

But, if you're looking for some more dynamic and well-defined event listending, you can use NativeEvents.onEvent(...), and NativeEvents.onGenericEvent(...) for generic event listening.

NativeEvents will be avaliable for all 3 script types (client/server/startup), so you can perform sided event listening, that is, for example, listen to client-only event in client_scripts, then this event listening will not happen on server side.

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)

The handler in JS side, is a callback that receives the event, for example: (event) => {...}

The eventType and genericClassType is something that can represent a class, like a string that holds the event class name, or the event class itself loaded by java(...) or Java.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

Changes in 1.4.0

In EventJS 1.4.0, in order to support ProbeJS Legacy out of the box, the eventType and genericClassFilter will only actively support Class loaded via java(...) (1.16.5) or Java.loadClass(...) (1.20.1).

let eventType         : Class
let genericClassFilter: Class

Supported Version

1.0.0: 1.16.5

1.1.0: 1.16.5, 1.20.1

1.2.0: all major version between 1.16 and 1.20

Do You Know That

The reason why I make this mod is that KubeJS is absurdly slow in implementing similar features. They added native event listener reloading only after KubeJS updated to 1.21, leaving all versions between 1.16~1.20 behind.

KubeJS for 1.21+ also contains support for native event listener reloading, using the same name NativeEvents, but its implementation is not the same as EventJS, so please dont make assumptions when interacting EventJS internals via Java.

EventJS

is a KubeJS addon that adds reloadable native events for KubeJS.

With EventJS, you can

  • refresh your native event listeners without restarting the whole game or store the handler within a global['someId'], which is both simpler and more performant.
  • add/remove native event listeners as you like without relaunching, which was impossible in KubeJS for 1.16-1.20
  • prevent your game from crashing if something goes wrong in your native event listener
  • add event listener only in server/client side

Usage

By default, EventJS will replace the original native event listening method to make it reloadable. So you actually don't need to learn anything new in order to use EventJS, just install it and you Forge event listening is reloadable now.

But, if you're looking for some more dynamic and well-defined event listending, you can use NativeEvents.onEvent(...), and NativeEvents.onGenericEvent(...) for generic event listening.

NativeEvents will be avaliable for all 3 script types (client/server/startup), so you can perform sided event listening, that is, for example, listen to client-only event in client_scripts, then this event listening will not happen on server side.

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)

The handler in JS side, is a callback that receives the event, for example: (event) => {...}

The eventType and genericClassType is something that can represent a class, like a string that holds the event class name, or the event class itself loaded by java(...) or Java.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

Changes in 1.4.0

In EventJS 1.4.0, in order to support ProbeJS Legacy out of the box, the eventType and genericClassFilter will only actively support Class loaded via java(...) (1.16.5) or Java.loadClass(...) (1.20.1).

let eventType: Class
let genericClassFilter: Class

Supported Version

1.0.0: 1.16.5

1.1.0: 1.16.5, 1.20.1

1.2.0: all major version between 1.16 and 1.20

Do You Know That

The reason why I make this mod is that KubeJS is absurdly slow in implementing similar features. They added native event listener reloading only after KubeJS updated to 1.21, leaving all versions between 1.16~1.20 behind.

KubeJS for 1.21+ also contains support for native event listener reloading, using the same name NativeEvents, but its implementation is not the same as EventJS, so please dont make assumptions when interacting EventJS internals via Java.

Screenshots

Gallery

  • reloadable_startup.png
    reloadable_startup.png reloadable_startup.png

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

1.6m
Total Downloads
CurseForge
1.6m
Modrinth
~35,000
Last Updated
CurseForge
Created
CurseForge
Modrinth
Last synced
When ModDex last fetched this project from CurseForge or Modrinth. Every project is re-checked on a schedule, and any project that ships a new file is synced automatically within hours of the release.
New file updates sync automatically
How syncing works