Class ItemWithChance

java.lang.Object
com.pixelmonmod.pixelmon.api.pokemon.drops.ItemWithChance

public class ItemWithChance extends Object
An object that represents an item that has a chance of being given, with a random amount selection
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemWithChance(net.minecraft.world.item.ItemStack itemStack, int amount)
    Guaranteed item with guaranteed amount
    ItemWithChance(net.minecraft.world.item.ItemStack itemStack, int amount, double chance)
    Item with guaranteed amount and a chance
    ItemWithChance(net.minecraft.world.item.ItemStack itemStack, int min, int max)
    Guaranteed item with min and max amount
    ItemWithChance(net.minecraft.world.item.ItemStack itemStack, int min, int max, double chance)
    Default constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Gets the chance of the item being given (0 - 1)
    net.minecraft.world.item.ItemStack
    Gets the item using randomness for the chance and amount
    net.minecraft.world.item.ItemStack
    Gets a copy of the ItemStack being cloned and then given to the player
    int
    Gets the maximum amount of the item
    int
    Gets the minimum amount of the item
    parse(com.google.gson.JsonArray array)
    Parses a JsonArray to a list of items with chance
    parse(com.google.gson.JsonObject object)
    Parses a JsonObject to am item with chance

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ItemWithChance

      public ItemWithChance(net.minecraft.world.item.ItemStack itemStack, int amount)
      Guaranteed item with guaranteed amount
      Parameters:
      itemStack - The item
      amount - The amount of the item
    • ItemWithChance

      public ItemWithChance(net.minecraft.world.item.ItemStack itemStack, int amount, double chance)
      Item with guaranteed amount and a chance
      Parameters:
      itemStack - The item being given
      amount - The amount of the item
      chance - The chance of being given
    • ItemWithChance

      public ItemWithChance(net.minecraft.world.item.ItemStack itemStack, int min, int max)
      Guaranteed item with min and max amount
      Parameters:
      itemStack - The item being given
      min - The minimum amount
      max - The maximum amount
    • ItemWithChance

      public ItemWithChance(net.minecraft.world.item.ItemStack itemStack, int min, int max, double chance)
      Default constructor
      Parameters:
      itemStack - The item
      min - The minimum amount
      max - The maximum amount
      chance - The chance of being given (max 1.0, min 0.0 - inclusive for both)
  • Method Details

    • getItemStack

      public net.minecraft.world.item.ItemStack getItemStack()
      Gets a copy of the ItemStack being cloned and then given to the player
      Returns:
      A copy of the item
    • getMin

      public int getMin()
      Gets the minimum amount of the item
      Returns:
      The minimum amount
    • getMax

      public int getMax()
      Gets the maximum amount of the item
      Returns:
      The maximum
    • getChance

      public double getChance()
      Gets the chance of the item being given (0 - 1)
      Returns:
      The chance
    • getItem

      public net.minecraft.world.item.ItemStack getItem()
      Gets the item using randomness for the chance and amount
      Returns:
      The item to be given this roll
    • parse

      public static List<ItemWithChance> parse(com.google.gson.JsonArray array)
      Parses a JsonArray to a list of items with chance
      Parameters:
      array - The array being parsed
      Returns:
      The items
    • parse

      public static ItemWithChance parse(com.google.gson.JsonObject object)
      Parses a JsonObject to am item with chance
      Parameters:
      object - The object being parsed
      Returns:
      The item