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

Minecraft Commands (often represented by the .mcfunction file extension in Datapacks) is an unintentionally Turing-complete esoteric scripting language embedded within the sandbox game Minecraft.

While originally designed for simple server administration and debugging, subsequent game updates expanded its syntax to the point where it can manipulate raw data structures, effectively turning the 3D game environment into a low-level CPU and memory buffer.

Computational features

Variables and Data Storage

The language completely lacks native variables. Developers cannot declare standard primitive types or structures. Instead, data persistence must be achieved through heavy abuse of game-specific state managers:

  • Scoreboards: Used to simulate signed 32-bit integer registers bound to dummy or virtual player profiles.
  • NBT Storage: A hierarchical data structure embedded in the game world used as a primitive raw memory block, often requiring data manipulation via item transfers or block updates.

Control Flow and Loops

There are no built-in looping constructs such as for or while. To achieve iteration, the language relies entirely on implicit self-referential recursion. An .mcfunction script must trigger itself conditionally through the game's execution engine (/execute), continuing until a scoreboard condition breaks the recursion chain.

Examples

Hello World

Using the raw text parsing engine to fetch and output data directly:

tellraw @a {"text":"Hello, World!"}

Infinite Loop via Recursion

Inside a file named loop.mcfunction:

# Print a message
tellraw @a {"text":"Looping..."}

# Call itself unconditionally to create an infinite loop
function custom:loop

String Concatenation and Functional Text Output

The language allows concatenating strings safely into a single memory register (NBT Storage) using the append string syntax. This approach is highly efficient for debugging because the combined output retains its embedded data structures—such as click events and functional triggers—even when printed directly to the chat interface.

Inside a file named concat_debug.mcfunction:

# Step 1: Initialize text fragments with embedded click actions in NBT storage
data modify storage esolang:debug Part1 set value '{"text":"[Click Here to Spawn] ","color":"green"}'
data modify storage esolang:debug Part2 set value '{"text":"[Warp to Lobby]","color":"blue","clickEvent":{"action":"run_command","value":"/spawn"}}'

# Step 2: Dynamically concatenate Part2 to the end of Part1 safely inside the storage
data modify storage esolang:debug Result set value from storage esolang:debug Part1
data modify storage esolang:debug Result append string storage esolang:debug Part2

# Step 3: Print the concatenated functional string directly to the chat log for testing
tellraw @a {"storage":"esolang:debug","path":"Result"}

See also