1

So basically what I want to do is create my own fake explosion to break only certain blocks. The trigger for that fake explosion however is supposed to be an actual TNT explosion in close proximity which I want to not destroy any blocks. I have looked through many similar questions answered but the solutions to these problems were not transferable to my problem.

So in conclusion: I need to check if a TNT was lit and to then trigger my fake explosion right when the TNT explodes. The fake explosion should be the easiest part and I can do that already. Thanks in advance!

0

I think I have the solution you're looking for.

First, run this command to disable mob griefing:

/gamerule mobGriefing false

Then you need to create a scoreboard:

/scoreboard objectives add TntTimer dummy

TntTimer is just what I named it, you can name it anything.


Then you need to put this command in a repeating command block:

execute if entity @e[type=tnt] run scoreboard players add TntTimer TntTimer 1

This will add 1 to the Player TntTimer to the score TntTimer. The first part is the name and you can put anything in, doesn't need to be an actual player.

You will then have another repeating command block with this command:

execute at @e[type=tnt] if score TntTimer TntTimer matches 79 run summon creeper ~ ~ ~ {Invulnerable:1b,ExplosionRadius:4b,Fuse:1,ignited:1b}

This will summon a Creeper that explodes basically immediately. Also, I changed the ExplosionRadius to 4, a tnt is set to 4 but a Creeper has a default of 3.

Then next I would recommend you use a chain command block so you don't have too many 'lose' command blocks, with this command:

execute as @e[type=tnt] if score TntTimer TntTimer matches 79 run kill @s

This command will kill the tnt so it doesn't explode, this will happen basically at the same time as the Creeper explodes.

And the last command to reset the score:

execute if score TntTimer TntTimer matches 79 run scoreboard players set TntTimer TntTimer 0

This will also make it so any tnt that is fused will explode when the first one has reached 79 game ticks. So if I activated a piece of TNT and another one 2 seconds later they would explode at the same time, 4 seconds after the first one was primed.

This is where your command comes in, ether you repeat the execute if score TntTimer TntTimer matches 79 for every one of your commands before you run the last command that resets the score.

Or you could add this command, which also needs to be before the score reset:

execute if score TntTimer TntTimer matches 79 run setblock x y z redstone_block

This will then place a Redstone block next to your command blocks and activate them. This is the easier way so you don't need to test for the score for each of your commands.


This is a screenshot of my setup:

setup

Here is it in action:

https://i.imgur.com/hbHhPRq.gif

3
  • For anyone who had the same problem when trying to recreate this setup: the two chain command blocks have to go on top of the repeating command block that summons the creeper so it doesn't kill the TNT before the creeper spawns and also not reset the scoreboard before the creeper has been spawned. It makes sense but I didnt think about it.
    – CrocDog
    Aug 20 at 18:30
  • I did show it in the image tho... :( Aug 20 at 19:35
  • Also if this was the answer you needed could you mark the answer with the checkmark so it gets marked as Completed. Aug 20 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.