582

Function Data Packs for Dummies | A tutorial blog series!school

Bertiecrafter4/7/20 4:45 pm history
582 emeralds 90.6k 121
10/28/2022 2:32 pm
TheOneWizard


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, I 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 I can teach you or you can correct me on.

More posts will be created in the future and existing posts might be improved. Feedback and questions are welcome in the replies below.

Table of Contents

  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 & Quality Control
  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)


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 avatar
Bertiecrafter
Site Moderator
Level 68 : High Grandmaster Stack
658

Create an account or sign in to comment.

121

3
10/28/2022 2:32 pm
Level 11 : Journeyman Explorer
TheOneWizard
TheOneWizard avatar
Thx I've already needed this
2
10/06/2022 12:10 pm
Level 5 : Apprentice System
amawdin
amawdin avatar
this is so good actually!
2
09/25/2022 7:19 pm
Level 56 : Grandmaster Professor
eyhoffi
eyhoffi 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.
2
10/06/2022 12:10 pm
Level 5 : Apprentice System
amawdin
amawdin avatar
hope you are getting better at it! how is it going ?
1
09/07/2022 2:09 pm
Level 1 : New Miner
Alinq1
Alinq1 avatar
like
1
09/02/2022 4:57 am
Level 12 : Journeyman Archer
Imposter1234
Imposter1234 avatar
so how do I make them?
2
09/06/2022 3:29 pm
Level 68 : High Grandmaster Stack
Bertiecrafter
Bertiecrafter avatar
Just a text editor is all you need :)
Click the links above to visit the blog posts, one part at a time.
3
09/04/2022 4:06 pm
Level 10 : Journeyman Narwhal
SolarWater
SolarWater avatar
I would make datapacks with MCreator
2
08/29/2022 4:23 pm
Level 1 : New Miner
Equimano
Equimano avatar
550 emerald
2
07/25/2022 10:15 pm
Level 1 : New Miner
User4250130G
User4250130G avatar
ok
2
07/19/2022 2:32 pm
Level 1 : New Miner
kelvin conrad
kelvin conrad avatar
como criar data packs
1
06/29/2022 10:29 pm
Level 1 : New Miner
Redywq
Redywq avatar
I know its kind of incovinient but can someone please help me make a datapack to prevent hoglins form spawning at light source 9 or something like that?
3
05/30/2022 2:15 pm
Level 34 : Artisan uwu
SEfaught
SEfaught avatar
501th emerald
2
03/14/2022 2:35 pm
Level 17 : Journeyman Miner
juanclack9878
juanclack9878 avatar
oko
2
02/24/2022 2:17 pm
Level 1 : New Crafter
Draguel
Draguel avatar
ender dragon
3
01/29/2022 1:45 pm
Level 26 : Expert Botanist
Moooshy
Moooshy avatar
Swaggy af :)
1
01/20/2022 3:08 pm
Level 1 : New Miner
User4000068G
User4000068G avatar
oi ficou muito bom
1
01/30/2022 5:54 am
Level 40 : Master Toast
blob_
blob_ avatar
io uuah hakwsnk hnawygds
2
01/18/2022 9:47 am
Level 1 : New Miner
Ziedhamad65
Ziedhamad65 avatar
non funziona come potrei fare
8
01/13/2022 12:14 am
Level 21 : Expert Engineer
Your_MoThEr375
Your_MoThEr375 avatar
“Who is JSON” that’s really funny cheered me up a bit
3
01/12/2022 2:00 pm
Level 1 : New Miner
User3988167G
User3988167G avatar
Oi
1
07/24/2022 3:48 pm
Level 1 : New Miner
MateusCraftGames
MateusCraftGames avatar
OI
2
12/13/2021 2:46 pm
Level 1 : New Miner
pequin369
pequin369 avatar
hello I found an error that the mobs of the negative layers of 1.18, that is, those of low y0 or less die and revive infinitely and do not move.
4
12/16/2021 2:24 pm
Level 68 : High Grandmaster Stack
Bertiecrafter
Bertiecrafter avatar
Please post the comments at the relevant submission.
5
12/08/2021 9:49 am
Level 2 : Apprentice Explorer
Vesely_skeleton
Vesely_skeleton avatar
THANK YOU
2
12/07/2021 10:10 pm
Level 1 : New Miner
SSAkhil
SSAkhil avatar
eeeeeeeeeeeeeeee
2
11/28/2021 8:40 am
Level 1 : New Miner
Gnomik31Gnomik
Gnomik31Gnomik avatar
hhjjhjhj
3
11/23/2021 3:38 am
Level 31 : Artisan Magical Boy
HiMeCoolss
HiMeCoolss avatar
Boom, just what i needed
5
11/17/2021 1:32 am
Level 38 : Artisan Toast
SoapSoapSoap
SoapSoapSoap avatar
I just misread NBT to NFT
2
01/20/2022 2:09 am
Level 34 : Artisan Electrician
RoyalQuackOG
RoyalQuackOG avatar
happened with me too.....
3
11/16/2021 1:17 pm
Level 34 : Artisan Engineer
Comradeee
Comradeee avatar
very interesting thank you
2
11/13/2021 5:13 am
Level 1 : New Miner
User3903417G
User3903417G avatar
nie działa mi
3
10/30/2021 3:44 am
Level 1 : New Explorer
boxDamiana
boxDamiana avatar
mogę pomóc???
3
10/27/2021 1:34 pm
Level 1 : New Crafter
GamePlaystar_HD
GamePlaystar_HD avatar
THANK YOU
2
10/23/2021 2:17 am
Level 1 : New Miner
artun121212
artun121212 avatar
nooooooo dowland no indirilmiyo çünlü
3
10/23/2021 2:16 am
Level 1 : New Miner
artun121212
artun121212 avatar
naber lan
2
10/27/2021 9:07 am
Level 1 : New Miner
DogukanAdal
DogukanAdal avatar
iyi ama indirilmiyo






























:(
3
10/22/2021 7:59 pm
Level 1 : New Miner
Juleea
Juleea avatar
Thank you
2
10/15/2021 12:08 pm
Level 21 : Expert Miner
ilovelampadaire
ilovelampadaire avatar
last good
2
09/26/2021 5:06 pm
Level 1 : New Miner
Potato123456789123456789
Potato123456789123456789 avatar
it didint work
2
09/23/2021 3:51 am
Level 1 : New Miner
frandickx
frandickx avatar
como lo activo? :v
6
08/25/2021 9:32 pmhistory
Level 40 : Master Engineer
ManaMage
ManaMage avatar
This is very informative for new Datapack enthusiasts.
5
07/16/2021 7:15 am
Level 14 : Journeyman Pokemon
KoalaTeen
KoalaTeen avatar
Thanks for telling me
6
07/12/2021 5:46 am
Level 5 : Apprentice Explorer
mohammmadgamerextrem
mohammmadgamerextrem avatar
hi
6
07/07/2021 2:44 pm
Level 29 : Expert Modder
Kerzinator_24
Kerzinator_24 avatar
this is longer than the average book
6
07/08/2021 1:09 am
Level 68 : High Grandmaster Stack
Bertiecrafter
Bertiecrafter avatar
Haha thank you!
5
07/07/2021 2:44 pm
Level 29 : Expert Modder
Kerzinator_24
Kerzinator_24 avatar
edit: longer than the bible
3
10/07/2021 7:23 am
Level 28 : Expert Geek
VidTDM
VidTDM avatar
Is it really?
5
08/08/2021 6:25 pm
Level 1 : New Explorer
EnderGamer96
EnderGamer96 avatar
lol
3
06/13/2021 9:26 am
Level 1 : New Miner
Junkwon
Junkwon avatar
I have mobile jow i instal mods?
Planet Minecraft

Website

© 2010 - 2022
www.planetminecraft.com

Welcome