How to summon a TNT that doesn't destroy its surroundings?

In the server The Hive, they have a special item called Boom Boxes, and what it essentially does is that they act like normal TNT, but with some custom bits, and can also be thrown. Now I want to try and replicate the Normal type, where it just gives damage to the entity, but not on the blocks.

So I found this, but I have no idea how to do it properly, plus, it is a Java question.

So what I want to try and do is to not summon a mob in the process, activate the TNT regularly, then explode with no debris or damage left behind.

The only thing I thought of is using a repeating command block:

execute @e[type=tnt] ~ ~ ~ setblock ~ ~ ~ water

Then another command where it removes the water, but I don't know how to detect the TNT no longer existing.

I thought of some solution, but it will only work in a certain plot of land and on a flat world, and has other inconsistencies.

fill 50 1 50 -50 3 -50 grass
kill @e[type=item, name=Dirt]

So how can I go about doing this?


Solution 1:

Using a repeating command block and a chain command block like this: First command:

execute @e[type=tnt] ~ ~ ~ summon Creeper ~ ~ ~ minecraft:start_exploding

The second command (in the chain block):

kill @e[type=tnt]

You need to make sure to disable mob griefing by:

/gamerule mobgriefing false

You can set the repeating command block to Needs Redstone and activate it by placing a Redstone block when you need to use the feature.

Solution 2:

When the TNT is about to explode, you need to spawn a creeper with a low fuse at its location, kill the TNT and quickly disable mob griefing. This can be accomplished by setting a scoreboard timer and checking if any creeper entities with a specific tag exist, and if not, enable mobGriefing again. (I have verified this works on Bedrock Edition, with the exact commands amount I said unless you want to implement the scoreboard timer and tags for turning on mobGriefing again.)