IItemStack

This represents an item. It can be retrieved using an Item BEP. Is an crafttweaker.api.item.IIngredient

这个类由mod-id为crafttweaker的模组添加. 因此,如果要使用此功能,则需要安装此mod。

导入相关包

如果遇到任何问题(例如强制转换数组),则可能需要导入软件包,因此,最好的方式就是导入包支持。

crafttweaker.api.item.IItemStack

已实现的接口

IItemStack implements the following interfaces. 这意味着对这个接口可用的任何方法也可以在此类上使用。

方法

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>);
参数类型描述
stackcrafttweaker.api.item.IItemStackThe stack to provide for this ingredient.

matches

Does the given stack match the ingredient?

返回为布尔值

<item:minecraft:dirt>.matches(stack as crafttweaker.api.item.IItemStack);
<item:minecraft:dirt>.matches(<item:minecraft:iron_ingot>);
参数类型描述
stackcrafttweaker.api.item.IItemStackThe stack to check

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");
参数类型描述
nameStringNew 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);
参数类型描述
damageintthe 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"]}});
参数类型描述
tagcrafttweaker.api.data.IDataThe tag to set.

参数

名称类型可获得可设置
amountinttruefalse
burnTimeinttruetrue
commandStringStringtruefalse
damageablebooleantruefalse
damagedbooleantruefalse
displayNameStringtruefalse
emptybooleantruefalse
foodcrafttweaker.api.food.MCFoodtruetrue
getOrCreatecrafttweaker.api.data.IDatatruefalse
getRepairCostinttruefalse
hasDisplayNamebooleantruefalse
hasEffectbooleantruefalse
hasTagbooleantruefalse
isCrossbowbooleantruefalse
isEnchantablebooleantruefalse
isEnchantedbooleantruefalse
itemscrafttweaker.api.item.IItemStack[]truefalse
maxDamageinttruefalse
maxStackSizeinttruefalse
registryNameStringtruefalse
stackablebooleantruefalse
tagcrafttweaker.api.data.IDatatruefalse
translationKeyStringtruefalse
useDurationinttruefalse

运算符

MUL

Sets the amount of the ItemStack

<item:minecraft:dirt> * amount as int
<item:minecraft:dirt> * 3
参数类型描述
amountintnew amount

Casters