411 REFERENCE · Wikibooks
Minecraft/Commands
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Commands can be executed on any version of Minecraft which has the chat console. To run a command, type a forward slash. There are many commands to learn.
+VariablesHow to selectWhat it is~Inserts the current axis position when used inside a position argument. This can be used so you don't need to know your coordinates, or if a command block is likely not going to be in a set location. You may add a number after it, positive or negative, to add an offset, so ~~-3~ is 3 blocks below, and ~~3~ is 3 blocks above. ~ 3 ~ would be an absolute y=3. ~3~ would not be invalid, however, as there is only an x and y, but not a z.@pThe closest player.@aAll players.@rRandom player.@eAll entities.@sSelf. Note that this does not work on command blocks unless using the /execute command.
The @ selectors also allow finer tuning, like this: @r[r=10,tags=alive] checks for a random player within ten blocks, with the "alive" tag (set with /tag). All of them are:
r: range. Note that this is a spherical radius!
rm: minimum range. Note that this is a spherical radius! Any entity closer than this radius will not be included.
l & lm: Level and minimum level, respectively.
c: count. The maximum number of entities that can be returned.
m: gamemode. Only works on players. Supported values are: creative, survival, adventure, spectator.
name: Checks the name of the entity matches this value.
tags: checks if a tag exists on that entity.
type: checks its identifier matches. The identifier is usually a snake_case (all lowercase, underscores instead of spaces) version of its name.
family: Checks if a entity is part of a particular entity family. Examples include undead, zombie, monster, and inanimate.
x / y / z: If a coordinate matches.
dx / dy / dz: distance from x / y / z. Example, an x of 0 and dx of 5 will only check x=0 to x=5. Set dx to -5 to reverse this, or x to -5 and dx to 10 to check between x=-5 and x=5. If one of these parameters are not set, and are used, a value of 0 is assumed.