Entity Action
Registration
// kubejs/startup_scripts/actions.js
OriginsJS.registerEntityAction("heal_half", (entity, params) => {
if (entity.isLiving()) {
entity.heal(entity.getMaxHealth() / 2);
}
});
OriginsJS.registerEntityAction("send_message", (entity, params) => {
let msg = params.get("message").getAsString();
if (entity.isPlayer()) {
entity.tell(msg);
}
});
JSON
{
"type": "origins:action_on_callback",
"entity_action_gained": {
"type": "origins_js:js_entity_action",
"id": "heal_half"
},
"entity_action_lost": {
"type": "origins_js:js_entity_action",
"id": "send_message",
"params": { "message": "You lost your origin!" }
}
}
How It Works
- The script registers callbacks under IDs
"heal_half"and"send_message". - The JSON references those IDs via
"type": "origins_js:js_entity_action". - When Origins fires the action,
paramsfrom the JSON are passed to the callback.