It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.capability.IItemHandler;

Name: extractItem

Extract from the given slot.

Returns: The stack extracted from the slot.
Return Type: IItemStack

ZenScript
Copy
// IItemHandler.extractItem(slot as int, amount as int, simulate as boolean) as IItemStack

myIItemHandler.extractItem(0, 5, false);
参数类型描述
参数
slot
类型
int
描述
The slot to extract from.
参数
amount
类型
int
描述
How much to extract from the slot.
参数
simulate
类型
布尔值
描述
If the extraction should actually happen, if true, no changes will be made.

Name: getSlotLimit

Gets how much of a stack can fit into the given slot.

Returns: The max stack size of the given stack.
Return Type: int

ZenScript
Copy
// IItemHandler.getSlotLimit(slot as int) as int

myIItemHandler.getSlotLimit(1);
参数类型描述
参数
slot
类型
int
描述
The slot to check.

Name: getSlots

Gets the amount of slots in the handler.

Returns: The amount of slots in the handler.
Return Type: int

ZenScript
Copy
// IItemHandler.getSlots() as int

myIItemHandler.getSlots();

Name: getStackInSlot

Gets the stack in the given slot.

Returns: The stack in the slot.
Return Type: IItemStack

ZenScript
Copy
// IItemHandler.getStackInSlot(slot as int) as IItemStack

myIItemHandler.getStackInSlot(1);
参数类型描述
参数
slot
类型
int
描述
The slot to get the stack of.

Name: insertItem

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.
Return Type: IItemStack

ZenScript
Copy
// IItemHandler.insertItem(slot as int, stack as IItemStack, simulate as boolean) as IItemStack

myIItemHandler.insertItem(1, <item:minecraft:dirt>, true);
参数类型描述
参数
slot
类型
int
描述
The slot to insert into.
参数
堆叠
类型
IItemstack
描述
The stack to insert.
参数
simulate
类型
布尔值
描述
If the insert should actually happen, if true, will be made.

Name: isItemValid

Checks if the given stack is valid for the given slot.

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

ZenScript
Copy
IItemHandler.isItemValid(slot as int, stack as IItemStack) as boolean
参数类型描述
参数
slot
类型
int
描述
The slot to check.
参数
堆叠
类型
IItemstack
描述
The stack to check.
名称类型可获得可设置描述
名称
slots
类型
int
可获得
true
可设置
false
描述
Gets the amount of slots in the handler.