From 696ca91d56011cf27711aeae548f0aa6d66892bc Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:31:13 -0800 Subject: [PATCH] add tnt compatibility - drop the item in the anvil, remove the entity --- init.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/init.lua b/init.lua index 6ecd9ff..c5ca93b 100644 --- a/init.lua +++ b/init.lua @@ -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