Skip to content

API reference / @jsprismarine/prismarine / entity/data/scene

entity/data/scene ​

Interfaces ​

EntityScene ​

Defined in: packages/prismarine/src/entity/data/scene.ts:77

The runtime as the AI projections read it.

Properties ​

host ​

readonly host: EntityHostFacts

Defined in: packages/prismarine/src/entity/data/scene.ts:79

world ​

readonly world: EntityWorldFacts

Defined in: packages/prismarine/src/entity/data/scene.ts:78

Methods ​

attack() ​

attack(attacker, target, damage?): void

Defined in: packages/prismarine/src/entity/data/scene.ts:127

Deals one entity's melee damage to another, or damage in its place.

Parameters ​
attacker ​

MobBody

target ​

GoalMob

damage? ​

number

Returns ​

void

blocks() ​

blocks(center, query): readonly GoalBlock[]

Defined in: packages/prismarine/src/entity/data/scene.ts:123

Blocks matching a query around a position, nearest first and up to its optional limit.

Parameters ​
center ​

EntityPosition

query ​

BlockQuery

Returns ​

readonly GoalBlock[]

breakBlock() ​

breakBlock(at): void

Defined in: packages/prismarine/src/entity/data/scene.ts:174

Breaks a block and drops what its loot table rolls.

Parameters ​
at ​

EntityPosition

Returns ​

void

breedWith() ​

breedWith(parent, mate): void

Defined in: packages/prismarine/src/entity/data/scene.ts:180

Produces the offspring of a successful breeding.

Parameters ​
parent ​

MobBody

mate ​

GoalMob

Returns ​

void

byId() ​

byId(id): DataEntity | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:93

Parameters ​
id ​

number

Returns ​

DataEntity | undefined

canBreedWith() ​

canBreedWith(parent, mate): boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:178

Whether two entities may breed with each other now.

Parameters ​
parent ​

MobBody

mate ​

GoalMob

Returns ​

boolean

canPickUpLoot() ​

canPickUpLoot(taker): boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:159

Whether a mob that picks up by chance may pick up at all, rolled once per mob.

Parameters ​
taker ​

MobBody

Returns ​

boolean

claimPoi() ​

claimPoi(pos, claimant): boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:212

Takes a ticket on a point of interest.

Parameters ​
pos ​

EntityPosition

claimant ​

number

Returns ​

boolean

combatOf() ​

combatOf(id): Pick<GoalMob, "lastHurt" | "lastHurtBy">

Defined in: packages/prismarine/src/entity/data/scene.ts:109

The blows an entity or a player remembers dealing and taking, which its goal mob answers.

Parameters ​
id ​

number

Returns ​

Pick<GoalMob, "lastHurt" | "lastHurtBy">

content() ​

content(): ServerContent

Defined in: packages/prismarine/src/entity/data/scene.ts:81

The built content, read back lazily because the adapter exists before the content does.

Returns ​

ServerContent

craftInto() ​

craftInto(inputIdentifier, outputIdentifier, availableInput, wantedOutput): GoalItemCraft | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:165

Finds a loaded crafting recipe that converts one item into another.

Parameters ​
inputIdentifier ​

string

outputIdentifier ​

string

availableInput ​

number

wantedOutput ​

number

Returns ​

GoalItemCraft | undefined

dismount() ​

dismount(rider): void

Defined in: packages/prismarine/src/entity/data/scene.ts:143

Takes an entity off whatever it rides.

Parameters ​
rider ​

MobBody

Returns ​

void

dropLoot() ​

dropLoot(table, at): void

Defined in: packages/prismarine/src/entity/data/scene.ts:182

Rolls a loot table and drops what it produced.

Parameters ​
table ​

string

at ​

EntityPosition

Returns ​

void

dropSnifferSeed() ​

dropSnifferSeed(body): void

Defined in: packages/prismarine/src/entity/data/scene.ts:186

Rolls and drops the sniffer's seed loot at its head.

Parameters ​
body ​

MobBody

Returns ​

void

ejectRiders() ​

ejectRiders(vehicle): void

Defined in: packages/prismarine/src/entity/data/scene.ts:145

Throws every rider off an entity.

Parameters ​
vehicle ​

MobBody

Returns ​

void

enchantEquipmentFromProvider() ​

enchantEquipmentFromProvider(entity, provider, slots): void

Defined in: packages/prismarine/src/entity/data/scene.ts:161

Enchants what a mob holds and wears in some slots through a Java enchantment provider.

Parameters ​
entity ​

DataEntity

provider ​

string

slots ​

readonly string[]

Returns ​

void

entities() ​

entities(): Generator<DataEntity, void, undefined>

Defined in: packages/prismarine/src/entity/data/scene.ts:83

Every live entity, in spawn order, walked in place.

Returns ​

Generator<DataEntity, void, undefined>

explode() ​

explode(source): void

Defined in: packages/prismarine/src/entity/data/scene.ts:139

Detonates an entity, which is what its minecraft:explode component declares.

Parameters ​
source ​

MobBody

Returns ​

void

giveCraftedItem() ​

giveCraftedItem(giver, taker, craft): void

Defined in: packages/prismarine/src/entity/data/scene.ts:172

Consumes a prepared recipe's inputs and gives its output to another entity.

Parameters ​
giver ​

MobBody

taker ​

GoalMob

craft ​

GoalItemCraft

Returns ​

void

giveItem() ​

giveItem(giver, taker, identifier, count?): void

Defined in: packages/prismarine/src/entity/data/scene.ts:163

Moves one item from an entity's inventory to another entity.

Parameters ​
giver ​

MobBody

taker ​

GoalMob

identifier ​

string

count? ​

number

Returns ​

void

hasLineOfSight() ​

hasLineOfSight(from, to): boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:99

Whether a solid block lies between two eye positions.

Parameters ​
from ​

EntityPosition

to ​

EntityPosition

Returns ​

boolean

inBox() ​

inBox(min, max): readonly DataEntity[]

Defined in: packages/prismarine/src/entity/data/scene.ts:92

Every entity whose collision box intersects the given AABB, in spawn order.

Parameters ​
min ​

EntityPosition

max ​

EntityPosition

Returns ​

readonly DataEntity[]

isVillageHero() ​

isVillageHero(playerId): boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:222

Whether a player carries Hero of the Village.

Parameters ​
playerId ​

number

Returns ​

boolean

items() ​

items(center, radius): readonly GoalItem[]

Defined in: packages/prismarine/src/entity/data/scene.ts:121

Item stacks lying within a radius, nearest first.

Parameters ​
center ​

EntityPosition

radius ​

number

Returns ​

readonly GoalItem[]

javaPointsOfInterest() ​

javaPointsOfInterest(center, radius, matches): readonly object[]

Defined in: packages/prismarine/src/entity/data/scene.ts:206

The Java points of interest of the accepted types near a position.

Parameters ​
center ​

EntityPosition

radius ​

number

matches ​

(type) => boolean

Returns ​

readonly object[]

knockback() ​

knockback(source, target, horizontal, vertical): void

Defined in: packages/prismarine/src/entity/data/scene.ts:131

Knocks a mob away from the entity.

Parameters ​
source ​

MobBody

target ​

GoalMob

horizontal ​

number

vertical ​

number

Returns ​

void

lastDamage() ​

lastDamage(entity): LastDamage | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:119

Java's LivingEntity::getLastDamageSource: the last blow that landed on the entity, for 40 ticks after it landed.

Parameters ​
entity ​

DataEntity

Returns ​

LastDamage | undefined

leashHolderOf() ​

leashHolderOf(entity): GoalMob | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:151

The entity holding this one's leash, or undefined when it is not leashed.

Parameters ​
entity ​

MobBody

Returns ​

GoalMob | undefined

mobById() ​

mobById(id): GoalMob | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:107

One entity or player, by runtime id, as a goal sees it.

The two live in different indexes, so this is the one place that looks in both: a damager, an owner or a rider is a runtime id and the goal does not care which index answered.

Parameters ​
id ​

number

Returns ​

GoalMob | undefined

mount() ​

mount(rider, vehicle): void

Defined in: packages/prismarine/src/entity/data/scene.ts:141

Puts an entity on a mob as a rider, if the mob has a seat free for it.

Parameters ​
rider ​

MobBody

vehicle ​

GoalMob

Returns ​

void

navigation(): NavigationView

Defined in: packages/prismarine/src/entity/data/scene.ts:97

The blocks as the path finder reads them.

Returns ​

NavigationView

near() ​

near(center, radius, families?): readonly DataEntity[]

Defined in: packages/prismarine/src/entity/data/scene.ts:90

Every live entity within a radius of a position, unsorted.

families narrows the candidates to entities whose data-driven family list intersects the hint, without excluding any possible match.

Parameters ​
center ​

EntityPosition

radius ​

number

families? ​

readonly string[]

Returns ​

readonly DataEntity[]

openTrade() ​

openTrade(trader, player): void

Defined in: packages/prismarine/src/entity/data/scene.ts:176

Opens one entity's trade screen for a player.

Parameters ​
trader ​

MobBody

player ​

GoalMob

Returns ​

void

pickUp() ​

pickUp(taker, item, count?, options?): void

Defined in: packages/prismarine/src/entity/data/scene.ts:157

Takes an item stack lying in the world into an entity's inventory.

Parameters ​
taker ​

MobBody

item ​

GoalItem

count? ​

number

options? ​

GoalPickupOptions

Returns ​

void

poi() ​

poi(kind, center, radius): EntityPosition | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:125

The nearest point of interest of a kind, for the eleven goals that ask.

Parameters ​
kind ​

string

center ​

EntityPosition

radius ​

number

Returns ​

EntityPosition | undefined

pushMob() ​

pushMob(source, target, velocity): void

Defined in: packages/prismarine/src/entity/data/scene.ts:137

Adds to another mob's velocity, Java's Entity.push.

Parameters ​
source ​

MobBody

target ​

GoalMob

velocity ​

EntityPosition

Returns ​

void

Java See ​

Entity.push(Lnet/minecraft/world/phys/Vec3;)V

releasePoi() ​

releasePoi(pos, claimant): void

Defined in: packages/prismarine/src/entity/data/scene.ts:214

Gives a ticket back.

Parameters ​
pos ​

EntityPosition

claimant ​

number

Returns ​

void

remove() ​

remove(id, reason): void

Defined in: packages/prismarine/src/entity/data/scene.ts:95

Parameters ​
id ​

number

reason ​

string

Returns ​

void

report() ​

report(message): void

Defined in: packages/prismarine/src/entity/data/scene.ts:228

Records what the runtime met and could not carry out.

Parameters ​
message ​

string

Returns ​

void

ridersOf() ​

ridersOf(vehicle): readonly GoalMob[]

Defined in: packages/prismarine/src/entity/data/scene.ts:153

Who rides an entity, in the order they got on.

Parameters ​
vehicle ​

MobBody

Returns ​

readonly GoalMob[]

setHeldItem() ​

setHeldItem(body, identifier): void

Defined in: packages/prismarine/src/entity/data/scene.ts:155

Puts one of an item in a mob's main hand, or empties the hand for undefined.

Parameters ​
body ​

MobBody

identifier ​

string | undefined

Returns ​

void

setVillagerProfession() ​

setVillagerProfession(body, profession): void

Defined in: packages/prismarine/src/entity/data/scene.ts:200

Gives a villager a profession, minecraft:none for none, and builds its brain again for it.

Parameters ​
body ​

MobBody

profession ​

string

Returns ​

void

shoot() ​

shoot(shooter, target, projectile): void

Defined in: packages/prismarine/src/entity/data/scene.ts:129

Fires one entity's projectile at a mob.

Parameters ​
shooter ​

MobBody

target ​

GoalMob

projectile ​

string | undefined

Returns ​

void

snifferDigPosition() ​

snifferDigPosition(body): EntityPosition | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:184

The block beneath the sniffer's head, or undefined if its body is not indexed.

Parameters ​
body ​

MobBody

Returns ​

EntityPosition | undefined

sonicBoom() ​

sonicBoom(body, targetId): void

Defined in: packages/prismarine/src/entity/data/scene.ts:188

Applies one warden sonic boom to a live entity or host-owned entity.

Parameters ​
body ​

MobBody

targetId ​

number

Returns ​

void

spawn() ​

spawn(identifier, at, options?): DataEntity | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:94

Parameters ​
identifier ​

string

at ​

EntityPosition

options? ​

SpawnOptions

Returns ​

DataEntity | undefined

startSleeping() ​

startSleeping(entity, bed): boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:194

Lays a body down in the bed at bed, marking it occupied: whether it lay down.

Parameters ​
entity ​

DataEntity

bed ​

EntityPosition

Returns ​

boolean

stopSleeping() ​

stopSleeping(entity): EntityPosition | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:196

Gets a body out of bed and stands it beside the bed: where it stood up, if it was in one.

Parameters ​
entity ​

DataEntity

Returns ​

EntityPosition | undefined

tameMount() ​

tameMount(mount, player): void

Defined in: packages/prismarine/src/entity/data/scene.ts:147

Tames a mount for the player whose ride won its temper roll.

Parameters ​
mount ​

MobBody

player ​

GoalMob

Returns ​

void

trigger() ​

trigger(source, event, target): void

Defined in: packages/prismarine/src/entity/data/scene.ts:226

Fires an entity event on a named subject, which trigger with a target does.

Parameters ​
source ​

MobBody

event ​

string

target ​

string

Returns ​

void

vehicleOf() ​

vehicleOf(rider): GoalMob | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:149

What an entity rides, or undefined when it rides nothing.

Parameters ​
rider ​

MobBody

Returns ​

GoalMob | undefined

villagerCanBreed() ​

villagerCanBreed(body, partnerId): boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:224

Whether two villagers may have a child now.

Parameters ​
body ​

MobBody

partnerId ​

number

Returns ​

boolean

villagerProfession() ​

villagerProfession(entity): string | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:202

A villager's profession, such as minecraft:farmer, or undefined for one with none.

Parameters ​
entity ​

DataEntity

Returns ​

string | undefined

villagerRaidEffect() ​

villagerRaidEffect(body, effect): void

Defined in: packages/prismarine/src/entity/data/scene.ts:192

Performs a raid effect through the host that owns that world state.

Parameters ​
body ​

MobBody

effect ​

VillagerRaidEffect

Returns ​

void

villagerRaidState() ​

villagerRaidState(body): VillagerRaidState | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:190

The host raid state at a villager's position, when a raid owner is connected.

Parameters ​
body ​

MobBody

Returns ​

VillagerRaidState | undefined

villagerRestock() ​

villagerRestock(body): void

Defined in: packages/prismarine/src/entity/data/scene.ts:198

Restocks a villager's trades, within the day's allowance.

Parameters ​
body ​

MobBody

Returns ​

void

villagerShowTrade() ​

villagerShowTrade(body, shown): void

Defined in: packages/prismarine/src/entity/data/scene.ts:220

Shows a trade in the villager's hand, or empties it.

Parameters ​
body ​

MobBody

shown ​

boolean

Returns ​

void

villagerStanding() ​

villagerStanding(body): { experience: number; level: number; } | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:204

A villager's trading level and the experience its trades earned it.

Parameters ​
body ​

MobBody

Returns ​

{ experience: number; level: number; } | undefined

villagerTask() ​

villagerTask(body, task, target?): boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:218

Carries out one piece of villager work.

Parameters ​
body ​

MobBody

task ​

VillagerTask

target? ​

number | EntityPosition

Returns ​

boolean

villagerWorkSpot() ​

villagerWorkSpot(body, task): EntityPosition | undefined

Defined in: packages/prismarine/src/entity/data/scene.ts:216

Where a farmer has farming to do.

Parameters ​
body ​

MobBody

task ​

"harvest_farmland" | "use_bonemeal"

Returns ​

EntityPosition | undefined

wasHurtRecently() ​

wasHurtRecently(entity): boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:114

Java's LivingEntity::wasHurtRecently: whether a blow took health from the entity in the last 10 ticks, while Java's hurtTime counts down from hurtDuration.

Parameters ​
entity ​

DataEntity

Returns ​

boolean


LastDamage ​

Defined in: packages/prismarine/src/entity/data/scene.ts:67

The last blow that landed on an entity, as EntityScene.lastDamage reports it.

Properties ​

attacker? ​

readonly optional attacker?: number

Defined in: packages/prismarine/src/entity/data/scene.ts:73

The runtime id of the entity that caused the blow, when one did.

cause ​

readonly cause: string

Defined in: packages/prismarine/src/entity/data/scene.ts:69

The damage cause, such as entity_attack.

damageType? ​

readonly optional damageType?: string

Defined in: packages/prismarine/src/entity/data/scene.ts:71

The Java damage type the blow named, when it named one.


SpawnOptions ​

Defined in: packages/prismarine/src/entity/data/scene.ts:26

How an entity came to exist, which decides the spawn event it runs.

Properties ​

admit? ​

readonly optional admit?: (entity) => boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:61

Whether the entity, once its spawn event has run, may enter the world. A refused entity is removed before any client hears of it and the spawn returns nothing.

Parameters ​
entity ​

DataEntity

Returns ​

boolean

beamTarget? ​

readonly optional beamTarget?: EntityPosition

Defined in: packages/prismarine/src/entity/data/scene.ts:45

The block an end crystal's beam points at, or absent for no beam.

cause? ​

readonly optional cause?: "born" | "spawned" | "transformed" | "primed"

Defined in: packages/prismarine/src/entity/data/scene.ts:30

born for breeding, transformed for a transformation, primed for TNT.

data? ​

readonly optional data?: Readonly<Record<string, unknown>>

Defined in: packages/prismarine/src/entity/data/scene.ts:51

Entity-specific fields supplied by the spawn source, preserved across saves.

event? ​

readonly optional event?: string

Defined in: packages/prismarine/src/entity/data/scene.ts:28

The event to run instead of the built-in one for the cause.

invulnerable? ​

readonly optional invulnerable?: boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:49

Whether the entity refuses all damage, as the respawn sequence's crystals do.

ownerId? ​

readonly optional ownerId?: number

Defined in: packages/prismarine/src/entity/data/scene.ts:43

The entity responsible for this spawn, such as the owner of chained TNT.

parents? ​

readonly optional parents?: readonly DataEntity[]

Defined in: packages/prismarine/src/entity/data/scene.ts:63

The entities a bred entity came from, which its inherited components read.

pitch? ​

readonly optional pitch?: number

Defined in: packages/prismarine/src/entity/data/scene.ts:41

pool? ​

readonly optional pool?: string

Defined in: packages/prismarine/src/entity/data/scene.ts:32

The pool whose cap the spawn counts against, when a spawn rule produced it.

prepare? ​

readonly optional prepare?: (entity) => void

Defined in: packages/prismarine/src/entity/data/scene.ts:56

Writes host state onto the entity before it enters the change log, so the state is part of the form it enters with. A dropped stack's contents are written this way.

Parameters ​
entity ​

DataEntity

Returns ​

void

showBottom? ​

readonly optional showBottom?: boolean

Defined in: packages/prismarine/src/entity/data/scene.ts:47

Whether an end crystal draws its base plate; absent keeps the client default, true.

yaw? ​

readonly optional yaw?: number

Defined in: packages/prismarine/src/entity/data/scene.ts:40

Which way the entity faces, in degrees, for a caller that knows.

Applied before the spawn event runs, so the body a client is first sent already faces the right way. A spawn rule names no rotation and gets 0, which is what every mob the spawner places has always had.