A comprehensive reference for Minecraft Java Edition (1.20.x) commands.
| Selector | Description |
|---|---|
@p |
Nearest player |
@r |
Random player |
@a |
All players |
@e |
All entities (includes mobs, items, etc.) |
@s |
The entity executing the command (Self) |
| Argument | Example | Description |
|---|---|---|
type |
@e[type=skeleton] |
Selects entities of a specific type |
distance |
@a[distance=..10] |
Selects within a radius (10 blocks) |
limit |
@e[limit=1] |
Limits the number of targets selected |
sort |
@a[sort=nearest] |
Sorts selection (nearest, furthest, random, arbitrary) |
gamemode |
@a[gamemode=creative] |
Selects players in a specific gamemode |
level |
@a[level=30..] |
Selects players with XP level 30 or higher |
Used to teleport entities to specific locations or other entities.
# Teleport yourself to coordinates
/tp @s 100 64 -200
# Teleport yourself to another player
/tp @s PlayerName
# Teleport a specific player to you
/tp PlayerName @s
# Teleport relative to current position (~ is relative)
/tp @s ~ ~10 ~ (Moves 10 blocks up)
# Teleport with rotation (yaw pitch)
/tp @s ~ ~ ~ 90 0 (Faces South)
Changes the player's game mode.
# Survival Mode
/gamemode survival
# Creative Mode
/gamemode creative
# Adventure Mode
/gamemode adventure
# Spectator Mode
/gamemode spectator
# Apply to other players
/gamemode creative @a[distance=..20]
Gives items to players.
# Give a diamond sword
/give @s diamond_sword
# Give 64 stone
/give @s stone 64
# Give item with NBT data (Unbreakable diamond pickaxe)
/give @s diamond_pickaxe{Unbreakable:1b}
Adds or removes experience points/levels.
# Add 5 levels
/xp add @s 5 levels
# Add 100 points
/xp add @s 100 points
# Query current level
/xp query @s levels
Sets or queries the world time.
# Set to day (1000 ticks)
/time set day
# Set to night (13000 ticks)
/time set night
# Set to noon (6000 ticks)
/time set noon
# Set to midnight (18000 ticks)
/time set midnight
# Add time (skip forward)
/time add 5000
Changes the weather.
# Clear weather
/weather clear
# Rain
/weather rain
# Thunderstorm
/weather thunder
# Set duration (in seconds)
/weather clear 600
Sets various rules for the world.
| Rule | Description |
|---|---|
keepInventory |
If true, players keep items on death |
doDaylightCycle |
If false, time is frozen |
doMobSpawning |
If false, mobs won't spawn naturally |
mobGriefing |
If false, creepers/endermen won't destroy blocks |
doWeatherCycle |
If false, weather never changes |
commandBlockOutput |
If false, command blocks don't spam chat |
# Enable keep inventory
/gamerule keepInventory true
# Disable phantom spawning
/gamerule doInsomnia false
Manages status effects on entities.
# Give Speed II for 30 seconds
/effect give @s speed 30 1
# Give Night Vision infinitely (hide particles)
/effect give @s night_vision infinite 0 true
# Clear all effects
/effect clear @s
Fills a region with a specific block.
# Fill a 10x10x10 cube with stone
/fill ~ ~ ~ ~10 ~10 ~10 stone
# Replace only water with air (drain)
/fill ~-5 ~-5 ~-5 ~5 ~5 ~5 air replace water
# Create a hollow box of glass
/fill ~ ~ ~ ~5 ~5 ~5 glass outline
Changes a single block.
# Place a torch at current location
/setblock ~ ~ ~ torch
# Destroy the block (drop item) and place stone
/setblock ~ ~-1 ~ stone destroy
Enchants the item currently held.
# Add Sharpness V
/enchant @s sharpness 5
# Add Fortune III
/enchant @s fortune 3
Finds the nearest structure or biome.
# Find nearest village
/locate structure village
# Find nearest cherry grove
/locate biome cherry_grove
Removes entities.
# Kill yourself
/kill @s
# Kill all slimes
/kill @e[type=slime]
# Kill all items on the ground (cleanup)
/kill @e[type=item]
Displays the world seed.
/seed