Replace ExtendedRecipe with data-driven functions - #45
Open
SquidDev wants to merge 1 commit into
Open
Conversation
SquidDev
force-pushed
the
squid/recipe-transformers
branch
from
August 10, 2026 14:54
d045e4a to
47387c7
Compare
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
force-pushed
the
squid/recipe-transformers
branch
from
August 11, 2026 08:31
47387c7 to
ac4934a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ExtendedRecipeand 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 ofRecipeFunctions (similar to loot functions, but for recipes) on the result.In most cases, we can use a simple
copy_componentsto 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" } }