Jump to content

New Recipes Unlocked Functionality


BaconBombing

Recommended Posts

I've searched far and wide, but I can't find an existing thread for this or a solution online. Can someone help me? I'm new to modding and making a new item tier. When you collect certain resources, for example diamonds, it pops up that recipes have been unlocked and it shows all recipes that use diamonds. They also appear in the crafting book helper.

 

Can I create this for custom items? For example, pick up emeralds and new items pop up for emerald tools and the recipes show in the crafting table. 

 

Thanks for your help!

Edited by BaconBombing
Link to comment
Share on other sites

Those work like advancements:

There's a small mention about advancements in recipes section, but doesn't really help much. https://mcforge.readthedocs.io/en/latest/utilities/recipes/

gamepedia is more helpful in this case: https://minecraft.gamepedia.com/Advancements

EDIT: advancements json format: https://minecraft.gamepedia.com/Advancements/JSON_format

about advancement conditions: https://minecraft.gamepedia.com/Advancements/Conditions

 

to get you started you could use this as a template: it goes under src/main/resources/data/modid/advancements/recipes/item_name.json

{
  "parent": "minecraft:recipes/root",
  "requirements": [
    [
      "has_item",
      "has_the_recipe"
    ]
  ],
  "criteria": {
    "has_item": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "tag": "forge:ingots/iron"
          }
        ]
      }
    },
    "has_the_recipe": {
      "trigger": "minecraft:recipe_unlocked",
      "conditions": {
        "recipe": "modid:mod_item"
      }
    }
  },
  "rewards": {
    "recipes": [
      "modid:mod_item"
    ]
  }
}

 

Edited by Crare1
added link: https://minecraft.gamepedia.com/Advancements/JSON_format
  • Thanks 1

Useful Tools - Early game items for your building and farming needs.

 

Link to comment
Share on other sites

3 hours ago, Crare1 said:

Those work like advancements

They are advancements, actually.

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

Thank you so much!! This worked super well! I read a bunch of both of your other replies on other topics and they really help. I also found this https://github.com/skylinerw/guides/blob/master/java/advancements.md for documentation on advancements.

 

Also, in my case do I still need the "has item recipe" condition? Emeralds don't really have a crafting recipe, if that's what that condition does.

 

Here is my code for others who want to add this same feature:

{
  "parent": "minecraft:recipes/root",
  "requirements": [
    [
      "has_item"
    ]
  ],
  "criteria": {
    "has_item": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "minecraft:emerald"
          }
        ]
      }
    }
  },
  "rewards": {
    "recipes": [
      "standardmaterials:emerald_sword",
      "standardmaterials:emerald_pickaxe",
      "standardmaterials:emerald_axe",
      "standardmaterials:emerald_shovel",
      "standardmaterials:emerald_hoe"
    ]
  }
}

 

Edited by BaconBombing
Link to comment
Share on other sites

5 hours ago, BaconBombing said:

Also, in my case do I still need the "has item recipe" condition?

Has recipe is a condition that says "does the player know the recipe? If so, grant the advancement."

The recipe in question here is whatever recipe you're rewarding the player with. Not the ingredient's crafting recipe.

 

Reward:

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/resources/data/expindustry/advancements/recipes/machine_filter.json#L29

Condition:
https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/resources/data/expindustry/advancements/recipes/machine_filter.json#L23

  • Thanks 1

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

Okay that kind of makes sense. I only added emerald sword to "has the recipe" condition and it now adds recipes to the crafting book when they get the corresponding materials, like it's supposed to. Thanks!

 

Does it make a difference to have all of the tools added instead? When I copy lines for the other items it gives the error "duplicate statement" on the statement "recipe". I checked your other files in the link to the GitHub, and it looks like you did separate files for each one. So if it does make a difference, how do I add multiple items to the "has the recipe" condition in the same file or should I do it separately? 

"has_the_recipe": {
      "trigger": "minecraft:recipe_unlocked",
      "conditions": {
        "recipe": "standardmaterials:emerald_sword"
      }
    }
  }

 

Edited by BaconBombing
Link to comment
Share on other sites

6 hours ago, BaconBombing said:

So if it does make a difference, how do I add multiple items to the "has the recipe" condition in the same file or should I do it separately? 

Technically, yes. Because the player could "have" the recipe for the pickaxe, but not the sword.

 

 

This one was done in 1.12, but the syntax should be the same.

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/resources/assets/harderores/advancements/recipes/stone_tools.json

  • Thanks 1

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



×
×
  • Create New...

Important Information

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