How to make a datapack in Minecraft
A datapack is just two things done right: a pack.mcmeta file and a .mcfunction in the correct folder. Get the nesting exact, run /reload and call it with /function welcome:hello. No mods, no plugins.
The single most common failure is the path. Your function must live at welcome/data/welcome/function/hello.mcfunction. On 1.21+ the folder is function (singular); on 1.20.x and earlier it was functions. Pick the one that matches your pack_format.
To run code on load, add data/minecraft/tags/function/load.json with { "values": ["welcome:hello"] }. Use tags/function/tick.json for code that runs every tick. Validate the JSON before /reload or the whole pack silently fails.
Quick answers
+What pack_format should I use?
+Why does /reload say my datapack is invalid?
+Do commands inside .mcfunction need a slash?
+What is the namespace in /function welcome:hello?
+How do I make it run automatically?
+Where do datapacks go on a server?
+Why does it work as a folder but break as a .zip?
+My pack loads but the function does nothing. Why?
+Can one datapack hold more than one function?
+Does pack_format change for resource packs?
+How do I run a function on a delay or repeat?
Mistakes that silently break a pack
Most failed packs are not bugs, they are typos in a path or a stray character. Check these before you blame the code:
- Editor saved the file as
hello.mcfunction.txt. Turn on file extensions in your OS and remove the extra.txt. The game only reads.mcfunction. - Comma after the last value in
pack.mcmeta. JSON does not allow a trailing comma, and one extra comma marks the whole pack incompatible. - Wrong folder name on 1.21+. It is
functionandtags/function, both singular. The pluralfunctionsonly worked through 1.20.x. - Spaces or capitals in the namespace. Use lowercase letters, numbers, and underscores only, so
welcomenotWelcome Pack.
After any edit, /reload reapplies the pack without leaving the world. Watch the chat line: Reloading! followed by no error means it parsed. If a function still does nothing, run it directly with /function welcome:hello to separate a broken tag from a broken command. To confirm a pack is active at any time, run /datapack list and look for it under the enabled list.
Blocks and items in this guide
All 2 of these are named in the guide above, starting with Fishing Rod. Look them up in the item database.