Jump to content

[1.16.5] Invalid or unsupported recipe type


bibouche_

Recommended Posts

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 by bibouche_
Link to comment
Share on other sites

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);

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.