From 23fe215721a816d49652f4523c9ff6458b010b4b Mon Sep 17 00:00:00 2001 From: sfence Date: Mon, 29 Nov 2021 17:01:16 +0100 Subject: [PATCH] Fix furnace block fuel (#2) * Fix blocking of fuel inventory by fuel replacement and losing of fuel replacements. --- compat-furnaces.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/compat-furnaces.lua b/compat-furnaces.lua index 1894056..797ecfd 100644 --- a/compat-furnaces.lua +++ b/compat-furnaces.lua @@ -189,8 +189,25 @@ local function furnace_node_timer(pos, elapsed) fuel_totaltime = 0 src_time = 0 else - -- Take fuel from fuel list - inv:set_stack("fuel", 1, afterfuel.items[1]) + -- prevent blocking of fuel inventory (for automatization mods) + local is_fuel = minetest.get_craft_result({method = "fuel", width = 1, items = {afterfuel.items[1]:to_string()}}) + if is_fuel.time == 0 then + table.insert(fuel.replacements, afterfuel.items[1]) + inv:set_stack("fuel", 1, "") + else + -- Take fuel from fuel list + inv:set_stack("fuel", 1, afterfuel.items[1]) + end + -- Put replacements in dst list or drop them on the furnace. + local replacements = fuel.replacements + if replacements[1] then + local leftover = inv:add_item("dst", replacements[1]) + if not leftover:is_empty() then + local above = vector.new(pos.x, pos.y + 1, pos.z) + local drop_pos = minetest.find_node_near(above, 1, {"air"}) or above + minetest.item_drop(replacements[1], nil, drop_pos) + end + end update = true fuel_totaltime = fuel.time + (fuel_time - fuel_totaltime) src_time = src_time + elapsed