From 12d5ca2f48694c990658d401e5f68d281f260aee Mon Sep 17 00:00:00 2001
From: Auke Kok <sofar@foo-projects.org>
Date: Mon, 25 Jan 2016 22:27:15 -0800
Subject: [PATCH] Allow the on_blast API to pass an itemstack.

If the node is special and has an on_blast() handler, we need
to call it instead of getting node drops manually. However, we
do want to know if drops should be added for the special nodes,
so we modify the on_blast() handler code to allow the nodedef
handlers to pass back itemstacks. This could be used by e.g.
the doors mod to drop door items after a blast.

Since this API is documented in lua_api.txt, a separate PR will
be incoming to update the on_blast() documentation.
---
 mods/tnt/init.lua | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mods/tnt/init.lua b/mods/tnt/init.lua
index 981cc9ee..6b16ab7e 100644
--- a/mods/tnt/init.lua
+++ b/mods/tnt/init.lua
@@ -93,7 +93,12 @@ local function destroy(drops, pos, cid)
 	end
 	local def = cid_data[cid]
 	if def and def.on_blast then
-		def.on_blast(vector.new(pos), 1)
+		local node_drops = def.on_blast(vector.new(pos), 1)
+		if node_drops then
+			for _, item in ipairs(node_drops) do
+				add_drop(drops, item)
+			end
+		end
 		return
 	end
 	if def and def.flammable then
-- 
GitLab