2

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?

1 Answer 1

2

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.

1
  • got the answer half way through reading your correction of me! great explanation - thank you very much
    – Xav
    Jul 19, 2018 at 17:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .