Minecraft Blogs / Tutorial

Datapack tags explained

  • 15,501 views, 19 today
  • 21
  • 9
  • 5
ShelLuser avatar ShelLuser
Level 55 : Grandmaster Engineer
Hi gang!


Minecraft 1.13 introduced us to datapacks, which allow you to add all sorts of stuff to the game. Most parts of a datapack pretty much speak for themselves. I mean.. if you come across a folder which is named 'functions' then I think it should be obvious that you can expect some functions to be defined there. Same goes for structures, recipes, loot tables and advancements.

But every once in a while players ask me what use tags actually are. Surely this is something Mojang came up with and which isn't really useful for us players?

Well... you'd be wrong, but it is true that tags have a very specific use. So I figured... tag! you're it! :-)

What are tags?

Simply put: tags are JSON files which group one or more things together. They can be used for blocks, fluids, functions and items. Sounds pretty straightforward, right?

I think the best (and easiest) example is a function tag. Setting up a function tag will allow you to run one (or more) functions after each other by simply using 1 single name (the tag).

For example... My friend Aya and me often use a specific set of tools. Aya is very fond of her customized trident while I often enjoy playing with a specific set of leather armor (which I copied from my favorite server). To make it easier on us I made 2 functions which allow us to quickly get our items: catslair:tools/aya is used to give Aya her items and catslair:tools/shell can be used to give me my armor. So far, so good.

But what if we're playing together? Even with the (excellent) tab completion it can become tedious if you have to run these same two functions after each other for a few times. The solution? Setting up a (function) tag of course!

"values": [

This is tools.json which I placed in the datapack (sub)folder: catslair\tags\functions. As a result I can now use: /function #catslair:tools which will run both of our 'tools functions' together:

#tools function

Simple, right?

Block tags

As I mentioned earlier there are 4 different types of tags, but all types do the same thing: they group things together.

Take for example a block tag, this can help you to group block types together which you might want to test for using commands.

Play field

Here I have a small playing field. The idea is simple: if a player is standing on a green block then they're "safe" and if they're standing on a normal block (sandstone) then they're not. Now, this could become tedious really fast because I'm using 5 different block types, so normally I would need 5 different tests to check for the right block(s).

Fortunately for us 1.13 has changed all this thanks to tags. All I have to do now is define a tag (so: a json file) which contains all five blocktypes:


I called this file safe_blocks.json and it sits in the subfolder catslair\tags\blocks. Now I don't have to perform 5 different checks, I can simply perform one test and use my newly created tag:

/execute at @p if block ~ ~-1 ~ #catslair:safe_blocks run say Player is safe!

So: I execute this command at the location of the player, but only if the block below them (~ ~-1 ~; so a y value of -1) corresponds with my #catslair:safe_blocks tag. And as you can see above this tag consists of all the 5 different green blocks. As a result Minecraft will check if the player is standing on any of those blocks, and if they are they're considered 'safe'.

Couldn't be easier.

Tags can't be used all the time

When I first learned about tags and noticed that you can even tag items I quickly started experimenting to see if you could somehow check a players inventory for a selection of items. Unfortunately that won't work. There are areas where you can't use tags (yet?). So if you're checking a players inventory and want to know if they have multiple items then you have no other choice but to specify those in your command. Item tags are currently only meant to be used within recipes and optionally loot tables.

And there you have it!

A shorter guide this time but I still hope it can be useful for some of you. If you ever wondered about tags... well, I think you can probably agree that they're a lot easier than they might seem at first. They're not always useful, but they can be in many cases.

Create an account or sign in to comment.

07/13/2022 2:35 pmhistory
Level 11 : Journeyman Crafter
lim_minecraft avatar
"So if you're checking a players inventory and want to know if they have multiple items then you have no other choice but to specify those in your command."

No, it can be done. At least for now

/execute store success score @s if_buttons run clear @s #minecraft:buttons 0

I think it should be clear what this command does
02/11/2022 3:33 pm
Level 28 : Expert Miner
LezaHMC75 avatar
thank you
09/15/2021 12:30 pm
Level 37 : Artisan Miner
Hansaka avatar
Thanks for Explain
Do you know how to set run function (or any command) automaticaly on world startup (not repeat I need to run it once)
03/19/2020 8:30 pm
Level 1 : New Miner
SeriousGuy888 avatar
Thank you for the explanation!
09/04/2018 10:30 am
Level 39 : Artisan Blockhead
oyo321 avatar
This is very good! Thank you!
Planet Minecraft


© 2010 - 2022