Jump to content

Accessing Minecraft Registry Items in 1.18


Recommended Posts



I am currently porting a mod from 1.16 to 1.18, and have run into an issue.

Originally in 1.16, Minecraft registry items could be referenced and found from within the registry using their Registry name, per the method 

Registry.ITEM.getOrDefault(new ResourceLocation(registryNameString));

After 1.17 however, these registries were wrapped into ResourceKeys and the original Registries were deprecated.

With this port, I am looking to compare an item from the Items class (i.e. Items.AIR) with a RegistryName stored in a config, essentially trying to verify if the RegistryName pulled from the config is AIR or not.

The following code was what was previously used:

for (String s : ClientConfig.items.get()) {

	Item item = Registry.ITEM_REGISTRY.getOrDefault(new ResourceLocation(s));
	if (item == Items.AIR) {

		System.out.println(s + " not found");

	} else {




The cache object being a set of Items (Set<Item>)  and every String s being a different RegistryName pulled (as a String) from the config.


If there is a new/better way to run this comparison, please let me know. Otherwise, I would appreciate some help understanding the new way to reference Minecraft registry items from the ResourceKey<Registry<Item>> object.


Thanks in advance!


- Rey

Link to comment
Share on other sites

I appreciate your pointers but in this case I want the config to be where the options can be adjusted, not through data packs, plus it is a client side only mod. I appreciate your help regardless, especially by pointing me to the forge registries. Thank you!

Edited by Reyzerbit
Link to comment
Share on other sites

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.

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.


  • Create New...

Important Information

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