Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 https://forum.minetest.net/viewtopic.php?pid=111868#p111868.
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.