Minecraft – teleport entity to the block the player is targeting usnig command blocks

minecraft-java-edition

The question is self-explanatory: Can I teleport a certain entity(by using @e[Name=enitiyname]) to the block a certain player(got with @p) targets? Like If I am looking at a block in the distance: can I teleport a PrimedTNT entity at that block?

I don't want something that works on that block, that block and that block only. I want something that is working for every block/player/entity.

Best Answer

The best way I know Is to use /summon Fireball. The player hits the fire charge and if goes flying. As something to it for costom things:

/summon Fireball ~ ~ ~ {ExplosionPower:0,direction:[0.0,0.0,0.0]}

Don't worry about direction; the player can hit it werever, adding a challenge of aiming correctly.change the integer for ExplosionPower to what ever the highst # you need is. To find out, google minecraft [block name] And click on the minecraft forums link. Under the image of the block you will see "Blast resistance" if the resistance is four set the ExplosionPower to something like 5.

To summon at the player, do (in the snapshot and hopefully the next update)

/execute @p ~ ~ ~ 
/summon Fireball ~ ~ ~ {ExplosionPower:0,direction:[0.0,0.0,0.0]}

ALL ONE COMMAND

Links to refer to: planetminecraft and Minecraft Wiki

Hope this helps and if you don't understand go to the above links, they got me a jump start into commands.

Sorry no TNT but if you find a way you can still use ExplosionPower on the primed TNT tag. Also you can modify how long the TNT exists, ex Time=99999 instead of direction, or it will explode opon summoning.