From 78354ea87ff266a1983d4430bebe2ecbf96ee139 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Tue, 25 Oct 2022 14:30:38 +0100 Subject: [PATCH] fix lava_pick outputs (thanks fluxionary) --- lava_flan.lua | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/lava_flan.lua b/lava_flan.lua index 8e2d085..441efac 100644 --- a/lava_flan.lua +++ b/lava_flan.lua @@ -150,29 +150,32 @@ function minetest.handle_node_drops(pos, drops, digger) local hot_drops = {} -- loop through current node drops - for _, drop in pairs(drops) do + for _, drop in ipairs(drops) do -- get cooked output of current drops local stack = ItemStack(drop) - local output = minetest.get_craft_result({ - method = "cooking", - width = 1, - items = {drop} - }) - -- if we have cooked result then add to new list - if output - and output.item - and not output.item:is_empty() then + while not stack:is_empty() do - table.insert(hot_drops, - ItemStack({ - name = output.item:get_name(), - count = output.item:to_table().count, - }) - ) - else -- if not then return normal drops - table.insert(hot_drops, stack) + local output, decremented_input = minetest.get_craft_result({ + method = "cooking", + width = 1, + items = {stack} + }) + + if output.item:is_empty() then + + table.insert_all(hot_drops, decremented_input.items) + break + else + if not output.item:is_empty() then + table.insert(hot_drops, output.item) + end + + table.insert_all(hot_drops, output.replacements) + + stack = decremented_input.items[1] or ItemStack() + end end end