use of ivorius.reccomplex.world.storage.loot.WeightedItemCollection in project RecurrentComplex by Ivorforce.
the class ItemInventoryGenMultiTag method generateInInventory.
@Override
public void generateInInventory(WorldServer server, IInventory inventory, Random random, ItemStack stack, int fromSlot) {
WeightedItemCollection weightedItemCollection = inventoryGenerator(stack);
inventory.setInventorySlotContents(fromSlot, ItemStack.EMPTY);
if (weightedItemCollection != null) {
IntegerRange range = getGenerationCount(stack);
int amount = range.getMin() < range.getMax() ? random.nextInt(range.getMax() - range.getMin() + 1) + range.getMin() : 0;
TIntList emptySlots = emptySlots(inventory);
for (int i = 0; i < amount; i++) {
int slot = emptySlots.isEmpty() ? random.nextInt(inventory.getSizeInventory()) : emptySlots.removeAt(random.nextInt(emptySlots.size()));
ItemStack generated = weightedItemCollection.getRandomItemStack(server, random);
if (generated != null)
inventory.setInventorySlotContents(slot, generated);
}
}
}
Aggregations