PilzAdam/TNT — pull request #1 by Wuzzy2 (2013-09-24 21:45:00+00:00)
Title: Add support for on_blast callback

on_blast is a nice little callback for nodes to tell them that an explosion happened close to them. Look it up in the documentation.
It is not used in the engine atm, it is intended to be used by mods.

The current version of TNT blindly removes anything, not really taking into account the properties of the node.
This pull request adds support for the callback “on_blast”. Instead of directly removing the node, first we check wheather the node defines the function “on_blast”. If yes, we don’t remove the node and call this function instead. Also there will be no item drop caused by TNT. It is completely the “responsibility” of the node then to handle the explosion. If the on_blast is nil, we do the default behaviour: removing the node and dropping items (or not).

I recently changed the bedrock mod to use on_blast. Use the bedrock mod along with this code if you wish to test. See .

This pull request also adds on_blast on tnt:tnt and tnt:tnt_burning themselves. This does away with the awkward direct checking like “Are you a TNT? Yes? Then explode!”. This change makes the TNT mod more general purpose, so any other mod that involves explosive just has to call on_blast (if it’s not nil), not even knowing that the node is tnt:tnt and letting the tnt mod do the rest. :-)

Currently, the itensity is not taken into account, the TNT simply explodes always. I assume that TNT is very sensitive to explosions of any kind.