Jump to content

[SOLVED] [1.12.2] Variable recipe ingredients


Daeruin

Recommended Posts

I want to make some recipes that are only slight variations on each other. Specifically, they will require an axe, but it doesn't matter which kind. Is there any way to make the axe type variable? The other ingredient will be a log, which means 30 recipes: 5 axe types times 6 log types. (The log can't be variable, because the output will be specific to the type of log.) If I ever want to add modded axes or logs, the number of recipes will keep increasing at a ridiculous rate. Is there any way to make a recipe that takes any kind of axe?

Edited by Daeruin
marking solved.
Link to comment
Share on other sites

Logs can be a variable: its called the ore dictionary.

 

For axes, you will need to create your own IRecipe implementation (for these recpies) or a custom Ingredient (for multiple recipes).

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

Huh. Unless you feel like showing me how it will be drastically faster or easier than creating several dozen recipe files, I don't think I'll bother. It won't take that long to create the recipes. It's just annoying to copy/paste the axe type so many times.

 

I'm aware of the ore dictionary. As I said, I don't need the logs to be variable. The type of log determines the type of output, so it wouldn't make sense to make the log variable--how would you know what output to give? (But even if I did need the logs to be variable, ore dictionary has not been working for my mod's logs, I think because they are "flat"--not using metadata for the type of wood. Anyway, I did a minor necro on an old post with that question, which nobody commented on.)

Link to comment
Share on other sites

I think you might be able to get past the "brute force" by using code-based recipe registration. You'd handle the registry event for IRecipe  and then create the IRecipe instances within loops that iterates through collections (like a list of the axes and a list of the logs). 

 

In that way you only have to type in each item type once but get all the combinations built for you by the power of nested loops.

 

Shouldn't be that painful and would scale well.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

2 hours ago, Daeruin said:

I have heard over and over not to register recipes in code but instead to use json. I still tried it but can't seem to get it to work (and there are apparently no examples out there). Pretty sure I could have brute forced it about 10 times over by now. Haha.

If you want to brute force it, you can! Your a programmer, automate it!

You might want to take a look at my implementation here

(I call the function in my main mod class)

you should only use this if your recipes aren’t exponentially large, otherwise you should use oreDictionary/ the Tag system/ a custom IRecipe. Your case seems to be at the edge of what should be done so you can choose whatever you think best suits your code & intentions 

Edited by Cadiboo
  • Like 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

16 minutes ago, Daeruin said:

I have heard over and over not to register recipes in code but instead to use json. 

That admonition only applies when JSON can do the job. In this case it cannot (well practically not, for as you said it won't scale as you could quickly need thousands of recipes) so you gotta code it. 

 

If you're going to code it you can either do it the simple way I already mentioned (generate a bunch of regular IRecipe instances using loops) or you can be a bit more sophisticated and create an IRecipe implementation that directly accepts all the axe types as being equivalent.

 

However, with all that being said, are you sure the Ore Dictionary can't do what you want? You could make a new ore dictionary definition for your axes and register all the axe types against that, then your JSON recipe could just refer to the ore dictionary ingredient.

Edited by jabelar
  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Thanks, everyone, for all the advice.

 

22 hours ago, jabelar said:

However, with all that being said, are you sure the Ore Dictionary can't do what you want? You could make a new ore dictionary definition for your axes and register all the axe types against that, then your JSON recipe could just refer to the ore dictionary ingredient.

Registering axes to the OreDictionary does not work, because then only undamaged axes will work in the recipes. Damaged axes don't work even when using the wildcard value. I guess it's because it doesn't make much sense to specify a data value for an ore dictionary ingredient, when the ore dictionary entry could be any arbitrary list of items.

 

20 hours ago, LexManos said:

This is the prime example of why a cutom ingredients, and constants are a thing in the Forge system.

Sweet, now I know that compound ingredients and constants are a thing, and have figured out how to use them. It works great.

 

Spoiler

_CONSTANTS:
[
  {
    "name": "AXE",
    "ingredient": [
      {
        "item": "minecraft:wooden_axe",
        "data": 32767
      },
      {
        "item": "minecraft:stone_axe",
        "data": 32767
      },
      {
        "item": "minecraft:iron_axe",
        "data": 32767
      },
      {
        "item": "minecraft:gold_axe",
        "data": 32767
      },
      {
        "item": "minecraft:diamond_axe",
        "data": 32767
      }
    ]
  }
]

RECIPE:
{
  "type": "forge:ore_shapeless",
  "ingredients": [
    {
      "item": "#AXE"
    },
    {
      "item": "minecraft:log",
      "data": 0
    }
  ],
  "result": {
    "item": "basketcase:item_bark_oak",
    "count": 4
  }
}

 

 

However, now that it's finally working, it made me realize that I hadn't thought the implementation all the way through. I want the axe to stay in the crafting grid and the log to be transformed into a stripped log (I made custom stripped logs before they were a thing in 1.13). I think I read somewhere that this would require an IRecipe implementation that overrides getRemainingItems.

Link to comment
Share on other sites

  • 2 weeks later...

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.