0

This question is similar to How can I randomly power one of several wires in Minecraft?, but uses command blocks and only 3 outputs.

I'm making a Minecraft server and it has three different hubs that one can spawn in when they join the server. Each hub is identical. When a player joins a the server, they spawn in a 1x2x1 box. This box has a pressure plate on the bottom. When the pressure plate is triggered, I want to be able to randomly select one of three hubs to teleport to. Is it possible to do this through command blocks? Or will I need to make a redstone device?

0

2 Answers 2

1

Summon an armor stands at the spawn point of each of the hubs like this:

/summon armor_stand ~ ~ ~ {Invisible:1,Marker:1,NoGravity:1,Tags:["hub"]}

Then just put this command into the command block under the pressure plate:

tp @p @r[type=armor_stand,tag=hub]

This teleports the player to a random one of these invisible armor stands.

10
  • Wow, a brillant loophole. +1 for thinking outside of the box.
    – rappatic
    Commented Nov 4, 2017 at 11:51
  • Actually, this is the standard way to do that. Commented Nov 4, 2017 at 11:55
  • Oh. Still. A good solution.
    – rappatic
    Commented Nov 4, 2017 at 12:18
  • Yep, the best. That's why people use it. :D Commented Nov 4, 2017 at 12:25
  • Oh, wait, now that I've built it, my command block can't find the armor stands.
    – rappatic
    Commented Nov 4, 2017 at 12:26
0

You need to make 3 armorstands with common tag (e.g "hub"), and place each of them to certain hub.

/scoreboard players tag @p[tag=!player,x=*,y=*,z=*,dx=0] add player
/execute @r[tag=hub,c=1] ~ ~ ~ /teleport @a[tag=player,c=1]
/scoreboard players tag @p[tag=player] remove player

* - coordinates of your box

1
  • This doesn't work. The first command selects no entity at all. The second command would only select players with that tag and the second half of the command doesn't work because of a bug. Commented Nov 4, 2017 at 11:51

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