Jump to content

[1.19.2] Programmatically apply a tag to a registered item.


LadyInStem

Recommended Posts

So let's say that I've set up an differed item register: 

private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, OpenResources.MOD_ID);

...and that I have registered a new item item with it:

public static final RegistryObject<Item> TEST = ITEMS.register("test", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS)));

The normal way to include a tag - let's say for example I used the tag "forge:ingots/iron" - I would include a file at the path `<SRC FOLDER>/resources/data/forge/tags/items/ingots/` called "iron.json", and that json would look like this:

{"replace": false, "values": ["<MOD_ID>:test"]}

This is all to say that I understand how to do this normally.

What I don't know how to do, and can't seem to find after looking through the documentation and searches online, is how do add this tag programmatically - meaning from the Java source code itself.

I want to do this because I need to dynamically add tags for a mod I am working on.

Thanks in advance for any help anyone is willing to provide.

Edited by LadyInStem
Link to comment
Share on other sites

  • LadyInStem changed the title to [1.19.2] Programmatically apply a tag to a registered item.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.