0

I was following this tutorial and I was trying to create a custom recipe.

However it seems that recipe jsons cannot be parsed and read properly.

[23:41:37] [Render thread/INFO] (Minecraft) Created: 1024x512x0 minecraft:textures/atlas/gui.png-atlas
[23:41:44] [Worker-Main-6/ERROR] (Minecraft) Couldn't parse data file 'tutorial-mod:pink_garnet' from 'tutorial-mod:recipe/pink_garnet.json': DataResult.Error['List is too short: 0, expected range [1-9]']
[23:41:44] [Worker-Main-6/ERROR] (Minecraft) Couldn't parse data file 'tutorial-mod:pink_garnet_block' from 'tutorial-mod:recipe/pink_garnet_block.json': DataResult.Error['Map entry '#' : Failed to parse either. First: Input does not contain a key [fabric:type]: MapLike[{"item":"tutorial-mod:pink_garnet"}]; Second: Failed to parse either. First: Not a string: {"item":"tutorial-mod:pink_garnet"}; Second: Failed to parse either. First: Not a json array: {"item":"tutorial-mod:pink_garnet"}; Second: Not a string: {"item":"tutorial-mod:pink_garnet"}']
[23:41:44] [Render thread/INFO] (Minecraft) Loaded 1370 recipes
[23:41:44] [Render thread/INFO] (Minecraft) Loaded 1481 advancements

Here is the resource/data/tutorial-mod/recipe/pink_garnet_block.json:

{
  "type": "minecraft:crafting_shaped",
  "category": "misc",
  "key": {
    "#": {
      "item": "tutorial-mod:pink_garnet"
    }
  },
  "pattern": [
    "###",
    "###",
    "###"
  ],
  "result": {
    "count": 1,
    "id": "tutorial-mod:pink_garnet_block"
  }
}

Here is the resource/data/tutorial-mod/recipe/pink_garnet.json:

{
  "type": "minecraft:crafting_shapeless",
  "category": "building",
  "ingredients": [
    {
      "item": "tutorial-mod:pink_garnet_block"
    }
  ],
  "result": {
    "count": 9,
    "id": "minecraft:diamond"
  }
}

Here is the src/main/java/me/saudoge/TutorialMod.java:

package me.saudoge;

import me.saudoge.block.ModBlocks;
import me.saudoge.item.ModItemGroups;
import me.saudoge.item.ModItems;
import net.fabricmc.api.ModInitializer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TutorialMod implements ModInitializer {
    public static final String MOD_ID = "tutorial-mod";

    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    @Override
    public void onInitialize() {

       LOGGER.info("Hello Fabric world!");
       ModItems.registerModItems();
       ModBlocks.registerModBlocks();
       ModItemGroups.registerItemGroups();
    }
}

Here is the folder structure:

folder structure image

Here is the github repo link if anyone wants to replicate the error:

https://github.com/SauDoge/tutorial-mod-template-1.21.4

I don't know what went wrong but I suspect that the folder structure is somehow wrong.

I saw a few questions asking about solving the problem by using "id" instead of "item", but I am already using "id".

2 Answers 2

2

The reason it is unable to parse the JSON file is because your syntax related to the ingredients has changed in 1.21.4. For your example the new syntax should look like this.

For the Pink Garnet Block:

{
  "type": "minecraft:crafting_shaped",
  "category": "misc",
  "key": {
    "#": "tutorial-mod:pink_garnet"
  },
  "pattern": [
    "###",
    "###",
    "###"
  ],
  "result": {
    "count": 1,
    "id": "tutorial-mod:pink_garnet_block"
  }
}

For the Pink Garnet Block to Diamond

{
  "type": "minecraft:crafting_shapeless",
  "category": "building",
  "ingredients": [
    {
      "tutorial-mod:pink_garnet_block"
    }
  ],
  "result": {
    "count": 9,
    "id": "minecraft:diamond"
  }
}

The ingredients no longer use the "'item':" tag for some reason.

Just as an added tidbit, you can check how all vanilla recipes are formatted in the "net.minecraft:minecraft-merged-abba00472f:1.21.4-net.fabricmc.yarn.1_21_4.1.21.4+build.8-v2" external library!

Sign up to request clarification or add additional context in comments.

Comments

0

I would like to add to the previous answer, which was very helpful.

I'm using neoforge 21.7.3-beta for minecraft 1.21.7, and I couldn't parse the json files with the syntax :

{
  "type": "minecraft:crafting_shapeless",
  "ingredients": [
    {
      "minecraft:dirt"
    }
  ],
  "result": {
    "id": "minecraft:diamond",
    "list": 1
  }
}

The correct syntax was :

{
  "type": "minecraft:crafting_shapeless",
  "ingredients": [
      "minecraft:dirt"
  ],
  "result": {
    "id": "minecraft:diamond",
    "list": 1
  }
}

Notice the lack of { } after "ingedients".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.