Posted July 8, 20214 yr Hi everyone, I wanted to create a new type of recipe for my mod, So I created a new class for the recipe, with the serializer, I have no problems at all, just that I have an error saying "Parsing error loading recipe alcamod:argentite_sword_forging" and "Invalid or unsupported recipe type 'alcamod:forging'". I made sure to register the serializer with the deferred Register, registered the DeferredRegister with the mod event bus and the recipe Type with IRecipeType.register(Alcamod.ModID + "forging") I also made sure that my recipe json is correct, with the right type and so on. But the game is still throwing the same error. Can someone please help me ? I looked everywhere on the forums but found nothing that solved my problem. Here is my Serializer : public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<ForgeRecipe> { @Override public ForgeRecipe read( ResourceLocation recipeId, JsonObject json) { Ingredient base = Ingredient.deserialize(JSONUtils.getJsonObject(json, "base")); Ingredient compressor = Ingredient.deserialize(JSONUtils.getJsonObject(json, "compressor")); ItemStack result = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(json, "result")); return new ForgeRecipe(recipeId, base, compressor, result); } @Nullable @Override public ForgeRecipe read( ResourceLocation recipeId, PacketBuffer buffer) { Ingredient base = Ingredient.read(buffer); Ingredient compressor = Ingredient.read(buffer); ItemStack result = buffer.readItemStack(); return new ForgeRecipe(recipeId, base, compressor, result); } @Override public void write( PacketBuffer buffer, ForgeRecipe recipe) { recipe.base.write(buffer); recipe.compressor.write(buffer); buffer.writeItemStack(recipe.result); } } My JSON recipe: { "type": "alcamod:forging", "base": { "item": "minecraft:netherite_sword" }, "compressor": { "item": "alcamod:tools_compressor_tier_1" }, "result": { "item": "alcamod:argentite_sword" } } And the registering: public class ModRecipes { public static final DeferredRegister <IRecipeSerializer<?>> recipe_serializers = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, Alcamod.ModID); public static class Types { public static final IRecipeType<ForgeRecipe> FORGING = IRecipeType.register(Alcamod.ModID + "forging"); } public static class Serializers { public static final RegistryObject<IRecipeSerializer<?>> FORGING = recipe_serializers.register("forging", ForgeRecipe.Serializer::new); } } Also the recipe: public class ForgeRecipe implements IRecipe <IInventory> { private final Ingredient base; private final Ingredient compressor; private final ItemStack result; private final ResourceLocation recipeId; public ForgeRecipe(ResourceLocation recipeId, Ingredient base, Ingredient compressor, ItemStack result) { this.recipeId = recipeId; this.base = base; this.compressor = compressor; this.result = result; } @Override public boolean matches( IInventory inv, World worldIn) { return this.base.test(inv.getStackInSlot(0)) && this.compressor.test(inv.getStackInSlot(2)); } @Override public ItemStack getCraftingResult( IInventory inv) { return this.result.copy(); } @Override public boolean canFit( int width, int height) { return width * height >= 3; } @Override public ResourceLocation getId() { return this.recipeId; } @Override public ItemStack getRecipeOutput() { return this.result; } @Override public ItemStack getIcon() { return new ItemStack(ModBlocks.FORGE_ITEM.get()); } @Override public IRecipeSerializer <?> getSerializer() { return ModRecipes.Serializers.FORGING.get(); } @Override public IRecipeType <?> getType() { return ModRecipes.Types.FORGING; } } Thank you for your help, and if I missed something please tell me (Edit: added the recipe class) Edited July 8, 20214 yr by bibouche_
July 8, 20214 yr Author The two nested classes are for organisation, not to mix up the type and the serializer. But ur right I can change the names to FORGING_TYPE and FORGING_SERIALIZER. I register it in my main class : ModRecipes.recipe_serializers.register(bus);
July 8, 20214 yr Author Alright, unnesting the two nested classes seems to fix the issue, but I don't really understand why they are not loading btw Edited July 8, 20214 yr by bibouche_
July 8, 20214 yr Author 1 minute ago, diesieben07 said: If you don't reference a class, it is not loaded. Oh, yeah indeed. Well, thanks !
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.