Minecraft Commands


Here, I will be posting a lot of Tutorials for Minecraft Commands. I will show you, how individual Commands work and what surprising things you can create with them!

Although I will only talk about normal Commands and everything I will talk about will be entirely possible in Commandblocks. If you want to do mor (e.g. Mapmaking), I would highly recommend checking my Datapack Tutorials out (and creating a Datapack).

Disclaimer: currently there are no Tutorials for Datapacks, but there will be!

Minigames

What do I need this for?

This System was developed for anyone, who wants to create Minigames in Minecraft, which need multiple Spawnplatforms on which Players will be distributed randomly.

That being said, you don't have to teleport Players, this will work with any Entity.

Redstone

If you use these Commands with Commandblocks and Redstone, you'll just need a simple Redstone Circut.

You will need 5 chained Commandblocks, the first one of them being a repeating Commandblock(needs Redstone). Next you'll need a Comparator, which activates, when the first Commandblock is successful. This Comparator will make sure, that the Commandblock chain isn't continuously running. When the Comparator deactivates, a Redstone torch will activate, which activates the Reset Command.

That's it! Wasn't that bad, was it?

Commands

Now we come to the fun part! Just make sure, that, when writing the Commands, you already have the Lobby and Spawnplatforms ready.

The first Command is just for detecting, if there are Players in the Lobby. The position of the Lobby will be x1 y1 and z1 and should be in the middle of the Lobby. I'll use distance=5.., because the Lobby 5 Blocks diagonally. Keep in mind that the Distance is spherical!

execute positioned x1 y1 z1 if entity @e[type=player, distance=..5]

In the second Command we give every Player, which doesn't yet have a tag, a tag, so we can easily teleport and select them later.

execute positioned x1 y1 z1 as @e[type=player, distance=..5, tag=!tag] at @s if entity @s run tag @s add tag

Let's move on from the Lobby and position our command in the middle of the Spawnplatforms(x2 y2 z2) and spawn a Marker with the tag "spawnsys_marker". We use distance=7.. to be sure, that we'll check for the marker.

execute positioned x2 y2 z2 unless entity @e[tag=spawnsys_marker, distance=..7] run summon marker ~ ~ ~ {Tags:["spawnsys_marker"]}

The following command is a bit more complicated, because this will be the command, in which we randomly teleport the marker. At first, we will check if there's a Player in the Lobby, if that's the case, the spreadplayers command will be executed at the Spawnplatforms. Spreadplayers needs the x2 and z2 coordinates only, because it always teleports to the highest block, if you don't want that to happen (e.g. You have a Roof), you just tell it to teleport to the highest block, under a certain Y-Level (under y3). After x2 and z2, the Syntax wants us to declare the distance between the teleporting Entities (the marker) and the distance of how far away they will be teleported. Important! The distance in this case is not spherical, unlike the distance in the selector, but a square. Finally we must tell it if teams should be considered and the selector.

execute as @e[tag=spawnsys_marker] at @s positioned x1 y1 z1 if entity @e[tag=tag, distance=..5] run spreadplayers x2 z2 1 5 under y3 false @s

The Second to last Command! The Command first checks, if the marker is ontop of a Spawnplatform(in my case blue_wool). If that is the case, it checks for players in the Lobby and finally teleports 1 player to the marker. Done! Almost...

execute as @e[tag=spawnsys_marker] at @s if block ~ ~-1 ~ blue_wool positioned x1 y1 z1 if entity @e[tag=tag, distance=..5] run tp @e[tag=tag, distance=..5, limit=1] @s

The only thing left, is the Reset, which removes the marker.

kill @e[tag=spawnsys_marker]