Skip to Content
Foundry Apparatus

Recipes

Available since 0.1.0

Teach machines what to do. Inputs and outputs, items, fluids and energy, chances, priorities, and crafting table recipes.

A recipe tells a machine what to take, how long to work and what to give back. Recipes live in foundry_apparatus/recipes/, one per file, and you can change them with /reload without restarting the game.

Your first recipe

This recipe turns one raw iron into one iron ingot in 5 seconds:

foundry_apparatus/recipes/smelt_iron.json
{
  "schema_version": 1,
  "id": "mypack:smelt_iron",
  "type": "foundry_apparatus:machine_recipe",
  "machines": [
    "mypack:iron_smelter"
  ],
  "duration": 100,
  "inputs": [
    {
      "type": "item",
      "id": "minecraft:raw_iron",
      "amount": 1
    }
  ],
  "outputs": [
    {
      "type": "item",
      "id": "minecraft:iron_ingot",
      "amount": 1
    }
  ]
}
  • type is foundry_apparatus:machine_recipe for every machine recipe.
  • machines lists the machines that can run it, by id. One recipe can serve several machines.
  • duration is how long it takes, in ticks. Minecraft runs 20 ticks per second, so 100 is 5 seconds.
  • inputs is what the machine takes; outputs is what it gives back.

Inputs and outputs

Every input and output has a type, what it is (id) and how much (amount):

{
  "type": "item",
  "id": "minecraft:raw_iron",
  "amount": 1
}

The amount is in the unit of the type:

TypeUnit of amount
itemitems
foundry_apparatus:fluidmillibuckets (1000 = one bucket)
foundry_apparatus:energyFE
foundry_apparatus:xpexperience points

Instead of one specific item, an input can accept a whole group with a tag. This input accepts any iron ore:

{
  "type": "item",
  "tag": "c:ores/iron",
  "amount": 1
}

Fluids and energy

A recipe can mix any types. This one, from a fluid mixer, takes a bucket of water and a bucket of lava, uses 40 FE every tick, and makes obsidian:

foundry_apparatus/recipes/mix_obsidian.json
{
  "schema_version": 1,
  "id": "mypack:mix_obsidian",
  "type": "foundry_apparatus:machine_recipe",
  "machines": [
    "mypack:fluid_mixer"
  ],
  "duration": 60,
  "inputs": [
    {
      "type": "foundry_apparatus:fluid",
      "id": "minecraft:water",
      "amount": 1000,
      "storage": "water_in"
    },
    {
      "type": "foundry_apparatus:fluid",
      "id": "minecraft:lava",
      "amount": 1000,
      "storage": "lava_in"
    },
    {
      "type": "foundry_apparatus:energy",
      "amount": 40,
      "consumption": "per_tick"
    }
  ],
  "outputs": [
    {
      "type": "item",
      "id": "minecraft:obsidian",
      "amount": 1
    }
  ]
}

Two new fields appear here:

  • storage says which of the machine's storages an input comes from. Without it, the machine looks in every storage that can hold that type. Use it when a machine has several storages of the same kind, like the water tank and the lava tank above.
  • consumption says when an input is taken:
ValueWhen it is taken
start (default)All at once, when the recipe starts.
per_tickamount every tick while the machine works. 40 FE per tick for 60 ticks is 2,400 FE in total.
endAll at once, when the recipe finishes.

A recipe only starts when every input is there and every output fits in the machine. If the output is full, the machine waits instead of losing anything.

Chances

An output with a chance is only produced sometimes. The chance is a percentage, and decimals are allowed:

"outputs": [
  {
    "type": "item",
    "id": "minecraft:obsidian",
    "amount": 1
  },
  {
    "type": "item",
    "id": "minecraft:crying_obsidian",
    "amount": 1,
    "chance": 5
  }
]

Obsidian always comes out; crying obsidian comes out too, 5% of the time. Each chance is rolled on its own.

Exactly one of several results

To give one result picked from a list, wrap them in one_of. Each chance is that result's share of a single roll:

"outputs": [
  {
    "one_of": [
      {
        "type": "item",
        "id": "minecraft:diamond",
        "amount": 1,
        "chance": 10
      },
      {
        "type": "item",
        "id": "minecraft:emerald",
        "amount": 1,
        "chance": 30
      }
    ]
  }
]

Here a diamond comes out 10% of the time, an emerald 30% of the time, and nothing the remaining 60%. The chances in one group can add up to 100 at most.

When several recipes match

If more than one recipe could run with what is inside the machine, the one with the highest priority wins (the default is 0). When priorities are equal, recipes are ordered by id, so the choice is always the same on every computer:

"priority": 10

To switch a recipe off without deleting its file, add "enabled": false.

Crafting table recipes

Your pack can also add normal crafting table recipes, for example to craft the machine itself. A shaped recipe draws the grid with letters:

foundry_apparatus/recipes/iron_smelter.json
{
  "schema_version": 1,
  "id": "mypack:iron_smelter",
  "type": "foundry_apparatus:crafting_shaped",
  "pattern": [
    "III",
    "IFI",
    "III"
  ],
  "key": {
    "I": {
      "id": "minecraft:iron_ingot"
    },
    "F": {
      "id": "minecraft:furnace"
    }
  },
  "result": {
    "id": "mypack:iron_smelter"
  }
}

Each letter in pattern is a slot of the crafting grid, a space is an empty slot, and key says which item each letter means. For recipes where the position does not matter, use foundry_apparatus:crafting_shapeless with an ingredients list instead.

What is next

Recipes take from and put into storages. To show their progress to players, give the machine a screen. Every field is listed in the recipe reference.

On this page