Skip to main content

KubeJS

Place scripts in kubejs/server_scripts/. This integration requires KubeJS.

ReincarnationLifespan​

MethodReturnBehaviour
remaining(entity)longRemaining ticks, or -1 for an unaccounted or closed ledger.
total(entity)longTotal ticks granted, -1 if unaccounted and 0 if closed.
set(entity, ticks)ResultSet remaining and total ticks to the same non-negative number.
add(entity, ticks)ResultPositive amounts extend both values. Negative amounts spend only the remainder.
unlimited(entity)ResultClose the ledger.
reincarnate(entity)ResultQueue rebirth in the configured mode.

Writes require a living entity and the logical server thread. Client reads return -1 and client writes return SERVER_ONLY. Inspect getFailure() and getData() on Saturn's Result. An empty failure means success. For queued rebirth, that means the request was accepted.

ReincarnationEvents​

The wrapper provides getType(), getPhase(), isCancellable() and getEvent(). Call cancel() on a Pre event to cancel the underlying operation.

EventPhasesNative event
lifespanEndPre, PostgetEntity() and getSpirit() expose the entity and lifespan ledger. Granting positive life in Pre resumes ageing. Cancelling without renewal closes the ledger. Post also has getOutcome().
lifespanRebirthPre, Post, FailedgetEntity(), getSpirit() and getMode(). Post supplies the resulting entity and its ledger. A rejected queued rebirth can report Failed with getFailure().

Explicit lifespan rebirth publishes lifespanRebirth events. Ordinary death-triggered full rebirth and /reincarnation rebirth use the full rebirth events.

kubejs/server_scripts/lifespan.js
ReincarnationEvents.lifespanEnd(event => {
if (event.getPhase() !== 'Pre') return
const entity = event.getEvent().getEntity()
if (!entity.getTags().contains('example:immortal')) return
ReincarnationLifespan.unlimited(entity)
event.cancel()
})