MCWeightedItemStack

An ItemStack with a chance, usually used for recipe outputs.

Careful, if the stack that was used to create the WeightedStack was mutable, then the size setter will mutate the original stack as well!

This class was added by a mod with mod-id crafttweaker. So you need to have this mod installed if you want to use this feature.

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.

crafttweaker.api.item.MCWeightedItemStack

Implemented Interfaces

MCWeightedItemStack implements the following interfaces. That means any method available to them can also be used on this class.

Constructors

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

new crafttweaker.api.item.MCWeightedItemStack(itemStack as crafttweaker.api.item.IItemStack, weight as double);
new crafttweaker.api.item.MCWeightedItemStack(<item:minecraft:bedrock>, 0.5D);
ParameterTypeDescription
itemStackcrafttweaker.api.item.IItemStackThe Stack
weightdoubleThe chance, between 0 (0%) and 1 (100%)

Methods

weight

Creates a new Weighted Stack with the given weight

Returns: A new WeightedItemStack

Return type: crafttweaker.api.item.MCWeightedItemStack

<item:minecraft:bedrock>.weight(0.5D).weight(newWeight as double);
<item:minecraft:bedrock>.weight(0.5D).weight(0.75D);
ParameterTypeDescription
newWeightdoubleThe percentage

Properties

이름TypeHas GetterHas Setter
commandStringStringtruefalse
stackcrafttweaker.api.item.IItemStacktruefalse
weightdoubletruefalse

연산자

MUL

Sets the itemStack's amount.

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

Returns: A new WeightedItemStack

<item:minecraft:bedrock>.weight(0.5D) * newAmount as int
<item:minecraft:bedrock>.weight(0.5D) * 5
ParameterTypeDescription
newAmountintThe new stack size
### MOD

Creates a new Weighted Stack with the given percentage

Returns: A new WeightedItemStack

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