MCItemStackMutable
An MCItemStackMutable object is the same as any other IItemStack. The only difference is that changes made to it will not create a new ItemStack, but instead modify the stack given.
This is useful for example when you are dealing with Event Handlers and need to shrink the stack the player is using without assigning a new stack.
导入相关包
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.item.MCItemStackMutable;
已实现的接口
MCItemStackMutable implements the following interfaces. That means all methods defined in these interfaces are also available in MCItemStackMutable
Casters
方法
Return Type: void
MCItemStackMutable.addShiftTooltip(content as MCTextComponent, showMessage as MCTextComponent) as void
参数 | 类型 | 描述 | 可选 | DefaultValue |
---|
内容 | MCText组件 | No Description Provided | false | |
showMessage | MCText组件 | No Description Provided | true | |
Return Type: void
MCItemStackMutable.addTooltip(content as MCTextComponent) as void
Return Type: IIngredientWithAmount
MCItemStackMutable.asIIngredientWithAmount() as IIngredientWithAmount
<item:minecraft:dirt>.mutable().asIIngredientWithAmount();
Clears any custom name set for this ItemStack
Return Type: void
MCItemStackMutable.clearCustomName() as void
<item:minecraft:dirt>.mutable().clearCustomName();
Return Type: void
MCItemStackMutable.clearTooltip() as void
<item:minecraft:dirt>.mutable().clearTooltip();
Does the ingredient contain the given ingredient?
Return Type: boolean
MCItemStackMutable.contains(ingredient as IIngredient) as boolean
<item:minecraft:dirt>.mutable().contains((<item:minecraft:iron_ingot> | <item:minecraft:gold_ingot>));
Return Type: MCItemDefinition
MCItemStackMutable.getDefinition() as MCItemDefinition
<item:minecraft:dirt>.mutable().getDefinition();
When this ingredient stack is crafted, what will remain in the grid? Does not check if the stack matches though! Used e.g. in Crafting Table recipes.
Return Type: IItemStack
MCItemStackMutable.getRemainingItem(stack as IItemStack) as IItemStack
<item:minecraft:dirt>.mutable().getRemainingItem(<item:minecraft:iron_ingot>);
参数 | 类型 | 描述 |
---|
stack | IItemStack | The stack to provide for this ingredient. |
Does the given stack match the ingredient?
Return Type: boolean
MCItemStackMutable.matches(stack as IItemStack) as boolean
<item:minecraft:dirt>.mutable().matches(<item:minecraft:iron_ingot>);
Return Type: void
MCItemStackMutable.modifyTooltip(function as ITooltipFunction) as void
Use this if you already have the condition from another ingredient
Return Type: MCIngredientConditioned<IIngredient>
MCItemStackMutable.only(condition as IIngredientCondition<IIngredient>) as MCIngredientConditioned<IIngredient>
Return Type: MCIngredientConditioned<IIngredient>
MCItemStackMutable.onlyIf(uid as string, function as Predicate<IItemStack>) as MCIngredientConditioned<IIngredient>
参数 | 类型 | 描述 | 可选 | DefaultValue |
---|
uid | string | No Description Provided | false | |
function | Predicate<IItemStack> | No Description Provided | true | |
Return Type: void
MCItemStackMutable.removeTooltip(regex as string) as void
参数 | 类型 | 描述 |
---|
regex | string | No Description Provided |
Return Type: MCWeightedItemStack
MCItemStackMutable.weight(weight as double) as MCWeightedItemStack
参数 | 类型 | 描述 |
---|
weight | double | No Description Provided |
运算符
Does the ingredient contain the given ingredient?
ingredient as IIngredient in myMCItemStackMutable
(<item:minecraft:iron_ingot> | <item:minecraft:gold_ingot>) in <item:minecraft:dirt>.mutable()
myMCItemStackMutable == o as Object
myMCItemStackMutable % percentage as int
myMCItemStackMutable | other as IIngredient
参数
名称 | 类型 | 可获得 | 可设置 |
---|
amount | int | true | false |
burnTime | int | true | true |
damageable | boolean | true | false |
damaged | boolean | true | false |
definition | MCItemDefinition | true | false |
displayName | string | true | false |
empty | boolean | true | false |
getOrCreate | 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 |
maxDamage | int | true | false |
maxStackSize | int | true | false |
owner | string | true | false |
registryName | MCResourceLocation | true | false |
stackable | boolean | true | false |
tag | IData | true | false |
translationKey | string | true | false |
useDuration | int | true | false |