Home Commands Examples Getting Started With Scripts Global Keywords
BracketDumpers BracketHandlers BracketValidators ResourceLocationBracketHandler

Inventory

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.

script.zs
import crafttweaker.api.entity.type.player.Inventory;

Implemented Interfaces

Inventory implements the following interfaces. That means all methods defined in these interfaces are also available in Inventory

Methods

Return Type: boolean

script.zs
Inventory.add(stack as ItemStack) as boolean
ParameterType
Parameter
stack
Type
ItemStack

Return Type: boolean

script.zs
Inventory.add(index as int, stack as ItemStack) as boolean
ParameterType
Parameter
index
Type
int
Parameter
stack
Type
ItemStack

Return Type: boolean

script.zs
Inventory.contains(stack as ItemStack) as boolean
ParameterType
Parameter
stack
Type
ItemStack

Return Type: boolean

script.zs
Inventory.contains(tag as KnownTag<ItemDefinition>) as boolean
ParameterType
Parameter
tag
Type
KnownTag<ItemDefinition>
script.zs
// Inventory.dropAll()
myInventory.dropAll();

Return Type: int

script.zs
Inventory.findSlotMatchingItem(stack as ItemStack) as int
ParameterType
Parameter
stack
Type
ItemStack

Return Type: int

script.zs
Inventory.findSlotMatchingUnusedItem(stack as ItemStack) as int
ParameterType
Parameter
stack
Type
ItemStack

Return Type: ItemStack

script.zs
Inventory.getArmor(armorIndex as int) as ItemStack
ParameterType
Parameter
armorIndex
Type
int

Return Type: int

script.zs
// Inventory.getFreeSlot() as int
myInventory.getFreeSlot();

Return Type: ItemStack

script.zs
// Inventory.getSelected() as ItemStack
myInventory.getSelected();

Return Type: int

script.zs
Inventory.getSlotWithRemainingSpace(stack as ItemStack) as int
ParameterType
Parameter
stack
Type
ItemStack

Return Type: int

script.zs
// Inventory.getSuitableHotbarSlot() as int
myInventory.getSuitableHotbarSlot();

Return Type: int

script.zs
// Inventory.getTimesChanged() as int
myInventory.getTimesChanged();
script.zs
Inventory.hurtArmor(source as DamageSource, damage as float, armorSlots as int[])
ParameterType
Parameter
source
Type
DamageSource
Parameter
damage
Type
float
Parameter
armorSlots
Type
int[]
script.zs
Inventory.pickSlot(index as int)
ParameterType
Parameter
index
Type
int
script.zs
Inventory.removeItem(stack as ItemStack)
ParameterType
Parameter
stack
Type
ItemStack
script.zs
Inventory.setPickedItem(stack as ItemStack)
ParameterType
Parameter
stack
Type
ItemStack

Properties

NameTypeHas GetterHas Setter
Name
freeSlot
Type
int
Has Getter
true
Has Setter
false
Name
selected
Type
ItemStack
Has Getter
true
Has Setter
false
Name
suitableHotbarSlot
Type
int
Has Getter
true
Has Setter
false
Name
timesChanged
Type
int
Has Getter
true
Has Setter
false