Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

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

 

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.

  • Author

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

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

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.

  • Author

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

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

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.