Skip to content

Commit

Permalink
Fix furnace block fuel (#2)
Browse files Browse the repository at this point in the history
* Fix blocking of fuel inventory by fuel replacement and losing of fuel replacements.
  • Loading branch information
sfence committed Nov 29, 2021
1 parent 8f067db commit 23fe215
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions compat-furnaces.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 23fe215

Please sign in to comment.