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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 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  
    • Create a new instance and start with Embeddium/Oculus and Valkyrien Skies Try different builds of Embeddium/Valkyrien Skies until you find a working combination - then add the rest of your mods one by one or in groups
  • Topics

×
×
  • Create New...

Important Information

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