TransWikia.com

Teleport all entities relative to themselves in 1.13

Arqade Asked by Xav on February 25, 2021

In 1.12, I had a command block to summon in minecarts on a single point. I then had another command to spread the minecarts out in a radius of 20 blocks, and a following chain command block to teleport them to the y level 64, because the spreadplayers command teleports entities to the highest solid block. The chained command was simply:

tp @e[type=minecart,r=30] ~ 64 ~

In 1.13, this now teleports all the minecarts to point point. I tried

execute at @e[type=minecart,distance=..30] as @e[type=minecart,distance=..30] run tp @s ~ 64 ~

but this does not work, it has the same effect (Teleporting them all on top of eachother). I also replaced @s with @e[type=minecart,distance=..30] to no avail.
Any solutions here?

One Answer

You're close, but the at @e[type=minecart,distance=..30] as @e[type=minecart,distance=..30] will execute at each minecart position, for each minecart. So each minecart is being teleported to each position in order (e.g: 8 minecarts would be 64 tp's total), all ending up at the last one.

Instead, you should use this:

execute as @e[type=minecart,distance=..30] at @s run tp @s ~ 64 ~

Which makes the minecarts all execute at themselves, to teleport themselves.

Correct answer by SirBenet on February 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP