Home Getting Started With Scripts Using this wiki Commands CTGUI Global functions Bracket Handlers

IItemDefinition

An IItemDefinition object is the direct reference to an item.
It is different from an IItemStack as this only refers to the item, it does not include any meta-information or NBT-values!

Importing the package

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.
import crafttweaker.item.IItemDefinition;

How to get one

The easiest way is from an IItemStack, but you can also get a list of all registered IItemDefinitions in the game and do something with that.

script.zs
//IItemStack Zengetter "definition" -> single IItemDefinition
val itemDefinition = <minecraft:stone>.definition;
//IGame zengetter "items" -> LIST!
val itemDefinitionList = game.items;

What to do with it

ZenGetters and parameterless ZenMethods

ZenGetterWhat does it doReturn Type
ZenGetter
id
What does it do
Returns the item ID
Return Type
string
ZenGetter
name
What does it do
Returns the unlocalized item Name
Return Type
string
ZenGetter
ores
What does it do
Returns all ore entries containing this item. Can also contain ore entries that refer to a sub-item.
Return Type
List<IOreDictEntry>
ZenGetter
owner
What does it do
Returns the mod name that this item belongs to.
Return Type
string
ZenGetter
defaultInstance
What does it do
Return Type
IItemStack
ZenGetter
creativeTab
What does it do
Return Type
ICreativeTab
ZenGetter
creativeTabs
What does it do
Return Type
ICreativeTab[]
ZenGetter
canItemEditBlocks
What does it do
Return Type
bool
ZenGetter
itemEnchantability
What does it do
Return Type
int
ZenGetter
subItems
What does it do
Returns a list of all subitems that are registered to this item. (like how potions have other items). This is not guaranteed to return the correct list for mods on a server.
Return Type
List<IItemStack>

ZenSetters and other void-Methods

ZenSetter/ZenMethodParameter Type
ZenSetter/ZenMethod
creativeTab
Parameter Type
ICreativeTab
ZenSetter/ZenMethod
setNoRepair()
Parameter Type
none
ZenSetter/ZenMethod
setContainerItem(IItemDefinition item)
Parameter Type
IItemDefinition

ZenMethods

  • def.makeStack(meta); Creates an IItemStack with the given metadata. Metadata is an int and OPTIONAL.
  • def.setHarvestLevel(String type, int level); Changes the item’s harvest level to the corresponding type and level
  • def.getSubItems(creativeTab); Returns a List<IItemStack> with all subitems for the given ICreativeTab. This is not guaranteed to return the correct list for mods on a server.
  • def.getItemBurntime(item); Returns an int representing either -1 (Vanilla logic will apply), 0 (Not smeltable) or the items burntime