How do I make TNT break only certain blocks?

I'm making a Legend of Zelda custom map and I'm trying to recreate the bombs. I only want the TNT to break cracked stone brick monster egg. How can I do this?

Note: I am using Minecraft 1.12.2


Solution 1:

That's impossible.

The only parameters of an explosion are its size, whether it creates fire and whether it destroys blocks at all (with gamerule).

The best you could do would be to create something with command blocks that mimics an explosion. The algorithm for explosions is complicated, but possible to completely recreate with command blocks. But that's extremely tedious, so you should instead think about what part of it you really need and how close to a real explosion it has to be.

I assume your bomb is just there to activate silver fish blocks in an area. In that case you could for example use /fill destroy on all silverfish blocks in an area. Sadly there isn't a parameter for only destroying a certain block type either, so you would have to check every block individually before you destroy it.

I programmed a solution in 1.13. I don't really want to translate it back to 1.12, because it's not fun, but I can at least post the commands for 1.13:

execute at @e[tag=tempWater2] if block ~ ~-1 ~ infested_stone_bricks run fill ~ ~-1 ~ ~ ~-1 ~ air destroy
execute at @e[type=tnt,nbt={Fuse:1s}] run summon armor_stand ~ ~ ~ {Tags:[tempWater1],Invulnerable:1,NoGravity:1,NoAI:1,Marker:1,Invisible:1}
execute at @e[tag=tempWater1] run setblock ~ ~ ~ water
execute at @e[tag=tempWater2] run setblock ~ ~ ~ air
execute at @e[tag=tempWater2] if block ~ ~-1 ~ infested_stone_bricks run fill ~ ~-1 ~ ~ ~-1 ~ air destroy
[repeat for blocks in the area]
kill @e[tag=tempWater2]
tag @e[tag=tempWater1] add tempWater2