IItemHandler

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.neoforge.api.capability.IItemHandler;

Operators

[](slot as int) as IItemStack
Gets the stack in the given slot.
script.zs
// IItemHandler[slot as int] as IItemStack
myIItemHandler[myInt]

Parameters:

slot Type: int - The slot to get the stack of.

Return Type: IItemStack

Members

extractItem(slot as int, amount as int, simulate as bool) as IItemStack
Extract from the given slot.

Returns: The stack extracted from the slot.

script.zs
// IItemHandler.extractItem(slot as int, amount as int, simulate as bool) as IItemStack;
myIItemHandler.extractItem(0, 5, false);

Parameters:

slot Type: int - The slot to extract from.
amount Type: int - How much to extract from the slot.
simulate Type: bool - If the extraction should actually happen, if true, no changes will be made.

Return Type: IItemStack

getSlotLimit(slot as int) as int
Gets how much of a stack can fit into the given slot.

Returns: The max stack size of the given stack.

script.zs
// IItemHandler.getSlotLimit(slot as int) as int;
myIItemHandler.getSlotLimit(1);

Parameters:

slot Type: int - The slot to check.

Return Type: int

getStackInSlot(slot as int) as IItemStack
Gets the stack in the given slot.

Returns: The stack in the slot.

script.zs
// IItemHandler.getStackInSlot(slot as int) as IItemStack;
myIItemHandler.getStackInSlot(1);

Parameters:

slot Type: int - The slot to get the stack of.

Return Type: IItemStack

insertItem(slot as int, stack as IItemStack, simulate as bool) as IItemStack
Inserts the stack into the given slot and returns the remainder.


The remainder returned is how much was not inserted.



For example if slot 0 had 63 dirt, and you tried to insert 5 dirt, you will get a remainder of 4 dirt.

Returns: The remaining stack that was not inserted.

script.zs
// IItemHandler.insertItem(slot as int, stack as IItemStack, simulate as bool) as IItemStack;
myIItemHandler.insertItem(1, <item:minecraft:dirt>, true);

Parameters:

slot Type: int - The slot to insert into.
stack Type: IItemStack - The stack to insert.
simulate Type: bool - If the insert should actually happen, if true, will be made.

Return Type: IItemStack

isItemValid(slot as int, stack as IItemStack) as bool
Checks if the given stack is valid for the given slot.

Returns: true if the stack is valid, false otherwise.

script.zs
// IItemHandler.isItemValid(slot as int, stack as IItemStack) as bool;
myIItemHandler.isItemValid(myInt, myIItemStack);

Parameters:

slot Type: int - The slot to check.
stack Type: IItemStack - The stack to check.

Return Type: bool

Getter
Gets the amount of slots in the handler.
script.zs
// IItemHandler.slots as int
myIItemHandler.slots

Return Type: int