1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2024-11-17 07:50:31 +01:00

Fix furnace block fuel (#2)

* Fix blocking of fuel inventory by fuel replacement and losing of fuel replacements.
This commit is contained in:
sfence 2021-11-29 17:01:16 +01:00 committed by GitHub
parent 8f067db7cd
commit 23fe215721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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