Jump to content

Recommended Posts

Posted
14 minutes ago, Arkyo said:

which shall I use

Depends on what you want to do. It is generally recommended to use json recipes whenever possible since you get:

  1. No ~1000line-long classes that register various recipes but instead each recipe is neatly in it's own file. Easy to edit anytime you want without having to spend minutes trying to search for that one line that defines the recipe
  2. Any pack maker can easily alter your recipe with a datapack(1.13). No specific recipe-altering mods required.
  3. The _constants file. In it you can easily define a constant that corresponds to an item. Or to multiple items. Or to an oredict enty. Or to both. Here is an example of me using one constant to handle differently named oredict entries. While you kinda can do the same with hardcoded recipes it's not as intuitive and easy as just writing a couple of files in your json.
  4. If something goes wrong with a json recipe the game will kindly provide a log of what went wrong. If something goes wrong with a hardcoded recipe - it just will be missing from the game with no indication as to why.
  5. You will need all your recipes to be json recipes for 1.13 anyway.

However for some complex recipes you will need to use "hardcoded" IRecipe implementation. An example of that would be leather armor dyeing or firework making. There is however a point to be made that even custom IRecipe implementations can still be registered with json as I do here and here.

 

14 minutes ago, Arkyo said:

how to use

If you are using json recipes simply create a recipes folder in your assets/modid folder. All json recipes will then go there. Here is a minecraftwiki page with a description of the format and here is the examples I used myself provided by Lex.

If you are using in-code registration subscribe to RegistryEvent.Register<IRecipe> and use event.getRegistry().register to register your recipes. Do not forget to give them a registry name!

Posted (edited)
12 minutes ago, V0idWa1k3r said:

Depends on what you want to do. It is generally recommended to use json recipes whenever possible since you get:

  1. No ~1000line-long classes that register various recipes but instead each recipe is neatly in it's own file. Easy to edit anytime you want without having to spend minutes trying to search for that one line that defines the recipe
  2. Any pack maker can easily alter your recipe with a datapack(1.13). No specific recipe-altering mods required.
  3. The _constants file. In it you can easily define a constant that corresponds to an item. Or to multiple items. Or to an oredict enty. Or to both. Here is an example of me using one constant to handle differently named oredict entries. While you kinda can do the same with hardcoded recipes it's not as intuitive and easy as just writing a couple of files in your json.
  4. If something goes wrong with a json recipe the game will kindly provide a log of what went wrong. If something goes wrong with a hardcoded recipe - it just will be missing from the game with no indication as to why.
  5. You will need all your recipes to be json recipes for 1.13 anyway.

However for some complex recipes you will need to use "hardcoded" IRecipe implementation. An example of that would be leather armor dyeing or firework making. There is however a point to be made that even custom IRecipe implementations can still be registered with json as I do here and here.

 

If you are using json recipes simply create a recipes folder in your assets/modid folder. All json recipes will then go there. Here is a minecraftwiki page with a description of the format and here is the examples I used myself provided by Lex.

If you are using in-code registration subscribe to RegistryEvent.Register<IRecipe> and use event.getRegistry().register to register your recipes. Do not forget to give them a registry name!

Thanks for the reply!

However my recipe still doesn't work...

 

{
    "type": "minecraft:crafting_shapeless",
    "ingredient": 
      {"item": "minecraft:lever"},
  "result": {
    "item": "openscriptie:bit"
  }
}

 

Also, is there anyway to specify number of ingredients in a single slot?

Edited by Arkyo
Posted (edited)
11 minutes ago, Arkyo said:

number of ingredients in a single slot?

No, vanilla crafting recipes do not work in this manner.'='

 

11 minutes ago, Arkyo said:

However my recipe still doesn't work...

What does the log say? Also did you even take a look at mcjty's tutorial? You're missing the key and pattern tag.

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 minute ago, Arkyo said:

What does the log say? 

There is no reference to your recipe in the log, where is the json file located, and

4 minutes ago, Animefan8888 said:

Also did you even take a look at mcjty's tutorial? You're missing the key and pattern tag.

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted (edited)
2 minutes ago, Animefan8888 said:

There is no reference to your recipe in the log, where is the json file located, and

 

I am using shapeless recipe, so no keys and patterns needed (?)

 

it is located as assets/openscripties/recipe/lever_to_bit.json

Edited by Arkyo
Posted
5 minutes ago, Arkyo said:

I am using shapeless recipe

 

it is located as assets/openscripties/recipe/lever_to_bit.json

That should be assets/<modid>/recipes/<filename>.json - "recipes", not "recipe"

Posted
2 minutes ago, desht said:

That should be assets/<modid>/recipes/<filename>.json - "recipes", not "recipe"

Thanks , changed to recipes , still failed.

Posted
10 minutes ago, Animefan8888 said:

You're missing the key and pattern tag.

Those are for shaped recipes, OP is using a shapeless one.

 

18 minutes ago, Arkyo said:

{

    "type": "minecraft:crafting_shapeless",

    "ingredient":

    {

        "item": "minecraft:lever"

    },

    "result":

    {

        "item": "openscriptie:bit"

    }

}

Shapeless recipes specify their ingredients as a json array named ingredients.

Additionally if the item has subtypes the "data" key must also be provided(data is metadata)

Posted
Just now, V0idWa1k3r said:

Those are for shaped recipes, OP is using a shapeless one. 

 

7 minutes ago, Arkyo said:

I am using shapeless recipe, so no keys and patterns needed (?)

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
{

  "type": "minecraft:crafting_shapeless",

  "ingredients":
  [
  {

    "item": "minecraft:lever"

  }],

  "result":

  {

    "item": "openscriptie:bit"

  }

}

Failed

Posted (edited)
21 minutes ago, Arkyo said:

Failed

Is there an error in the log? Its most likely the ingredients being an array of objects instead of an array of strings.

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
8 minutes ago, Animefan8888 said:

Is there an error in the log? Its most likely the ingredients being an array of objects instead of an array of strings.

I found an interesting thing

recipes seems to be completely ignored

[20:39:35] [main/TRACE] [FML]: Recursing into package assets
[20:39:35] [main/TRACE] [FML]: Recursing into package assets/openscriptie
[20:39:35] [main/TRACE] [FML]: Recursing into package assets/openscriptie/lang
[20:39:35] [main/TRACE] [FML]: Recursing into package assets/openscriptie/models
[20:39:35] [main/TRACE] [FML]: Recursing into package assets/openscriptie/models/item
[20:39:35] [main/TRACE] [FML]: Recursing into package assets/openscriptie/textures
[20:39:35] [main/TRACE] [FML]: Recursing into package assets/openscriptie/textures/items
[20:39:35] [main/TRACE] [FML]: Recursing into package chingdim
[20:39:35] [main/TRACE] [FML]: Recursing into package chingdim/OpenScriptie
[20:39:35] [main/TRACE] [FML]: Recursing into package chingdim/OpenScriptie/eventhandler
[20:39:35] [main/TRACE] [FML]: Recursing into package chingdim/OpenScriptie/item
Posted
11 minutes ago, Arkyo said:

I found an interesting thing

recipes seems to be completely ignored

 

24 minutes ago, Animefan8888 said:

Is there an error in the log?

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted (edited)
4 minutes ago, Animefan8888 said:

Your path is assets/openscripties/recipes not assets/openscriptie/recipes

My mistake , modid is openscriptie , no s

Changed ingredients to array of string , failed

Edited by Arkyo
Posted
14 minutes ago, Animefan8888 said:

Change it back, that was my mistake as noted by me striking out the text.

Done , and of course still failed :(

Posted
5 minutes ago, Animefan8888 said:

Post updated json and path as well as the log.

 

lol , just found a wrong path issue , resolved and now recipe shows.

 

Thank you so much for following up on my case!

Posted

Yeah, the "problem" with the JSON asset system is that you have to get everything exactly right and if you don't there isn't always a lot of good warning on exactly what is wrong. For actual Java code, your IDE (like Eclipse) will warn you instantly of references to non-recognizable things, misspellings, wrongly formatted code. But for JSON you have to usually do a lot more manual checking -- is path exactly right, is filename exactly right, is the file a properly formed JSON, are the values in the JSON exactly right.

 

Once you're used to the amount of detail required though you'll pay attention and also have some common ideas on where to look to fix problems that arise.

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

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.