mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
inlined getOreNameOrItemStackFromName
This commit is contained in:
parent
76cec04771
commit
98832e18f8
@ -211,22 +211,20 @@ object Recipes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else throw new RecipeException("Invalid ingredient type (no oreDict, item or block entry).")
|
else throw new RecipeException("Invalid ingredient type (no oreDict, item or block entry).")
|
||||||
case name: String => getOreNameOrItemStackFromName(name)
|
case name: String =>
|
||||||
case _ => throw new RecipeException("Invalid ingredient type (not a map or string).")
|
if (name == null || name.trim.isEmpty) null
|
||||||
}
|
else if (OreDictionary.getOres(name) != null && !OreDictionary.getOres(name).isEmpty) name
|
||||||
|
else {
|
||||||
private def getOreNameOrItemStackFromName(name: String) =
|
Item.itemsList.find(itemNameEquals(_, name)) match {
|
||||||
if (name == null || name.trim.isEmpty) null
|
case Some(item) => new ItemStack(item, 1, 0)
|
||||||
else if (OreDictionary.getOres(name) != null && !OreDictionary.getOres(name).isEmpty) name
|
case _ => Block.blocksList.find(blockNameEquals(_, name)) match {
|
||||||
else {
|
case Some(block) => new ItemStack(block, 1, 0)
|
||||||
Item.itemsList.find(itemNameEquals(_, name)) match {
|
case _ => throw new RecipeException("No ore dictionary entry, item or block found for ingredient with name '" + name + "'.")
|
||||||
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) =
|
private def itemNameEquals(item: Item, name: String) =
|
||||||
item != null && (item.getUnlocalizedName == name || item.getUnlocalizedName == "item." + name)
|
item != null && (item.getUnlocalizedName == name || item.getUnlocalizedName == "item." + name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user