Minecraft – Need help with /spreadplayers command

minecraft-commandsminecraft-java-edition

So, I am making a mini game and I want it to put all of the players in one of the five maps that they have selected. I put bedrock walls about 20 blocks high all around the map, and barriers on the ceiling. However, whenever I do a test run, I am put on the barrier roof above the map. How to I make it so that it will put them under the roof? This is the command I am using, spreadplayers -35 -14 10 11 false @a[team=Game]. Thanks for any answers!

Best Answer

This is by design, unfortunately; spreadplayers will place players on the highest block on the x/z coordinate it picked.

There is a decent workaround I can think of though: right after the game finishing spreading players, teleport all players 3 blocks or so down (with resistance 5 to stop fall damage). So your command set would look something like this:

spreadplayers -35 -14 10 11 false @a[team=Game]
effect @a[team=Game] minecraft:resistance 60 4
tp @a[team=Game] ~ ~-3 ~

This will spread players, give them resistance 5 for 60 seconds, and teleport them below the barrier allowing them to fall below it. There are some edge cases where this will not work though: for example, your players might end up in a lava lake or an ocean, since this set does not check to see that the block below the player is solid, so keep that in mind.