Wiki 9Minecraft Wiki 9Minecraft
Graal Wiki › Guides › Communicate Between Multiple Mods Using Graal Scripts

Communicate Between Multiple Mods Using Graal Scripts

How Inter-Mod Communication Works

Graal Mod acts as a bridge between different mods by exposing their Java APIs to a shared JavaScript runtime. If multiple mods are Graal-aware, they can exchange data and trigger actions through scripts.

Accessing Other Mod APIs

Each mod typically registers its own Java objects or interfaces into the Graal context. In your script, reference these objects:

`javascript

var modA_api = /* reference to Mod A's exposed API */;

var modB_api = /* reference to Mod B's exposed API */;

modA_api.doSomething();

modB_api.respondToEvent();

`

Creating Event Handlers

Set up listeners or callbacks that trigger when other mods emit events:

`javascript

modA_api.onEventFired(function(eventData) {

modB_api.handleEvent(eventData);

});

`

The exact API depends on which mods you're using. Check each mod's Graal integration documentation for available methods and events. This approach eliminates the need for hard-coded mod dependencies—mods communicate through a neutral scripting layer.