Skip to content

Commit

Permalink
Add tnt compatibility - drop the item in the anvil, remove the entity (
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxionary authored Nov 16, 2023
1 parent 2fe0120 commit cafef4e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ minetest.register_entity("anvil:item", {
end
return ""
end,
on_blast = function()
return false, false, {}
end,
})

local remove_item = function(pos, node)
Expand Down Expand Up @@ -473,6 +476,20 @@ minetest.register_node("anvil:anvil", {
puncher:set_wielded_item(wielded)
end,
is_ground_content = false,

on_blast = function(pos, intensity)
local drops = {"anvil:anvil"}
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local input = inv:get_stack("input", 1)
if not input:is_empty() then
drops[2] = input:to_string()
end
remove_item(pos)
minetest.remove_node(pos)

return drops
end,
})

-- automatically restore entities lost due to /clearobjects or similar
Expand Down

0 comments on commit cafef4e

Please sign in to comment.