Class WeightedItemStack

java.lang.Object
org.cyclops.cyclopscore.item.WeightedItemStack

public class WeightedItemStack extends Object
An ItemStack that has a certain weight that can be used to occur with a certain chance.
  • Constructor Details

    • WeightedItemStack

      public WeightedItemStack()
  • Method Details

    • createWeightedList

      public static List<WeightedItemStack> createWeightedList(Set<WeightedItemStack> input)
      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 from createWeightedList(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

      public String toString()
      Overrides:
      toString in class Object