Jump to content

[1.12.2] Is it still possible to programatically register recipes?


Recommended Posts

Posted (edited)

I assume I'm just doing something wrong here.  My test recipe shows up in NEI, but it doesn't show up in the recipe book and can't be crafted.  Here's the code:

  @SubscribeEvent
  public static void registerRecipes(final RegistryEvent.Register<IRecipe> event) {
    event.getRegistry().register(
        new ShapelessRecipes(
            "gradient",
            new ItemStack(Items.APPLE),
            NonNullList.from(null, 
                Ingredient.fromStacks(new ItemStack(Items.CLAY_BALL)),
                Ingredient.fromStacks(new ItemStack(Blocks.SAND, 1, OreDictionary.WILDCARD_VALUE))
            )
        ).setRegistryName(GradientMod.MODID, "recipe.tests")
    );
  }

 

For the record, I want to move some of my json recipes back to code because prior to 1.12, many recipes were automatically generated based on melting point, hardness, etc.  With json recipes, whenever I add a new cast/metal/tool/whatever I have to add quite a few files manually.

 

Sub-question:

Was wildcard support removed from json recipes?  When I updated from 1.12 to 1.12.2, this recipe stopped working:

{
  "type": "minecraft:crafting_shapeless",
  "result": {
    "item": "gradient:clay_cast_unhardened",
    "data": 0
  },
  "ingredients": [{
    "item": "minecraft:clay_ball"
  }, {
    "item": "minecraft:sand",
    "data": 32767
  }]
}

 

There were no other changes.  When data is changed from 32767 to 0, the recipe works (but obviously only supports regular sand).

Edited by Corey
Posted

You can yes, but you shouldn't. If you have all the data you need at compile time, then just generate the json files. 

As for your second question, we're looking into it, but due to how the recipe book works, you need to specify all sub-items in recipes.

  • Like 1

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Cool, that sounds like a good solution.  Thanks for the help.

 

For anyone else looking for an answer to the second question: until there's a better way, I just ended up defining a _constant called #SAND that includes sand with data 0 and 1.

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.