We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Minecraft commands

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

Minecraft's commands are various functions which allow the player or the game to query or modify the world in some way. The game allows the invocation of functions through the chat, via "command blocks", or as executables ("datapacks"), the lattermost of which is the more powerful standard.

Commands

Running a command in the chat requires that the first character is a forward slash. In command blocks and datapacks, the forward slash is optional, however each command must be separated with a newline in the latter. The immediate next word is the command to execute, followed by additional arguments, each separated with a space.

To teleport a random entity to the coordinates (100, 50, 100) facing the nearest separate entity, the command is as such:

# Java edition
teleport <targets> <location> facing entity <facingEntity>
teleport @r 100 50 100 facing entity @n

# Bedrock edition
teleport <victim: target> <destination: x y z> facing <lookAtEntity: target>
teleport @r 100 50 100 facing @n

In general, how a command's arguments are parsed depends on what is passed to the command, evaluated from left to right.

# Java edition
teleport <destination>
teleport <targets> <destination>
teleport <location>
teleport <targets> <location>
teleport <targets> <location> <rotation>
teleport <targets> <location> facing <facingLocation>
teleport <targets> <location> facing entity <facingEntity> [<facingAnchor>]

Targets

The target of a command is either an entity's identifier or a selector. Some commands only accept selectors which return a single entity.

Selector Description
@s The entity invoking the command, or the current target as determined by the execute ... as ... command.
@a All players.
@e All entities.
@p The nearest player from where the command was executed. "Where" can be changed by the execute ... at ... command.
@n The nearest entity from where the command was executed. "Where" can be changed by the execute ... at ... command.
@r A random player.

Selectors that return multiple candidates can be filtered by appending square brackets after the selector in the format of [<argument>=<value>,...].

Command blocks

Command blocks, excluding the "minecart with command block", are blocks within the world that are able to run commands and interact with redstone. Command blocks are categorized as either impulse, chain, or repeating command blocks, executing either when activated, when triggered by a previous command block, or every tick, respectively. Command blocks do not execute if they are not powered by redstone unless they are set to "Always active". When a command block executes, it will attempt to trigger any chain command blocks its top side is directly facing, so long as the chain command block is set to "Unconditional" or the invoker successfully executed its command.

Datapacks

Datapacks contain several "functions" which execute commands linearly. Datapacks can only achieve control flow by executing other functions via the function command, typically through the execute command to allow for conditional execution.

See also