From 98832e18f87bdb09f3a00c84afe7220a5e97df2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Wed, 25 Dec 2013 00:55:07 +0100 Subject: [PATCH] inlined getOreNameOrItemStackFromName --- li/cil/oc/Recipes.scala | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/li/cil/oc/Recipes.scala b/li/cil/oc/Recipes.scala index a796e082c..e1aadf7e6 100644 --- a/li/cil/oc/Recipes.scala +++ b/li/cil/oc/Recipes.scala @@ -211,22 +211,20 @@ object Recipes { } } else throw new RecipeException("Invalid ingredient type (no oreDict, item or block entry).") - case name: String => getOreNameOrItemStackFromName(name) - case _ => throw new RecipeException("Invalid ingredient type (not a map or string).") - } - - private def getOreNameOrItemStackFromName(name: String) = - if (name == null || name.trim.isEmpty) null - else if (OreDictionary.getOres(name) != null && !OreDictionary.getOres(name).isEmpty) name - else { - Item.itemsList.find(itemNameEquals(_, name)) match { - case Some(item) => new ItemStack(item, 1, 0) - case _ => Block.blocksList.find(blockNameEquals(_, name)) match { - case Some(block) => new ItemStack(block, 1, 0) - case _ => throw new RecipeException("No ore dictionary entry, item or block found for ingredient with name '" + name + "'.") + case name: String => + if (name == null || name.trim.isEmpty) null + else if (OreDictionary.getOres(name) != null && !OreDictionary.getOres(name).isEmpty) name + else { + Item.itemsList.find(itemNameEquals(_, name)) match { + case Some(item) => new ItemStack(item, 1, 0) + case _ => Block.blocksList.find(blockNameEquals(_, name)) match { + case Some(block) => new ItemStack(block, 1, 0) + case _ => throw new RecipeException("No ore dictionary entry, item or block found for ingredient with name '" + name + "'.") + } } } - } + case _ => throw new RecipeException("Invalid ingredient type (not a map or string).") + } private def itemNameEquals(item: Item, name: String) = item != null && (item.getUnlocalizedName == name || item.getUnlocalizedName == "item." + name)