Skip to content

Replace ExtendedRecipe with data-driven functions - #45

Open
SquidDev wants to merge 1 commit into
CaitlynMainer:main-MC1.21.1from
SquidDev:squid/recipe-transformers
Open

Replace ExtendedRecipe with data-driven functions#45
SquidDev wants to merge 1 commit into
CaitlynMainer:main-MC1.21.1from
SquidDev:squid/recipe-transformers

Conversation

@SquidDev

@SquidDev SquidDev commented Aug 9, 2026

Copy link
Copy Markdown

ExtendedRecipe and its associated recipe classes transform the output of the recipe according to some rules defined by the shape of the recipe. This is a little confusing and inflexible (for instance, the floppy dying recipes are meant to preserve their contents, but don't!).

We replace this system with a new transform_{shaped,shapeless} recipe type, which applies a list of RecipeFunctions (similar to loot functions, but for recipes) on the result.

In most cases, we can use a simple copy_components to copy some or all of the components from an item in the crafting recipe to the result. For instance, floppy dying now copies all components except for the colour (and similarly for robot flags).

I'm marking this as draft, as I want to get some feedback on this approach before writing too much more code. This feels a little over-engineered, but I think actually ends up providing the right level of flexibility — I think we'll need a couple more recipe functions to handle things like EEPROM swapping and print crafting, but it avoids having to build many custom recipes types.

Some of this code is originally taken from CC:T, but I am the sole author, so happy to relicense under OC's license.

Example

{
  "type": "opencomputers:transform_shapeless",
  "category": "misc",
  "functions": [
    {
      "type": "opencomputers:copy_components",
      "exclude": [
        "opencomputers:robot_flag"
      ],
      "from": {"item": "opencomputers:robot"}
    }
  ],
  "ingredients": [
    {"tag": "c:dyes/light_blue"},
    {"tag": "c:dyes/pink"},
    {"tag": "c:dyes/white"},
    {"item": "minecraft:stick"},
    {"item": "opencomputers:robot"}
  ],
  "result": {
    "components": {
      "opencomputers:robot_flag": "opencomputers:trans_flag"
    },
    "count": 1,
    "id": "opencomputers:robot"
  }
}

@SquidDev
SquidDev force-pushed the squid/recipe-transformers branch from d045e4a to 47387c7 Compare August 10, 2026 14:54
@SquidDev
SquidDev marked this pull request as ready for review August 10, 2026 14:57
ExtendedRecipe and its associated recipe classes transform the output of
the recipe according to some rules defined by the shape of the recipe.
This is a little confusing and inflexible (for instance, the floppy
dying recipes are *meant* to preserve their contents, but don't!).

We replace this system with a new transform_{shaped,shapeless} recipe
type, which applies a list of "RecipeFunction"s (similar to loot
functions, but for recipes) on the result.

In most cases, we can use a simple "copy_components" to copy some or all
of the components from an item in the crafting recipe to the result.
For instance, floppy dying now copies all components except for the
colour. However, we also require several other functions:

 - AddPrintLight: Increases the print light by a set amount.
 - ReplaceEEPROM: Replaces the EEPROM within an item's component list.
 - SetDefaultArchitecture: Sets the default architecture to the
   currently configured default.
 - SetEEPROMData: Sets the EEPROM code/data to the *current* contents of
   the asset.
 - SetSourceMap: Copies the resulting map into the navigation upgrade.
 - SetUniqueTunnel: Generates a unique tunnel ID.
@SquidDev
SquidDev force-pushed the squid/recipe-transformers branch from 47387c7 to ac4934a Compare August 11, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant