1
0
mirror of https://codeberg.org/tenplus1/mobs_monster.git synced 2024-12-23 01:10:26 +01:00

refactor lava pick dig function

This commit is contained in:
tenplus1 2024-06-28 11:31:26 +01:00
parent 50039fe67d
commit 4ab678d7ec

View File

@ -138,19 +138,13 @@ local old_handle_node_drops = minetest.handle_node_drops
function minetest.handle_node_drops(pos, drops, digger) function minetest.handle_node_drops(pos, drops, digger)
-- are we the player holding a Lava Pick? -- are we a player using the lava pick?
if not digger if digger and digger:get_wielded_item():get_name() == ("mobs:pick_lava") then
or (digger and digger:get_wielded_item():get_name() ~= ("mobs:pick_lava")) then
return old_handle_node_drops(pos, drops, digger)
end
-- reset new smelted drops
local hot_drops = {} local hot_drops = {}
-- loop through current node drops
for _, drop in ipairs(drops) do for _, drop in ipairs(drops) do
-- get cooked output of current drops
local stack = ItemStack(drop) local stack = ItemStack(drop)
while not stack:is_empty() do while not stack:is_empty() do
@ -177,7 +171,10 @@ function minetest.handle_node_drops(pos, drops, digger)
end end
end end
return old_handle_node_drops(pos, hot_drops, digger) drops = hot_drops -- replace normal drops with cooked versions
end
return old_handle_node_drops(pos, drops, digger)
end end
minetest.register_tool(":mobs:pick_lava", { minetest.register_tool(":mobs:pick_lava", {