KubeJS Compat
Epiphany provides full KubeJS compatibility, allowing modpack authors to listen to events, call APIs, and query data through JavaScript scripts. All functionality is registered via the standard KubeJS plugin mechanism.
TIP
All scripts reside in the server_scripts/ directory and run on the server side only.
INFO
All concepts introduced in this section correspond one-to-one with Custom Events and Manager API. Unless otherwise noted, behavior is identical to the Java side.
Overview
Epiphany provides two entry points via the KubeJS plugin:
| Namespace | Purpose | Source |
|---|---|---|
EpiphanyEvents.* | Listen to events (15 events related to Module/Insight/Epiphany/Aptitude) | KubeJS EventGroup |
Epiphany.* | Call API (Manager methods + data queries) | KubeJS Binding |
Namespace separation
Event listening uses EpiphanyEvents.*, API calls use Epiphany.*. The two are deliberately placed in different namespaces to avoid name collisions.
Plugin entry point: ink.myumoon.epiphany.event.kubejs.EpiphanyKubeJSPlugin, discovered via kubejs.plugins.txt.
Events (EpiphanyEvents.*)
All events carry a player field (ServerPlayer). Each event carries relevant id fields (e.g., moduleId, insightId, epiphanyId) for scripts to read.
Naming Convention
| Suffix | Meaning | Cancellable |
|---|---|---|
Present tense (e.g., moduleUnlock, moduleSelect, moduleComplete) | Pre event, cancel with event.cancel() | ✅ |
Past tense (e.g., moduleUnlocked, moduleSelected, moduleCompleted) | Post event, notification only | ❌ |
Cancellation mechanism
Pre events are cancelled using KubeJS-standard event.cancel(), not the Java-side setCanceled(true). The plugin internally bridges to native NeoForge events.
Module Events
| Event Name | Type | When It Fires |
|---|---|---|
moduleUnlock | Pre (cancellable) | Module is about to be unlocked |
moduleUnlocked | Post | Module has been unlocked |
moduleSelect | Pre (cancellable) | Module is about to be selected |
moduleSelected | Post | Module has been selected |
moduleComplete | Pre (cancellable) | Module is about to be completed |
moduleCompleted | Post | Module has been completed |
Insight Events
Cascading
After insightSelected fires, if all insights in the owning module are now unlocked, it automatically chains into Module's moduleComplete / moduleCompleted. A single insightSelect call can trigger a full 4-event chain.
| Event Name | Type | Description |
|---|---|---|
insightSelect | Pre (cancellable) | Insight is about to be unlocked |
insightSelected | Post | Insight has been unlocked |
Epiphany Events
| Event Name | Type | Description |
|---|---|---|
epiphanyUnlock | Pre (cancellable) | Epiphany is about to be unlocked |
epiphanyUnlocked | Post | Epiphany has been unlocked |
epiphanySelect | Pre (cancellable) | Epiphany is about to be activated |
epiphanySelected | Post | Epiphany has been activated |
Aptitude Events (All Post)
Trigger frequency differences
aptitudeLevelUp fires once per +1 Insight Point (one addAptitude call can trigger it multiple times). In contrast, insightPointsChanged is a settlement-level event — regardless of how many internal level-ups occur in one call, it fires only once. Use the latter for notifications, the former for per-point tracking.
| Event Name | Description |
|---|---|
aptitudeChanged | When aptitude value changes |
aptitudeLevelUp | When the bar fills and an Insight Point is earned (once per +1) |
insightPointsChanged | When the Insight Point balance changes (settlement-level, once per call) |
Bindings (Epiphany.*)
All methods execute synchronously on the server side. The player parameter must be of type ServerPlayer.
Utilities
Epiphany.id(namespace, path) // Construct a ResourceLocation
Epiphany.id('mymod', 'foo') // → 'mymod:foo'You can also use KubeJS string literals like 'mymod:foo' — both are equivalent.
Module
| Method | Description |
|---|---|
isModuleUnlocked(player, id) | Query: is the module unlocked? |
isModuleSelected(player, id) | Query: is the module selected? |
isModuleCompleted(player, id) | Query: is the module completed? |
moduleUnlock(player, id) | Unlock the module |
moduleLock(player, id) | Lock the module |
moduleSelect(player, id) | Select the module (consumes Insight Points) |
moduleForceSelect(player, id) | Force select (ignores cost/conditions/cap) |
moduleComplete(player, id) | Complete the module (requires all insights unlocked) |
moduleForceComplete(player, id) | Force complete |
moduleReset(player, id) | Reset the module (refunds Insight Points, removes rewards) |
Insight
| Method | Description |
|---|---|
isInsightSelected(player, id) | Query: is the insight unlocked? |
isInsightModuleSelected(player, id) | Query: is the insight's owning module selected? |
insightSelect(player, insightId, moduleId) | Unlock the insight (consumes Insight Points) |
insightForceSelect(player, insightId, moduleId) | Force unlock (ignores cost/prerequisites) |
insightReset(player, id) | Reset the insight |
Epiphany
| Method | Description |
|---|---|
isEpiphanyUnlocked(player, id) | Query: is the epiphany unlocked? |
isEpiphanySelected(player, id) | Query: is the epiphany activated? |
epiphanyUnlock(player, id) | Unlock the epiphany |
epiphanyLock(player, id) | Lock the epiphany |
epiphanySelect(player, id) | Activate the epiphany (consumes 1 slot) |
epiphanyForceSelect(player, id) | Force activate (ignores slot limits) |
epiphanyReset(player, id) | Reset the epiphany |
Tools
| Method | Returns | Description |
|---|---|---|
getEpiphanySlots(player) | int | Epiphany Slots unlocked by the player |
getUsedEpiphanySlots(player) | int | Epiphany Slots currently occupied |
getMaxEpiphanySlots() | int | Configured hard cap on selectable Epiphanies |
getSelectedModuleCount(player) | int | Modules the player currently has selected |
getMaxSelectedModules() | int | Configured hard cap on simultaneously selected Modules |
Reset
| Method | Description |
|---|---|
resetAll(player) | Remove all rewards and Epiphany data, then restore initially SELECTABLE entries |
resetSelections(player) | Clear selections and rewards, preserve aptitude, refund selection costs, then restore initially SELECTABLE entries |
Event behavior
These methods are equivalent to /epiphany reset all and /epiphany reset select. They intentionally fire no aptitude, Insight Point, or selection events.
Aptitude / Points
| Method | Returns | Description |
|---|---|---|
getAptitude(player) | long | Current aptitude |
getInsightPoints(player) | int | Available Insight Points |
getTotalInsightPointsSpent(player) | int | Total Insight Points spent |
getTotalInsightPoints(player) | long | Spent and unspent Insight Points combined |
canGainInsightPoints(player) | boolean | Whether the player can gain more aptitude and points; false at the total cap |
setAptitude(player, value) | — | Set aptitude; increases use the growth curve, decreases do not take back points |
addAptitude(player, amount) | — | Add the specified aptitude without the gain multiplier; use the growth curve to level up and retain the remainder |
addAptitudeWithMultiplier(player, amount) | — | Add aptitude after applying the player's aptitude_gain_multiplier; the scaled amount is rounded down |
setInsightPoints(player, value) | — | Set available points without changing spent points; increases obey the total cap |
addInsightPoints(player, amount) | — | Add or subtract points, with a minimum balance of 0; increases obey the total cap |
fillAptitude(player) | long | Top up to the next point using the growth curve; return the aptitude added, or 0 at the cap |
getRequiredForNextPoint(player) | long | Get the aptitude threshold for the player's next Insight Point |
calcRequiredAptitude(totalSpent, points) | long | Calculate the next point's cost using the server's current growth curve |
The total cap counts spent + unspent points. These methods use the same settlement rules as the Java API: one aptitude grant can earn multiple points, with the remainder retained. Progression stops at the total cap, and excess aptitude is discarded when the cap is reached. Normal spending and corresponding refunds preserve total points; direct deductions lower the total. See Growth Curve for configuration.
Aptitude Source (Custom Aptitude Sources)
| Method | Returns | Description |
|---|---|---|
grantAptitude(player, behaviorId, targetId, registry) | boolean | Roll regular and first-time rewards per datapack rules, apply the player multiplier once to their sum, and return whether a grant succeeded |
resolveAptitudeSource(player, behaviorId, targetId, registry) | Resolution | Query reward ranges without rolling, applying the multiplier, or claiming a first-time reward |
For tag matching, pass the target's registry as registry. Pass null when matching concrete IDs only; tags will not match. For example, item targets use Java.loadClass('net.minecraft.core.registries.BuiltInRegistries').ITEM. See Registering a New Aptitude Source.
Use baseReward() and firstReward() to inspect the regular and available first-time reward ranges separately, or minReward() / maxReward() for their combined bounds:
let result = Epiphany.resolveAptitudeSource(
player,
Epiphany.id('mymod', 'fishing'),
Epiphany.id('minecraft', 'cod'),
null
);
if (result.applies()) {
console.info('Base reward range: ' + result.minReward() + '–' + result.maxReward());
}Here, player is a server player provided by an event. applies() indicates that the rules allow a positive reward. Use Epiphany.canGainInsightPoints(player) to check whether the player is capped. The old result.reward() is deprecated and works only for fixed values; query bounds for random rewards, and call grantAptitude to issue them.
See Aptitude & Insight Point for range formats and first-time reward rules.
Data Queries (Datapack Registry)
Look up one datapack-defined entry by ID. Returns null when not found:
| Method | Return Type |
|---|---|
getModule(id) | ModuleData |
getInsight(id) | InsightData |
getEpiphany(id) | EpiphanyData |
getPath(id) | PathData |
You can also list every registered Module, Epiphany, or Insight:
| Method | Return Type | Description |
|---|---|---|
allModuleIds() | ResourceLocation[] | All Module IDs, sorted |
allModules() | ModuleData[] | All Module definitions |
allEpiphanyIds() | ResourceLocation[] | All Epiphany IDs, sorted |
allEpiphanies() | EpiphanyData[] | All Epiphany definitions |
allInsightIds() | ResourceLocation[] | All Insight IDs, sorted |
allInsights() | InsightData[] | All Insight definitions |
Iterate as arrays
The bulk query methods return Java arrays rather than Lists. Use indexed access in KubeJS; Rhino's List.get(i) can return incorrect elements.
let ids = Epiphany.allModuleIds();
for (let i = 0; i < ids.length; i++) {
console.info(ids[i]);
}
let insights = Epiphany.allInsights();
for (let i = 0; i < insights.length; i++) {
console.info(insights[i].cost());
}The returned records' fields can be accessed directly. For example:
let module = Epiphany.getModule('mymod:combat');
if (module) {
console.info(module.name); // Optional<Component>
console.info(module.description); // Optional<Component>
console.info(module.initialState); // 'locked' or 'selectable'
console.info(module.weight); // number
module.insights.forEach(entry => {
console.info(entry.id, entry.depth); // insight ID + depth
});
}Optional fields and lang fallback
The name, description, and *_description fields exposed on records are raw Optionals — they contain whatever was written in the datapack JSON, without applying the default lang fallback logic. For example:
module.name→Optional<Component>, may be empty (if JSON omittedname)module.name.get().getString()→ returns the JSON literal (or translation key string), but does not go through lang translation fallback
If you provide multilingual support via resource packs, use each data type's effectiveXxx(id) method:
let id = 'mymod:combat';
let module = Epiphany.getModule(id);
if (module) {
// Raw — may be empty
let rawName = module.name; // Optional<Component>
// Resolved — goes through full lang fallback chain
let displayName = module.effectiveName(id).getString();
let displayDesc = module.effectiveDescription(id).getString();
}Each type's effectiveXxx methods correspond to its Component fields (name, description, condition_description, reward_description, etc.). When omitted, they look up the conventional translation keys in assets/<ns>/lang/*.json. See Module · Text Components & i18n for naming rules.
KubeJS Stage Condition
Epiphany provides condition and reward types based on KubeJS Stages for use in datapack JSON:
{ "type": "epiphany:kubejs_stage", "stage": "nether_access" }The condition passes when the player has the specified KubeJS Stage. Without KubeJS installed, it always returns false without crashing.
Example Scripts
Welcome Reward on Module Selection
// server_scripts/welcome.js
EpiphanyEvents.moduleSelected(event => {
let player = event.player;
let moduleId = event.moduleId;
// Notify the player
player.tell('You selected module: ' + moduleId);
// Give an iron sword on the first selection of the combat module
if (moduleId === 'mymod:combat') {
let hasClaimed = player.stages.has('combat_welcome');
if (!hasClaimed) {
player.give('minecraft:iron_sword');
player.stages.add('combat_welcome');
player.tell('Welcome to the warrior path! Received: Iron Sword x1');
}
}
});Pre Event: Prevent Module Selection
// server_scripts/restrict.js
EpiphanyEvents.moduleSelect(event => {
let player = event.player;
// Prevent module selection during a boss fight
if (player.stages.has('boss_fight_active')) {
event.cancel();
player.tell('A boss fight is in progress. You cannot select a new module.');
}
});
// The same rule applies to epiphanies
EpiphanyEvents.epiphanySelect(event => {
if (event.player.stages.has('boss_fight_active')) {
event.cancel();
}
});Aptitude Tracking and Notifications
// server_scripts/aptitude_notify.js
// Notify the player when Insight Points are gained
EpiphanyEvents.insightPointsChanged(event => {
if (event.isGain) {
event.player.tell(
'Insight Points gained! Current: ' + event.newValue + ' (+' + event.delta + ')'
);
}
});
// Track each aptitude level-up separately
let levelUpCounter = {};
EpiphanyEvents.aptitudeLevelUp(event => {
let uuid = event.player.uuid;
levelUpCounter[uuid] = (levelUpCounter[uuid] || 0) + 1;
// Give a reward every 10 level-ups
if (levelUpCounter[uuid] % 10 === 0) {
event.player.give('minecraft:diamond');
}
});Managing Player Data Through the API
// server_scripts/admin_helper.js
PlayerEvents.loggedIn(event => {
let player = event.player;
// Query progress
let pts = Epiphany.getInsightPoints(player);
let apt = Epiphany.getAptitude(player);
console.info('[Epiphany] ' + player.name + ' Insight Points=' + pts + ', Aptitude=' + apt);
// Give 100 aptitude on the first login
if (!player.stages.has('epiphany_gift') && Epiphany.canGainInsightPoints(player)) {
Epiphany.addAptitude(player, 100);
player.stages.add('epiphany_gift');
player.tell('Welcome gift claimed. Check your aptitude and Insight Points.');
}
});Querying Datapack Definitions
// server_scripts/inspect.js
// List a module's insights and their depths
let moduleId = 'mymod:combat';
let module = Epiphany.getModule(moduleId);
if (!module) {
console.warn('Module not found: ' + moduleId);
} else {
console.info('Module: ' + moduleId + ', weight=' + module.weight);
module.insights.forEach(entry => {
let insight = Epiphany.getInsight(entry.id);
if (!insight) {
console.info(' - depth=' + entry.depth + ': ' + entry.id + ' → (missing)');
} else {
let desc = insight.effectiveDescription(entry.id.toString()).getString();
console.info(' - depth=' + entry.depth + ': ' + entry.id + ' → ' + desc);
}
});
}Custom Aptitude Sources
This example calls a custom mymod:module_completion behavior when a module is completed, using the module ID as its target. First, add the datapack definition:
// data/mymod/epiphany/aptitude/module_completion.json
{
"default": [2, 5],
"specials": [
{
"target": "mymod:combat",
"reward": [8, 12],
"first_reward": 30
}
]
}Then add a server script:
// server_scripts/custom_aptitude.js
EpiphanyEvents.moduleCompleted(event => {
Epiphany.grantAptitude(
event.player,
Epiphany.id('mymod', 'module_completion'),
event.moduleId,
null
);
});This example matches concrete module IDs, so registry is null. The first completion of mymod:combat grants a combined regular and first-time reward of 38–42 aptitude before the player multiplier. The system tracks first-time rewards by player, behavior, and target, so no separate Stage is needed. At the total point cap, nothing is granted and the first-time reward is not consumed.
Epiphany already provides the epiphany:module_completed behavior. To adjust its aptitude reward, configure that behavior's JSON directly. The example above is for cases where a script needs to trigger a separate reward.