Fix crash issue

This commit is contained in:
James David Clarke 2024-01-02 11:48:35 +00:00
parent 3b70b56560
commit da4f4f5e23
No known key found for this signature in database
GPG Key ID: 9F5ECFD0E20F1C4C
1 changed files with 19 additions and 16 deletions

View File

@ -121,22 +121,25 @@ function technic.get_recipe(typename, items)
return return
end end
local recipe = technic.recipes[typename].recipes[index] local recipe = technic.recipes[typename].recipes[index]
if recipe then if recipe then
local new_input = {} local new_input = {}
for i, stack in ipairs(items) do for i, stack in ipairs(items) do
if stack:get_count() < recipe.input[stack:get_name()] then local input_count = recipe.input[stack:get_name()]
return nil if input_count == nil then
else -- Handle nil value, maybe return nil or log a warning
new_input[i] = ItemStack(stack) return nil
new_input[i]:take_item(recipe.input[stack:get_name()]) end
end if stack:get_count() < input_count then
end return nil
return {time = recipe.time, else
new_input = new_input, new_input[i] = ItemStack(stack)
output = recipe.output} new_input[i]:take_item(input_count)
else end
return nil end
end return {time = recipe.time, new_input = new_input, output = recipe.output}
else
return nil
end
end end