Grouping Items Using Datapack Tags (Step by Step)
Minecraft datapacks provide an incredibly versatile framework for customizing and extending the game’s core functionalities. Among the most fundamental and powerful tools within this framework are item tags. Item tags are essentially JSON files designed to group multiple distinct items under a single, unified identifier. This grouping mechanism is invaluable for creating flexible and robust custom content, particularly in the realm of crafting recipes and, optionally, in defining loot tables.
![]()
The primary benefit of employing item tags is the flexibility they introduce, especially in crafting. Instead of requiring a specific, individual item for a recipe, a tag allows for any item belonging to that defined group to fulfill the requirement. For instance, a crafting recipe for a simple wooden tool might traditionally specify minecraft:oak_planks. However, by utilizing an item tag, such as #minecraft:planks, the recipe becomes compatible with any type of wood plank available in the game, whether it’s oak, spruce, birch, or any other variant. This significantly enhances the player experience by removing unnecessary restrictions and making custom content feel more integrated and forgiving. While their most prominent use is in crafting, item tags can also be optionally integrated into loot tables, offering a similar level of categorical inclusion for items that might be generated in chests or dropped by entities.
Technically, an item tag is structured as a simple JSON file. The core of this file is a values array, which contains a list of the full Minecraft IDs of all the items intended to be part of that specific group. This straightforward structure makes it easy to define and manage item categories. When referencing these custom-defined groups within other datapack components, a specific format is used: #<namespace>:<tag_name>. The hash symbol (#) serves as an indicator that a tag is being referenced, followed by the namespace (which identifies the datapack or source of the tag), and finally, the specific name of the tag itself.
It is also important to recognize that Minecraft itself leverages this tagging system extensively for its internal mechanics. The game comes with numerous pre-defined, built-in tags that categorize various items. A prime example is the tag #minecraft:planks, which internally groups all standard plank types within the game. Understanding how these existing internal tags function provides a clear illustration of the utility and power that custom item tags can bring to your own datapack creations, allowing you to mimic and extend the game’s own organizational logic.
Setting Up Your Datapack
The journey to creating custom item tags begins with establishing a properly structured datapack. A datapack is a collection of files that Minecraft reads to apply modifications or add new content. To initiate this, you must first create a standard datapack folder structure. This typically involves a root folder for your datapack, which then contains a data folder and a pack.mcmeta file. The pack.mcmeta file is an essential component; it provides Minecraft with crucial metadata about your datapack, such as its format version and a descriptive text. While the detailed contents of this file are not directly related to the specifics of item tags, its correct presence and configuration are non-negotiable for your datapack to be recognized and loaded by the game. Ensuring this foundational setup is accurate is the critical first step for any custom content, including the item tags you intend to create.
Establishing the Folder Structure for Item Tags
Once your base datapack structure is in place, the next step involves creating the precise directory path where your item tag files will be stored. All custom data within a datapack resides within its data folder. Inside this data directory, you must create a subfolder that will act as your unique namespace. A namespace is vital for preventing conflicts between different datapacks and for clearly attributing the origin of custom content. For instance, if your datapack is named “MyAwesomePack,” a suitable namespace might be “myawesomepack” or “custom_resources.”
Within your chosen namespace folder, a further, highly specific path must be created to house your item tag definitions. This path is tags/items/. Consequently, the complete hierarchical path for your item tag files, starting from the root of your datapack folder, will resemble this structure:
<your_datapack_folder>/data/<your_namespace>/tags/items/
This exact folder structure is paramount. Minecraft’s datapack loading system relies on these predefined directory paths to locate and integrate different categories of custom content. Any deviation from this specific structure for your item tag JSON files will result in the game failing to detect them, rendering your custom tags inoperable.
Creating Your Item Tag File
With the folder structure correctly established, the subsequent step is to create the actual JSON file that will define your specific item group. Navigate to the items folder you previously created (e.g., <your_datapack_folder>/data/<your_namespace>/tags/items/). Inside this directory, you will create a new file, ensuring it has a .json extension. The filename you assign to this JSON file will directly become the name of your item tag. For example, if your intention is to group various types of valuable gems, you might name your file valuable_gems.json. In this specific scenario, your tag would then be referenced elsewhere in your datapack using the format #<your_namespace>:valuable_gems.
It is highly recommended to choose descriptive and unique filenames for each tag. This practice helps maintain clarity within your datapack and minimizes the potential for naming conflicts, especially as your collection of custom item groups grows. Following standard Minecraft naming conventions, filenames should ideally be in lowercase and use underscores to separate words for improved readability.
Defining Items Within the Tag File
The final and most critical step in the process is to populate your newly created JSON file with the specific items you wish to include in your group. Open your .json file (for example, my_group.json) using any plain text editor. The content of this file will be a simple JSON object, which must contain a single, mandatory key: values. The value associated with this values key will be a JSON array. Within this array, you will list the full Minecraft IDs of all the individual items that are to be part of this tag.
The fundamental structure of an item tag JSON file appears as follows:
{
"values": [
"minecraft:item_id_1",
"minecraft:item_id_2",
"your_namespace:custom_item_id",
// ... additional item IDs
]
}
Let’s elaborate on each component:
-
{ ... }: This signifies a JSON object, which serves as the root element for the entire file. -
"values": This is the essential key within the JSON object. Its presence explicitly indicates that the subsequent array contains the list of item identifiers for this particular tag. -
[ ... ]: This denotes a JSON array. Each individual element enclosed within these square brackets must be a string that corresponds to an item’s unique identifier. -
"minecraft:item_id_1": This is an example of a full Minecraft ID. It is absolutely crucial to use the complete ID, which always includes the item’s namespace. For vanilla Minecraft items, the namespace isminecraft(e.g.,"minecraft:oak_planks", not simply"oak_planks"). If you are including an item from your own datapack or another mod, you would use its specific namespace (e.g.,"mycustompack:my_custom_tool"). Each ID must be enclosed in double quotes.
You have the flexibility to list as many item IDs as necessary within the values array. Each ID should be enclosed within double quotes and separated from the next ID by a comma, with the exception of the very last item in the list, which should not be followed by a comma. For instance, to create a tag named #mycustompack:building_blocks that includes cobblestone, stone bricks, and diorite, your building_blocks.json file would be structured as follows:
{
"values": [
"minecraft:cobblestone",
"minecraft:stone_bricks",
"minecraft:diorite"
]
}
After you have saved this JSON file with its defined item list, you will need to reload your datapack in Minecraft. This is typically accomplished by executing the /reload command within the game. Upon successful reload, your custom item tag will become active and available for use in various datapack components, such as crafting recipes, loot tables, or even custom advancements. This robust grouping mechanism is a cornerstone for developing highly modular, organized, and easily maintainable datapacks, making the process of creating complex customizations significantly more manageable and scalable.