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

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
hasPowerFromSource(source, powerId)Check from a specific source
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

Static Shortcut Methods

OriginsJS.getPlayerHolder(player)
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)