Jump to content

[1.7.10] OreRecipes


Pancake

Recommended Posts

Greetings!

 

If you don't like reading, read my question at the bottom (bold). If you don't know what I'm talking about, read the text.

 

I want to make an autocrafting system. I can currently load ShapedRecipes and ShapelessRecipes correctly into an Object that will be generated once at the initialisation. (although the code is now in a onBlockActivated method, for testing)

I have an issue regarding OreRecipes though.

 

I'd link to link (HashMap) every output (ItemStack) to a collection (HashSet) of possible outputs (HashMap) where every ingredient (ItemStack) is linked to the amount you need (Integer). The complete type of this Object is HashMap<ItemStack,HashSet<HashMap<ItemStack,Integer>>>. It looks complicated, but it contains everything I'll need. I use this for ShapedRecipes and ShapelessRecipes. The ShapedOreRecipe and ShapelessOreRecipe are a different story...

 

For those I'll replace the HashMap<ItemStack,Integer> by a HashMap<Object,Integer> where the Object can be an ItemStack (normal, non OreDictionary item) or an Integer (the OreDictionary ID). My problem lies within getting that ID. I'll explain how data is retrieved from OreRecipes for those who want to try it themselves.

 

A ShapedOreRecipe gives you, just like the ShapedRecipe, an array of size 9, but it isn't an ItemStack array, it's an Object array. It can contain null (no item), an ItemStack (just a normal item with no OreRegistry ID mapped to it) or an ArrayList (a special kind of ArrayList, but whatever). If it's an ArrayList, It will contain all possible ItemStacks for that slot.

 

You can ask the OreDictionary IDs (it can have multiple) of an ItemStack, it gives you integer array (int[]). I get those arrays of all the items in the arraylist, and check which value(s) are common between all items.

 

Now for, my problem...

 

Let's suppose someone made a recipe that combines any 2 metals, and gives a mixed metal ingot. there are 2 metals in game: "oreCopper" and "oreTin" and they are both also registered as "oreMetal". The valid items for slot 1 would be "oreCopper" AND "oreTin". I try to get the common ore ID, and get the number associated with "oreMetal" (it's the common between an itemstack of copper and tin).

 

Now we try to paint wool red. for slot 1 you get a common name of "cloth" or something like that. for slot 2, there's only 1 option: rose red. what are the common ore names for that 1 item? "dye" and "dyeRed". there's no way to check which is the more 'specific' one, because there's only 1 item.

 

If you understood all of that, and comprehend where the problem lies, congratulations to you. And to me, for explain so well ;) If not... i'm sorry. feel free to ask questions.

 

Now for my core question: is it possible to, instead of an arraylist of all the possible blocks that fit in that slot, get the OreDictionary name/ID for that slot? Is there anyway to get the name used in the constructor of an OreRecipe? (they require them)

 

 

Thanks in advance,

Pancake.

 

PS: If an admin/moderator storms in, blurts out an answer without reading and closes this thread, I reserve the right for myself to copy-paste this wall of text, and recreate an exact copy of this thread. #nohate

Link to comment
Share on other sites

I might've found a work-around. It's amazing how writing everything down, and trying to formulate things for another person orders your thoughts for yourself, allowing you to think outside the pattern that you've been in for hours.

 

So, when getting that arraylist, it contains all possible itemstacks that fit there, right?

I take the first stack, get all the oredictionary ids for that stack (int[]).

For each id, I get oreDictionary.getOres(id), which is what the OreRecipe classes get and put in their fields.

I then check if that arraylist is equal to the original arraylist. Exactly one of the ids should produce the exact same ArrayList ('exact' is a big word, it's a different object), and that id is the one filled in in the constructor.

 

I rest my case.

 

It would still be nice if the OreRecipes would save the OreDictionary strings as fields though. It'd be faster that way. But hey. 10 milliseconds for all the ShapedOreRecipes isn't bad... And it should only run once anyways.

Link to comment
Share on other sites

I might've found a work-around. It's amazing how writing everything down, and trying to formulate things for another person orders your thoughts for yourself, allowing you to think outside the pattern that you've been in for hours.

 

Story of my life.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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

    • They are heartless scammers, they ruined my life, by making me develop an interest in investing my hard-earned money. I deposited 67,000 USD which was later turned into 110,450 USD including my payout bonus, there was an impressive improvement in a few weeks, later I had an emergency and needed money to pay my insurance fee, I tried reaching out to them to collect the money I invested, they cut the live chats and got me harassed then I realized that I was being scammed. I just wanted my money back! I was advised by a friend to seek help from a recovery firm to assist me in recovering my invested funds, God was so kind I came across some great positive reviews about BETAFORT ONLINE on how they helped scammed victims like me to recover their lost cryptocurrency assets, I took no delay and got in touch with BETAFORT ONLINE, the Expert immediately looked into my case and after providing all the required information they need, and it took them less then a day to recover all my funds. And now I really feel obligated to recommend BETAFORT ONLINE and their team, their recovery strategies, and for working relentlessly to help me recover my funds. Feel free to reach out to BETAFORT ONLINE via google search and they will guide you on how to recover your invested funds, I advise everyone to be careful with these heartless cryptocurrency scammers.  
    • yeah I believe so, its been something deep with the modpack I'm guessing. ill fix each error it states if its saying to replace or download a mod but I'm not sure where to go from here. I have been spending days and have yet to find the issue    
    • It worked, thank you very much 😭
    • https://spark.lucko.me/0ZaR1OAi2F I use spark mod to do a scan and send it here to search for help and if someone know about this issue I dont know to much about, but one thing i see in the record of the minecraft launcher when i play says: can't keep up server overloaded and etc, etc.  I assign 6GB ram to minecraft from the 16 GB of my pc, and fps is not a problem...(no to much) its something about tic rate/second and i am in SINGLE PLAYER. The funny thing is, minecraft vanilla (No mods) works normaly. My mods list (130): https://imgur.com/a/kY3yQr1  Datapacks: https://imgur.com/CTDBe7D ResourcePacks: https://imgur.com/AztTOOw so plis, is someone help me T_T a work  a loot of time in downloading and trying to all mods work but i dont know what to do anymore. Last thing  I SPEAK SPANISH so... sorry if my english is a little scuff or ... werever... bad. Thanks :3
    • Whenever I try to create an world my game crashes. I´ve tried to figure it out myself but wasnt able to do it.   Here are the logs
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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