IItemStack
This represents an item. It can be retrieved using an Item BEP. Is an crafttweaker.api.item.IIngredient
This class was added by a mod with mod-id crafttweaker
. So you need to have this mod installed if you want to use this feature.
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.
crafttweaker.api.item.IItemStack
Implemented Interfaces
IItemStack implements the following interfaces. That means any method available to them can also be used on this class.
Methods
clearCustomName
Clears any custom name set for this ItemStack
<item:minecraft:dirt>.clearCustomName();
getRemainingItem
When this ingredient stack is crafted, what will remain in the grid? Does not check if the stack matches though! Used e.g. in CrT's net.minecraft.item.crafting.ICraftingRecipe
Returns crafttweaker.api.item.IItemStack
<item:minecraft:dirt>.getRemainingItem(stack as crafttweaker.api.item.IItemStack);
<item:minecraft:dirt>.getRemainingItem(<item:minecraft:iron_ingot>);
matches
Does the given stack match the ingredient?
Returns boolean
<item:minecraft:dirt>.matches(stack as crafttweaker.api.item.IItemStack);
<item:minecraft:dirt>.matches(<item:minecraft:iron_ingot>);
setDisplayName
Sets the display name of the ItemStack
Returns crafttweaker.api.item.IItemStack
<item:minecraft:dirt>.setDisplayName(name as String);
<item:minecraft:dirt>.setDisplayName("totally not dirt");
Parameter | Type | Description |
---|
name | String | New name of the stack. |
withDamage
Sets the damage of the ItemStack
Returns crafttweaker.api.item.IItemStack
<item:minecraft:dirt>.withDamage(damage as int);
<item:minecraft:dirt>.withDamage(10);
Parameter | Type | Description |
---|
damage | int | the new damage value |
withTag
Sets the tag for the ItemStack.
Returns crafttweaker.api.item.IItemStack
<item:minecraft:dirt>.withTag(tag as crafttweaker.api.data.IData);
<item:minecraft:dirt>.withTag({Display: {lore: ["Hello"]}});
Properties
Name | Type | Has Getter | Has Setter |
---|
amount | int | true | false |
burnTime | int | true | true |
commandString | String | true | false |
damageable | boolean | true | false |
damaged | boolean | true | false |
displayName | String | true | false |
empty | boolean | true | false |
food | crafttweaker.api.food.MCFood | true | true |
getOrCreate | crafttweaker.api.data.IData | true | false |
getRepairCost | int | true | false |
hasDisplayName | boolean | true | false |
hasEffect | boolean | true | false |
hasTag | boolean | true | false |
isCrossbow | boolean | true | false |
isEnchantable | boolean | true | false |
isEnchanted | boolean | true | false |
items | crafttweaker.api.item.IItemStack[] | true | false |
maxDamage | int | true | false |
maxStackSize | int | true | false |
registryName | String | true | false |
stackable | boolean | true | false |
tag | crafttweaker.api.data.IData | true | false |
translationKey | String | true | false |
useDuration | int | true | false |
Operators
MUL
Sets the amount of the ItemStack
<item:minecraft:dirt> * amount as int
<item:minecraft:dirt> * 3
Parameter | Type | Description |
---|
amount | int | new amount |
Casters