MineToolsminetools.cn · Minecraft Java Tools

Command Syntax Guide

Learn Minecraft commands from scratch: target selectors, relative and local coordinates, item component syntax, execute usage, common errors, and how command syntax differs across versions 1.14 to 26.3.

Command Basics

A command consists of a command name and arguments separated by spaces. For example:

/give @p minecraft:diamond_sword 1

When entering a command in chat, include the leading /; you can omit it in a command block, function file, or server console. The chat box allows up to 256 characters. For longer commands, use a command block (there's a “Command Block” button at the bottom of each tool).

Target Selectors

SelectorMeaning
@pNearest Player
@aAll players
@rA random player
@sThe entity executing the command
@eAll entities
@nThe nearest entity

You can add filters in square brackets, such as @e[type=zombie,distance=..10,limit=1]. You can add filters in square brackets, such as Target Selector tool lets you build selectors visually.

Coordinates

  • Absolute coordinates:100 64 -200, which are the coordinates shown on the F3 screen.
  • Relative coordinates:~ ~1 ~, using the execution position as the origin;~1 means to add 1.
  • Local coordinates:^ ^ ^5, based on the direction you're facing: left, up, and forward, respectively. These can't be mixed with the other coordinate types.

Item Components (1.20.5 and Later)

Item names, enchantments, and other data go in square brackets after the item ID. The format for 1.21.5 and later is:

/give @p diamond_sword[custom_name={text:"神剑",color:"gold"},enchantments={sharpness:5}]

1.20.4 and earlier use NBT:/give @p diamond_sword{display:{Name:'{"text":"神剑","color":"gold"}'},Enchantments:[{id:"minecraft:sharpness",lvl:5s}]}, and this syntax no longer works in 1.20.5 and later.Item Generator The command syntax will automatically match the version selected in the top-right corner.

execute: Changing Execution Context

/execute as @a at @s if block ~ ~-1 ~ minecraft:gold_block run effect give @s speed 1 2

This means: for each player, use their position, and if there's a Block of Gold beneath them, give them Speed.as changes the executor,at changes the position,if / unless checks a condition,run is followed by the command to run. Use the Command Builder to build it step by step.

Common Errors

  • Unknown or Incomplete Command: The command name is misspelled or a required argument is missing.
  • Can Only Select One Entity: A parameter that requires a single target (such as the destination for tp) uses @a / @e; add limit=1。
  • Wrong version: Online tutorials often use syntax for a different game version than yours (for example, NBT vs. components, orkeepInventory and keep_inventory). Select your version in the top-right corner first, then use a command generated on this site.