MCWeightedItemStack

Link to mcweighteditemstack

Ein ItemStack mit einer Chance, in der Regel für die Rezeptausgabe.

Vorsichtig, wenn der Stapel verwendet wurde, um den WeightedStack zu erstellen war veränderbar, dann wird der Größensatz auch den ursprünglichen Stapel mutieren!

Diese Klasse importieren

Link to diese-klasse-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 at the very top of the file.

ZenScript
Copy
import crafttweaker.api.item.MCWeightedItemStack;

Implemented Interfaces

Link to implemented-interfaces

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

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

ZenScript
Copy
new MCWeightedItemStack(itemStack as IItemStack, weight as double) as MCWeightedItemStack
new MCWeightedItemStack(<item:minecraft:bedrock>, 0.5D);
ParameterTypeBeschreibung
Parameter
itemStack
Type
IItemStack
Beschreibung
Der Stapel
Parameter
weight
Type
double
Beschreibung
Die Chance, zwischen 0 (0%) und 1 (100%)

Name: weight

Creates a new Weighted Stack with the given weight

Returns: A new WeightedItemStack
Return Type: MCWeightedItemStack

ZenScript
Copy
// MCWeightedItemStack.weight(newWeight as double) as MCWeightedItemStack

<item:minecraft:bedrock>.weight(0.5D).weight(0.75D);
ParameterTypeBeschreibung
Parameter
neues Gewicht
Type
double
Beschreibung
Der Prozentsatz

Name: MOD

Creates a new Weighted Stack with the given percentage

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

Name: MUL

Sets the itemStack's amount.

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

ZenScript
Copy
myMCWeightedItemStack * newAmount as int
<item:minecraft:bedrock>.weight(0.5D) * 5
NameTypeHas GetterHas SetterBeschreibung
Name
stack
Type
IItemStack
Has Getter
true
Has Setter
false
Beschreibung
Gets the original (unweighted) stack
Name
weight
Type
double
Has Getter
true
Has Setter
false
Beschreibung
Gets the weight (usually between 0 and 1)