Add tnt compatibility - drop the item in the anvil, remove the entity (#37)

This commit is contained in:
fluxionary 2023-11-16 12:38:05 -08:00 committed by GitHub
parent 2fe012076b
commit cafef4eb9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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