3

Since we can use ^ ^ ^ for relative coordinates with 1.13 like

/execute as Asaf31214 run summon lightning_bolt ^ ^ ^10

(Summons a lightning at 10 blocks from me to the direction I look. By the way, first part is how many blocks to left, second is up and third is how far from you, if you see this function for first time. It is just like cylindrical coordinates at science.)

I tried to write a command that throws a TNT out of me to the direction i want. It was supposed to be:

/summon tnt ^ ^1 ^10 //1 block up and 10 block forward// {Fuse:50,Motion[^0,^1,^10]} 

if I don't use ^ it will throw the TNT to constant x direction. But it gives an error if I use it with new ^ coordinate system.

Can you explain me how to do this? I guess this coordinate system isn't fully useful yet since it is brand new, and this can be impossible for now.

2

Just like you can't use relative coordinates with ~ in NBT, you also can't use relative coordinates with ^. What you can do instead is getting both your and the TNT's position and subtracting it to get a momentum.

For the position, you can use the NBT tag "Pos", because that can be read with data get. The rest is pretty straightforward, just putting Pos NBT into scoreboards, applying an operation to it and putting it back into NBT, this time Motion.

Preparation:

scoreboard objectives add x dummy
scoreboard objectives add y dummy
scoreboard objectives add z dummy

When you want to activate it:

execute as @p at @s run summon tnt ^ ^ ^1 {Fuse:80,Tags:["toMove"]}
execute as @e[type=tnt,tag=toMove] store result score @s x run data get entity @s Pos[0] 10
execute as @e[type=tnt,tag=toMove] store result score @s y run data get entity @s Pos[1] 10
execute as @e[type=tnt,tag=toMove] store result score @s z run data get entity @s Pos[2] 10
execute as @p store result score @s x run data get entity @s Pos[0] 10
execute as @p store result score @s y run data get entity @s Pos[1] 10
execute as @p store result score @s z run data get entity @s Pos[2] 10
scoreboard players operation @e[type=tnt,tag=toMove] x -= @p x
scoreboard players operation @e[type=tnt,tag=toMove] y -= @p y
scoreboard players operation @e[type=tnt,tag=toMove] z -= @p z
execute as @e[type=tnt,tag=toMove] store result entity @s Motion[0] double 0.1 run scoreboard players get @s x
execute as @e[type=tnt,tag=toMove] store result entity @s Motion[1] double 0.1 run scoreboard players get @s y
execute as @e[type=tnt,tag=toMove] store result entity @s Motion[2] double 0.1 run scoreboard players get @s z

This works for multiple TNTs at once, but not yet for multiple players. If you want to use it in multiplayer, you have to replace @p with your selector and probably also use tags for them.

For a way that works with multiple entities at once, see here.

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.