How to Use the Function Command in Minecraft
This Minecraft tutorial explains how to use the /function command with screenshots and step-by-step instructions.
You can use the /function command to run a function in Minecraft. This is a great way to chain multiple commands without using a command block. Let's explore how to use this cheat (game command).
Supported Platforms
The /function command is available in the following versions of Minecraft:
Platform | Supported (Version*) |
---|---|
Java Edition (PC/Mac) | Yes (1.12) |
Pocket Edition (PE) | Yes (1.9.0) |
Xbox 360 | No |
Xbox One | Yes (1.9.0) |
PS3 | No |
PS4 | Yes (1.14.0) |
Wii U | No |
Nintendo Switch | Yes (1.9.0) |
Windows 10 Edition | Yes (1.9.0) |
Education Edition | Yes (1.9.0) |
* The version that it was added or removed, if applicable.
NOTE: Pocket Edition (PE), Xbox One, PS4, Nintendo Switch, and Windows 10 Edition are now called Bedrock Edition. We will continue to show them individually for version history.
Requirements
To run game commands in Minecraft, you have to turn cheats on in your world.
Function Command
Where is the Function File Stored in Java Edition?
Each function belongs to a specific saved world.
When storing functions, you must first create a new folder under the data\functions\
folder for the saved world. You can then store your function within this new folder. The filename for the function must have a .mcfunction extension.
For example, you could create a new folder called digminecraft
for the saved world called World1. You would then store the function give_diamond.mcfunction
in this new folder. Depending on your version of Minecraft, this function would be saved under one of the following hidden paths (Note: path may be different on your system):
Path for Windows
C:\Users\<username>\AppData\Roaming\.minecraft\saves\World1\data\functions\digminecraft\give_diamond.mcfunction
Path for Mac
/Users/<username>/Library/Application Support/minecraft/saves/World1/data/functions/digminecraft/give_diamond.mcfunction
You could then run the file called give_diamond.mcfunction
with the following /function command:
/function digminecraft:give_diamond
As you can see, you do not need to enter the .mcfunction extension when using the /function command.
TIP #1: Make sure you are in the correct saved world. Since each function is stored under the data\functions\
folder for a specific saved world, the function can only be run from within that saved world.
TIP #2: Always run the /reload command after saving or changing a function file before using the /function command.
Examples
How to Enter the Command
1. Open the Chat Window
The easiest way to run a command in Minecraft is within the chat window. The game control to open the chat window depends on the version of Minecraft:
- For Java Edition (PC/Mac), press the T key to open the chat window.
- For Pocket Edition (PE), tap on the chat button at the top of the screen.
- For Xbox One, press the D-Pad (right) on the controller.
- For PS4, press the D-Pad (right) on the controller.
- For Nintendo Switch, press the right arrow button on the controller.
- For Windows 10 Edition, press the T key to open the chat window.
- For Education Edition, press the T key to open the chat window.
2. Type the Command
In this example, we will run the function called give_diamond.mcfunction in Minecraft Java Edition (PC/Mac) 1.20 with the following command:
/function digminecraft:give_diamond
Type the command in the chat window. As you are typing, you will see the command appear in the lower left corner of the game window. Press the Enter key to run the command.
Once the cheat has been entered, all commands within the function will be executed.
You will see the message "Executed 1 command(s) from function 'digminecraft:give_diamond'" appear in the lower left corner of the game window to indicate that the function was successfully run.
In this tutorial, the file called give_diamond.mcfunction is very simple and only has the following command inside:
give @p diamond
/
character at the start of each command.If you want to execute multiple commands in a function, just enter each new command on a separate line inside the function file.
For example:
give @p diamond give @p gold_block setblock ~ ~ ~1 tnt 0 replace
Congratulations, you just learned how to use the /function command in Minecraft!
Advertisements