697

The Data Pack Knowledge Book (with Challenges!)school

Bertiecrafter's Avatar Bertiecrafter4/7/20 4:45 pm history
697 emeralds 199.9k 139
3/28/2024 7:16 pm
Megamind5547's Avatar Megamind5547

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.
  1. What are data packs and why would I create them?
  2. Who's JSON (and what's /tellraw)?
  3. Creating a new data pack and your first function
  4. Debugging
  5. Let's play tag! (Load, tick, uninstall and other functions)
  6. Who? What? Where? But How? (Target Selectors and Relative Coordinates)
  7. The Scoreboard
    1. The Scoreboard: Where numbers are created, stored and juggled
    2. The Scoreboard (+ Triggers): We've got to go deeper!
  8. The Command Environment (/execute)
  9. Check a lot of things, but only once! (+ /execute if/unless)
  10. Named Binary Tag (NBT) format
    1. NBT: The hidden layer behind all of Minecraft
    2. NBT: Taking Control (/data & /execute store)
    3. NBT based targeting (+ /execute if data)
  11. The return of JSON
    1. The return of JSON: Introduction & Wiki Pages
    2. The return of JSON: The Workshop (+ Custom Recipes)

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.
  1. Helpful and interesting links for datapackers
  2. Repeat it over and over again... | Loops
  3. This is so random... | Randomizing
  4. Help, I'm lagging! | Lag
  5. ... more planned in the near future ...


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
  • 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:
Posted by Bertiecrafter's Avatar
Bertiecrafter
Retired Moderator
Level 70 : Legendary Engineer
775
CollaboratorsKefaku's Avatar Kefaku

Create an account or sign in to comment.

139

6
04/08/2020 12:49 am
Level 37 : Artisan Artist
how do i delete account
how do i delete account's Avatar
Great tutorial!
7
04/08/2020 2:09 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
Thank you :P
6
04/08/2020 7:44 amhistory
Level 33 : Artisan Imposter
Jatzylap
Jatzylap's Avatar
Cool. Maybe custom game resources such as modelling & textural animation mechanics next time? :)
5
04/08/2020 8:07 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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
04/08/2020 2:41 pm
Level 30 : Artisan Toast
mouse36
mouse36's Avatar
cool this is helpful i like it
8
04/12/2020 8:33 pm
Level 49 : Master Crafter
NTDan
NTDan's Avatar
Gotta say, this is an amazing tutorial. I already knew data packs pretty well, but this posts still gave me new knowledge!
3
04/26/2020 8:33 pm
Level 1 : New Miner
AKRAMSONTA
AKRAMSONTA's Avatar
como me descargo estoooo
3
04/27/2020 1:40 pm
Level 1 : New Miner
WhiteRavenZX
WhiteRavenZX's Avatar
no lo se
8
04/16/2020 7:58 pm
Level 24 : Expert Hunter
Darth_Builder
Darth_Builder's Avatar
it's actually helpful
3
04/27/2020 1:38 pm
Level 1 : New Miner
WhiteRavenZX
WhiteRavenZX's Avatar
no entiendo nada ;-;
3
04/27/2020 2:11 pmhistory
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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
1
07/10/2021 10:54 am
Level 1 : New Miner
anonpmc3388343
anonpmc3388343's Avatar
[deleted]
1
04/29/2020 7:44 pm
Level 41 : Master Spider Rider
GiantPlaytime
GiantPlaytime's Avatar
translation I do not understand anything ;-;
2
04/27/2020 1:39 pm
Level 1 : New Miner
WhiteRavenZX
WhiteRavenZX's Avatar
lol porque no escribe en español
1
04/29/2020 7:42 pm
Level 41 : Master Spider Rider
GiantPlaytime
GiantPlaytime's Avatar
translation lol because he doesn't write in spanish
2
04/29/2020 5:07 pm
Level 22 : Expert Birb
rukreep
rukreep's Avatar
Interesting...
1
04/29/2020 7:39 pm
Level 25 : Expert Explorer
The Dirty Pirate
The Dirty Pirate's Avatar
Don't really understand.....😐😐❓❓
05/06/2020 10:42 am
This reply was removed by the poster or a moderator.
1
05/06/2020 11:44 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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.
1
05/07/2020 4:16 pm
Level 58 : Grandmaster Theorist
Chimerabot
Chimerabot's Avatar
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
05/07/2020 5:30 pm
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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
05/11/2020 8:07 pm
Level 47 : Master Engineer
advoacite
advoacite's Avatar
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
2
05/12/2020 8:50 amhistory
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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
05/12/2020 11:12 am
Level 47 : Master Engineer
advoacite
advoacite's Avatar
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
05/15/2020 1:50 pm
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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
05/15/2020 10:54 pm
Level 1 : New Miner
Rune_Bloodstone
Rune_Bloodstone's Avatar
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.
2
05/16/2020 4:03 amhistory
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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.
1
07/07/2021 2:45 pm
Level 31 : Artisan Modder
Kerzinator_24
Kerzinator_24's Avatar
nice
1
05/19/2020 2:18 amhistory
Level 1 : New Miner
NAchatmahr
NAchatmahr's Avatar
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
05/19/2020 3:59 pm
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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.
3
05/30/2020 7:46 pm
Level 22 : Expert Engineer
Loumardes
Loumardes's Avatar
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
1
06/06/2020 8:51 pm
Level 1 : New Miner
TheOnlyXDgamerZ
TheOnlyXDgamerZ's Avatar
How to activate the packs
1
06/11/2020 9:55 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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.
1
06/16/2020 11:36 am
Level 1 : New Miner
Duda games25
Duda games25's Avatar
I como wue joga o datapack me ajudem
2
06/23/2020 1:34 pm
Level 34 : Artisan Skinner
RealPandaBoyPlaysYT
RealPandaBoyPlaysYT's Avatar
thanks
1
07/04/2020 7:53 pm
Level 1 : New Miner
cocoruta
cocoruta's Avatar
eu sei isso
3
07/19/2020 10:51 am
Level 1 : New Miner
marcelocajado
marcelocajado's Avatar
Eu realmente aprecio que você continue atualizando este datapack. Agradeço sua dedicação 🙏
3
07/19/2020 10:57 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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
08/21/2020 9:23 pm
Level 26 : Expert Robot
barrett41z10
barrett41z10's Avatar
... what?
2
09/01/2020 10:29 am
Level 29 : Expert Archer
4nd73_j4q
4nd73_j4q's Avatar
you trying to spell fnaf
2
08/07/2020 10:45 am
Level 1 : New Miner
HIHIHIHHI
HIHIHIHHI's Avatar
Data pack to minecraft players
1
03/25/2021 7:13 pm
Level 30 : Artisan Warrior
LukaMudrohYT
LukaMudrohYT's Avatar
So?
2
08/10/2020 2:02 pm
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
Published part 9.3: NBT based targeting (+ /execute if data)!
2
09/04/2020 1:48 pmhistory
Level 25 : Expert Explorer
The Dirty Pirate
The Dirty Pirate's Avatar
I use windows 10 so how would I do this? :[
3
09/04/2020 4:33 pm
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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.
2
03/25/2021 7:13 pm
Level 30 : Artisan Warrior
LukaMudrohYT
LukaMudrohYT's Avatar
Same as win 7
4
09/11/2020 7:16 am
Level 7 : Apprentice Warrior
pronetherite145
pronetherite145's Avatar
Cool
2
11/14/2020 1:24 pm
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
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
12/07/2020 10:44 pm
Level 1 : New Miner
User3329379G
User3329379G's Avatar
seerrrrrrrrrrrrrrrrrrrrrrfffff
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome