Jump to content

Item Interface: Difference between revisions

From Advanced Computers Wiki
No edit summary
No edit summary
Line 23: Line 23:
|Returns information about the itemstack in the slot of the inventory at the given side. This will be a table with the following entries: <code>name</code>, <code>stackSize</code>, <code>maxStackSize</code>, <code>damage</code>, <code>maxDamage</code>, <code>hasNbt</code>, <code>isEdible</code>.
|Returns information about the itemstack in the slot of the inventory at the given side. This will be a table with the following entries: <code>name</code>, <code>stackSize</code>, <code>maxStackSize</code>, <code>damage</code>, <code>maxDamage</code>, <code>hasNbt</code>, <code>isEdible</code>.
|}
|}




{{Navbox content}}
{{Navbox content}}

Revision as of 18:08, 1 August 2026

Item interface block
Item interface block

The Item Interface allows interacting with in-world inventories and moving items between inventories of blocks that are adjacent to the item interface. A basic example would be reading inventory contents, or making a sorting system that automatically voids certain items by dropping them into lava.

Example setup utilizing the item interface to transfer items between two chests and a dropper.
Example setup utilizing the item interface to transfer items between two chests and a dropper.

Provided component

This block provides the itemInterface component, offering methods shown below. For information on the side argument, see API:Sides.

ItemInterfaceUD component methods
Name Type Description
:getNeighborBlockName(side:integer) String Returns the name of the block that is connected on that side, e.g. minecraft:chest or minecraft:air.
:getNeighborSlotCount(side:integer) integer Returns the number of slots of the given inventory.
moveItemStackFromTo(sideSource:integer, slotSource:integer, sideDest:integer, slotDest:integer[, maxAmount:integer]) integer Moves the maximum amount of items from the given source side and source slot to the given destination side and destination slot. If maxAmount is omitted, it defaults to 2311.
getStackInSlot(side:integer, slot:integer) table Returns information about the itemstack in the slot of the inventory at the given side. This will be a table with the following entries: name, stackSize, maxStackSize, damage, maxDamage, hasNbt, isEdible.