Minecraft – Primed TNT on summoned mobs

minecraft-commandsminecraft-java-edition

I want to be able to summon a baby zombie that has a TNT block on its head.
The command I have so far is

/summon Zombie ~ ~1 ~ {IsVillager:0,IsBaby:1,Equipment:[{},{},{},{},     {id:tnt,Count:1}],DropChances:[0.085F,0.085F,0.085F,0.085F,0.0F],Attributes: [{Name:generic.maxHealth,Base:8},{Name:generic.attackDamage,Base:0}]}

However, is there any way to prime that TNT? Im guessing that this would not have anything to do with setting a block over the zombies head, but I do want that for aesthetic value — and to let the player know the zombie is probably going to blow up.

When doing a little research on the subject before coming here, I came across summoning the TNT at the zombies with a fuse of 0 (zero). For me I don't think that this would work, because the TNT would still not stay with/on the zombie, and would just blow up where it was summoned (killing the zombie in the process most likely. Perhaps there is a way to summon the primedTNT when the baby (summoned with the command above) came with one block of the player? If so this also needs to instantly kill the zombie. Any ideas are welcome.

Best Answer

You can't ignite the TNT in the Zombie's head slot, but you can use the Passengers tag to summon the Zombie with PrimedTnt riding it.

Example:

/summon Zombie ~ ~ ~5 {Passengers:[{id:"PrimedTnt", tag:{Fuse:100}}]}  

Since the Passengers tag is only really a flag that the /summon command looks for, /entitydata and similar commands won't be able to place a PrimedTnt on the Zombie. This means that if you want a PrimedTnt entity on the Zombie, the only real practical solution is to summon him with the TNT.

If you want a proximity trigger, you could summon a PrimedTnt with a fuse time of 0 at Zombies near Players.

Example:

/execute @e[type=Player] ~ ~ ~ execute @e[type=Zombie,r=1]  ~ ~ ~ summon PrimedTnt ~ ~ ~ {Fuse:0}  

We use @e[type=Player] instead of @a to avoid targeting dead players: we likely don't want a Zombie to explode because it's trying to walk over a corpse.