Properly handle multiple cookable drops
This commit is contained in:
parent
4cef3ba46f
commit
94d6bd9b44
51
init.lua
51
init.lua
@ -113,28 +113,41 @@ function lavastuff.burn_drops(tool)
|
|||||||
-- loop through current node drops
|
-- loop through current node drops
|
||||||
for _, drop in pairs(drops) do -- get cooked output of current drops
|
for _, drop in pairs(drops) do -- get cooked output of current drops
|
||||||
local stack = ItemStack(drop)
|
local stack = ItemStack(drop)
|
||||||
local output = minetest.get_craft_result({
|
local safety = 0
|
||||||
method = "cooking",
|
|
||||||
width = 1,
|
|
||||||
items = {drop}
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, name in pairs(lavastuff.blacklisted_items) do
|
repeat
|
||||||
if name == drop then
|
local output, leftover = minetest.get_craft_result({
|
||||||
return old_handle_node_drops(pos, drops, digger, ...)
|
method = "cooking",
|
||||||
|
width = 1,
|
||||||
|
items = {stack:to_string()}
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, name in pairs(lavastuff.blacklisted_items) do
|
||||||
|
if name == drop then
|
||||||
|
return old_handle_node_drops(pos, drops, digger, ...)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- if we have cooked result then add to new list
|
-- if we have cooked result then add to new list
|
||||||
if output and output.item and not output.item:is_empty() and output.time <= lavastuff.cook_limit then
|
if output and output.item and not output.item:is_empty() and output.time <= lavastuff.cook_limit then
|
||||||
table.insert(hot_drops,
|
table.insert(hot_drops,
|
||||||
ItemStack({
|
ItemStack({
|
||||||
name = output.item:get_name(),
|
name = output.item:get_name(),
|
||||||
count = output.item:to_table().count,
|
count = output.item:to_table().count,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
else -- if not then return normal drops
|
|
||||||
table.insert(hot_drops, stack)
|
stack = leftover.items[1]
|
||||||
|
else -- if not then return normal drops
|
||||||
|
table.insert(hot_drops, stack)
|
||||||
|
stack = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
safety = safety + 1
|
||||||
|
until (safety > 999 or not stack or stack:get_count() <= 0)
|
||||||
|
|
||||||
|
if safety > 999 then
|
||||||
|
minetest.log("error", "[lavastuff]: Something went wrong with drop cooking")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user