Skip to main content

API Reference

JS Action / Condition Types

All custom types use the origins_js: namespace prefix. For the standard types these wrap, see the corresponding documentation:

JSON typeRegistration MethodCallback ArgsStandard Docs
origins_js:js_entity_actionregisterEntityAction(entity, params)Entity Action
origins_js:js_block_actionregisterBlockAction(level, pos, direction, params)Block Action
origins_js:js_item_actionregisterItemAction(level, entity, slotAccess, params)Item Action
origins_js:js_bientity_actionregisterBiEntityAction(actor, target, params)Bi-entity Action
origins_js:js_entity_conditionregisterEntityCondition(entity, params) => boolEntity Condition
origins_js:js_block_conditionregisterBlockCondition(level, pos, params) => boolBlock Condition
origins_js:js_item_conditionregisterItemCondition(level, itemStack, params) => boolItem Condition
origins_js:js_bientity_conditionregisterBiEntityCondition(actor, target, params) => boolBi-entity Condition
origins_js:js_biome_conditionregisterBiomeCondition(biomeHolder, pos, params) => boolBiome Condition
origins_js:js_damage_conditionregisterDamageCondition(damageSource, amount, params) => boolDamage Condition
origins_js:js_fluid_conditionregisterFluidCondition(fluidState, params) => boolFluid Condition
origins_js:js_powerpowerBuilder(id).grant/.../...register()Builder: .grant((holder, params) => ...)Power Types

HolderWrapper API

warning

Using HelperWrapper is recommended for querying and manipulating power state. It uses the new PowerHelper API internally, which is safer and more flexible than the older HolderWrapper methods.

Available methods on the wrapper returned by OriginsJS.getHolder(entity):

Origin Management

See Origin JSON Format and Layer JSON Format for data structure details.

MethodDescription
setOrigin(layerId, originId)Assign an origin to a layer
clearOrigin(layerId)Remove the origin from a layer
hasOrigin(originId)Check if entity has the given origin (in any layer)
hasOriginInLayer(layerId, originId)Check in a specific layer
hasLayer(layerId)Check if the layer has any origin
getOriginId(layerId)Get the origin ID string for a layer, or null
getAllOrigins()Returns [[layerId, originId], ...]
hasAllOrigins()Whether all layers are assigned
fillAutoChoosing()Fill auto-choosing layers
randomOrigin(layerId)Randomly assign an origin

Power Management

See Power JSON Format for data structure details. See /power command for command equivalents.

MethodDescription
grantPower(source, powerId)Grant a power from a source
revokePower(source, powerId)Revoke a power from a source
revokeAllPowers(source)Remove all powers from a source
hasPower(powerId)Check whether the entity has a power
getAllPowerIds()List all power ID strings

Resource (Integer resource bar)

See Resource (Power Type) for the underlying power type.

MethodDescription
getResource(powerId)Get the current resource value
setResource(powerId, value)Set the resource to a specific int
addResource(powerId, delta)Add/subtract to the resource

Cooldown (Usage cooldown timer)

See Cooldown (Power Type) for the underlying power type.

MethodDescription
getCooldown(powerId)Get remaining cooldown ticks
startCooldown(powerId)Start the cooldown
canUseCooldown(powerId)Check whether the cooldown is ready

Entity Set (Per-power entity tracking set)

See Action On Set (Entity Action) and Set Size (Condition) for types that interact with entity sets.

MethodDescription
addToEntitySet(powerId, uuid)Add an entity (by UUID string)
removeFromEntitySet(powerId, uuid)Remove an entity
isInEntitySet(powerId, uuid)Check if an entity is in the set
getEntitySetSize(powerId)Get the number of entities in the set
getEntitySetMembers(powerId)Get all UUID strings in the set

Available on the wrapper returned by OriginsJS.getHelper(entity) or holder.getHelper(). Uses the new PowerHelper API internally. This is the recommended way to query and manipulate power state.

Active State

MethodDescription
anyActive()Check if ANY power is currently active
noneActive()Check if no power is currently active
hasActive(powerId)Check if a specific power (by ID) has any active instance
hasNoneActive(powerId)Check if a specific power has no active instances

Toggle

MethodDescription
toggle(key)Toggle a power by key (e.g. "primary", "secondary")

Stream / List / GetFirst

MethodDescription
streamActive(powerId)Stream all active instances of the power type
listActive(powerId)List all active instances
listActive(powerId, filter)List active instances matching a predicate
getFirst(powerId)Get the first active instance, or null
getFirst(powerId, filter)Get the first active instance matching a predicate, or null

Execute

execute(powerId, (holder, power) => { ... }) — Run a callback on every active instance.

MethodDescription
execute(powerId, action)Execute callback on every active instance
execute(powerId, filter, action)Execute callback on matching active instances

The callback receives (OriginDataHolder, Power).

Modify

Apply modifier power effects to a base value. Only works on powers that implement ModifierPowerHelper (e.g. origins:modify_attribute).

MethodDescription
modifyInt(powerId, base)Modify an int base value
modifyInt(powerId, filter, base)Modify int with predicate filter
modifyFloat(powerId, base)Modify a float base value
modifyFloat(powerId, filter, base)Modify float with predicate filter
modifyDouble(powerId, base)Modify a double base value
modifyDouble(powerId, filter, base)Modify double with predicate filter

Reduce

Fold over all active instances, accumulating a result.

MethodDescription
reduceDouble(powerId, identity, reducer)Reduce double. reducer: (holder, acc, power) => newAcc
reduce(powerId, identity, reducer, combiner)Generic reduce with custom type and combiner

Apply Modifiers

Apply a list of Modifiers to a base value.

MethodDescription
applyModifiers(modifiers, base)Apply modifiers (int/float/double)

Component Access

MethodDescription
getComponent(powerId, class)Get a component attached to a power, or null
getComponentFor(power, class)Get component from a specific power instance
getComponentHolder(powerId, class)Get a component holder, or null

Resource / Cooldown / Entity Set

Same as HolderWrapper, available directly:

MethodDescription
getResource(powerId) / setResource(powerId, value) / addResource(powerId, delta)Resource management
getCooldown(powerId) / startCooldown(powerId) / canUseCooldown(powerId)Cooldown management
addToEntitySet(powerId, uuid) / removeFromEntitySet(powerId, uuid) / isInEntitySet(powerId, uuid) / getEntitySetSize(powerId) / getEntitySetMembers(powerId)Entity Set management

Static Shortcut Methods

OriginsJS.getPlayerHolder(player)
OriginsJS.getHelper(entity) // Get HelperWrapper directly
OriginsJS.grantPower(entity, source, powerId)
OriginsJS.revokePower(entity, source, powerId)
OriginsJS.hasPower(entity, powerId)
OriginsJS.setOrigin(entity, layerId, originId)
OriginsJS.hasOrigin(entity, originId)
OriginsJS.powerBuilder("mypack:power").grant(...).tick(...).register()

// Resource
OriginsJS.getResource(entity, powerId)
OriginsJS.setResource(entity, powerId, value)
OriginsJS.addResource(entity, powerId, delta)

// Cooldown
OriginsJS.getCooldown(entity, powerId)
OriginsJS.startCooldown(entity, powerId)
OriginsJS.canUseCooldown(entity, powerId)

// Entity Set
OriginsJS.addToEntitySet(entity, powerId, uuid)
OriginsJS.removeFromEntitySet(entity, powerId, uuid)
OriginsJS.isInEntitySet(entity, powerId, uuid)
OriginsJS.getEntitySetSize(entity, powerId)

// PowerHelper shortcuts
OriginsJS.anyPowerActive(entity)
OriginsJS.noPowerActive(entity)
OriginsJS.togglePower(entity, key)