mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 02:39:48 -04:00
Trying to prevent NPE in item cost computation.
This commit is contained in:
parent
56184a210a
commit
f4f6881bdd
@ -100,24 +100,27 @@ object ItemCosts {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val recipes = CraftingManager.getInstance.getRecipeList.map(_.asInstanceOf[IRecipe])
|
val recipes = CraftingManager.getInstance.getRecipeList.map(_.asInstanceOf[IRecipe])
|
||||||
val recipe = recipes.find(recipe => recipe.getRecipeOutput != null && fuzzyEquals(stack, recipe.getRecipeOutput))
|
if (recipes == null) Iterable((stack, 1.0))
|
||||||
val (ingredients, output) = recipe match {
|
else {
|
||||||
case Some(recipe: ShapedRecipes) => (recipe.recipeItems.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
|
val recipe = recipes.filter(_ != null).find(recipe => recipe.getRecipeOutput != null && fuzzyEquals(stack, recipe.getRecipeOutput))
|
||||||
case Some(recipe: ShapelessRecipes) => (recipe.recipeItems.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
|
val (ingredients, output) = recipe match {
|
||||||
case Some(recipe: ShapedOreRecipe) => (recipe.getInput.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
|
case Some(recipe: ShapedRecipes) => (recipe.recipeItems.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
|
||||||
case Some(recipe: ShapelessOreRecipe) => (recipe.getInput.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
|
case Some(recipe: ShapelessRecipes) => (recipe.recipeItems.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
|
||||||
case _ => FurnaceRecipes.smelting.getSmeltingList.asInstanceOf[util.Map[ItemStack, ItemStack]].find {
|
case Some(recipe: ShapedOreRecipe) => (recipe.getInput.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
|
||||||
case (_, value) => fuzzyEquals(stack, value)
|
case Some(recipe: ShapelessOreRecipe) => (recipe.getInput.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
|
||||||
} match {
|
case _ => FurnaceRecipes.smelting.getSmeltingList.asInstanceOf[util.Map[ItemStack, ItemStack]].find {
|
||||||
case Some((rein, raus)) => (accumulate(rein, path :+ stack), raus.stackSize)
|
case (_, value) => fuzzyEquals(stack, value)
|
||||||
case _ => (Iterable((stack, 1.0)), 1)
|
} match {
|
||||||
|
case Some((rein, raus)) => (accumulate(rein, path :+ stack), raus.stackSize)
|
||||||
|
case _ => (Iterable((stack, 1.0)), 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
val scaled = deflate(ingredients.map {
|
||||||
|
case (ingredient, count) => (ingredient.copy(), count / output)
|
||||||
|
}).toArray.sortBy(_._1.getUnlocalizedName)
|
||||||
|
cache += new ItemStackWrapper(stack.copy()) -> scaled
|
||||||
|
scaled
|
||||||
}
|
}
|
||||||
val scaled = deflate(ingredients.map {
|
|
||||||
case (ingredient, count) => (ingredient.copy(), count / output)
|
|
||||||
}).toArray.sortBy(_._1.getUnlocalizedName)
|
|
||||||
cache += new ItemStackWrapper(stack.copy()) -> scaled
|
|
||||||
scaled
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case list: util.ArrayList[ItemStack]@unchecked if !list.isEmpty =>
|
case list: util.ArrayList[ItemStack]@unchecked if !list.isEmpty =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user