Jump to content

Item Interface: Difference between revisions

From Advanced Computers Wiki
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
== Provided component ==
== Provided component ==
This block provides the <code>itemInterface</code> component, offering methods shown below. For information on the side argument, see [[API:Sides]].
This block provides the <code>itemInterface</code> component, offering methods shown below. For information on the side argument, see [[API:Sides]].
{| class="wikitable"
|+ItemInterfaceUD component properties
!Name
!Type
!Read/Write
!Description
|-
|<code>uniqueId</code>
|<code>integer</code>
|READ
|A unique numeric ID tied to this peripheral device, generated on block placement and persistent across restarts.
|}
{| class="wikitable"
{| class="wikitable"
|+ ItemInterfaceUD component methods
|+ ItemInterfaceUD component methods
Line 15: Line 29:
| style="white-space: nowrap;" | <code>:getNeighborSlotCount(side:integer)</code>|| <code>integer</code>|| Returns the number of slots of the given inventory.
| style="white-space: nowrap;" | <code>:getNeighborSlotCount(side:integer)</code>|| <code>integer</code>|| Returns the number of slots of the given inventory.
|-
|-
|<code>moveItemStackFromTo(sideSource:integer, slotSource:integer, sideDest:integer, slotDest:integer[, maxAmount:integer])</code>
|<code>:moveItemStackFromTo(sideSource:integer, slotSource:integer, sideDest:integer, slotDest:integer[, maxAmount:integer])</code>
|<code>integer</code>
|<code>integer</code>
|Moves the maximum amount of items from the given ''source side'' and ''source slot'' to the given ''destination side'' and ''destination slot''. If <code>maxAmount</code> is omitted, it defaults to <math display="inline">2^{31}-1</math>.
|Moves the maximum amount of items from the given ''source side'' and ''source slot'' to the given ''destination side'' and ''destination slot''. If <code>maxAmount</code> is omitted, it defaults to <math display="inline">2^{31}-1</math>.
|-
|-
|<code>getStackInSlot(side:integer, slot:integer)</code>
|<code>:getStackInSlot(side:integer, slot:integer)</code>
|<code>table</code>
|<code>table</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>.
|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>.

Latest revision as of 02:10, 7 September 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 properties
Name Type Read/Write Description
uniqueId integer READ A unique numeric ID tied to this peripheral device, generated on block placement and persistent across restarts.
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.