Jump to content

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


ZTagre

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

 

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
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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://pastebin.com/VwpAW6PX My game crashes upon launch when trying to implement the Oculus mod to this mod compilation, above is the crash report, I do not know where to begin to attempt to fix this issue and require assistance.
    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. 📈 Skills: RPG-style skill system that enhances your gaming experience! 🎮 Leaderboards: Compete and shine! Top players are rewarded weekly! 🏆 Random Teleporter: Travel instantly across different worlds with a click! 🌐 Custom World Generation: Beautifully generated world. 🌍 Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. 🏰 Kits: Unlock ranks and gain access to various kits. 🛠️ Fishing Tournament: Compete in a friendly fishing tournament! 🎣 Chat Games: Enjoy games right within the chat! 🎲 Minions: Get some help from your loyal minions. 👥 Piñata Party: Enjoy a festive party with Piñatas! 🎉 Quests: Over 1000 quests that you can complete! 📜 Bounty Hunter: Set a bounty on a player's head. 💰 Tags: Displayed on nametags, in the tab list, and in chat. 🏷️ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! 🟢 Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. 🔲✨[ Player Warp: Set your own warp points for other players to teleport to. 🌟 Display Shop: Create your own shop and sell to other players! 🛒 Item Skins: Customize your items with unique skins. 🎨 Pets: Your cute loyal companion to follow you wherever you go! 🐾 Cosmetics: Enhance the look of your character with beautiful cosmetics! 💄 XP-Bottle: Store your exp safely in a bottle for later use! 🍶 Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! 📦 Glowing: Stand out from other players with a colorful glow! ✨ Player Particles: Over 100 unique particle effects to show off. 🎇 Portable Inventories: Over virtual inventories with ease. 🧳 And a lot more! Become part of our growing community today! Discord: https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working   I am not familiar with Linux - check for similar/related issues  
  • Topics

×
×
  • Create New...

Important Information

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