mirror of
https://github.com/minetest-mods/unified_inventory.git
synced 2025-06-30 23:40:38 +02:00
Return early when there's not enough items for craft
This commit is contained in:
@ -213,6 +213,11 @@ function unified_inventory.match_items(m, craft_index, item_index)
|
||||
local times_used = #item.craft_positions
|
||||
local cell_count = math.floor(index.total_count / times_used)
|
||||
|
||||
if cell_count == 0 then
|
||||
m.count = 0
|
||||
return
|
||||
end
|
||||
|
||||
index.times_matched = times_used
|
||||
m.count = math.min(m.count, cell_count)
|
||||
|
||||
@ -241,6 +246,11 @@ function unified_inventory.match_groups(m, craft_index, item_index)
|
||||
end
|
||||
end
|
||||
|
||||
if cell_count == 0 then
|
||||
m.count = 0
|
||||
return
|
||||
end
|
||||
|
||||
m.count = math.min(m.count, cell_count)
|
||||
m.items[craft_pos] = matched_item.name
|
||||
|
||||
@ -261,6 +271,10 @@ function unified_inventory.get_match_table(craft_index, item_index)
|
||||
unified_inventory.match_items(match_table, craft_index, item_index)
|
||||
unified_inventory.match_groups(match_table, craft_index, item_index)
|
||||
|
||||
if match_table.count == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
return match_table
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user