use of net.minecraft.util.WeightedRandomItem in project MineFactoryReloaded by powercrystals.
the class TileEntityLaserDrill method getRandomDrop.
private ItemStack getRandomDrop() {
List<WeightedRandomItemStack> drops = new LinkedList<WeightedRandomItemStack>();
int boost = WeightedRandom.getTotalWeight(MFRRegistry.getLaserOres()) / 30;
for (WeightedRandomItem i : MFRRegistry.getLaserOres()) {
WeightedRandomItemStack oldStack = (WeightedRandomItemStack) i;
WeightedRandomItemStack newStack = new WeightedRandomItemStack(oldStack.itemWeight, oldStack.getStack());
drops.add(newStack);
for (ItemStack s : _inventory) {
if (s == null || s.itemID != MineFactoryReloadedCore.laserFocusItem.itemID || MFRRegistry.getLaserPreferredOres(s.getItemDamage()) == null) {
continue;
}
List<ItemStack> preferredOres = MFRRegistry.getLaserPreferredOres(s.getItemDamage());
for (ItemStack preferredOre : preferredOres) {
if (UtilInventory.stacksEqual(newStack.getStack(), preferredOre)) {
newStack.itemWeight += boost;
}
}
}
}
return ((WeightedRandomItemStack) WeightedRandom.getRandomItem(_rand, drops)).getStack();
}
Aggregations