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?
-
2Possible duplicate of How to summon a TNT that doesn't destroy its surroundings? – pppery Jun 30 '22 at 21:17
1 Answers
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 @swill use whatever command is afterrunat the location of a TNT with 3 ticks (3/20ths of a second) leftsummon 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.
-
-
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 Oct 25 '21 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
executeto detect for a change in blocks andclonethe piece of terrain from a template area containing it; however, it will still likely drop items. – xTerrene Oct 25 '21 at 11:07