getRecipeInfo - FireDragon91245/CCT-Resource-API GitHub Wiki
getRecipeInfo
[!NOTE] getRecipeInfo returns the 1st matching recipe
signature:
-- regex = str that will be evaluatet as regex
-- nbt = table that represents nbt
-- item = str thats a item id like minecraft:stone
getRecipeInfo(
recipeId: str | filter: table {
[recipeid: regex],
[modid: regex],
[type: str],
[group: str],
[result: item | table(ItemStack) {
[itemid: regex],
[modid: regex],
[count: int],
[nbt: nbt]
}],
[ingredients: item | table(Ingedient[]) {
[itemid: regex],
[modid: regex],
[count: int],
[{item}: int], -- anything with key of item (str) and int for example "minecraft:stone": 3
[{int}: item | table(Ingedient) { -- anything with key of int and str | table as value
[itemid: regex],
[modid: regex],
[count: int],
[{item}: int], -- anything with key of item (str) and int for example "minecraft:stone": 3
[{int}: item | table(ItemStack) { -- anything with key of int and str | table as value
[itemid: regex],
[modid: regex],
[count: int],
[nbt: nbt]
}]
}]
}]
}
)
return: table: recipe
performance impact: medium
filter explaination:
[{item}: int]
-- This filters recipees that match that exact item count of all child item stacks
-- example:
getRecipeInfo({
ingredients = {
["minecraft:stone"] = 3
}
})
-- this filters any recipee that takes 3*minecraft:stone (not exlusivly stone but exactly 3 stone other ingedients are ignored)
-- this will acumulate all child itemStacks so for each Ingredient for each ItemStack in that ingredient and compare to 3*minecraft:stone
-- to filter exclusivly 3*minecraft:stone do
getRecipeInfo({
ingredients = {
modid = "minecraft",
itemid = "stone",
["minecraft:stone"] = 3
}
})
-- this filters recipes where all ingredient items match mod: minecraft and item: stone and has an item count minecraft:stone = 3 so exclusivly recipees with 3*stone
[{int}: item | table(Ingedient) {}]
[{int}: item | table(ItemStack) {}]
-- This filters exact entrys in the hirarchy
-- example:
getRecipeInfo({
ingedients = {
[1] = {
[1] = "minecraft:stone"
}
}
})
-- this filters recipes where the 1st (remember lua is 1 indexed) ingredients 1st item stack is the item "minecraft:stone"
getRecipeInfo({
ingedients = {
[1] = {
[1] = {
modid = "minecraft",
itemid = "stone",
count = 1
}
}
}
})
-- this filters recipes where the 1st ingedients 1st item stack has a count of 1 and is "minecraft:stone"
examples
-- I dont recoment hard coding recipe ids always instead serach for what you want
-- modpacks could always change or remove recipes
-- DONT
getRecipeInfo("minecraft:stone_slab") -- recipeid
-- DO
getRecipeInfo({
result = "minecraft:stone_slab" -- itemid
})
-- note item and recipe id can be completly diferent (not related at all)
-- find a crafting recipe for advanecd computer
getRecipeInfo({
type = "crafting",
result = "computercraft:computer_advanced"
})