697

The Data Pack Knowledge Book (with Challenges!)school

Bertiecrafter's Avatar Bertiecrafter4/7/20 4:45 pm history
697 emeralds 200.2k 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

10
01/13/2022 12:14 am
Level 24 : Expert Engineer
Your_MoThEr375
Your_MoThEr375's Avatar
“Who is JSON” that’s really funny cheered me up a bit
10
03/11/2021 9:44 pm
Level 13 : Journeyman Miner
-Google-
-Google-'s Avatar
It so cool!!!
8
04/16/2020 7:58 pm
Level 24 : Expert Hunter
Darth_Builder
Darth_Builder's Avatar
it's actually helpful
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
7
01/25/2021 12:51 am
Level 38 : Artisan Pixel Painter
Dunk__
Dunk__'s Avatar
thx now I know how to make datapacks!! :)
6
10/28/2022 2:32 pm
Level 20 : Expert Explorer
TheOneWizard
TheOneWizard's Avatar
Thx I've already needed this
6
08/25/2021 9:32 pmhistory
Level 44 : Master Engineer
ManaMage
ManaMage's Avatar
This is very informative for new Datapack enthusiasts.
6
07/12/2021 5:46 am
Level 6 : Apprentice Explorer
mohammmadgamerextrem
mohammmadgamerextrem's Avatar
hi
6
07/07/2021 2:44 pm
Level 31 : Artisan Modder
Kerzinator_24
Kerzinator_24's Avatar
this is longer than the average book
6
07/08/2021 1:09 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
Haha thank you!
5
07/07/2021 2:44 pm
Level 31 : Artisan Modder
Kerzinator_24
Kerzinator_24's Avatar
edit: longer than the bible
5
08/08/2021 6:25 pm
Level 1 : New Explorer
EnderGamer96
EnderGamer96's Avatar
lol
3
10/07/2021 7:23 am
Level 34 : Artisan Geek
VidTDM
VidTDM's Avatar
Is it really?
6
04/13/2021 12:35 pm
Level 1 : New Miner
Mirilapro
Mirilapro's Avatar
hola
6
04/08/2020 2:41 pm
Level 30 : Artisan Toast
mouse36
mouse36's Avatar
cool this is helpful i like it
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 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
5
01/06/2023 10:46 am
Level 30 : Artisan Dragonborn
EndermanDotDat
EndermanDotDat's Avatar
the memes oh comparing json to jason lol.
5
09/25/2022 7:19 pm
Level 59 : Grandmaster Professor
eyhoffi
eyhoffi's Avatar
two years and i din't recogniced this thread. how cool that someone is explainig this stuff. now i need a cool commands tut for dummies , too. very nice. thank you.
4
10/06/2022 12:10 pm
Level 57 : Grandmaster uwu
amandin
amandin's Avatar
hope you are getting better at it! how is it going ?
5
12/08/2021 9:49 am
Level 2 : Apprentice Explorer
Vesely_skeleton
Vesely_skeleton's Avatar
THANK YOU
5
11/17/2021 1:32 am
Level 44 : Master Procrastinator
SoapSoapSoap
SoapSoapSoap's Avatar
I just misread NBT to NFT
2
01/20/2022 2:09 am
Level 36 : Artisan Electrician
RoyalQuackOG
RoyalQuackOG's Avatar
happened with me too.....
5
07/16/2021 7:15 am
Level 17 : Journeyman Pokemon
KoalaTeen
KoalaTeen's Avatar
Thanks for telling me
5
03/25/2021 7:13 pm
Level 30 : Artisan Warrior
LukaMudrohYT
LukaMudrohYT's Avatar
290 th sub Congratulations Bro!
I don't need this sh1t but ok lol :'D
5
03/26/2021 2:36 amhistory
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
Thank you! It's a bit odd, but also satisfying how the counter on this submission is only showing 256
5
08/02/2021 9:16 am
Level 5 : Apprentice Crafter
MCAlexisYT
MCAlexisYT's Avatar
8-bits
5
02/23/2021 7:34 am
Level 1 : New Miner
ceylin551042
ceylin551042's Avatar
Bu nasıl indiriliyor acaba
???
4
07/29/2021 3:21 pm
Level 1 : New Miner
CallMeMan
CallMeMan's Avatar
aha ya kosom al sersin omk arha oa abok mn bean
1
03/09/2023 1:22 am
Level 1 : New Miner
Limeed
Limeed's Avatar
4
02/23/2021 11:41 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
Translated to "I wonder how this is downloaded"

You cannot download anything in this, these are articles teaching you how to make your own data pack.
5
01/18/2021 8:04 am
Level 1 : New Explorer
SanctuaryThief
SanctuaryThief's Avatar
This is a great resource, and well worth the read. Thank you!
4
08/29/2023 1:45 am
Level 4 : Apprentice System
lytDARK
lytDARK's Avatar
Bertiecrafter What do you think about function macros?
3
09/12/2023 1:35 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
Oooh, thanks for hinting at this new functionality. (I haven't kept up with latest news on new versions). They sound very promising and a long awaited feature in the data pack community. Can't wait to see all the insane stuff that can be done with them.
4
10/06/2022 12:10 pm
Level 57 : Grandmaster uwu
amandin
amandin's Avatar
this is so good actually!
4
08/29/2022 4:23 pm
Level 1 : New Miner
Equimano
Equimano's Avatar
550 emerald
4
07/25/2022 10:15 pm
Level 1 : New Miner
User4250130G
User4250130G's Avatar
ok
4
07/19/2022 2:32 pm
Level 1 : New Miner
kelvin conrad
kelvin conrad's Avatar
como criar data packs
4
05/04/2021 9:18 pm
Level 1 : New Miner
Andrea0608
Andrea0608's Avatar
grax =3
4
09/11/2020 7:16 am
Level 7 : Apprentice Warrior
pronetherite145
pronetherite145's Avatar
Cool
3
08/22/2023 3:16 pm
Level 3 : Apprentice Skinner
PastelBLACKCat
PastelBLACKCat's Avatar
Question, can 1.17 datapacks work on 1.20.1?
2
09/12/2023 1:38 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
It will try to run, but if the command syntax has changed, some commands might prevent certain function files from running. Which ultimately breaks the entire data pack.
2
08/29/2023 1:44 am
Level 4 : Apprentice System
lytDARK
lytDARK's Avatar
Obviously not
1
10/08/2023 9:50 am
Level 31 : Artisan Crafter
Denistic
Denistic's Avatar
yes they can. you just need to change the pack.mceta file in the datapack to format:15 or 18.
1
09/07/2023 8:41 pm
Level 1 : New Miner
AnnyParker
AnnyParker's Avatar
For the most part, yes, barring a few command changes. You may have to do minor tweaking, but not much beyond that
3
02/12/2023 10:52 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar

Added in-depth blogs on combining several individual concepts to create more complex mechanics


Written by Kefaku, with more to come!
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome