Package org.cyclops.cyclopscore.item
Class WeightedItemStack
java.lang.Object
org.cyclops.cyclopscore.item.WeightedItemStack
An ItemStack that has a certain weight that can be used to occur with a certain chance.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<WeightedItemStack>
createWeightedList
(Set<WeightedItemStack> input) Create a weighted list of the given input items.net.minecraft.world.item.ItemStack
getItemStackWithRandomizedSize
(net.minecraft.util.RandomSource random) Get a copy of the itemstack with a randomized stacksize.static WeightedItemStack
getRandomWeightedItemStack
(List<WeightedItemStack> list, net.minecraft.util.RandomSource random) Get a random item from the given list.toString()
-
Constructor Details
-
WeightedItemStack
public WeightedItemStack()
-
-
Method Details
-
createWeightedList
Create a weighted list of the given input items.- Parameters:
input
- The set of unique weighted itemstacks.- Returns:
- A list which can be used to get random weighted itemstacks.
-
getRandomWeightedItemStack
public static WeightedItemStack getRandomWeightedItemStack(List<WeightedItemStack> list, net.minecraft.util.RandomSource random) Get a random item from the given list.- Parameters:
list
- The list, generated fromcreateWeightedList(java.util.Set<org.cyclops.cyclopscore.item.WeightedItemStack>)
random
- A random instance.- Returns:
- A random item.
-
getItemStackWithRandomizedSize
public net.minecraft.world.item.ItemStack getItemStackWithRandomizedSize(net.minecraft.util.RandomSource random) Get a copy of the itemstack with a randomized stacksize. The original itemstack size represent the maximum stacksize +1.- Parameters:
random
- A random instance.- Returns:
- A new itemstack.
-
toString
-