#Custom Recipe not loading [RESOLVED]

5 messages · Page 1 of 1 (latest)

timid shoal
#

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`
#

If you need more info, please let me know and I will be happy to provide. let me know if anyone has any experience or insights with this

#

Custom Recipe not loading (Unknown Category)

burnt heart
#

I suspect your recipe class isn't returning the category correctly in the method to get it

timid shoal
#

This was the issue! Thank you, resolved.