Creating Crafting and Smelting Recipes

This is another chapter with no Java programming and all the configuration will be done using JSON files.

We will go over how to create all kinds of crafting recipes and also add smelting functionality to our copper ore block.

For the sake of demonstration, a new copper_block is added using the same process as before. Feel free to do it on your own as a practice.

copper_block texture

copper item

Crafting recipes

Crafting recipes are divided into two types: shaped recipes and shapeless recipes. The difference is whether there's a required pattern. Think of crafting an enchanting table versus dyeing wool.

Shaped recipe

Let's start with the most simple case. We want to write a recipe that crafts one copper_block from nine copper ingots.

We will add a recipe file.

src/main/resources
├── assets
│   └── ...
├── data
│   └── examplemod
│       ├── loot_tables
│       │   └── blocks
│       │       └── copper_ore.json
│       └── recipes
│           └── copper_block.json*
├── META-INF
│   └── mods.toml
└── pack.mcmeta

filenames with a * next to them are ones added or modified


recipes/copper_block.json

{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "xxx",
    "xxx",
    "xxx"
  ],
  "key": {
    "x": {
      "item": "examplemod:copper"
    }
  },
  "result": {
    "item": "examplemod:copper_block",
    "count": 1
  }
}

This file describes how to make a copper_block from copper ingots. The pattern field shows what to place in the nine squares while the key field helps elaborate what the symbols mean. Lastly, the result field, as the name suggests, specifies the output of the recipe and the quantity.

shaped recipe

Also, keep in mind that we are not limited to just one ingredient. Take a look at the enchanting table recipe from the vanilla game:

enchanting_table.json

{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    " B ",
    "D#D",
    "###"
  ],
  "key": {
    "B": {
      "item": "minecraft:book"
    },
    "#": {
      "item": "minecraft:obsidian"
    },
    "D": {
      "item": "minecraft:diamond"
    }
  },
  "result": {
    "item": "minecraft:enchanting_table"
  }
}

Shapeless recipe

Shapeless recipes are just like shaped recipes but don't have a set pattern. You toss in the required ingredients and get your result.

Just for fun, let's add a recipe that crafts a diamond from one iron_ingot plus two copper ingots:

src/main/resources
├── assets
│   └── ...
├── data
│   └── examplemod
│       ├── loot_tables
│       │   └── blocks
│       │       └── copper_ore.json
│       └── recipes
│           ├── copper_block.json
│           └── diamond.json*
├── META-INF
│   └── mods.toml
└── pack.mcmeta

filenames with a * next to them are ones added or modified


recipes/diamond.json

{
  "type": "minecraft:crafting_shapeless",
  "ingredients": [
    {
      "item": "minecraft:iron_ingot"
    },
    {
      "item": "examplemod:copper"
    },
    {
      "item": "examplemod:copper"
    }
  ],
  "result": {
    "item": "minecraft:diamond"
  }
}

In this case, we just have the ingredients field instead of pattern and key. Also, note that count doesn't work here and we need to copy the ingredient item multiple times.

basic loot table

Smelting

Smelting is handled using recipes as well. A smelting recipe is easy to write:

src/main/resources
├── assets
│   └── ...
├── data
│   └── examplemod
│       ├── loot_tables
│       │   └── blocks
│       │       └── copper_ore.json
│       └── recipes
│           ├── copper_block.json
│           ├── copper_from_smelting.json*
│           └── diamond.json
├── META-INF
│   └── mods.toml
└── pack.mcmeta

filenames with a * next to them are ones added or modified


copper_from_smelting.json

{
  "type": "minecraft:smelting",
  "ingredient": {
    "item": "examplemod:copper_ore"
  },
  "result": "examplemod:copper",
  "experience": 0.7,
  "cookingtime": 200
}

We can define the ingredient, cookingtime, and the amount of experience gained.

basic loot table

What about the Blast Furnace?

Adding support for the blast furnace is also quite simple. Just add another recipe and you are done.

src/main/resources
├── assets
│   └── ...
├── data
│   └── examplemod
│       ├── loot_tables
│       │   └── blocks
│       │       └── copper_ore.json
│       └── recipes
│           ├── copper_block.json
│           ├── copper_from_blasting.json*
│           ├── copper_from_smelting.json
│           └── diamond.json
├── META-INF
│   └── mods.toml
└── pack.mcmeta

filenames with a * next to them are ones added or modified


copper_from_blasting.json

{
  "type": "minecraft:blasting",
  "ingredient": {
    "item": "examplemod:copper_ore"
  },
  "result": "examplemod:copper",
  "experience": 0.7,
  "cookingtime": 100
}

It is basically the same as a smelting recipe. Change the type and cookingtime and you should be good to go.

basic loot table

Closing

Hope you enjoyed this chapter on crafting and smelting recipes. In the next chapter, we will move on to some more advanced topics and take a look at natural ore generation. Meanwhile, go make some more recipes 🍳

results matching ""

    No results matching ""