1
0
mirror of https://codeberg.org/tenplus1/mobs_monster.git synced 2024-12-22 17:00: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)
-- are we the player holding a Lava Pick?
if not digger
or (digger and digger:get_wielded_item():get_name() ~= ("mobs:pick_lava")) then
return old_handle_node_drops(pos, drops, digger)
end
-- are we a player using the lava pick?
if digger and digger:get_wielded_item():get_name() == ("mobs:pick_lava") then
-- reset new smelted drops
local hot_drops = {}
-- loop through current node drops
for _, drop in ipairs(drops) do
-- get cooked output of current drops
local stack = ItemStack(drop)
while not stack:is_empty() do
@ -177,7 +171,10 @@ function minetest.handle_node_drops(pos, drops, digger)
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
minetest.register_tool(":mobs:pick_lava", {