NeoForge icon indicating copy to clipboard operation
NeoForge copied to clipboard

[1.20.4] "override" field for solving overlaps in recipe ingredients and patterns.

Open bconlon1 opened this issue 9 months ago • 4 comments

This PR adds a new field called 'override" to Crafting and Smelting recipes that allows for specifying a String that correlates to another recipe's ID. The recipe with the override field will then be prioritized over the recipe with the given ID. This is different from overriding by file in datapacks because it is intended as a way of solving problems caused by a recipe using a broad tag and a modder needing to make a recipe with the same pattern and only one ingredient of that tag.

For example, a modder may be trying to make a Chest for a specific wood type, but in Vanilla, crafting Chests uses the #planks tag, so all wood types are normally going to give the default Chest block. Using this, a modder could specify "override": "minecraft:chest" in their recipe and it would make their recipe take priority only if using the specific wood block that the chest uses.

Attached is a datapack that demonstrates this system in action. 2024-05-05_11 53 43 2024-05-05_11 53 54 Recipe Override Test.zip

This PR changes some of the data structures used in first constructing the recipe map in RecipeManager to allow for this, as in Vanilla it uses a HashMap that can't be ordered. The changes in this PR have the side effect of also making recipes now be ordered logically by their ResourceLocation, which is mostly alphabetical.

bconlon1 avatar May 05 '24 19:05 bconlon1

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 05 '24 19:05 CLAassistant

  • [ ] Publish PR to GitHub Packages

Marking as draft; need to reduce the amount of patches.

bconlon1 avatar May 05 '24 19:05 bconlon1

I've done this with no changes to vanilla with just a custom recipe on 1.19, same idea could port over to 1.20+

All you have to do is a custom implementation of matches which returns false if it matches the "override" recipe. Its a little bit less efficient than your approach, but does not require changing so many recipe manager internals

KnightMiner avatar May 05 '24 20:05 KnightMiner