697
The Data Pack Knowledge Book (with Challenges!)school
Let's learn about Function Data Packs
Have you thought about creating a data pack, but have no idea how to start or perhaps you already know how to create basic data packs, but would like to learn more? Fortunately, we took the time to create an extensive blog tutorial series that anyone can start reading. Even if your command knowledge doesn't go beyond /time, /kill and /gamemode, you can still start right this second and create your first datapack today. The more experienced data pack creators can skip ahead the first few posts and see if there is anything that we can teach you or you can correct us on.
More posts will be created in the future and existing posts might be improved. Feedback and questions are welcome in the replies below.
flash_on Quickstart |
If you know your way around computers, JSON, common minecraft commands and want to learn by example, then feel free to take a nose dive with this quickstart tutorial, covering parts 1 to 5 below. Create your first data pack today. |
build The Tools |
Ever wondered how the greatest data packs were made with just "simple commands"? It will all start to make sense after you have discovered all the individual components that can be used during the creation of a data pack. Bertiecrafter will guide you throughout your travels into the world of data packs. |
|
color_lens The Trade |
You have already learned a thing or two about datapacks and commands? Great! You started to wonder how to link them together for more complex functionalities? Even better, because guess what: We've got just the thing for you. Kefaku will help you evolve from a newbie in the world of datapacks to a developer of sophisticated projects. |
|
Resources, Notes & Best Practices
The tutorials provide links to resources whenever they are needed. However, you can use the following list for an overview of these resources, notes and best practices.
Cheat sheet
- Functions are files that consist of multiple commands. Tags are groups of functions.
- Conventions
- Give your data pack a unique namespace (like your own username) and also create a folder inside the functions folder to uniquely identify functions across your own data packs.
- Any kind of tag starts with #, like /function #minecraft:load. Besides minecraft:load, minecraft:tick is another built-in tag that you can register your functions in.
- You should provide an uninstall function to avoid leaving a mess when your datapack gets uninstalled.
- Always put an #As/At comment on the first line of a function to avoid spending hours on debugging. You can split it up into separate #As and #At comments if the location is different from the executing entity location.
- Try to be efficient with checks and avoid duplicates.
- JSON Basics
- Explanation of the JSON/NBT type icons that are used in JSON/NBT structures on the wiki pages
- JSON: Do not add a comma behind the last item of an array or object
- Contents of pack.mcmeta and latest pack_format number
- JSON structure for text components (/tellraw, but also signs, name tags and books)
- JSON for text components: Do not use array notation, always start with an object.
- Target Selectors:
- Any player arguments in commands can have target selectors, which can target non-player entities as well.
- All target selector variables and arguments
- The distance target selector argument needs a range, since an exact distance will never match anything. So use distance=..5 instead of distance=5
- ~x ~y ~z defines a location relative to the coordinates of the execution location, while ^left ^up ^forwards also takes the rotation of the execution location into account.
- Scoreboard:
- The health scoreboard criteria shows up as fancy hearts in the tab list.
- The display name of scoreboard objectives can contain unicode characters (fun symbols), which show up in the display slots.
- All scoreboard criteria
- The scoreboard doesn't allow decimals. Multiply the value by a big number before dividing to see more digits behind the dot.
- Read-only objectives can be modified by first copying the values to a dummy objective using the "operation" subcommand of /scoreboard
- The values of an objective with "trigger" criteria can be modified by /trigger. Since /trigger can be used by non-op players, you can create clickable buttons in chat using /tellraw and then fire functions whenever their score is 1.
- Command Environment:
- By default data pack commands execute as the "server entity" at worldspawn.
- The /execute command can change the context of execution.
- The /execute command has "instructions" that can be chained together as much as you want.
- Order matters in the /execute command.
- Full /execute syntax
- NBT:
- NBT looks like JSON, but distinguishes between more types (with suffixes) and doesn't require quotes around key names.
- JSON within NBT must be surrounded by apostrophes!
- Use /data to edit NBT data.
- Use /execute to store NBT data on the scoreboard for arithmetic operations, before moving it back.
- NBT: Color Picker and Hex to Integer conversion
- NBT: Chunk Format - For all mobs, projectiles, vehicles, falling blocks, block entities and a couple of other things.
- NBT: Player.dat Format - This page describes the NBT format for the "player" entity and all items.
- NBT: UUID generator
- NBT Path syntax
- Check for NBT using the "nbt=" target selector, the "/execute if data" instruction or the "/execute if block xyz <block>[states]{nbt}" instruction.
- You cannot access JSON elements within NBT (for text on signs or in books) using NBT paths, since JSON must always be provided as a string instead of an object.
- JSON Extended:
- Advancements, loot tables, predicates, recipes and dimensions are just JSON files. You just need to know how to read the wiki pages (see JSON Basics).
- Data pack file paths
- Advancement JSON
- Loot Table JSON
- Predicates JSON
- Recipe JSON
- Tags JSON
- Dimensions JSON, Dimension Type JSON and World Generation Components JSON
Create an account or sign in to comment.
139
6
Great tutorial!
7
Thank you :P
6
Cool. Maybe custom game resources such as modelling & textural animation mechanics next time? :)
5
Both of these belong to resource packs. I first need to finish covering the commands area of datapacks, then extend to other technical files like advancements, recipes, structures and all that. In the end, if everything that's closer to the core of datapacks is covered, I might write about resource packs xD
6
cool this is helpful i like it
8
Gotta say, this is an amazing tutorial. I already knew data packs pretty well, but this posts still gave me new knowledge!
3
como me descargo estoooo
3
no lo se
8
it's actually helpful
3
no entiendo nada ;-;
3
GOOGLE TRANSLATE IN ACTION:
ES: Intenta poner toda la página en el traductor de Google: haga clic aquí
EN: Try putting the entire page in Google Translate: Click here
I tried haha
ES: Intenta poner toda la página en el traductor de Google: haga clic aquí
EN: Try putting the entire page in Google Translate: Click here
I tried haha
1
[deleted]
1
translation I do not understand anything ;-;
2
lol porque no escribe en español
1
translation lol because he doesn't write in spanish
2
Interesting...
1
Don't really understand.....😐😐❓❓
05/06/2020 10:42 am
This reply was removed by the poster or a moderator.
1
Well, it's in the title.... Idk what you expected haha
Even though commands are a priority, in a far future the other parts of a datapack will be covered as well.
The tutorial series is meant to teach you about creating data packs, not just create 1 specific complex datapack. If it was just that, a lot of people would struggle to create a different datapack.
There are challenges and a quick start guide though, if you're looking for more hands-on experience.
Even though commands are a priority, in a far future the other parts of a datapack will be covered as well.
The tutorial series is meant to teach you about creating data packs, not just create 1 specific complex datapack. If it was just that, a lot of people would struggle to create a different datapack.
There are challenges and a quick start guide though, if you're looking for more hands-on experience.
1
Is there changeable variables for visibility in, say, water or lava? I was thinking of creating a datapack in anticipation of the Nether update allowing you to swim in lava as you would in water, but that might be too complicated...
2
No, you can't really change graphics settings or modify the block behaviour. However, you can see if a resource pack allows you to make the water a little more opaque (it works for the block textures of water, but idk about the "fog" you see while you swim) or perhaps night vision, fire resistance or water breathing increase visibility in lava? You'd have to just try it.
1
your pack.mcmeta is wrong
{
"pack": {
"description": "Some awesome description",
"pack_format": 5
}
}
If you want to you could link my datapack generator for anyone who just wants to save time at the start, I was going to do a blog on this topic myself but you beat me too it
Check it out and if you think it helpful add it to your blog post
https://www.nbt-data.com/datapack-generator
{
"pack": {
"description": "Some awesome description",
"pack_format": 5
}
}
If you want to you could link my datapack generator for anyone who just wants to save time at the start, I was going to do a blog on this topic myself but you beat me too it
Check it out and if you think it helpful add it to your blog post
https://www.nbt-data.com/datapack-generator
2
Although the structure of pack.mcmeta I posted is not wrong, it uses the wrong pack_format number. At the time of writing, it said that the number was not used and therefore I wrote a "1". I will update the blog with the right number and a minecraft wiki source for up-to-date format numbers.
1
yeah no problem i was just confused i suppose if you want to support older version of minecraft you would change the umber to suit ;)
1
Is it me or did "recipe packs" (that use nothing but recipe files) decrease by A LOT this last month? Whether it's because of this tutorial series or not, I enjoy seeing the higher quality uploads! =)
1
Great series so far. I was having trouble following the info on Gamepedia, but I got everything working up to tutorial 4! What I really am having trouble with is changing loot tables. A cow that drops a diamond might be interesting! Can you add something about loot tables?
I think the problem I'm having is how to get my custom loot table (namespaced) to replace the vanilla one. I can unload the vanilla datapack and when I kill a cow it drops nothing. Not sure how I can get my cow.json to become active.
Thanks.
I think the problem I'm having is how to get my custom loot table (namespaced) to replace the vanilla one. I can unload the vanilla datapack and when I kill a cow it drops nothing. Not sure how I can get my cow.json to become active.
Thanks.
2
You could replace the vanilla loot table. So make the file path and filename perfectly match the vanilla minecraft one, causing it to overwrite it.
You can go to .minecraft/versions/<version>/<version>.jar and open it with 7Zip or WinRAR to find the file path of the loot table, so you can replicate the path inside the minecraft namespace in your datapack.
Another way is using the /data command (will be covered in a future tutorial, perhaps part 9.2) to overwrite the DeathLootTable NBT tag (see 9.1 for getting to know NBT) for each newly spawned cow. Make sure to give each cow a tag to prevent setting the tag every tick. Something like /data modify entity @e[type=cow,tag=!set_loot_table] ....... & /tag @e[type=cow,tag=!set_loot_table] add set_loot_table
Syntax of loot tables themselves might not be covered for a while as covering everything about commands is my first priority. Advancements and predicates are also on the list for after commands, so I'd have to think about what comes next when we're at that point.
You can go to .minecraft/versions/<version>/<version>.jar and open it with 7Zip or WinRAR to find the file path of the loot table, so you can replicate the path inside the minecraft namespace in your datapack.
Another way is using the /data command (will be covered in a future tutorial, perhaps part 9.2) to overwrite the DeathLootTable NBT tag (see 9.1 for getting to know NBT) for each newly spawned cow. Make sure to give each cow a tag to prevent setting the tag every tick. Something like /data modify entity @e[type=cow,tag=!set_loot_table] ....... & /tag @e[type=cow,tag=!set_loot_table] add set_loot_table
Syntax of loot tables themselves might not be covered for a while as covering everything about commands is my first priority. Advancements and predicates are also on the list for after commands, so I'd have to think about what comes next when we're at that point.
1
nice
1
I have a idea but I dont know if it can be done. But I was wondering if a double ender chest might be do able... The thinking for this is to some how get the double chest data of a normal chest, add or change the ender chest to be similar but with the ender chest properties. A bigger ender chest!? I think it would be fun or great to have for worlds/servers with alot of new items. Tho I think this might be pushing it but never hurts to ask or try.
2
Unfortunately, it's not possible for the following reasons:
- Ender chests are stored on the player data itself and you can't modify player data.
- Data modifications require a good understanding of NBT (9.1) and how to modify it (upcoming 9.2)
- Even if ender chests would be normal chests, Minecraft does have some error-correcting code in place. This is very inconsistent though, so I'm not sure if it will tell you off if you try to put an item in a non-existant slot.
- Another thing you could come up with is using normal chests and writing/reading from /data "storage". The problem with that is that you can't dynamically select data. (See 9.1, if you would put each player chest into a key with a certain value, you can't get access to the value based on a key, unless you write that key statically into the function file. AKA you can't insert any kind of "variable" to get a compound value by key).
- You could then try putting the key as integer into the chest data and use a list of chests instead of a compound, but then you need to assign each player a new id and then try every piece of chest data for that id until you find one. (By taking the first chest data from the list, checking it and moving it to the end of the list, repeat).
As you can see, it's really easy to stumble down a rabbit hole and I don't even know if you can work out that last option without walking into another wall.
- Ender chests are stored on the player data itself and you can't modify player data.
- Data modifications require a good understanding of NBT (9.1) and how to modify it (upcoming 9.2)
- Even if ender chests would be normal chests, Minecraft does have some error-correcting code in place. This is very inconsistent though, so I'm not sure if it will tell you off if you try to put an item in a non-existant slot.
- Another thing you could come up with is using normal chests and writing/reading from /data "storage". The problem with that is that you can't dynamically select data. (See 9.1, if you would put each player chest into a key with a certain value, you can't get access to the value based on a key, unless you write that key statically into the function file. AKA you can't insert any kind of "variable" to get a compound value by key).
- You could then try putting the key as integer into the chest data and use a list of chests instead of a compound, but then you need to assign each player a new id and then try every piece of chest data for that id until you find one. (By taking the first chest data from the list, checking it and moving it to the end of the list, repeat).
As you can see, it's really easy to stumble down a rabbit hole and I don't even know if you can work out that last option without walking into another wall.
3
actually you can quite easily store and load back the whole chest data at once using /data into a storage, just target the item list itself instead of each individual items, I have done something similar with structureblocks
What will need you extra work is the player id system to assign back enderchest, and adding a second id layer to distinct each enderchest per players
@Nachatmahr, if you have discord, there is many dedicated discord servers you may join, and nice people wich can help you to figure out stuff and get unstuck with yours projects
Also my own experience learning datapacking was to get my hand of few commands technics, find out a creative way to do something with it and doing it
and now I got way much more creatives ideas which I know I can implement myself, than I have time to achieve them ;)
Currently working on ambitious projects on minecraft never seen before, I wish you good luck and great datapacking experiences
What will need you extra work is the player id system to assign back enderchest, and adding a second id layer to distinct each enderchest per players
@Nachatmahr, if you have discord, there is many dedicated discord servers you may join, and nice people wich can help you to figure out stuff and get unstuck with yours projects
Also my own experience learning datapacking was to get my hand of few commands technics, find out a creative way to do something with it and doing it
and now I got way much more creatives ideas which I know I can implement myself, than I have time to achieve them ;)
Currently working on ambitious projects on minecraft never seen before, I wish you good luck and great datapacking experiences
1
How to activate the packs
1
Please provide more information if you are having problems with something. What are you trying to do and what isn't working?
Part 3 should explain how to create a data pack and check if it works.
Part 3 should explain how to create a data pack and check if it works.
1
I como wue joga o datapack me ajudem
2
thanks
1
eu sei isso
3
Eu realmente aprecio que você continue atualizando este datapack. Agradeço sua dedicação 🙏
3
I had to google translate this and I hope it translated correctly, but thank you for the kind words! =)
07/19/2020 6:21 pm
This reply was removed by the poster or a moderator.
2
... what?
2
you trying to spell fnaf
2
Data pack to minecraft players
1
So?
2
Published part 9.3: NBT based targeting (+ /execute if data)!
2
I use windows 10 so how would I do this? :[
3
All tutorials are cross-platform (besides the first one). So assume you can use all info as-is, unless it specifically tells you that a certain section is not for Windows. On windows 10, make sure you know whether or not you're using the Java or Bedrock Edition.
Java edition has a launcher and no in-game store, which supports data packs. Bedrock Edition does have an in-game store, but doesn't support data packs. You'll need to find yourself a different tutorial on behavior packs if you want to modify Bedrock Edition functionality.
Java edition has a launcher and no in-game store, which supports data packs. Bedrock Edition does have an in-game store, but doesn't support data packs. You'll need to find yourself a different tutorial on behavior packs if you want to modify Bedrock Edition functionality.
2
Same as win 7
4
Cool
2
Part 10 released! I also reorganized the "Resources, Notes & Best Practices" section with a multi-level list and wrapping it all in a spoiler.
2
seerrrrrrrrrrrrrrrrrrrrrrfffff
view more replies ( 140 )