Container
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.
import crafttweaker.api.world.Container;
Implemented Interfaces
Container implements the following interfaces. That means all methods defined in these interfaces are also available in Container
Methods
Return Type: boolean
Container.canPlaceItem(index as int, stack as ItemStack) as boolean
Parameter | Type |
---|---|
Parameter index | Type int |
Parameter stack | Type ItemStack |
Return Type: int
Container.countItem(item as ItemDefinition) as int
Parameter | Type |
---|---|
Parameter item | Type ItemDefinition |
Return Type: int
Container.countStack(item as IItemStack) as int
Parameter | Type |
---|---|
Parameter item | Type IItemStack |
Gets the size (how many slots) of this Container
Returns: The amount of slots this Container has.
Return Type: int
// Container.getContainerSize() as int
myContainer.getContainerSize();
Gets the ItemStack in the given slot.
Returns: the ItemStack in the given slot.
Return Type: ItemStack
Container.getItem(index as int) as ItemStack
Parameter | Type | Description |
---|---|---|
Parameter index | Type int | Description The slot index to get. |
Return Type: int
// Container.getMaxStackSize() as int
myContainer.getMaxStackSize();
Return Type: boolean
Container.hasAnyOf(items as Set<ItemDefinition>) as boolean
Parameter | Type |
---|---|
Parameter items | Type Set<ItemDefinition> |
Checks if this Container is empty.
Returns: True if empty. False otherwise.
Return Type: boolean
// Container.isEmpty() as boolean
myContainer.isEmpty();
Return Type: ItemStack
Container.removeItem(var1 as int, var2 as int) as ItemStack
Parameter | Type |
---|---|
Parameter var1 | Type int |
Parameter var2 | Type int |
Return Type: ItemStack
Container.removeItemNoUpdate(index as int) as ItemStack
Parameter | Type |
---|---|
Parameter index | Type int |
// Container.setChanged()
myContainer.setChanged();
Container.setItem(index as int, stack as ItemStack)
Parameter | Type |
---|---|
Parameter index | Type int |
Parameter stack | Type ItemStack |
Container.startOpen(player as Player)
Parameter | Type |
---|---|
Parameter player | Type Player |
Return Type: boolean
Container.stillValid(player as Player) as boolean
Parameter | Type |
---|---|
Parameter player | Type Player |
Container.stopOpen(player as Player)
Parameter | Type |
---|---|
Parameter player | Type Player |
Properties
Name | Type | Has Getter | Has Setter | Description |
---|---|---|---|---|
Name changed | Type void | Has Getter true | Has Setter false | Description |
Name containerSize | Type int | Has Getter true | Has Setter false | Description Gets the size (how many slots) of this Container |
Name isEmpty | Type boolean | Has Getter true | Has Setter false | Description Checks if this Container is empty. |
Name maxStackSize | Type int | Has Getter true | Has Setter false | Description |