Jump to content

[1.10.2] [Solved] Search for items from other mods via ID?


Recommended Posts

Posted (edited)

I have recently ran into a situation that I would like to find a way of rectifying (if indeed it is possible!).

 

   I have / am developing  a mod that has a copper ore and ingot as items. I use these blocks / items for various purposes within my mod (duh), and this is all working out - no problems in this regard. I have added my copper ingot to the ore dictionary as is the "norm", and I know that my copper ingot is usable by other mods which utilize copper ingots in their recipes, so that's working (yeah!).

 

   The problem is that I also like using a mod that I have NOT developed myself, but that works fine nevertheless. However, this particular mod ALSO has a copper ore and copper ingot; the KICKER is - that mod's author did NOT add his copper to the ore dictionary. That mod's copper ingot will NOT work in mods whose recipes call for "ingotCopper", etc. Thus, his copper is not compatible with my mod, either :-{

 

   Which leads me to my question: Is there a way to "search" through all the registered items in the RUNNING GAME, "looking" for specific items by their registered ID's? And, then, should a specific item be found, is it then possible to add that item to the ore dictionary "on the fly" so to speak? This would allow my mod (and others I use in my game play) to utilize that particular mod's copper ingot (as an example) in all ore-dictionary-aware  recipes.

 

   The alternative is to not be able to use that mod's copper for any other purposes but in which that modder intended (ie. recipes within that particular mod only.). That would be a shame!

 

   Now, I am aware that there are mods out there that work to "merge" all items of a certain type into one "global" type (that is, take all "ingotCopper" entries in the ore dictionary, and merge them all into a single "ingotCopper", compatible with all mods utilizing the ore dictionary (at least, I think that's what those mods do?). But this particular idea is different, because the item does not yet have an ore dictionary entry (otherwise, I would not be asking this question!).

 

   Is what I'm describing at all possible? If so, a small snippet of example code would be most helpful! I would of course provide full credit in my mod's code for the example code I wind up using (or, even, simply giving credit to anyone providing me with a "leg up" on how I might do this).

 

   I really hate having that mod's copper going to waste, but I just can't use it for what I need!!!

 

   But, even if what I have described (finding an item from an "outside" mod, via its registered ID, and then adding it to the ore dictionary "on the fly" ) is NOT possible, is it still possible merely to find out if a SPECIFIC ITEM is present in the running game? That is, if I wanted to know whether a specific mod's copper ingot was indeed "registered" in my running game, could I do so, and how would I accomplish this?

 

   Thanks in advance,

   ZTagre.

Edited by ZTagre
solved
Posted

Get the Item registry from the ForgeRegistries class, then use IForgeRegistry#getValue to get the Item with the specified registry name. You can then register this Item with the Ore Dictionary.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Thanks for the advice, Choonster!

 

Here's what I did (in postInit() )

 

        // Here, we are using the method Choonster provided to
        // acquire an Item ID for the zeiyocraft:copperIngot"
        // item, which we will then use to add this ingot to the
        // Ore Dictionary...
        ResourceLocation rloc;
        final IForgeRegistry item_registry = GameRegistry.findRegistry(Item.class);
        rloc = new ResourceLocation("zeiyocraft","copperIngot");
        final IForgeRegistryEntry<Item> zeiyocraft_copper_ingot = item_registry.getValue(rloc);
        OreDictionary.registerOre("ingotCopper", (Item)zeiyocraft_copper_ingot);

 

   It works splendidly :-}

 

   Thanks a bunch...

   ZTagre.

Posted (edited)

You should try contacting the author of the mod so he can register the ores to the OreDictionary himself. The mod is open-source, so you can also try to make an issue or PR to add it to the mod.

Edited by larsgerrits
  • Like 1

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted (edited)

 

Thanks for that advice,  larsgerrits!

 

   I plan on doing just that; however, I felt that KNOWING how to do this would assist in any situation I might encounter, including those where the author(s) no longer maintain the mod(s)...

  

   I can't INSIST that those author(s) who haven't already USED Ore Dictionary registration begin doing so, and since the process of ore registration is so straightforward, it's really surprising to me that they didn't do this in the first place :-}

 

   I'm relatively new to Minecraft modding, and I realized very quickly just how important ore dictionary registration was for overall mod resource cooperation.

 

PS.- Yeah, it's OreDictionary (one word) I know, I just find that WHAT IT IS looks more understandable when discussed as two separate words...my bad...

   Again, thanks!

 

   ZTagre.

Edited by ZTagre
addendum

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.