[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / entity/mobLoot

# entity/mobLoot

## Interfaces

### LootEntity

Defined in: [packages/prismarine/src/entity/mobLoot.ts:223](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L223)

The little of an entity the loot predicates read, so an actor satisfies it as it is.

#### Methods

##### getPosition()

> **getPosition**(): `object`

Defined in: [packages/prismarine/src/entity/mobLoot.ts:225](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L225)

###### Returns

`object`

###### getX()

> **getX**(): `number`

###### Returns

`number`

###### getY()

> **getY**(): `number`

###### Returns

`number`

###### getZ()

> **getZ**(): `number`

###### Returns

`number`

##### getType()

> **getType**(): `string`

Defined in: [packages/prismarine/src/entity/mobLoot.ts:224](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L224)

###### Returns

`string`

##### n()?

> `optional` **n**(): `object`

Defined in: [packages/prismarine/src/entity/mobLoot.ts:231](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L231)

The inventory, which only something humanlike has. The optional
member is what lets an actor
without one - a skeleton, a cactus - satisfy this type.

###### Returns

`object`

###### getItemInHand()

> **getItemInHand**(): `object`

###### Returns

`object`

###### asPredicateStack()

> **asPredicateStack**(): [`ItemStack`](https://jsprismarine.dev/api/@jsprismarine/predicates/index.md#itemstack)

###### Returns

[`ItemStack`](https://jsprismarine.dev/api/@jsprismarine/predicates/index.md#itemstack)

***

### LootKill

Defined in: [packages/prismarine/src/entity/mobLoot.ts:241](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L241)

The little of a import('./DamageSource').DamageSource the loot
predicates read.

Written structurally rather than against the class so a test can state a
kill without building two live entities to have it happen between.

#### Properties

##### attacker

> `readonly` **attacker**: [`LootEntity`](#lootentity) \| `null`

Defined in: [packages/prismarine/src/entity/mobLoot.ts:244](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L244)

Whoever is answerable, which for a fired arrow is the archer.

##### cause

> `readonly` **cause**: [`DamageCause`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/DamageCause/index.md#damagecause-1)

Defined in: [packages/prismarine/src/entity/mobLoot.ts:242](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L242)

##### projectile

> `readonly` **projectile**: [`LootEntity`](#lootentity) \| `null`

Defined in: [packages/prismarine/src/entity/mobLoot.ts:246](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L246)

What made contact, when that is not the attacker.

***

### MobDropContext

Defined in: [packages/prismarine/src/entity/mobLoot.ts:105](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L105)

What a death knows about itself, beyond the mob that died.

#### Properties

##### damage?

> `readonly` `optional` **damage?**: [`DamageSource`](https://jsprismarine.dev/api/@jsprismarine/predicates/index.md#damagesource)

Defined in: [packages/prismarine/src/entity/mobLoot.ts:111](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L111)

How it died and who is answerable. Build one with [lootDamageSource](#lootdamagesource).

##### level?

> `readonly` `optional` **level?**: [`LevelView`](https://jsprismarine.dev/api/@jsprismarine/predicates/index.md#levelview)

Defined in: [packages/prismarine/src/entity/mobLoot.ts:113](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L113)

The world the clock and location conditions read.

##### position?

> `readonly` `optional` **position?**: [`Vec3`](https://jsprismarine.dev/api/@jsprismarine/predicates/index.md#vec3)

Defined in: [packages/prismarine/src/entity/mobLoot.ts:107](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L107)

Where it fell, which `origin` and the position predicates read.

##### random?

> `readonly` `optional` **random?**: [`RandomSource`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#randomsource)

Defined in: [packages/prismarine/src/entity/mobLoot.ts:115](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L115)

Replaces the table's own sequenced stream, for a test that wants a scripted draw.

##### self?

> `readonly` `optional` **self?**: [`MobLootState`](#moblootstate)

Defined in: [packages/prismarine/src/entity/mobLoot.ts:109](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L109)

What this mob is, past its type; see [MobLootState](#moblootstate).

## Type Aliases

### MobLootState

> **MobLootState** = `Omit`\<[`EntityView`](https://jsprismarine.dev/api/@jsprismarine/predicates/index.md#entityview), `"type"` \| `"position"`\>

Defined in: [packages/prismarine/src/entity/mobLoot.ts:102](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L102)

What the entity predicates read about a mob beyond its type and where it
stood: the flags it carries, its data components and its per-type state.

These decide real branches. A sheep's wool is keyed by its
`minecraft:sheep/color` component, a slime drops slime balls only at the
smallest size, and a mob that died burning drops its meat cooked. A table
rolled without them takes the other branch rather than failing, so the
mobs whose drops depend on one have to supply it.

## Functions

### damageTagsOf()

> **damageTagsOf**(`content`, `type`): readonly `string`[]

Defined in: [packages/prismarine/src/entity/mobLoot.ts:273](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L273)

The tags one damage type carries, read off the stack's own
`tags/damage_type/` files rather than listed here. A turtle struck by
lightning and a ghast killed by its own fireball both turn on one.

#### Parameters

##### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

##### type

`string`

#### Returns

readonly `string`[]

***

### lootDamageSource()

> **lootDamageSource**(`content`, `source`): [`DamageSource`](https://jsprismarine.dev/api/@jsprismarine/predicates/index.md#damagesource) \| `undefined`

Defined in: [packages/prismarine/src/entity/mobLoot.ts:314](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L314)

The kill as the damage-source predicates read it.

#### Parameters

##### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

The content build, for its `damage_type` tags.

##### source

[`LootKill`](#lootkill) \| `null` \| `undefined`

What killed the mob, or null when nothing is on record.

#### Returns

[`DamageSource`](https://jsprismarine.dev/api/@jsprismarine/predicates/index.md#damagesource) \| `undefined`

The source, or undefined for a death with no record, which rolls
  against UNRECORDED.

***

### mobLootTableOf()

> **mobLootTableOf**(`content`, `identifier`): `string` \| `undefined`

Defined in: [packages/prismarine/src/entity/mobLoot.ts:83](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L83)

The Java loot table a Bedrock mob dies through.

#### Parameters

##### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

##### identifier

`string`

#### Returns

`string` \| `undefined`

The table id, or undefined for a mob the stack registered no
  table for, which is a Bedrock-only entity or a stack with no Java half.

***

### rollMobDrops()

> **rollMobDrops**(`content`, `identifier`, `context?`): readonly [`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop)[]

Defined in: [packages/prismarine/src/entity/mobLoot.ts:137](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/mobLoot.ts#L137)

Rolls what one mob leaves behind.

#### Parameters

##### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

##### identifier

`string`

The Bedrock entity identifier, as `Entity.getType` reports it.

##### context?

[`MobDropContext`](#mobdropcontext) = `{}`

#### Returns

readonly [`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop)[]

The stacks that fell, empty for a mob with no table - which is
  also the right answer for the wolves, cats and villagers Java gives an
  empty one.
