API reference / @jsprismarine/prismarine / inventory/EntityInventory
inventory/EntityInventory
Classes
Interfaces
EntityInventoryObserver
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:49
Hears every write to what an entity carries, which is how it reaches the change log.
Methods
handSlot()
handSlot(
before,after):void
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:53
The hand moved from one hotbar slot to another.
Parameters
before
number
after
number
Returns
void
slot()
slot(
container,slot,before,after):void
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:51
One slot of one container changed, from before to after.
Parameters
container
slot
number
before
after
Returns
void
InventoryLayout
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:38
Which containers an entity has, and how big each one is.
Type Parameters
C
C extends InventoryContainer
Properties
containers
readonlycontainers: readonly (readonly [C,number])[]
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:40
Each container's name and number of slots.
hotbar?
readonlyoptionalhotbar?:number
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:45
How many of the first inventory slots the hand can point at, which is a player's hotbar. Without it the main hand is the mainhand container's one slot.
SlotAddress
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:32
One slot of one container of an EntityInventory.
Properties
container
readonlycontainer:InventoryContainer
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:33
slot
readonlyslot:number
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:34
Type Aliases
InventoryContainer
InventoryContainer =
Exclude<EntityContainer,"crafting">
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:29
The containers an EntityInventory holds: every entity container but the crafting grid.
MobInventoryContainer
MobInventoryContainer =
ReturnType<typeofmobLayout>["containers"][number][0]
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:104
The containers a mob layout has.
PlayerInventoryContainer
PlayerInventoryContainer = typeof
PLAYER_LAYOUT["containers"][number][0]
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:85
The containers a player layout has.
Variables
ARMOR_SLOTS
constARMOR_SLOTS:4=4
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:23
Helmet, chestplate, leggings, boots: the armor container's slots, in the order the client numbers them.
HOTBAR_SIZE
constHOTBAR_SIZE:9=9
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:26
Slots the hotbar reaches, and so the range a player's hand slot may name.
PLAYER_LAYOUT
constPLAYER_LAYOUT:object
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:73
The containers a player carries, besides the crafting grid.
inventoryis the 36 main slots, hotbar first. The hand slot names one of the first nine.armoris a container of its own rather than four more main slots, because the client addresses it as one (ContainerUiId.ARMOR_CONTAINER) and because everything that walks the inventory looking for space would otherwise offer to put a pickaxe on your head.offhandis one slot, for a shield or a torch.ender_chestis on the player and not on a block for the reason vanilla puts it there: everyminecraft:ender_chestin every dimension shows the same 27 slots to one player.cursoris the stack held by the pointer between picking it up and putting it down. A drag is two requests, one that moves a stack onto the pointer and a later one that moves it off, so the stack needs somewhere to be in between.
Type Declaration
containers
readonlycontainers: readonly [readonly ["inventory",36], readonly ["armor",4], readonly ["offhand",1], readonly ["ender_chest",27], readonly ["cursor",1]]
hotbar
readonlyhotbar:9=HOTBAR_SIZE
Functions
mobEquipmentAddress()
mobEquipmentAddress(
slot):SlotAddress
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:110
The container slot an equipment slot reads in a layout with no hotbar, before any alias: a mob's own mainhand, offhand and body slot, or its armor slot.
Parameters
slot
"head" | "chest" | "feet" | "mainhand" | "offhand" | "body" | "legs"
Returns
mobLayout()
mobLayout(
inventorySize):object
Defined in: packages/prismarine/src/inventory/EntityInventory.ts:92
A mob's layout: one slot each for the main hand, the off hand and the body, four armor slots and an inventory of the size its minecraft:inventory component gives.
Parameters
inventorySize
number
The inventory container's number of slots, 0 for a mob with none.
Returns
object
containers
readonlycontainers: readonly [readonly ["mainhand",1], readonly ["offhand",1], readonly ["armor",4], readonly ["body",1], readonly ["inventory",number]]