7 ‐ Datapack Support - terrarium-earth/Cognition GitHub Wiki

As of v2.4.5, filling, emptying and infecting recipes are data-driven alongside Metamorpher recipes, and custom recipes may be added via datapacks. This page provides a guide on recipe formatting for datapack makers.

⚠️ Recipe formatting is slightly different between Minecraft 1.21.1 and 1.20.1. In 1.20.1, the id field in result (where the item id of the result itemstack is passed in) is called item instead.

Metamorphosis

A standard Metamorpher recipe looks like this:

{
  "type": "cognition:molecular_metamorphosis",
  "ingredient1": {
    "item": "cognition:astute_assembly"
  },
  "count1": 1,
  "ingredient2": {
    "tag": "minecraft:saplings"
  },
  "count2": 1,
  "ingredient3": {
    "item": "minecraft:gold_ingot"
  },
  "count3": 1,
  "result": {
    "id": "cognition:primordial_assembly",
    "count": 1
  },
  "cost": 315,
  "processTime": 100,
  "id": "cognition:primordial_assembly"
}

Each of the ingredient fields accept either a singular item or an item tag representing a set of valid items. For instance, this recipe would accept any vanilla or modded item tagged with minecraft:saplings for the second ingredient. Each of the count fields represent the number of each ingredient required in each input slots for the recipe to be initiated. The result of the recipe goes in the result field, where additional data may be added to the result item stack using data components. Lastly, the cost field describes the cost of the recipe in experience points, while the processTime field describes the number of ticks it takes for the Metamorpher to process it.

All JSON Metamorpher recipes are shapeless, which is to say the arrangement of the ingredients in the Metamorpher's input slots does not matter. The only exceptions are the name formatting recipes, which are shaped (in order to make it clear to the Metamorpher which of the three inputs is the target item).

Should your recipe require only one or two input slots, one or more of the ingredients may be left blank by passing in an empty array [] as follows:

{
  "type": "cognition:molecular_metamorphosis",
  "ingredient1": {
    "item": "minecraft:copper_ingot"
  },
  "count1": 1,
  "ingredient2": {
    "item": "cognition:cognitive_flux"
  },
  "count2": 2,
  "ingredient3": [],
  "count3": 0,
  "result": {
    "id": "cognition:cognitive_alloy",
    "count": 1
  },
  "cost": 16,
  "processTime": 20,
  "id": "cognition:cognitive_alloy_metamorphosis"
}

Infecting

A typical infecting recipe looks like this:

{
  "type": "cognition:infecting",
  "input": {
    "tag": "c:bookshelves"
  },
  "result": {
    "id": "cognition:infected_bookshelf",
    "count": 1
  },
  "infectionCount": 1,
  "id": "cognition:infected_bookshelf"
}

The input field accepts either a singular item or item tag, while the result field accepts an item stack. Both the input and result items must be block items for the recipe to work.

Two things of note:

  • The infectionCount field exists only for convenience purposes when displaying recipes in JEI and does not do anything in-game. The property of being infected more than once for conversion is intrinsic to Fluorescent Agar, and counts greater than 1 will be ignored for any other block.
  • Even though this recipe deals with blocks, ingredient fields don't support block tags, meaning that only item tags can be used. You will have to make your own item tags if they don't already exist.

Filling and Emptying

Typical filling recipes look like this:

{
  "type": "cognition:filling",
  "ingredient": {
    "item": "minecraft:glass_bottle"
  },
  "result": {
    "id": "minecraft:experience_bottle",
    "count": 1
  },
  "cost_mB": 250,
  "id": "cognition:experience_bottle_filling"
}

The ingredient field, once again, accepts either a singular item or tag, while the result field accepts an item stack. The amount of Cognitium in mB that is consumed from the Obelisk is set in the cost_mB field.

Emptying recipes are much the same, with the gain_mB field describing how much Cognitium is added to the Obelisk when the experience item is emptied. The sole important difference is the hasResultStack field. When set to false, this will tell the Fountain to consume the experience item without leaving behind a result item. A valid item stack has to be present in the result field regardless, or the recipe will fail to parse.

{
  "type": "cognition:emptying",
  "ingredient": {
    "item": "minecraft:experience_bottle"
  },
  "result": {
    "id": "minecraft:glass_bottle",
    "count": 1
  },
  "hasResultStack": true,
  "gain_mB": 250,
  "id": "cognition:experience_bottle_emptying"
}

A sample recipe that does not have a result item:

{
  "type": "cognition:emptying",
  "ingredient": {
    "item": "forbidden_arcanus:xpetrified_orb"
  },
  "result": {
    "id": "minecraft:barrier",
    "count": 1
  },
  "hasResultStack": false,
  "gain_mB": 1820,
  "id": "cognition:xpetrified_orb_emptying"
}