-
-
Notifications
You must be signed in to change notification settings - Fork 125
cfunction
Mohammad Sarabi edited this page Mar 18, 2025
·
1 revision
The /cfunction
command executes a sequence of Minecraft commands defined in a .mcfunction
, with the same syntax as vanilla datapack functions (except with client-side commands only).
The .mcfunction
files are located in .minecraft\config\clientcommands\functions
. Create a file with a .mcfunction
extension in this directory, like example.mcfunction
, and then write your client-side commands, one command per line, inside this file.
There are special file names that run automatically when the world starts. To learn how to use them, see the cstartup page.
/cfunction <function_name>
- The
function_name
argument specifies the name of the.mcfunction
file to execute (without the.mcfunction
extension).
For example, lets say you want to detect all the entities around you that have armor with thorns enchantments, and glow them in red:
- Create a
thorns.mcfunction
file in.minecraft\config\clientcommands\functions
and open it with a text editor. - Write the command
cglow
three times to detect each level of thorns enchantment like this and save the file:cglow --keep-searching entities @e[nbt={ArmorItems:[{components:{"minecraft:enchantments":{levels:{"minecraft:thorns":1}}}}]}] 1 color red cglow --keep-searching entities @e[nbt={ArmorItems:[{components:{"minecraft:enchantments":{levels:{"minecraft:thorns":2}}}}]}] 1 color red cglow --keep-searching entities @e[nbt={ArmorItems:[{components:{"minecraft:enchantments":{levels:{"minecraft:thorns":3}}}}]}] 1 color red
- Now in the game, use the command
/cfunction thorns
. clientcommands will execute those three commands for you each time you run this command.
Home |
Features |
Usage |
What is RNG |
Earthcomputer