WeightedItemStack
Link to weighteditemstack
A Weighted Item Stack is like a normal IItemStack but has a percentage added to it.
You normally use them when dealing with percentage based actions like drops or secondary outputs.
导入相关包
Link to 导入相关包
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.WeightedItemStack;
Implementing IWeightedIngredient
Link to implementing-iweightedingredient
WeightedItemStack implements IWeightedIngredient. That means all functions available to IWeightedIngredient also are available to WeightedItemStack.
Calling a weightedItemStack
Link to calling-a-weighteditemstack
You can derive a weightedItemStack from an IItemStack by either using the modulo operator or the weight function on it.
ZenScript Copyval itemStack = <minecraft:dirt>;
//both create a weightedItemstack object with a chance of 20%
val wItemStack = itemStack % 20;
val wItemStack2 = itemStack.weight(0.2);
ZenGetters
Link to zengetters
ZenGetter | 功能 | 返回值类型 |
---|---|---|
ZenGetter 堆叠 | 功能 Returns the associated itemStack | 返回值类型 IItemstack |
ZenGetter chance | 功能 Returns the stack's chance as decimal (e.g. 0.2) | 返回值类型 float |
ZenGetter percent | 功能 Returns the stack's chance as percentage (e.g. 20.0) | 返回值类型 float |