710
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.
141
Datapacks don't work anymore in 1.21. I could be missing something, but I just don't know
A lot of directories names have changed as well as the names of some nbt data has shifted a little. It all works functionally the same, just requires some renaming. Minecraft Java Edition 1.21 | Minecraft: Java Edition
I've been spending most of the day porting a lot of my 1.20 packs to my 1.21 server lol
I've been spending most of the day porting a lot of my 1.20 packs to my 1.21 server lol
how would one make an item unremovable from the player's inventory
Well, that depends on what version of minecraft you're using. If it's bedrock I'm pretty sure you use this command: /give <target> <item> 1 0 {"item lock": {"mode": "lock_in_slot"}}
I believe in java you have to use "/item replace" , I'm not sure what the parameters are for it, though.
I believe in java you have to use "/item replace" , I'm not sure what the parameters are for it, though.
Hello guys
I want a data pack to import into Minecraft
I want a data pack to import into Minecraft
Bertiecrafter What do you think about function macros?
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.
Question, can 1.17 datapacks work on 1.20.1?
yes they can. you just need to change the pack.mceta file in the datapack to format:15 or 18.
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.
For the most part, yes, barring a few command changes. You may have to do minor tweaking, but not much beyond that
Obviously not
As a pro datapack developer, reading through the index, this looks very good, but I have not read it yet.
Have you read through it now?
Added in-depth blogs on combining several individual concepts to create more complex mechanics
Written by Kefaku, with more to come!
smh
the memes oh comparing json to jason lol.
Thx I've already needed this
this is so good actually!
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.
hope you are getting better at it! how is it going ?
like
so how do I make them?
Just a text editor is all you need :)
Click the links above to visit the blog posts, one part at a time.
Click the links above to visit the blog posts, one part at a time.
I would make datapacks with MCreator
550 emerald
ok
como criar data packs
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?
501th emerald
oko
ender dragon
02/16/2022 7:55 am
This reply was removed by the poster or a moderator.
u sus
Swaggy af :)
oi ficou muito bom
io uuah hakwsnk hnawygds
non funziona come potrei fare
“Who is JSON” that’s really funny cheered me up a bit
Oi
OI
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.
Please post the comments at the relevant submission.
THANK YOU
eeeeeeeeeeeeeeee
hhjjhjhj
Boom, just what i needed
I just misread NBT to NFT
view more replies ( 1 )
view more replies ( 84 )