Tnt modifications
it appears i'm a bumbling idiot, and didn't notice the Bedrock tag.
the information below pertains to Java, and will not work on Bedrock due to the inability to view or edit NBT data.
as far as i'm aware, this is borderline impossible to do on Bedrock since you can't test for TNT explosion time, nor summon a Creeper with set explosion time; however, i've decided to keep the information below for preservation's sake in the hopes it may still help people.
there's actually a rather simple way to do this involving some funky command usage.
first, make sure that gamerule mobGriefing
is set to false
. this will prevent mobs from destroying terrain.
next, in a repeating command block, we want to find any TNT that's about to explode, and summon a Creeper at the same spot;
execute as @e[type=tnt,nbt={Fuse:3s}] at @s run summon creeper ~ ~ ~ {ignited:1b,Fuse:2s}
-
execute as @e[type=tnt,nbt={Fuse:3s}] at @s
will use whatever command is afterrun
at the location of a TNT with 3 ticks (3/20ths of a second) left -
summon creeper ~ ~ ~ {ignited:1b,Fuse:2s}
will summon an ignited Creeper with 2 ticks before it explodes
then, in a second repeating, we want to run the command execute as @e[type=tnt,nbt={Fuse:1s}] at @s run kill @s
, which will kill the nearly-about-to-explode TNT before it actually does, leaving the Creeper to do the exploding. because gamerule mobGriefing
is set to false
, you'll have all the damage without any of the terrain damage.