Started by
Hollowplayz
on
Topic category: Help with Minecraft modding (Java Edition)
Hey, I've seen a handful of topics about this but never got a clear answer for my case
How would you go about specifying or adding NBT tags to items through procedures?
For example, if you crafted something together and give the result an NBT tag, how do you check if that tag exists in a procedure?
And just to be specific, I mean items that you hold, not item entities
What are you trying to do with it? Like custom data?

This worked in a custom code snippet for setting the unbreakable component,
itemstack.applyComponents(DataComponentMap.builder().set(DataComponents.UNBREAKABLE, new Unbreakable(true)).build());
I'm trying to put different tags on foods that correspond to potion effects
So if you combine food with a specific item, the result is the same food you used with an NBT tag that specifies which effect you put on it, then when you eat it, you get the effect
Well you can use the "new" consumable component to apply effects when you consume it, but it gets quite long
So I'm not super great at line coding, could you break this down for me and explain how to implement it?
sure,
implementing it is easy, just put it in a custom code snippet like https://mcreator.net/comment/284160/#comment-284160
# Breakdown
so you can basically just ignore the first line
itemStack.applyComponents(DataComponentMap.builder().set(DataComponents.CONSUMABLE,
It basically is just like telling the code that the following lines will be a consumable component which will be added to the item.
Then we create the actual consumable component, each parameter explained in comments (lines starting with //)
Hope that helps, feel free to ask if not!
Yes, this helps a ton! Thank you so much!
I'll update the Forum once I get it working