- 20,277 views, 29 today
775
This series of tutorials will teach you how to create your very own data packs, assuming you know absolutely nothing about commands. Although data packs could just contain files that replace built-in assets like resource packs, these posts will focus on adding new features and mechanics to the game. In every part I assume you've read the previous parts.
This post flies through the first five blog posts at an incredibly high speed. If you know your way around computers, JSON, common minecraft commands and want to learn by example, this post is for you. If you prefer a more guided tutorial or get curious about the detailed reasoning behind these instructions, refer to the individual parts, starting here.
Let's get started with a datapack that allows us to quickly switch between creative and spectator!
By typing a command in chat, you're giving minecraft direct instructions to do something for you. Functions are files that consist of a bunch of commands. Tags are groups that can consist of functions, blocks, entities, items and fluids. They are represented by files and any datapack can extend a tag defined elsewhere. Data packs are bundles of functions, but also loot tables, recipes and structures. Players can simply drop a data pack into their world and start using it, they won't have to mess with the individual files within the data pack.
Data packs are not mods or plug-ins. They are a bit easier to create, but are more limited.
Now run the /reload command in your minecraft world followed by /datapack list. Your first datapack should show up, hover over the entry of the data pack to see the description you specified. The description can be any Minecraft JSON text component and visit this page for the latest pack_format number.
During this tutorial we'll look at multiple other JSON files with references to wiki pages. These external pages use icons to indicate the JSON type, use this page for information on the meaning behind these icons.
Creating your first function
Create a folder named "data" and create another folder inside. It's name should be something you own, like your username. The folder represents your namespace and should be globally unique, which is only possible by using a name you own. Note that you must replace "<namespace>" with the name of this folder in any of the snippets below.
Create a folder named "functions" inside that, with another folder inside. This last folder should be used to uniquely identify your functions across all data packs created by you. An abbreviation of the data pack name should be enough, so call it "crea-util". Now create a toggle-gamemode.mcfunction file with the following contents:
It should be located at:
At the first line, the player is given a tag if in spectator mode. If we were to change the gamemode immediately, it would be changed back right away on the second line. The second and third lines swap gamemodes and the fourth line cleans up the mess we made on the first line.
Now run /reload followed by /function <namespace>:crea-util/toggle-gamemode. As long as you were in creative or spectator, it should have toggled your gamemode.
Go back to the data folder. Alongside your namespace folder, create a new folder named "minecraft". Create a folder named "tags" inside that, with another folder named "functions" inside. Now create a load.json file:
Lastly, create a uninstall.mcfunction file with the following contents:
Subscribe if you want to get notified of new posts.
This post flies through the first five blog posts at an incredibly high speed. If you know your way around computers, JSON, common minecraft commands and want to learn by example, this post is for you. If you prefer a more guided tutorial or get curious about the detailed reasoning behind these instructions, refer to the individual parts, starting here.
Let's get started with a datapack that allows us to quickly switch between creative and spectator!
But first, what are functions, tags and data packs?
By typing a command in chat, you're giving minecraft direct instructions to do something for you. Functions are files that consist of a bunch of commands. Tags are groups that can consist of functions, blocks, entities, items and fluids. They are represented by files and any datapack can extend a tag defined elsewhere. Data packs are bundles of functions, but also loot tables, recipes and structures. Players can simply drop a data pack into their world and start using it, they won't have to mess with the individual files within the data pack.Data packs are not mods or plug-ins. They are a bit easier to create, but are more limited.
Getting an editor and showing the logs
Download Notepad++, which is an editor that gives suggestions based on previously typed words. Very useful for referencing things you've created earlier by name in later tutorials. In the Minecraft Launcher, click Settings and tick the checkbox that says "Open output log when Minecraft: Java Edition starts". If you now launch the game, you see a second window that will list errors in function files which helps during debugging (the process of fixing bugs). Those are the same errors you would otherwise see in chat if you were to type in a broken command like "/gamemode epic".Creating a data pack
Open the datapacks folder of a world by using the Minecraft client (Edit > Open World Folder > datapacks folder) or navigate to %APPDATA%/.minecraft/saves/<your world>/datapacks. Create a new folder and call it "Creative Utilities". Go inside the folder and create a pack.mcmeta file.{
"pack": {
"pack_format": 11,
"description": "put some text here"
}
}
Now run the /reload command in your minecraft world followed by /datapack list. Your first datapack should show up, hover over the entry of the data pack to see the description you specified. The description can be any Minecraft JSON text component and visit this page for the latest pack_format number.
During this tutorial we'll look at multiple other JSON files with references to wiki pages. These external pages use icons to indicate the JSON type, use this page for information on the meaning behind these icons.
Creating your first function
Create a folder named "data" and create another folder inside. It's name should be something you own, like your username. The folder represents your namespace and should be globally unique, which is only possible by using a name you own. Note that you must replace "<namespace>" with the name of this folder in any of the snippets below.Create a folder named "functions" inside that, with another folder inside. This last folder should be used to uniquely identify your functions across all data packs created by you. An abbreviation of the data pack name should be enough, so call it "crea-util". Now create a toggle-gamemode.mcfunction file with the following contents:
tag @s[gamemode=spectator] add tut_cu_go_creative
gamemode spectator @s[gamemode=creative]
gamemode creative @s[tag=tut_cu_go_creative]
tag @s[tag=tut_cu_go_creative] remove tut_cu_go_creativef
It should be located at:
.minecraft/saves/<world_name>/datapacks/Creative Utilities/data/<namespace>/functions/crea-util/toggle-gamemode.mcfunction
At the first line, the player is given a tag if in spectator mode. If we were to change the gamemode immediately, it would be changed back right away on the second line. The second and third lines swap gamemodes and the fourth line cleans up the mess we made on the first line.
Now run /reload followed by /function <namespace>:crea-util/toggle-gamemode. As long as you were in creative or spectator, it should have toggled your gamemode.
Hooking into Minecraft
There are two built-in tags: minecraft:load and minecraft:tick. By registering our function into those tags, we can have minecraft automatically run our commands instead of making the players type /function commands. The functions inside the minecraft:tick tag run 20 times a second.Go back to the data folder. Alongside your namespace folder, create a new folder named "minecraft". Create a folder named "tags" inside that, with another folder named "functions" inside. Now create a load.json file:
{
"values": [
"<namespace>:crea-util/load"
]
}
and a tick.json file:{
"values": [
"<namespace>:crea-util/tick"
]
}
The file names match the minecraft:load and minecraft:tick tags. The listed values inside match function files we still have to create. The exact JSON structure can be found here. Go back to the data folder again and into your <namespace>/functions/crea-util folder. Create a new load.mcfunction file with these contents:tellraw @a {"text":"Hello World!","color":"yellow","extra":[{"text":"\nThe Creative Utilities datapack is created by <your username>","color":"aqua"},{"text":"\n Run /function <namespace>:crea-util/uninstall to uninstall.","color":"gray"}]}
Usually you use the load function to setup your datapack. The tellraw command uses JSON to describe text, see this page for the full text component structure. Then create another file named tick.mcfunction with these contents:execute as @a[x_rotation=-90] at @s run function <namespace>:crea-util/toggle-gamemode
execute as @a[x_rotation=-90] at @s run tp @s ~ ~ ~ ~ 0
The first line calls the toggle-gamemode function when you look up, the second line rotates you back to a horizontal position. Now run the /reload command. A message should be printed to chat and because the commands above are run every tick, you should be able to look up any time to switch gamemodes.Lastly, create a uninstall.mcfunction file with the following contents:
tellraw @a {"text":"Successfully uninstalled Creative Utilities!","color":"aqua"}
datapack disable "file/Creative Utilities"
datapack disable "file/Creative Utilities.zip"
Although uninstall functions aren't an official thing, I recommend creating them to clean up any mess your datapack made in the load function. If you do provide an uninstall function, make sure to tell the players on load that they should use a /function command to do an uninstall before removing the data pack.Challenge Yourself
If you followed this tutorial without looking at the file contents, you probably have no idea what the commands do or why it works. Don't worry though, that's the nature of a quickstart guide. If you know a little about commands, maybe you can try adding extra features to the datapack. Regardless, try to understand what everything in the data pack means. Play around and see how modifications affect its behaviour. Maybe even search for information on parts you don't understand.Awesome! What's next?
If this quickstart guide left you with a lot of questions, feel free to have a look at the five individual parts, starting here. If you're ready to continue, have a look at the Quality Control section that I left out in part 4. Part 6 will be about target selectors, which are the components starting with @ in the commands above and allow you to dynamically select players and other entities. Examples of relative coordinates are the squigly lines (~) in the tick function.Subscribe if you want to get notified of new posts.
Tags |
2 Update Logs
Added a section about a recommended editor and opening the log window : by Bertiecrafter 07/15/2020 12:00:50 pmJul 15th, 2020
See title.
This is also to match the new information in blog #3.
This is also to match the new information in blog #3.
LOAD MORE LOGS
tools/tracking
4536092
6
function-data-packs-for-dummies-1-4-quickstart-create-your-first-datapack
Create an account or sign in to comment.
So in short, all functions are completely implemented by you. They do nothing you don't tell them to do. So do whatever you want in the uninstall function, but it will most likely consist of cleaning stuff up. How to "reinstall" will depend on what you did during the uninstall.
thanks for the tutorials and I'm sorry for taking up so much of your time today