API reference / @jsprismarine/prismarine / entity/equipment
entity/equipment
Interfaces
MobEquipmentRollOptions
Defined in: packages/prismarine/src/entity/equipment.ts:147
What rollMobEquipment reads.
Properties
content
readonlycontent:ServerContent
Defined in: packages/prismarine/src/entity/equipment.ts:149
The running content: the tables to roll and the items to resolve against.
itemOf
readonlyitemOf: (drop) =>Item|null
Defined in: packages/prismarine/src/entity/equipment.ts:153
Resolves one rolled drop to an item, so this module does not reach into the inventory.
Parameters
drop
Returns
Item | null
report?
readonlyoptionalreport?: (message) =>void
Defined in: packages/prismarine/src/entity/equipment.ts:155
Where a drop that resolves to no item is reported.
Parameters
message
string
Returns
void
table
readonlytable:string
Defined in: packages/prismarine/src/entity/equipment.ts:151
The minecraft:equipment.table the entity's active components name.
Type Aliases
MobEquipmentSet
MobEquipmentSet =
Readonly<Partial<Record<MobEquipmentSlot,ContentItemDrop>>>
Defined in: packages/prismarine/src/entity/equipment.ts:79
What a mob has in each slot, with a slot it has nothing in left out.
MobEquipmentSlot
MobEquipmentSlot = typeof
MOB_EQUIPMENT_SLOTS[number]
Defined in: packages/prismarine/src/entity/equipment.ts:76
One of MOB_EQUIPMENT_SLOTS.
Variables
BEDROCK_EQUIPMENT_SLOT_NAMES
constBEDROCK_EQUIPMENT_SLOT_NAMES:object
Defined in: packages/prismarine/src/entity/equipment.ts:86
Bedrock's fully qualified name for each equipment slot, which components such as minecraft:on_equipment_changed and minecraft:burns_in_daylight use, and which /replaceitem names the slot's group by.
Type Declaration
body
readonlybody:"slot.armor.body"='slot.armor.body'
chest
readonlychest:"slot.armor.chest"='slot.armor.chest'
feet
readonlyfeet:"slot.armor.feet"='slot.armor.feet'
head
readonlyhead:"slot.armor.head"='slot.armor.head'
legs
readonlylegs:"slot.armor.legs"='slot.armor.legs'
mainhand
readonlymainhand:"slot.weapon.mainhand"='slot.weapon.mainhand'
offhand
readonlyoffhand:"slot.weapon.offhand"='slot.weapon.offhand'
MOB_EQUIPMENT_SLOTS
constMOB_EQUIPMENT_SLOTS: readonly ["mainhand","offhand","head","chest","legs","feet","body"]
Defined in: packages/prismarine/src/entity/equipment.ts:65
The slots a mob's equipment reaches a client in.
The keys of ViewableEquipment, which is the record the rest of the server already passes around as "items by slot", so the enchantment views and this agree by construction rather than by being kept in step. satisfies is the tie: a slot added or renamed there fails to compile here until this tuple lists it.
body is the fifth positional slot in MobArmorEquipmentPacket; entity interactions can equip horse armor, llama carpet and wolf armor there.
Functions
mobEquipmentSlotOf()
mobEquipmentSlotOf(
name):"head"|"chest"|"feet"|"mainhand"|"offhand"|"body"|"legs"|undefined
Defined in: packages/prismarine/src/entity/equipment.ts:112
The slot a minecraft:equipment.slot_drop_chance entry names.
A behavior pack spells these slot.weapon.mainhand and slot.armor.head, while an item component uses the bare slot name. Both forms resolve through the same slot list.
Parameters
name
string
The slot as the component spells it.
Returns
"head" | "chest" | "feet" | "mainhand" | "offhand" | "body" | "legs" | undefined
The slot, or undefined for an unsupported name such as slot.armor.saddle.
rollMobEquipment()
rollMobEquipment(
options):MobEquipmentSet
Defined in: packages/prismarine/src/entity/equipment.ts:168
Rolls one equipment table and sorts what it produced into slots.
A later entry wins a slot an earlier one filled, which is the order the pools are written in. A rolled item goes where slotForItem puts it, and a nautilus shell to the off hand.
Parameters
options
Returns
What the mob holds and wears. Empty when the registry has no such table, and empty for a roll whose every pool failed its chance gate, which is what a zombie spawning bare is.
sameDrop()
sameDrop(
left,right):boolean
Defined in: packages/prismarine/src/entity/equipment.ts:217
Whether two drops are the same item in the same condition, counts included.
Parameters
left
ItemDrop | undefined
right
ItemDrop | undefined
Returns
boolean
sameEquipmentItems()
sameEquipmentItems(
left,right):boolean
Defined in: packages/prismarine/src/entity/equipment.ts:213
Whether two sets of resolved items would reach a client as the same bytes.
Compared as what the packets carry rather than field by field, which is the same test blockentity/blockEntityWrite.ts applies to a block entity compound and for the same reason: two items that encode identically are the same item to a client however they were built, and an item rebuilt from a saved drop has been through a round trip the one it is compared against has not.
Parameters
left
right
Returns
boolean
slotForItem()
slotForItem(
item):"head"|"chest"|"feet"|"mainhand"|"offhand"|"body"|"legs"
Defined in: packages/prismarine/src/entity/equipment.ts:137
Where one rolled item goes.
minecraft:equippable is the game's own answer and the only one that stays right as the item set changes; a table of identifiers here would go stale the first time a pack added a helmet. An item without the component is a weapon rather than nothing, so a bow, a crossbow and the fox's emerald all reach the main hand.
Parameters
item
Pick<Item, "getEquipmentSlot">
The rolled item, resolved against the running content. Only its declared slot is read, which is the whole of what this needs an item for.
Returns
"head" | "chest" | "feet" | "mainhand" | "offhand" | "body" | "legs"
The slot it occupies.
wornArmorOf()
wornArmorOf(
equipment):object
Defined in: packages/prismarine/src/entity/equipment.ts:268
The armor points and toughness a set of worn items gives, summed over the five armor slots.
Parameters
equipment
Returns
object
defensePoints
readonlydefensePoints:number
toughness
readonlytoughness:number