I'm trying to implement a custom recipe for my custom block entity, but I'm running into some issues.
The Error
Unknown recipe category: [!!!com.mojang.logging.LogUtils$1ToString@5cde7cee=>java.lang.NullPointerException:Cannot invoke "Object.toString()" because the return value of "java.util.function.Supplier.get()" is null!!!]/golden-plague:infectious_sludge_from_separating
Description
The error only happens on loading data(packs). The result is that nothing happens, and I've found that given a defined Optional<RecipeEntry<SeparatorRecipe>> recipe, recipe.isPresent() is false
Recipe JSON:
{
"type": "golden-plague:separating",
"ingredients": [
{
"item": "golden-plague:plagued_dirt"
},
{
"item": "minecraft:coal"
},
{
"item": "golden-plague:infectious_sludge"
},
{
"item": "golden-plague:pustule"
}
],
"output": {
"id": "golden-plague:infectious_sludge"
},
"group": "separator",
"experience": 0.1,
"processTime": 150
}
In my serializer, I have this for the mapCodec:
this.codec = RecordCodecBuilder.mapCodec(
instance -> instance.group(
Codec.list(Ingredient.DISALLOW_EMPTY_CODEC).fieldOf("ingredients").forGetter(recipe -> recipe.recipeItems),
ItemStack.VALIDATED_UNCOUNTED_CODEC.fieldOf("output").forGetter(recipe -> recipe.output),
CraftingRecipeCategory.CODEC.fieldOf("category").orElse(CraftingRecipeCategory.MISC).forGetter(recipe -> recipe.category),
Codec.STRING.optionalFieldOf("group", "").forGetter(recipe -> recipe.group),
Codec.FLOAT.fieldOf("experience").orElse(0.0f).forGetter(recipe -> recipe.experience),
Codec.INT.fieldOf("processTime").orElse(processTime).forGetter(recipe -> recipe.processTime)
).apply(instance, recipeFactory::create)
);```
and the read/write methods are correctly reading/writing a value of `CraftingRecipeCategory.MISC`