IItemHandler
Link to iitemhandler
Importing the class
Link to importing-the-class
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 Copyimport crafttweaker.neoforge.api.capability.IItemHandler;
Methods
Link to methods
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);
Parameter | Type | Description |
---|---|---|
Parameter slot | Type int | Description The slot to extract from. |
Parameter amount | Type int | Description How much to extract from the slot. |
Parameter simulate | Type boolean | Description 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);
Parameter | Type | Description |
---|---|---|
Parameter slot | Type int | Description The slot to check. |
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);
Parameter | Type | Description |
---|---|---|
Parameter slot | Type int | Description 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);
Parameter | Type | Description |
---|---|---|
Parameter slot | Type int | Description The slot to insert into. |
Parameter stack | Type IItemStack | Description The stack to insert. |
Parameter simulate | Type boolean | Description 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 CopyIItemHandler.isItemValid(slot as int, stack as IItemStack) as boolean
Parameter | Type | Description |
---|---|---|
Parameter slot | Type int | Description The slot to check. |
Parameter stack | Type IItemStack | Description The stack to check. |
Properties
Link to properties
Name | Type | Has Getter | Has Setter | Description |
---|---|---|---|---|
Name slots | Type int | Has Getter true | Has Setter false | Description Gets the amount of slots in the handler. |