Skip to content

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

entity/data/host ​

Interfaces ​

ContentItemEntity ​

Defined in: packages/prismarine/src/entity/data/host.ts:52

One item stack lying in the world, as the pickup goals read it.

Properties ​

filterView? ​

readonly optional filterView?: FilterItemView

Defined in: packages/prismarine/src/entity/data/host.ts:58

Tags, auxiliary data, and components the entity pickup rules read.

id ​

readonly id: number

Defined in: packages/prismarine/src/entity/data/host.ts:54

The runtime id, which is what EntityHostFacts.takeItem takes.

item ​

readonly item: ItemDrop

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

pickupDelay? ​

readonly optional pickupDelay?: number

Defined in: packages/prismarine/src/entity/data/host.ts:65

Ticks before anything may pick the stack up, Java's ItemEntity.pickupDelay. Left out by a host that keeps none, which reads as no delay.

Java See ​

ItemEntity.pickupDelay

position ​

readonly position: ContentPosition

Defined in: packages/prismarine/src/entity/data/host.ts:55


DamageCommit ​

Defined in: packages/prismarine/src/entity/data/host.ts:391

One committed blow, as EntityHostFacts.damageCommitted hears it.

Properties ​

dealt ​

readonly dealt: number

Defined in: packages/prismarine/src/entity/data/host.ts:397

The blow after the grace period and before armor, which Java's DamagePredicate calls dealt.

died ​

readonly died: boolean

Defined in: packages/prismarine/src/entity/data/host.ts:401

Whether the blow killed the entity.

intent ​

readonly intent: DamageIntent

Defined in: packages/prismarine/src/entity/data/host.ts:395

The intent as the guards left it.

taken ​

readonly taken: number

Defined in: packages/prismarine/src/entity/data/host.ts:399

What came off the health.

target ​

readonly target: DataEntity

Defined in: packages/prismarine/src/entity/data/host.ts:393

The entity that was hit, still in the store.


EntityHostFacts ​

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

The facts about entities that the data-driven index does not hold.

Players are the server's, not the runtime's: a player is driven by a network session rather than by a component set, so it never enters the entity index and has to be asked for. Item drops are the item subsystem's for the same reason.

Extended by ​

Methods ​

applySonicBoom()? ​

optional applySonicBoom(id, amount, sourceId, impulse): void

Defined in: packages/prismarine/src/entity/data/host.ts:364

Hurts an external target, then applies the warden's three-dimensional impulse if it lands.

Parameters ​
id ​

number

amount ​

number

sourceId ​

number

impulse ​

ContentPosition

Returns ​

void

applyStatusEffect()? ​

optional applyStatusEffect(id, effect): void

Defined in: packages/prismarine/src/entity/data/host.ts:252

Applies a data-defined melee effect to a live entity or player.

Parameters ​
id ​

number

effect ​

StatusEffectInput

Returns ​

void

applyStatusEffectIfChanged()? ​

optional applyStatusEffectIfChanged(id, effect): boolean

Defined in: packages/prismarine/src/entity/data/host.ts:254

Applies an effect and reports whether its active state changed.

Parameters ​
id ​

number

effect ​

StatusEffectInput

Returns ​

boolean

attackSound()? ​

optional attackSound(id): void

Defined in: packages/prismarine/src/entity/data/host.ts:242

Plays the attack sound for a data-driven entity.

Parameters ​
id ​

number

Returns ​

void

boostGlider()? ​

optional boostGlider(id, ticks): void

Defined in: packages/prismarine/src/entity/data/host.ts:227

Tells a gliding player's client that a firework rocket boosts it for ticks; the client flies the boost, as it moves its own player.

Parameters ​
id ​

number

ticks ​

number

Returns ​

void

breakMinedBlock()? ​

optional breakMinedBlock(playerId, mining): void

Defined in: packages/prismarine/src/entity/data/host.ts:211

Breaks the block a store player mines for a client that never reports the break, once the player has mined it for long enough, through the input step as the client's own report of the break would. Called every tick of such mining; the break ends it. Left out, such a block never breaks.

Parameters ​
playerId ​

number

mining ​

PlayerMining

Returns ​

void

damageCommitted()? ​

optional damageCommitted(commit): void

Defined in: packages/prismarine/src/entity/data/host.ts:387

Hears every committed blow on a data-driven entity, after its health changed and before a death it caused removes it. The host raises its damage and death events and its advancement triggers from here.

Parameters ​
commit ​

DamageCommit

Returns ​

void

damageMitigation()? ​

optional damageMitigation(target, intent): DamageMitigation | undefined

Defined in: packages/prismarine/src/entity/data/host.ts:381

What a data-driven entity wears against one blow: armor points, toughness and protection.

Parameters ​
target ​

DataEntity

intent ​

DamageIntent

Returns ​

DamageMitigation | undefined

destroyBlock()? ​

optional destroyBlock(at, options): boolean

Defined in: packages/prismarine/src/entity/data/host.ts:122

Raises a block's onBreak and puts what it yields on the ground.

The write is still the caller's: this is the half of a destruction the runtime cannot do itself. Raising the hook is what spills a chest a creeper blew up, and the drops a family makes while it runs have to be told apart from the loot table's own roll, which needs the world those drops go to. src/world/blockDestroy.ts is the one place that knows how.

Call it before writing over the block, because a family reads the block entity it is about to lose.

Left out by a host with no live world behind it, which makes the caller roll the table itself and leave the hook unraised, the way it did before this existed.

Parameters ​
at ​

ContentPosition

options ​
dropsBlock? ​

boolean

Whether the block yields anything of itself, which is the doTileDrops game rule. It still spills what it was holding either way.

explosionRadius? ​

number

sourceId? ​

number

Returns ​

boolean

True when the host took the drops, so the caller owes nothing more for them.

drop() ​

drop(at, item): void

Defined in: packages/prismarine/src/entity/data/host.ts:102

Drops an item stack as an entity at a position.

Parameters ​
at ​

ContentPosition

item ​

ItemDrop

Returns ​

void

entitySound()? ​

optional entitySound(id, event): void

Defined in: packages/prismarine/src/entity/data/host.ts:250

Plays a level sound event as a data-driven entity's own, such as the ambient an entity file's play_sound names, which a client plays in the entity type's voice. Left out, the name plays as a sound definition.

Parameters ​
id ​

number

The entity's runtime id.

event ​

LevelSoundEvent

The level sound event.

Returns ​

void

explosionHit()? ​

optional explosionHit(at): void

Defined in: packages/prismarine/src/entity/data/host.ts:321

Runs the onExplosionHit hook of the block at at, which a blast that triggers blocks reached, as Java's ServerExplosion.interactWithBlocks does for a wind charge's burst. Left out by a host with no live world, where nothing is triggered.

Parameters ​
at ​

ContentPosition

The block's position.

Returns ​

void

Java See ​

ServerExplosion.interactWithBlocks

fallingBlockLanded()? ​

optional fallingBlockLanded(id, at): void

Defined in: packages/prismarine/src/entity/data/host.ts:278

A falling block came to rest as a block, which the players tracking it are shown at once, before the block change reaches them.

Parameters ​
id ​

number

The falling block's runtime id, which is gone by the time it is shown.

at ​

ContentPosition

The block it became.

Returns ​

void

finishMeal()? ​

optional finishMeal(playerId, item): void

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

Finishes a store player's meal: the item in hand runs onConsume, which feeds the player and hands back what the meal leaves. Left out, a finished meal does nothing.

Parameters ​
playerId ​

number

item ​

string

Returns ​

void

fireworkExploded()? ​

optional fireworkExploded(id): void

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

Shows a firework rocket's explosion to the players that see it, before it leaves the world.

Parameters ​
id ​

number

Returns ​

void

fireworkLaunched()? ​

optional fireworkLaunched(id, at): void

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

Plays a firework rocket's launch where it starts, on its first tick.

Parameters ​
id ​

number

at ​

ContentPosition

Returns ​

void

givePlayerItem()? ​

optional givePlayerItem(playerId, itemId, item): number

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

Gives a dropped stack to a player: the inventory, the take animation and the advancement.

Parameters ​
playerId ​

number

The runtime id of the player taking it.

itemId ​

number

The runtime id of the dropped stack, which the take animation names.

item ​

ItemDrop

The stack.

Returns ​

number

How many of the stack's items did not fit. Left out, nothing is ever taken.

handsOf()? ​

optional handsOf(playerId): PlayerHands | undefined

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

What a store player holds in each hand, by identifier, which the store does not model yet. Left out, or answering undefined, the entity's own equipment stands for it.

Parameters ​
playerId ​

number

Returns ​

PlayerHands | undefined

heldItemOf()? ​

optional heldItemOf(playerId): string | undefined

Defined in: packages/prismarine/src/entity/data/host.ts:177

The item a store player holds in its main hand, by identifier, or undefined for an empty hand. Left out by a host that keeps no inventory for store players, such as a test's.

Parameters ​
playerId ​

number

Returns ​

string | undefined

hurt()? ​

optional hurt(id, amount, cause, sourceId, deathMessageOverride?): void

Defined in: packages/prismarine/src/entity/data/host.ts:240

Deals damage to something the entity index does not hold.

A player is the case that matters: a zombie's melee_attack goal names its target by runtime id, and a player's id belongs to the server's own entity list rather than to this index. Left out by a server that cannot route damage, which makes a mob swing and connect with nothing rather than silently pretending it hit.

Parameters ​
id ​

number

The runtime id of whatever is being hurt.

amount ​

number

cause ​

string

sourceId ​

number | undefined

The runtime id of the entity answerable for the blow.

deathMessageOverride? ​

string

Returns ​

void

hurtByProjectile()? ​

optional hurtByProjectile(id, amount, projectileId, ownerId): void

Defined in: packages/prismarine/src/entity/data/host.ts:258

Deals damage to an entity with the projectile and its owner preserved as the source.

Parameters ​
id ​

number

amount ​

number

projectileId ​

number

ownerId ​

number | undefined

Returns ​

void

hurtFeedback()? ​

optional hurtFeedback(id, blow): void

Defined in: packages/prismarine/src/entity/data/host.ts:264

Sends the hurt animation and entity-attributed sound for one runtime-applied hit.

Parameters ​
id ​

number

The data-driven entity's runtime id.

blow ​

HurtBlow

What hurt it.

Returns ​

void

itemBurnedAway()? ​

optional itemBurnedAway(itemId, at): void

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

Plays the hiss of a dropped stack that lava burned away, at the point it lay.

Parameters ​
itemId ​

number

at ​

EntityPosition

Returns ​

void

itemCooldown()? ​

optional itemCooldown(id, category, ticks): void

Defined in: packages/prismarine/src/entity/data/host.ts:347

Starts an item cooldown on a player's client, as Java's ItemCooldowns.addCooldown reaches it with a cooldown packet. Nothing is sent for a runtime id no client watches as itself.

Parameters ​
id ​

number

The player's runtime id.

category ​

string

The Bedrock cooldown category, such as shield.

ticks ​

number

How long the cooldown runs.

Returns ​

void

Java See ​

ItemCooldowns.addCooldown(Lnet/minecraft/resources/Identifier;I)V

items()? ​

optional items(): readonly ContentItemEntity[]

Defined in: packages/prismarine/src/entity/data/host.ts:132

Every item stack lying in the dimension.

Left out by a server whose item entities are not indexed, which makes the pickup goals find nothing rather than find a guess.

Returns ​

readonly ContentItemEntity[]

itemsNear()? ​

optional itemsNear(center, radius): readonly ContentItemEntity[]

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

Item stacks whose horizontal positions may be inside a pickup radius.

The runtime still applies the exact three-dimensional radius and nearest-first ordering. A live host can use its spatial index here; hosts without one retain items.

Parameters ​
center ​

ContentPosition

radius ​

number

Returns ​

readonly ContentItemEntity[]

itemStackChanged()? ​

optional itemStackChanged(itemId, count): void

Defined in: packages/prismarine/src/entity/data/host.ts:170

Tells clients that a dropped stack now holds count items, after a merge or a partial take.

Parameters ​
itemId ​

number

count ​

number

Returns ​

void

knockback()? ​

optional knockback(id, directionX, directionZ, strength): void

Defined in: packages/prismarine/src/entity/data/host.ts:362

Applies projectile knockback to an entity outside the data-driven index.

Parameters ​
id ​

number

directionX ​

number

directionZ ​

number

strength ​

number

Returns ​

void

levelEvent()? ​

optional levelEvent(at, event, data): void

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

Plays a level event at a point, such as the burst of an eye of ender that shatters.

Parameters ​
at ​

ContentPosition

event ​

number

data ​

number

Returns ​

void

lightningStruck()? ​

optional lightningStruck(at, fire): void

Defined in: packages/prismarine/src/entity/data/host.ts:330

Does a lightning strike's work on the blocks: a fire where the bolt stands and four more round it when fire holds, and the lightning rod under it powered.

Parameters ​
at ​

ContentPosition

The block the bolt stands in.

fire ​

boolean

Whether the strike sets fire, which the runtime decides from the difficulty and how far fire spreads from a player.

Returns ​

void

Java See ​

LightningBolt.spawnFire

lootLevel()? ​

optional lootLevel(): LevelView | undefined

Defined in: packages/prismarine/src/entity/data/host.ts:183

The world as a loot roll reads it, which a trade's exploration_map searches for its structure. Left out, or answering undefined, an explorer map trade finds nothing and makes no offer.

Returns ​

LevelView | undefined

mobEventActive() ​

mobEventActive(event): boolean

Defined in: packages/prismarine/src/entity/data/host.ts:370

Whether a named mob event, such as minecraft:pillager_patrols_event, is running.

Parameters ​
event ​

string

Returns ​

boolean

playerById()? ​

optional playerById(id): ContentEntity | undefined

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

One player in the dimension by runtime id, when the host can index players directly.

Parameters ​
id ​

number

Returns ​

ContentEntity | undefined

playerEvent()? ​

optional playerEvent(playerId, event): void

Defined in: packages/prismarine/src/entity/data/host.ts:271

Tells a player's client something that happened to the player alone, such as a pufferfish's sting or an elder guardian's curse.

Parameters ​
playerId ​

number

The player's runtime id.

event ​

ShownPlayerEvent

What happened.

Returns ​

void

playerIdentityOf()? ​

optional playerIdentityOf(id): string | undefined

Defined in: packages/prismarine/src/entity/data/host.ts:98

Stable identity of a player runtime id, or undefined when it names no player.

Parameters ​
id ​

number

Returns ​

string | undefined

playerIdForIdentity()? ​

optional playerIdForIdentity(identity): number | undefined

Defined in: packages/prismarine/src/entity/data/host.ts:100

Current runtime id of a stable player identity, or undefined while that player is offline.

Parameters ​
identity ​

string

Returns ​

number | undefined

playerRidingInLava()? ​

optional playerRidingInLava(id, start): void

Defined in: packages/prismarine/src/entity/data/host.ts:305

A player's vehicle is in lava, and has been since start, where the player was when the vehicle went in.

Parameters ​
id ​

number

The player's runtime id.

start ​

EntityPosition

Where the player was when its vehicle went into the lava.

Returns ​

void

players() ​

players(): readonly ContentEntity[]

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

Every player in the dimension.

Returns ​

readonly ContentEntity[]

playerStartedRiding()? ​

optional playerStartedRiding(id): void

Defined in: packages/prismarine/src/entity/data/host.ts:298

A player got on a vehicle.

Parameters ​
id ​

number

The player's runtime id.

Returns ​

void

playerView()? ​

optional playerView(id): FilterEntityView | undefined

Defined in: packages/prismarine/src/entity/data/host.ts:96

A live player's full entity-filter view, or undefined when the player has left.

Parameters ​
id ​

number

Returns ​

FilterEntityView | undefined

playSoundAt()? ​

optional playSoundAt(at, sound): void

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

Plays a named sound at an exact point, for an entity rather than a block, which ContentEffectSink.playSound centers on.

Parameters ​
at ​

ContentPosition

sound ​

string

Returns ​

void

projectileHitBlock()? ​

optional projectileHitBlock(at, hit): void

Defined in: packages/prismarine/src/entity/data/host.ts:338

Runs the onProjectileHit hook of the block at at, which a projectile flew into, as Java's Projectile.onHitBlock does. Left out by a host with no live world.

Parameters ​
at ​

ContentPosition

The block's position.

hit ​

Omit<BlockProjectileHitEvent, "block">

What the block's rule reads of the projectile.

Returns ​

void

Java See ​

Projectile.onHitBlock

removeStatusEffect()? ​

optional removeStatusEffect(id, identifier): boolean

Defined in: packages/prismarine/src/entity/data/host.ts:256

Removes one effect from a live entity or player.

Parameters ​
id ​

number

identifier ​

string

Returns ​

boolean

riderDismounted()? ​

optional riderDismounted(id, at): void

Defined in: packages/prismarine/src/entity/data/host.ts:293

Puts a player its vehicle let off where the vehicle sets it down, as Java's ServerPlayer.dismountTo teleports the player there.

Parameters ​
id ​

number

The player's runtime id.

at ​

EntityPosition

Where the vehicle lets it off.

Returns ​

void

showDeath()? ​

optional showDeath(id, stage): void

Defined in: packages/prismarine/src/entity/data/host.ts:354

Shows a step of a living entity's death to the players that see it: the death animation starting, the body vanishing at its end, or a dead player standing again.

Parameters ​
id ​

number

The runtime id of the entity that died, or of the player that came back.

stage ​

DeathStage

Which step it is.

Returns ​

void

startDeathAnimation()? ​

optional startDeathAnimation(id): void

Defined in: packages/prismarine/src/entity/data/host.ts:360

Announces that an entity's data-defined death hold began, so clients play the long death animation. Only the ender dragon's minecraft:behavior.dragondeath starts one.

Parameters ​
id ​

number

The data-driven entity's runtime id.

Returns ​

void

stepOn()? ​

optional stepOn(at, entity): void

Defined in: packages/prismarine/src/entity/data/host.ts:313

Runs the onStepOn hook of the block at at, which a body's box has just moved into, as Java's Entity.checkInsideBlocks calls entityInside.

Parameters ​
at ​

EntityPosition

The block's position.

entity ​

DataEntity

The body that moved into it.

Returns ​

void

Java See ​

Entity.checkInsideBlocks(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/InsideBlockEffectApplier$StepBasedCollector;Lit/unimi/dsi/fastutil/longs/LongSet;I)I

structureSpawnOverrideAt()? ​

optional structureSpawnOverrideAt(identifier, at): boolean | undefined

Defined in: packages/prismarine/src/entity/data/host.ts:379

Whether Java structure spawn data reserves this type at one position.

Parameters ​
identifier ​

string

at ​

ContentPosition

Returns ​

boolean | undefined

takeExperienceOrb()? ​

optional takeExperienceOrb(playerId, orbId, value): void

Defined in: packages/prismarine/src/entity/data/host.ts:168

Gives a player one experience orb, Java's ExperienceOrb.playerTouch: Mending repairs what it can of the player's gear and the rest of the points are experience. Left out, an orb a player takes is lost.

Parameters ​
playerId ​

number

The runtime id of the player taking it.

orbId ​

number

The runtime id of the orb.

value ​

number

The points one orb is worth.

Returns ​

void

Java See ​

ExperienceOrb.playerTouch

takeItem()? ​

optional takeItem(id, count?): ItemDrop | undefined

Defined in: packages/prismarine/src/entity/data/host.ts:148

Takes items from one item entity, removing it when the whole stack was taken.

Parameters ​
id ​

number

The runtime id of the dropped stack.

count? ​

number

The maximum number to take, or all items when omitted.

Returns ​

ItemDrop | undefined

What was taken, or undefined when nothing of that id is lying there, which is what two mobs reaching for the same stack get.

useDeathProtection()? ​

optional useDeathProtection(playerId): unknown

Defined in: packages/prismarine/src/entity/data/host.ts:199

Uses up one death protection item, a totem of undying, from a store player's main hand or else its off hand, and answers with its minecraft:death_protection component. Undefined when neither hand holds one. Left out, a store player's totems save nothing.

Parameters ​
playerId ​

number

Returns ​

unknown

villageBorderDistance()? ​

optional villageBorderDistance(at): number | undefined

Defined in: packages/prismarine/src/entity/data/host.ts:377

How far a position is from the nearest village border, negative inside it and undefined when no village is near. Left out by a server with no village index, which makes minecraft:player_in_village_filter refuse rather than match everywhere.

Parameters ​
at ​

ContentPosition

Returns ​

number | undefined

villagerRaidEffect()? ​

optional villagerRaidEffect(id, effect): void

Defined in: packages/prismarine/src/entity/data/host.ts:368

Performs a world-owned effect requested by a villager raid behavior.

Parameters ​
id ​

number

effect ​

VillagerRaidEffect

Returns ​

void

villagerRaidStateAt()? ​

optional villagerRaidStateAt(at): VillagerRaidState | undefined

Defined in: packages/prismarine/src/entity/data/host.ts:366

The raid facts at a position, supplied by the world raid owner.

Parameters ​
at ​

ContentPosition

Returns ​

VillagerRaidState | undefined

wakePlayer()? ​

optional wakePlayer(id): boolean

Defined in: packages/prismarine/src/entity/data/host.ts:286

Gets a player out of bed the way anything but morning wakes it, as a blow does: the players that see it watch it get up, its client is put beside the bed, and the count of sleepers is told again.

Parameters ​
id ​

number

The player's runtime id.

Returns ​

boolean

Whether the player's world woke it; a player in no world is left to the runtime.

wearHeldItem()? ​

optional wearHeldItem(playerId, hand, amount): void

Defined in: packages/prismarine/src/entity/data/host.ts:193

Spends durability of what a store player holds in one hand, as a blocked blow wears a shield. A stack worn through breaks. Left out, the entity's own equipment is worn.

Parameters ​
playerId ​

number

hand ​

keyof PlayerHands

amount ​

number

Returns ​

void


EntityWorldFacts ​

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

The groups the blocks, world and network subsystems own, as the entity runtime reads them.

Properties ​

blocks ​

readonly blocks: ContentBlockAccess

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

effects ​

readonly effects: ContentEffectSink

Defined in: packages/prismarine/src/entity/data/host.ts:72

level ​

readonly level: ContentLevelFacts

Defined in: packages/prismarine/src/entity/data/host.ts:70

random ​

readonly random: RandomSource

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


HurtBlow ​

Defined in: packages/prismarine/src/entity/data/host.ts:38

A blow that hurt an entity, as its hurt feedback reads it.

Properties ​

attacker? ​

readonly optional attacker?: number

Defined in: packages/prismarine/src/entity/data/host.ts:42

The runtime id of the entity answerable for it, when there is one.

byLiving ​

readonly byLiving: boolean

Defined in: packages/prismarine/src/entity/data/host.ts:48

Whether a living entity is answerable for it, which puts a player in combat.

damageType ​

readonly damageType: string

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

The Java damage type it stands for, such as minecraft:player_attack.

origin? ​

readonly optional origin?: EntityPosition

Defined in: packages/prismarine/src/entity/data/host.ts:46

Where it came from, which it shoves the entity away from, when it came from somewhere.

projectile? ​

readonly optional projectile?: number

Defined in: packages/prismarine/src/entity/data/host.ts:44

The runtime id of the projectile that landed it, when one did.


PlayerHands ​

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

What a player holds in each hand, by item identifier; an empty hand is left out.

Properties ​

mainhand? ​

readonly optional mainhand?: string

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

offhand? ​

readonly optional offhand?: string

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