I want to tp an entity (an armor_stand named "note" exactly) to a random position in axis X and Y, how can I do this ?

/spreadplayers only teleport random entities on axis X and Z, but it's not what I want.

I'm on 1.16 last snapshot (20w22a).

  • You should be able to still use /spreadplayers on it, but somewhere else and then copy its Z coordinate to its Y coordinate after doing some calculations on it. I'll test some things later and write an answer then. Jun 4 '20 at 6:44
  • Oh yeah that's a great idea
    – Ayfri
    Jun 4 '20 at 11:12
  • After tests, I can't use that, my platform where I want the armor_stands is at 70 of height in a void world, so if I put the Z coordinates value to the Y coordinates values, Z must be around 70, but my platform is not around Z 70
    – Ayfri
    Jun 4 '20 at 12:03

You could randomly generate 2 numbers with a range of your choice and modify the armor stand's x and y position to that number if there is enough space at that location. You can do random number generation with the following video

and modify the armor stand's location with mcstacker's /data generation https://mcstacker.net/ command example

/data modify entity 'armor stand selector goes here' 'directory to x and y pos goes here' 'after that i cant remember the syntax after that but you can replace the nbt with scores'

as well you can do

/execute as 'armor stand selector' at @s store result entity @s 'directory to x and y pos goes here' 1 run 'scoreboard get command'

this doesnt work with players if you plan to use that method in the future. To make it work with players you would have to teleport the player to a armor stand or aec with random cords using this method. I hope this helped.

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.