Fix potential division by zero in loot disk cycling recipe.

This commit is contained in:
Florian Nücke 2016-07-03 19:58:27 +02:00
parent 650ee2c45d
commit 32ab472370

View File

@ -15,10 +15,10 @@ class LootDiskCyclingRecipe extends IRecipe {
}
override def getCraftingResult(crafting: InventoryCrafting): ItemStack = {
collectStacks(crafting).find(Loot.isLootDisk) match {
case Some(lootDisk) =>
val lootFactoryName = getLootFactoryName(lootDisk)
val lootDiskStacks = Loot.worldDisks.map(_._1)
collectStacks(crafting).find(Loot.isLootDisk) match {
case Some(lootDisk) if lootDiskStacks.nonEmpty =>
val lootFactoryName = getLootFactoryName(lootDisk)
val oldIndex = lootDiskStacks.indexWhere(s => getLootFactoryName(s) == lootFactoryName)
val newIndex = (oldIndex + 1) % lootDiskStacks.length
lootDiskStacks(newIndex).copy()