API reference / @jsprismarine/prismarine / entity/data/live / LiveEntityRuntime
Class: LiveEntityRuntime
Defined in: packages/prismarine/src/entity/data/live.ts:830
One dimension's entity runtime over a running server, shown to its clients through store actors.
Constructors
Constructor
new LiveEntityRuntime(
options,players?):LiveEntityRuntime
Defined in: packages/prismarine/src/entity/data/live.ts:858
Parameters
options
players?
StorePlayers = ...
The server's store players, whose actors show them as players and whose inventories answer the host's meal and armor facts.
Returns
LiveEntityRuntime
Properties
actors
readonlyactors:StoreActors
Defined in: packages/prismarine/src/entity/data/live.ts:839
Each entity as the clients are shown it and the rest of the server reaches it, read from the store: an ItemActor for a dropped stack and an InertActor for a saved actor no pack declares.
runtime
readonlyruntime:EntityRuntime
Defined in: packages/prismarine/src/entity/data/live.ts:832
The entities themselves, for the content adapter's three groups and for tests.
Accessors
droppedItems
Get Signature
get droppedItems():
DroppedItems
Defined in: packages/prismarine/src/entity/data/live.ts:1176
The dropped stacks of this dimension.
Returns
Methods
adoptItem()
adoptItem(
arrived,at,portalCooldown):DataEntity|undefined
Defined in: packages/prismarine/src/entity/data/live.ts:1208
Takes in a stack that left another dimension's store through a portal, with the state it left with, at where it arrives.
Parameters
arrived
The stack's actor in the store it left.
at
Where it arrives, which it reports itself at.
portalCooldown
number
The cooldown it arrives with.
Returns
DataEntity | undefined
The entity, or undefined when the actor held no stack.
attach()
attach(
adapter):void
Defined in: packages/prismarine/src/entity/data/live.ts:1147
Takes the assembled adapter for this dimension, which is where the spawn rules read the world from.
Separate from the constructor because the adapter holds groups projected out of this runtime, so the runtime exists first. The spawn world is src/content/world/views.ts's projection rather than another one written here, so a spawn rule and a block behavior read the same world.
Parameters
adapter
Returns
void
attachLead()
attachLead(
holderId,targetId):boolean
Defined in: packages/prismarine/src/entity/data/live.ts:1273
Attaches a live entity or player as holder of a data-driven entity's leash.
Parameters
holderId
number
targetId
number
Returns
boolean
canDyeEntity()
canDyeEntity(
target,color):boolean
Defined in: packages/prismarine/src/entity/data/live.ts:1322
Whether this live body is a data-driven entity that accepts the requested dye.
Parameters
target
The entity, a store entity through its actor.
color
string
The dye color name.
Returns
boolean
Whether the runtime entity accepts the dye.
canNameEntity()
canNameEntity(
target):boolean
Defined in: packages/prismarine/src/entity/data/live.ts:1298
Whether this live body is a data-driven entity that accepts a name tag.
Parameters
target
The entity, a store entity through its actor.
Returns
boolean
Whether its runtime entity accepts name tags.
damageEntity()
damageEntity(
target,amount,source,route):boolean|undefined
Defined in: packages/prismarine/src/entity/data/live.ts:1082
Hurts a data-driven entity through the store's damage pipeline, for a caller that describes the blow with a legacy DamageSource, such as a player's swing or a legacy blast.
Parameters
target
The entity, a store entity through its actor.
amount
number
source
route
Which path the blow came by.
Returns
boolean | undefined
Whether it took health off the entity, or undefined when it is not a store entity and the caller still owns the blow.
dropItem()
dropItem(
lying,start):DataEntity|undefined
Defined in: packages/prismarine/src/entity/data/live.ts:1185
Puts a stack on the ground as a store entity.
Parameters
lying
Where it lies; it reports itself a little above.
start
Returns
DataEntity | undefined
The entity, or undefined when the stack is empty or the content declares no item.
dyeEntity()
dyeEntity(
target,color):boolean
Defined in: packages/prismarine/src/entity/data/live.ts:1334
Applies a supported dye through the live data-driven entity runtime.
Parameters
target
The entity, a store entity through its actor.
color
string
The dye color name.
Returns
boolean
Whether the runtime changed the color.
igniteEntity()
igniteEntity(
target,seconds):boolean
Defined in: packages/prismarine/src/entity/data/live.ts:1101
Sets a store entity on fire for some seconds, as Java's Entity.igniteForSeconds does, never shortening a fire already burning longer.
Parameters
target
seconds
number
Returns
boolean
Whether it is a store entity.
Java Source
Entity.igniteForTicks
interactWithItem()
interactWithItem(
target,player,itemIdentifier,heldItem?):EntityItemInteraction
Defined in: packages/prismarine/src/entity/data/live.ts:1389
Applies a held item to a data-driven entity and carries out its world, item, and animation effects.
Parameters
target
player
itemIdentifier
string
heldItem?
Returns
isInRide()
isInRide(
id):boolean
Defined in: packages/prismarine/src/entity/data/live.ts:1286
Whether an entity rides something or carries a rider.
Bedrock sends nothing with passengers through a portal (MCPE-47288), and the only riding the server models is the data-driven minecraft:rideable index, so a player on a mob answers through the mob's side and a written entity never rides.
Parameters
id
number
The entity's runtime id.
Returns
boolean
killEntity()
killEntity(
target,source,route):boolean|undefined
Defined in: packages/prismarine/src/entity/data/live.ts:1114
Kills a data-driven entity through the store's damage pipeline, with a blow of its whole health that ignores armor and the grace period, which is what /kill deals.
Parameters
target
source
route
Returns
boolean | undefined
Whether it died, or undefined when it is not a store entity.
launchProjectile()
launchProjectile(
action,shooter):DataEntity|undefined
Defined in: packages/prismarine/src/entity/data/live.ts:1247
Launches an item projectile from its live source through the data-driven runtime.
A player's position is already at eye height; other entity positions are at their feet. The entity definition supplies flight and hit behavior through minecraft:projectile.
Parameters
action
The item behavior's projectile identifier, speed, spread, and payload.
shooter
The live entity that used the item.
Returns
DataEntity | undefined
The spawned projectile, or undefined when its loaded definition is not a projectile.
Java See
Projectile.shootFromRotation
nameEntity()
nameEntity(
target,name):boolean
Defined in: packages/prismarine/src/entity/data/live.ts:1310
Names a live body through its data-driven runtime entity.
Parameters
target
The entity, a store entity through its actor.
name
string
The custom name being assigned.
Returns
boolean
Whether the runtime accepted the name tag.
onEntityRemoved()
onEntityRemoved(
listener): () =>void
Defined in: packages/prismarine/src/entity/data/live.ts:1133
Hears about every entity the runtime removes, after the body is gone.
The End's dragon fight learns of its dragon's death through this rather than through a field on the runtime, so the runtime stays ignorant of who is watching. The reason is the removal reason the runtime recorded: death and death_behavior are deaths, chunk unload means the entity still exists in the save.
Parameters
listener
(entity, reason) => void
Returns
A function that unsubscribes the listener.
() => void
persist()
persist():
void
Defined in: packages/prismarine/src/entity/data/live.ts:1464
Writes every entity's record into its actor's tags, ready for a save. A dropped stack's actor record is the item's own tags, which EntitySerializer.toNBT writes, and an inert actor keeps the tags it was loaded with, so neither is given a record.
Called by World.saveChunks before it writes anything, rather than once a tick: the record is a snapshot of state that changes every tick, and nothing reads it until a chunk is written. The chunk serializer reads it from the actor with every other tag it carries.
Returns
void
restore()
restore(
record,stored):DataEntity|undefined
Defined in: packages/prismarine/src/entity/data/live.ts:1514
Brings one saved entity back into the runtime.
The store entity is what enters the world, shown through its actor. Everything the file carried that this server does not model, the actor's UniqueID first among them, moves onto the actor, so the next save addresses the same actor rather than writing a second one.
Parameters
record
stored
What EntitySerializer read from the actor NBT.
Returns
DataEntity | undefined
The entity, or undefined when no loaded pack declares its type.
restoreExisting()
restoreExisting(
stored):DataEntity|undefined
Defined in: packages/prismarine/src/entity/data/live.ts:1556
Migrates a saved actor without runtime state when its pack type is available.
This covers entities saved by an older class-based runtime as well as actors rebuilt from a provider's lightweight entity snapshot. The type's spawn event initializes current components, goals, and physics, while the original actor tags stay on the actor for fields the runtime does not model yet.
Parameters
stored
Returns
DataEntity | undefined
restoreInert()
restoreInert(
stored):DataEntity|undefined
Defined in: packages/prismarine/src/entity/data/live.ts:1603
Brings back a saved actor that no loaded pack declares, or whose type would not spawn, as an inert store entity: it keeps its identifier, its position, its tags, its portal cooldown, a TNT's fuse and every actor record tag, a data entity record among them, is shown to clients as itself and runs nothing. The next save writes it back as it was loaded, so a world loaded once without the pack that declares its mobs still has them when the pack comes back.
Parameters
stored
Returns
DataEntity | undefined
The entity, or undefined when the content has no inert type either.
restoreItem()
restoreItem(
stored):DataEntity|undefined
Defined in: packages/prismarine/src/entity/data/live.ts:1194
Brings a saved dropped stack back as a store entity, from the actor record a chunk carried.
Parameters
stored
Returns
DataEntity | undefined
The entity, or undefined when the record holds no stack.
restoreRecord()
restoreRecord(
record,at,kept):DataEntity|undefined
Defined in: packages/prismarine/src/entity/data/live.ts:1527
Brings one entity back into the runtime from its record, at a position, with what the record does not hold: the actor record tags to carry forward, and the name tag, tags and status effects the actor record held apart from it.
Parameters
record
at
kept
Returns
DataEntity | undefined
The entity, or undefined when no loaded pack declares its type.
savedRecords()
savedRecords():
ReadonlyMap<StoreActor,DataEntityRecord>
Defined in: packages/prismarine/src/entity/data/live.ts:1477
The record LiveEntityRuntime.persist would write for each entity that persists, by actor, without writing it, so a replay digest can hash what a save holds and change nothing.
Returns
ReadonlyMap<StoreActor, DataEntityRecord>
The records, each keyed by a store actor.
tick()
tick(
tick,shouldTick?):void
Defined in: packages/prismarine/src/entity/data/live.ts:1164
Runs one server tick for eligible entities. Clients are shown what it changed from the change log, after the world's tick seals.
The spawn loop starts on the first tick because it reads the loaded spawn rules.
Parameters
tick
number
The world's tick counter, which the pools' cadences use.
shouldTick?
(position) => boolean
Optional chunk eligibility rule; omitted callers tick every entity.
Returns
void