Search in sources :

Example 1 with WeightedItemStack

use of cavern.util.WeightedItemStack in project Cavern2 by kegare.

the class RandomiteHelper method getDropItem.

public static ItemStack getDropItem() {
    if (DROP_ITEMS.isEmpty()) {
        return ItemStack.EMPTY;
    }
    int totalWeight = WeightedRandom.getTotalWeight(DROP_ITEMS);
    WeightedItemStack item = WeightedRandom.getRandomItem(DROP_ITEMS, RANDOM.nextInt(totalWeight));
    return item != null ? item.getItemStack() : ItemStack.EMPTY;
}
Also used : WeightedItemStack(cavern.util.WeightedItemStack)

Aggregations

WeightedItemStack (cavern.util.WeightedItemStack)1