Script (Item Condition Type)

Passes when a script returns true for the item stack.

Passes when a script returns a truthy value for the stack. event.stack is the stack; event.entity is the holder when there is one.

Type ID: apoli:script

Fields

FieldTypeDefaultDescription
scriptIdentifierrequiredThe script to run. Either an id registered from KubeJS with ApoliEvents, or the path of a .js file shipped in a data pack at data/<namespace>/apoli/scripts/<path>.js — in which case the .js is part of the id.
paramsNBToptionalValues handed to the script. Read them with event.params from KubeJS, or params inside a data pack script. This is how one script serves several powers.

Example

// kubejs/server_scripts/heirloom.js
ApoliEvents.itemCondition('mypack:is_heirloom', event => {
  return event.stack.hasCustomName() && event.stack.enchantments.size() >= 3
})
{
  "type": "apoli:prevent_item_use",
  "item_condition": {
    "type": "apoli:script",
    "script": "mypack:is_heirloom"
  }
}

Needs KubeJS. Without it the type still loads and the pack still works — the call logs once and does nothing. Scripts always run on the server.