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.

Dieses Paket importieren

Link to dieses-paket-importieren

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;

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
Copy
val itemStack = <minecraft:dirt>;

//both create a weightedItemstack object with a chance of 20%
val wItemStack = itemStack % 20;
val wItemStack2 = itemStack.weight(0.2);
ZenGetterWhat does it doRückgabetyp
ZenGetter
stack
What does it do
Returns the associated itemStack
Rückgabetyp
IItemStack
ZenGetter
chance
What does it do
Returns the stack's chance as decimal (e.g. 0.2)
Rückgabetyp
float
ZenGetter
percent
What does it do
Returns the stack's chance as percentage (e.g. 20.0)
Rückgabetyp
float