Ran into this today, it seems to be caused by Gradle 7.6, as going back to 7.5 makes the issue go away. I'm not sure what is going on beyond that though.
I was trying to use this to remove a recipe (not a vanilla recipe) however this doesn't seem to be allowed.
if (ForgeRegistries.RECIPES.containsValue(recipe)) {
ForgeRegistries.RECIPES.getEntries().remove(recipe);
}
I'll try replacing it instead.