0

I’m making an adventure mode map. I want tnt to be part of it to deal damage to mobs but I don’t want it to destroy terrain. How do I do this?

1

1 Answer 1

2

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 after run 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.

3
  • This looks like Java edition, or am I wrong? Commented Oct 24, 2021 at 3:11
  • i actually didn't notice the Bedrock tag! my answer is, in fact, for Java, and thus won't work since you can't view or edit NBT data on Bedrock. i'll look into it and see if i can find an answer that fits!
    – xTerrene
    Commented Oct 25, 2021 at 10:47
  • after looking some info up and trying to make some workarounds, i didn't find anything good. sorry i couldn't help after all! your best bet would be to use execute to detect for a change in blocks and clone the piece of terrain from a template area containing it; however, it will still likely drop items.
    – xTerrene
    Commented Oct 25, 2021 at 11:07

Not the answer you're looking for? Browse other questions tagged .