MCWeightedItemStack

Link to mcweighteditemstack

一个带有机会的物品堆栈,通常用于配方输出。

小心,如果用来创建权重堆的堆栈是可变的,那么尺寸设置也会变换原始堆栈!

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.

ZenScript
Copy
import crafttweaker.api.item.MCWeightedItemStack;

已实现的接口

Link to 已实现的接口

MCWeightedItemStack implements the following interfaces. That means all methods defined in these interfaces are also available in MCWeightedItemStack

Constructor #构造函数

Link to constructor-构造函数

Manually creates the weightedItemStack.
Usually you can use the operator or .weight(weight) method of IItemStack, though

ZenScript
Copy
new MCWeightedItemStack(itemStack as IItemStack, weight as double) as MCWeightedItemStack
new MCWeightedItemStack(<item:minecraft:bedrock>, 0.5D);
参数类型描述
参数
物品应用
类型
IItemstack
描述
堆栈:
参数
weight
类型
double
描述
机会介于 0 (0%) 和 1 (100%) 之间

Name: weight

Creates a new Weighted Stack with the given weight

Returns: A new WeightedItemStack
Return Type: MCWeightedItemStack

ZenScript
Copy
// MCWeightedItemStack.weight(newWeight as double) as MCWeightedItemStack

<item:minecraft:bedrock>.weight(0.5D).weight(0.75D);
参数类型描述
参数
新权重
类型
double
描述
百分比

Name: MOD

Creates a new Weighted Stack with the given percentage

ZenScript
Copy
myMCWeightedItemStack % newWeight as int
<item:minecraft:bedrock>.weight(0.5D) % 75

Name: MUL

Sets the itemStack's amount.

If the original Stack was mutable, also mutates the original stack's size.

ZenScript
Copy
myMCWeightedItemStack * newAmount as int
<item:minecraft:bedrock>.weight(0.5D) * 5
名称类型可获得可设置描述
名称
堆叠
类型
IItemstack
可获得
true
可设置
false
描述
Gets the original (unweighted) stack
名称
weight
类型
double
可获得
true
可设置
false
描述
Gets the weight (usually between 0 and 1)