MCWeightedItemStack

Un ItemStack con una possibilità, di solito usato per gli output delle ricette.

Attenzione, se lo stack che è stato utilizzato per creare il WeightedStack era mutabile, allora il setter di dimensioni muterà anche lo stack originale!

Importing the class

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.MCWeightedItemStack;

Interfacce Implementate

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

Constructors

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

new MCWeightedItemStack(itemStack as IItemStack, weight as double) as MCWeightedItemStack
new MCWeightedItemStack(<item:minecraft:bedrock>, 0.5D);
ParameterTypeDescription
itemStackIItemStackLa Pila
weightdoubleLa possibilità, tra 0 (0%) e 1 (100%)

Methods

weight

Creates a new Weighted Stack with the given weight

Return Type: MCWeightedItemStack

MCWeightedItemStack.weight(newWeight as double) as MCWeightedItemStack
<item:minecraft:bedrock>.weight(0.5D).weight(0.75D);
ParameterTypeDescription
NuovoPesodoubleLa percentuale

Operators

MOD

Creates a new Weighted Stack with the given percentage

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

MUL

Sets the itemStack's amount.

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

myMCWeightedItemStack * newAmount as int
<item:minecraft:bedrock>.weight(0.5D) * 5

Properties

NameTypeHa GetterHa Setter
stackIItemStacktruefalse
weightdoubletruefalse