I wanted to add a recipe thats takes a water bucket and an other item (soybeans) and outputs a bucket of another liquid (soymilk). However, doing this the usual way gives an empty bucket back (only the water is consumed as water bucket is set to have a empty bucket as a remainder)
This is why I started to set up a SpecialCraftingRecipe and tried to copy how Mojang does it by looking at the code for others SpecialCraftingRecipe. My ultimate goal with this SpecialCraftingRecipe is to override the method getRemainder().
In my data generator class, among my other recipe builders, I added this line:
ComplexRecipeJsonBuilder.create(SoymilkRecipe::new).offerTo(exporter, "mymodname:soymilk");
I also added the class :
public class SoymilkRecipe extends SpecialCraftingRecipe {...}
Whose body doesn't matter that much for now, the only problematic method is getSerializer, this is where my error is coming from. Here is the method:
@Override
public RecipeSerializer<?> getSerializer() {
return Registry.register(Registries.RECIPE_SERIALIZER, "mymodname:crafting_special_soymilk", new SpecialRecipeSerializer<>(SoymilkRecipe::new));
}
When running the data generation I get this error:
Caused by: java.lang.IllegalStateException: Registry is already frozen (trying to add key ResourceKey[minecraft:recipe_serializer / mymodname:crafting_special_soymilk])
My problem probably comes from my very little understanding of registries and how or when they are initialized and frozen.