Posted May 1, 20223 yr Hello! 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 { cache.add(item); } } 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
May 1, 20223 yr Author The purpose of the config is to allow users to change which items they want this mod to apply to... is there a good way to apply a tag to only the items listed in the config?
May 5, 20223 yr Author 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 May 5, 20223 yr by Reyzerbit
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.