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

Inventory

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.api.entity.type.player.Inventory;

Implements

Inventory implements the following interfaces:

Container,Nameable,Clearable

Operators

in(stack as ItemStack) as bool
script.zs
// ((stack as ItemStack) in Inventory) as bool
myItemStack in myInventory

Parameters:

stack Type: ItemStack

Return Type: bool

in(tag as KnownTag<Item>) as bool
script.zs
// ((tag as KnownTag<ItemDefinition>) in Inventory) as bool
myKnownTag<Item> in myInventory

Parameters:

Return Type: bool

Members

add(stack as ItemStack) as bool
script.zs
// Inventory.add(stack as ItemStack) as bool;
myInventory.add(myItemStack);

Parameters:

stack Type: ItemStack

Return Type: bool

add(index as int, stack as ItemStack) as bool
script.zs
// Inventory.add(index as int, stack as ItemStack) as bool;
myInventory.add(myInt, myItemStack);

Parameters:

index Type: int
stack Type: ItemStack

Return Type: bool

canPlaceItem(index as int, stack as ItemStack) as bool
script.zs
// Inventory.canPlaceItem(index as int, stack as ItemStack) as bool;
myInventory.canPlaceItem(myInt, myItemStack);

Parameters:

index Type: int
stack Type: ItemStack

Return Type: bool

Getter
script.zs
// Inventory.changed
myInventory.changed
changed()
script.zs
// Inventory.changed();
myInventory.changed();
clearContent()
Clears the contents of this Clearable.
script.zs
// Inventory.clearContent();
myInventory.clearContent();
Getter
Gets the size (how many slots) of this Container
script.zs
// Inventory.containerSize as int
myInventory.containerSize

Return Type: int

containerSize() as int
Gets the size (how many slots) of this Container

Returns: The amount of slots this Container has.

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

Return Type: int

contains(stack as ItemStack) as bool
script.zs
// Inventory.contains(stack as ItemStack) as bool;
myInventory.contains(myItemStack);

Parameters:

stack Type: ItemStack

Return Type: bool

contains(tag as KnownTag<Item>) as bool
script.zs
// Inventory.contains(tag as KnownTag<ItemDefinition>) as bool;
myInventory.contains(myKnownTag);

Parameters:

Return Type: bool

countItem(item as Item) as int
script.zs
// Inventory.countItem(item as ItemDefinition) as int;
myInventory.countItem(myItem);

Parameters:

Return Type: int

countStack(item as IItemStack) as int
script.zs
// Inventory.countStack(item as IItemStack) as int;
myInventory.countStack(myIItemStack);

Parameters:

item Type: IItemStack

Return Type: int

Getter
script.zs
// Inventory.customName as Component
myInventory.customName

Return Type: Component

customName() as Component
script.zs
// Inventory.customName() as Component;
myInventory.customName();

Return Type: Component

Getter
script.zs
// Inventory.displayName as Component
myInventory.displayName

Return Type: Component

displayName() as Component
script.zs
// Inventory.displayName() as Component;
myInventory.displayName();

Return Type: Component

dropAll()
script.zs
// Inventory.dropAll();
myInventory.dropAll();
findSlotMatchingItem(stack as ItemStack) as int
script.zs
// Inventory.findSlotMatchingItem(stack as ItemStack) as int;
myInventory.findSlotMatchingItem(myItemStack);

Parameters:

stack Type: ItemStack

Return Type: int

findSlotMatchingUnusedItem(stack as ItemStack) as int
script.zs
// Inventory.findSlotMatchingUnusedItem(stack as ItemStack) as int;
myInventory.findSlotMatchingUnusedItem(myItemStack);

Parameters:

stack Type: ItemStack

Return Type: int

Getter
script.zs
// Inventory.freeSlot as int
myInventory.freeSlot

Return Type: int

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

Return Type: int

getArmor(armorIndex as int) as ItemStack
script.zs
// Inventory.getArmor(armorIndex as int) as ItemStack;
myInventory.getArmor(myInt);

Parameters:

armorIndex Type: int

Return Type: ItemStack

getItem(index as int) as ItemStack
Gets the ItemStack in the given slot.

Returns: the ItemStack in the given slot.

script.zs
// Inventory.getItem(index as int) as ItemStack;
myInventory.getItem(myInt);

Parameters:

index Type: int - The slot index to get.

Return Type: ItemStack

getSlotWithRemainingSpace(stack as ItemStack) as int
script.zs
// Inventory.getSlotWithRemainingSpace(stack as ItemStack) as int;
myInventory.getSlotWithRemainingSpace(myItemStack);

Parameters:

stack Type: ItemStack

Return Type: int

hasAnyOf(items as Set<Item>) as bool
script.zs
// Inventory.hasAnyOf(items as Set<ItemDefinition>) as bool;
myInventory.hasAnyOf(mySet);

Parameters:

items Type: Set<ItemDefinition>

Return Type: bool

Getter
script.zs
// Inventory.hasCustomName as bool
myInventory.hasCustomName

Return Type: bool

hasCustomName() as bool
script.zs
// Inventory.hasCustomName() as bool;
myInventory.hasCustomName();

Return Type: bool

hurtArmor(source as DamageSource, damage as float, armorSlots as int[])
script.zs
// Inventory.hurtArmor(source as DamageSource, damage as float, armorSlots as int[]);
myInventory.hurtArmor(myDamageSource, myFloat, myInt[]);

Parameters:

source Type: DamageSource
damage Type: float
armorSlots Type: int[]
Getter
Checks if this Container is empty.
script.zs
// Inventory.isEmpty as bool
myInventory.isEmpty

Return Type: bool

isEmpty() as bool
Checks if this Container is empty.

Returns: True if empty. False otherwise.

script.zs
// Inventory.isEmpty() as bool;
myInventory.isEmpty();

Return Type: bool

Getter
script.zs
// Inventory.maxStackSize as int
myInventory.maxStackSize

Return Type: int

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

Return Type: int

Getter
script.zs
// Inventory.name as Component
myInventory.name

Return Type: Component

name() as Component
script.zs
// Inventory.name() as Component;
myInventory.name();

Return Type: Component

pickSlot(index as int)
script.zs
// Inventory.pickSlot(index as int);
myInventory.pickSlot(myInt);

Parameters:

index Type: int
removeItem(stack as ItemStack)
script.zs
// Inventory.removeItem(stack as ItemStack);
myInventory.removeItem(myItemStack);

Parameters:

stack Type: ItemStack
removeItem(var1 as int, var2 as int) as ItemStack
script.zs
// Inventory.removeItem(var1 as int, var2 as int) as ItemStack;
myInventory.removeItem(myInt, myInt);

Parameters:

var1 Type: int
var2 Type: int

Return Type: ItemStack

removeItemNoUpdate(index as int) as ItemStack
script.zs
// Inventory.removeItemNoUpdate(index as int) as ItemStack;
myInventory.removeItemNoUpdate(myInt);

Parameters:

index Type: int

Return Type: ItemStack

Getter
script.zs
// Inventory.selected as ItemStack
myInventory.selected

Return Type: ItemStack

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

Return Type: ItemStack

setItem(index as int, stack as ItemStack)
script.zs
// Inventory.setItem(index as int, stack as ItemStack);
myInventory.setItem(myInt, myItemStack);

Parameters:

index Type: int
stack Type: ItemStack
setPickedItem(stack as ItemStack)
script.zs
// Inventory.setPickedItem(stack as ItemStack);
myInventory.setPickedItem(myItemStack);

Parameters:

stack Type: ItemStack
startOpen(player as Player)
script.zs
// Inventory.startOpen(player as Player);
myInventory.startOpen(myPlayer);

Parameters:

player Type: Player
stillValid(player as Player) as bool
script.zs
// Inventory.stillValid(player as Player) as bool;
myInventory.stillValid(myPlayer);

Parameters:

player Type: Player

Return Type: bool

stopOpen(player as Player)
script.zs
// Inventory.stopOpen(player as Player);
myInventory.stopOpen(myPlayer);

Parameters:

player Type: Player
Getter
script.zs
// Inventory.suitableHotbarSlot as int
myInventory.suitableHotbarSlot

Return Type: int

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

Return Type: int

Getter
script.zs
// Inventory.timesChanged as int
myInventory.timesChanged

Return Type: int

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

Return Type: int