Custom tags in Fabric Minecraft mods are collections of items or blocks that share common properties, allowing modders to create flexible, extensible systems where other mods can add items to the tag without modifying the original mod's code. To implement custom tags, modders create static classes in a dedicated 'tags' package with tag keys of type Block or Item, register them using Registries.BLOCK.define() or Registries.ITEM.define(), and populate them using data generators with ItemTagsProvider or BlockTagsProvider. Tags are accessed through the mod tags class (e.g., ModTags.Items.TransformableItems) and checked using the is() method, which returns true if an item belongs to the tag. This approach replaces hard-coded item lists with dynamic, modifiable collections that can be extended by other mods.
深掘り
前提条件
- データがありません。
次のステップ
- データがありません。
深掘り
Fabric Modding Tutorial - Minecraft 26.1: Custom Tags | #13追加:
Let's group items together and add tags to our Minecraft mod. If you want to go deeper, the 26.x modding courses are linked down below. 30 plus hours covering complex block entities with fluid and energy handling, custom mobs, custom networking, and even custom biomes and dimensions. Everything you need for 26.x all in one place, linked down below in the description.
All right, everyone, it's Bacon once more, and in this tutorial we'll be adding tags to our Minecraft mod. Now, these are not name tags. I know that it can be a little bit confusing or one might, you know, it it invokes the idea of a name tag. Now, it's not actually that bad, but the idea is that yes, we are tagging things, but we're not giving them names, but rather we're giving them groups. We've seen these previously in the block tags over here, where we added our blocks to the minable with pickaxe tag, and there are other tags that sort of confer a certain functionality to blocks or items, and we'll see plenty of those down the road, but generally speaking here for the block tags, what we're going to have is or we're actually going to have an item tag, and then item tag is going to be specifically for, exactly, the magic block. Right now, it is fully hard-coded, which is never a good thing that you really not want in any sort of your mod.
You basically always want to have things a little bit, at least a little bit sort of exchangeable, and changeable, and and in this case here, the is valid item method right now just says, "Yo, is it fluorite or is it an iron iron ingot?"
And that's it. A better sort of setup would be we would have a list on the magic block that you could feasibly change or add to, and then that would be pretty good, right? Because then, you know, another modder could feasibly add to that list. Fair enough, that would work. Or, we just use the built-in version of, I mean, I I don't want to say lists because it's not really I mean, it's just a list, but it's a it's a little bit different tags, which would be just a collection, and that way we're going to say, "Hey, is this like a valid item? Is this a transformable item?" And just like that, boom, we have it. So, for this, we're going to first of all make a a class that we would will let me able to use our tags with or we will be able to reference our tags, and then we'll also make the tag via data gen, of course. So, in the tutorial mod package, we're going to make a new package called tags. Before, this was always in the utils package, but I know that people don't like that, so we're going to put it into the tags package with the mod tags plus. Very straightforward, easy enough, and there we go. Now, we'll start off with two different static classes. One of them we're not going to even use, but we'll just add it already.
This is the blocks class over here, so a public static class blocks inside of the text mod tags plus. Not not to worry, works totally fine. And then here we're going to basically have a private static tag key. This is the sort of the thing that This is the key that is associated with this tag, and this is always of a type, so it's a generic, so the angle brackets here, and this is of type block, making sure we choose net.minecraft.world.level.
block. As per usual, of course, we always want to make sure that we choose that one, and there we go. And this is basically then the type of tag that we're creating. So, this is the create tag method with a string name parameter, and we will simply return the tag key.
That create method right here, which um this Yeah, oh no, wait a second. Don't we have block Is there no block tags create method? There isn't. Oh, it might actually not be um it that might not be accessible for us. Let me double-check over here. I do want to know. There is a create method, but it's not Oh, it's it's better. Okay. Yeah, that's fair.
Fair enough. So, we need to basically do this. Okay. Well, it's all right. So, basically, we're going to say return tag key. That create, then we have the define the registries, so registries.block, because this is a block tag, so we're defining what type of tag it is, and then we're saying identifier from namespace and path. Once again, I'm just hitting the tab key to auto-complete this, and passing in when we have from namespace and path, it's basically always the same. We pass in the tutorial mode and mode ID and the name over here given right here. Some people also for the identifier right here just do like an ID in their tutorial mode class like a like a static method that just like does all of this.
But the reason I'm not doing it is because for people who don't have that, it might be a little bit confusing. So there we go. And if you didn't know what I just said, that's totally fine as well. Do not worry. We're going to duplicate the blocks class right here and we will rename it to items because well, of course we also have the items where we change the tag key to the type of item and then the registries here are simply item. Simple as that and that already gets us the items class. We might expand this the mod tags class in the future for some other stuff as well, but for the time being, we'll just add one item tag. And that is going to be a public static final and this is a tag key once again of type item and this is the transformable_items equal to the create tag method that is literally right here. Right? And then here we simply put in a string name.
This is going to be the exact name for the tag as well. So this is transformable_items.
I'm pretty sure this follows the same laws. It governs It is governed by the same laws as the mod ID. So it's you know, all lower case, no spaces, things like that. With that said and that done, we have the mod tags class done. There's no sort of other registration that we need to do. This is all fine and now we just need to make sure that this is actually populated. Now the question is should we populate it first or should we use it first? We're going to use it first and then populate it. So how do we use the tag? It is unbelievably easy because instead of all of this craziness, we're just going to say item is and then mod tags. items.
transformable_items. Boom. That's it.
There's another is method that takes in a tag key and basically says okay, is this specific item stack over here, is it part of the transformable items tag?
Yes, let's go. It's a valid item. No, no, it's not a valid item. We're not turning into a diamond. That's literally it. That's all we that we have over here. It It sounds pretty crazy, but this is really how easy it is to add a a user tag in this instance. But now, on to actually putting things into the tag.
Of course, you could make your, you know, a data tag like a data directory over here and then put the tag it No, no, no. What do we have data driven for?
Exactly. So, this is going to be the mod items tags provider over here, which is going to I believe that this is a fabric one, right? Yeah, fabric extends from the fabric tags provider.
Item tags provider. We'll hover over this to implement the add tags method.
Hover over this again, create constructor matching super.
I don't think it matters too much which one we take. We're going to take the second one with the output and the completable future of holder lookup provider. It always looks a pretty insane like when you look at it, but it's not actually that complicated. We will be using that in the in the in the future as well. Don't worry, not right now. So, here we're going to call the value lookup builder method passing in mod tags. Mod items. Transformable items. And then here just adding the items that we want. So, let's say for example, we're going to add the fluorite. And then we're also going to add items. Let's say we had the iron ingot in there. And let's just add like two more. Just for the sake of argument, let's add the coal right here, you know, and maybe I don't even know. Give me Give me something random over here. I'm just going to zoop. How about that? Brew it. Brewery shirt. Okay, maybe a brick.
How about that? Okay, I'm going to go with the brick. A shirt. A random shirt.
How about we don't do that one. But there we go. So, now we have, you know, two additional ones just for testing purposes over here. And of course, the cool thing is that, you know, if there's another mod, they can now make their theoretically they can either make this manually like the the transformable items tag. They can just make it manually inside of the tutorial mod package or the name space. And then it would also work and add those tags there. Or there's also ways to automate it in theory, like for example, to have an optional tag and and add optional things and all sorts of other things that you could work. But generally speaking, that is basically the way for us to do it, you know, if there's another mod that wants to add stuff, that's a little bit more complicated, but generally it would still work. With that being said, we have this now done.
So now let's go to our tutorial mod data generator right here, and we're going to add the well, simply add provider mod item tags provider colon colon new.
Nothing crazy, literally like we've seen, you know, the four previous times over here for the data generators. And then, well, let's run the data generators and we'll see once again, these are just very very simple in the data tutorial mod, and it's going to be under tags block no item item, there we go. And there we go, we have the four different values in here. Like I said, it is more or less just a list, you know, just a list as it's doing a little bit more heavy lifting, but generally speaking, it's a JSON file with a list of values. It can be items, blocks, whatever we so choose. And in this case, obviously, it's the items that can be transformed by the magic block. So I would say, let's jump into the game and see if it works. All right, friends, I'm back in Minecraft once again, and let's take a look. So we have coal that we could throw on there. We have a brick, and then let's also get ourselves some of the fluorite just for the sake of argument here. And if I throw it on there, boom, it turns into a freaking diamond, and all of those also turn into diamonds.
Um oh, those are nether bricks. Well, that's not going to work. That's not going to work, but I did that on purpose, of course, to show that the nether bricks do not change, but the bricks do. Look at that. And that is exactly what is happening. So only certain items, literally like we've defined in the tag here, work. So that is custom tags added to Minecraft.
Awesome.
And as per usual, all of the code is available to you down below, and don't forget that you can join the stone brick supporter tier as a YouTube member to get early access to if 14 days of videos on YouTube or here on further tutorials.
For example, next time when we talk about custom stairs, that's already available. Hope to see you there. So, yeah.
関連おすすめ
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
Re: 🗣️📍theprophedu📍2026 GST 103 CLASS (E-EXAM REVISION)
theprophedu
636 views•2026-06-04
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Instagram accounts got PWNed
EricParker
13K views•2026-06-03











