How to fix datapacks "Unknown function" error in Minecraft 1.21
1.21 changed the name of the functions directory
Huge thank you to redditor pyrostunts:
The datapack file structure for Minecraft 1.21 Java Edition (OSX) is:
my_datapack/
- pack.mcmeta
- data/
- my_namespace/
- function/
my_function.mcfunction
So if you have a namespace of castle
and a function of build
, you would execute your function with:
/function castle:build
You should see an autocomplete option if your function loaded correctly. If you don't, you can view all loaded datapacks with this command to figure out if it's the datapack or function that's not loading.
/datapacks list
This structure is a departure from Minecraft versions prior to 1.21, where the functions directory was named the plural /functions
.