CraftTweaker

CraftTweaker

151M Downloads

[1.17] Restructure IRecipeManager with generics

Darkhax opened this issue · 2 comments

commented

Feature request name
Restructure IRecipeManager with generics.

Feature request description
I would like to see IRecipeManager accept a generic parameter of <T extends IRecipe<?>>. This type would then be used instead of WrappedRecipe.

Feature request reason
Having natively typed IRecipeManager would really clean up custom mod support. For example I currently have to write my own "get by id" method to give people my type, and often run into people who are trying to use the built in method which returns the wrong type.

Natively typed IRecipeManager would also allow for several new types of features to be added to the underlying interface. For example a forEach and iterator on IRecipeManager would be really useful for scripts that aim to make sweeping changes.

Feature request dependencies
This feature would require breaking changes to IRecipeManager and WrappedRecipe. If done carefully I don't think this would break scripts. All the WrappedRecipe code would simply be replaced with a new native for IRecipe<?>.

Game Version
1.17 because 1.16 would be a breaking change for current mod implementations.

commented

It's done.

for rec in craftingTable.getRecipesByOutput(<item:minecraft:iron_ingot>) {
    println((rec as Recipe<Container>).getId().commandString);
}

Is how it can be used in a script (cast to the specific recipe type, like BlastingRecipe for the recipe manager

commented

Thanks :)