Class ItemWithChance
java.lang.Object
com.pixelmonmod.pixelmon.api.pokemon.drops.ItemWithChance
An object that represents an item that has a chance of being given, with a random amount selection
-
Constructor Summary
ConstructorDescriptionItemWithChance
(net.minecraft.world.item.ItemStack itemStack, int amount) Guaranteed item with guaranteed amountItemWithChance
(net.minecraft.world.item.ItemStack itemStack, int amount, double chance) Item with guaranteed amount and a chanceItemWithChance
(net.minecraft.world.item.ItemStack itemStack, int min, int max) Guaranteed item with min and max amountItemWithChance
(net.minecraft.world.item.ItemStack itemStack, int min, int max, double chance) Default constructor -
Method Summary
Modifier and TypeMethodDescriptiondouble
Gets the chance of the item being given (0 - 1)net.minecraft.world.item.ItemStack
getItem()
Gets the item using randomness for the chance and amountnet.minecraft.world.item.ItemStack
Gets a copy of theItemStack
being cloned and then given to the playerint
getMax()
Gets the maximum amount of the itemint
getMin()
Gets the minimum amount of the itemstatic List<ItemWithChance>
parse
(com.google.gson.JsonArray array) Parses aJsonArray
to a list of items with chancestatic ItemWithChance
parse
(com.google.gson.JsonObject object) Parses aJsonObject
to am item with chance
-
Constructor Details
-
ItemWithChance
public ItemWithChance(net.minecraft.world.item.ItemStack itemStack, int amount) Guaranteed item with guaranteed amount- Parameters:
itemStack
- The itemamount
- 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 givenamount
- The amount of the itemchance
- 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 givenmin
- The minimum amountmax
- The maximum amount
-
ItemWithChance
public ItemWithChance(net.minecraft.world.item.ItemStack itemStack, int min, int max, double chance) Default constructor- Parameters:
itemStack
- The itemmin
- The minimum amountmax
- The maximum amountchance
- 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 theItemStack
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
Parses aJsonArray
to a list of items with chance- Parameters:
array
- The array being parsed- Returns:
- The items
-
parse
Parses aJsonObject
to am item with chance- Parameters:
object
- The object being parsed- Returns:
- The item
-