MultiLoader 26.1+ · Part 8

Data Generation: Block & Item Tags (MultiLoader 26.1+)

INTERMEDIATE MULTILOADER 26.1-26.1.2 18 min read · Jun 12, 2026
MultiLoader 26.1+ · 17 parts
1 Getting Started with MultiLoader 26.1+ 2 Setting Up RegistrationUtils (MultiLoader 26.1+) 3 Creating Items (MultiLoader 26.1+) 4 Creating Blocks (MultiLoader 26.1+) 5 Data Generation: Block & Item Models (MultiLoader 26.1+) 6 Data Generation: Block Loot Tables (MultiLoader 26.1+) 7 Data Generation: Crafting Recipes (MultiLoader 26.1+) 8 Data Generation: Block & Item Tags (MultiLoader 26.1+) 9 Data Generation: Language Files (MultiLoader 26.1+) 10 Data Generation: Advancements (MultiLoader 26.1+) 11 Data Generation: Sound Definitions (MultiLoader 26.1+) 12 Data Generation: Particle Descriptions (MultiLoader 26.1+) 13 Data Generation: Enchantments (MultiLoader 26.1+) 14 Custom Food Items (MultiLoader 26.1+) 15 Custom Tools (MultiLoader 26.1+) 16 Custom Armour (MultiLoader 26.1+) 17 Block Entities (MultiLoader 26.1+)

Tags are named sets of blocks, items, or other registry objects that game mechanics and recipe ingredients can reference without knowing the exact members. In this tutorial we generate block and item tag files using datagen, add our custom block to the vanilla tool-requirement tags so it can only be harvested correctly, and create a custom mod-scoped item tag for use in recipes.

NOTE
Complete the Data Generation: Crafting Recipes tutorial before continuing. We add two new providers to the existing gatherData method.

Why Tags Matter

Without the correct tool tags, your block will drop its item regardless of what the player digs with. Adding BlockTags.MINEABLE_WITH_PICKAXE tells Minecraft that a pickaxe is the correct tool, and adding BlockTags.NEEDS_IRON_TOOL makes it so that only an iron-tier pickaxe or better actually harvests the block. Without that second tag the block is diggable with any pickaxe, including a wooden one.

Item tags serve a different purpose: they let recipe ingredients match a group of items rather than a single specific one. We will create an examplemod:mod_items tag containing all items from this mod, which can then be used as a recipe ingredient in future tutorials.

Block Tags Provider

In your NeoForge data package, create a class called ExampleBlockTagsProvider extending BlockTagsProvider. In 26.1 the constructor no longer takes an ExistingFileHelper:

java
public class ExampleBlockTagsProvider extends BlockTagsProvider {
public ExampleBlockTagsProvider(PackOutput output,
CompletableFuture<HolderLookup.Provider> lookupProvider) {
super(output, lookupProvider, Constants.MOD_ID);
}
@Override
protected void addTags(HolderLookup.Provider provider) {
tag(BlockTags.MINEABLE_WITH_PICKAXE)
.add(BlockRegistry.NEW_DIRT.get());
tag(BlockTags.NEEDS_IRON_TOOL)
.add(BlockRegistry.NEW_DIRT.get());
}
}

The tag(...).add(...) pattern appends your block to an existing vanilla tag file without replacing its other members. The replace: false flag is written into the JSON automatically, which tells the game to merge rather than overwrite.

TIP
Other useful vanilla block tags include BlockTags.MINEABLE_WITH_AXE, BlockTags.MINEABLE_WITH_SHOVEL, BlockTags.NEEDS_STONE_TOOL and BlockTags.NEEDS_DIAMOND_TOOL. Pick the tool type and tier that fits your block's material.

Item Tags Provider

In the same package, create ExampleItemTagsProvider extending ItemTagsProvider. In 26.1 the constructor is simplified: it no longer takes an ExistingFileHelper or a separate block tag lookup future:

java
public class ExampleItemTagsProvider extends ItemTagsProvider {
public ExampleItemTagsProvider(PackOutput output,
CompletableFuture<HolderLookup.Provider> lookupProvider) {
super(output, lookupProvider, Constants.MOD_ID);
}
@Override
protected void addTags(HolderLookup.Provider provider) {
TagKey<Item> modItems = ItemTags.create(
Identifier.fromNamespaceAndPath(Constants.MOD_ID, "mod_items"));
tag(modItems)
.add(ItemRegistry.IRON_STICK.get())
.add(BlockRegistry.NEW_DIRT.get().asItem());
}
}

The modItems tag key declares a new tag under your mod's namespace. You can reference this key anywhere a TagKey<Item> is accepted, for example as an ingredient in a ShapedRecipeBuilder definition.

TIP
If you need to mirror a block tag into its matching item tag (for example, mirroring a stone tag so both the placed block and the item form share the same group), use BlockTagCopyingItemTagProvider instead and call copy(blockTag, itemTag) inside addTags.

Registering the Providers

Open gatherData and add both tag providers. Neither requires an ExistingFileHelper or a dependency on each other's contents getter:

java
public static void gatherData(GatherDataEvent event) {
DataGenerator generator = event.getGenerator();
PackOutput output = generator.getPackOutput();
CompletableFuture<HolderLookup.Provider> registries = event.getLookupProvider();
generator.addProvider(true,
new LootTableProvider(output, Set.of(),
List.of(new LootTableProvider.SubProviderEntry(
ExampleBlockLootTableProvider::new,
LootContextParamSets.BLOCK
)), registries));
generator.addProvider(true,
new ExampleRecipeProvider.Runner(output, registries));
generator.addProvider(true,
new ExampleBlockTagsProvider(output, registries));
generator.addProvider(true,
new ExampleItemTagsProvider(output, registries));
}

Running Datagen

Run the NeoForge Data configuration. Afterwards, check the generated resources folder for two new directories:

  • data/minecraft/tags/block/mineable/pickaxe.json and data/minecraft/tags/block/needs_iron_tool.json should each contain examplemod:new_dirt in their values array.
  • data/examplemod/tags/item/mod_items.json should list both examplemod:iron_stick and examplemod:new_dirt.
json
// data/minecraft/tags/block/mineable/pickaxe.json
{
"replace": false,
"values": ["examplemod:new_dirt"]
}
// data/examplemod/tags/item/mod_items.json
{
"replace": false,
"values": [
"examplemod:iron_stick",
"examplemod:new_dirt"
]
}

Testing In-Game

Launch the client in survival mode and try to break a New Dirt block with your fist and then with a wooden pickaxe. Neither should produce a drop. Switch to an iron pickaxe and break it; the block should drop itself, as expected from the loot table tutorial. This confirms both tool-type and tool-tier tags are working correctly.

WARNING
If the block still drops with the wrong tool, check that your generated tag files are in data/minecraft/tags/block/ (the vanilla namespace) and not in data/examplemod/tags/block/. Tool requirement tags must be in the minecraft namespace to be recognised by the game.

You can find the source for this tutorial here:

View Source on GitHub
NEXT IN SERIES

Data Generation: Language Files (MultiLoader 26.1+)

Replace hand-written lang JSON with a LanguageProvider, use typed add() helpers for blocks and items, and hook the provider into GatherDataEvent.Client alongside the model provider.

Continue →