Home Getting Started With Scripts Using this wiki Commands CTGUI Global functions Bracket Handlers

WeightedOreDictEntry

A Weighted OreDict Entry is like a normal IOreDictEntry but has a percentage added to it.
You normally use them when dealing with percentage based actions like drops or secondary outputs.

Importing the package

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.oredict.WeightedOreDictEntry;

Implementing IWeightedIngredient

WeightedOreDictEntry implements IWeightedIngredient. That means all functions available to IWeightedIngredient also are available to WeightedOreDictEntry.

Calling a weightedOreDictEntry

You can derive a weightedOreDictEntry from an IOreDictEntry by either using the modulo operator or the weight function on it.

script.zs
val oreDictEntry = <ore:ingotGold>;
//both create a weightedOreDictEntry object with a chance of 20%
val wOreDictEntry = liquidStack % 20;
val wOreDictEntry2 = liquidStack.weight(0.2);

ZenGetters

ZenGetterWhat does it doReturn Type
ZenGetter
entry
What does it do
Returns the associated OreDictEntry
Return Type
IOreDictEntry
ZenGetter
chance
What does it do
Returns the stack’s chance as decimal (e.g. 0.2)
Return Type
float
ZenGetter
percent
What does it do
Returns the stack’s chance as percentage (e.g. 20.0)
Return Type
float