Jump to content

(SOLVED) Custom Crafting Table recipes not working


Recommended Posts

It's me again. I got the custom crafting table to work – it appears in the world, I can open it, and it doesn't close right away, which is always a plus. However, it doesn't seem my new recipe type has registered. Here is a picture of my directory to see which classes I copied over.

How am I supposed to register a new recipe type?

Screen Shot 2020-05-14 at 7.45.10 PM.png

Edited by TheThorneCorporation
  • Thanks 1
Link to comment
Share on other sites

debug.logBumping because I can't figure out how to register the Recipe/RecipeSerializer.

I have this class to store the advanced crafting recipe type:

public interface IThorneRecipeType<T extends IRecipe<?>> extends IRecipeType<T> {
   IRecipeType<IAdvancedCraftingRecipe> ADVANCED_CRAFTING = register("advanced_crafting");

   static <T extends IRecipe<?>> IThorneRecipeType<T> register(final String key) {
      return Registry.register(Registry.RECIPE_TYPE, new ResourceLocation(key), new IThorneRecipeType<T>() {
         public String toString() {
            return key;
         }
      });
   }

   default <C extends IInventory> Optional<T> matches(IRecipe<C> recipe, World worldIn, C inv) {
      return recipe.matches(inv, worldIn) ? Optional.of((T)recipe) : Optional.empty();
   }
}

which should have registered the recipe type. (I'm doing both shapeless and shaped advanced crafting recipes.)

I also have this class which should have registered the advanced recipe type serializers:

public interface IThorneRecipeSerializer<T extends IRecipe<?>> extends IRecipeSerializer<T> {

	IRecipeSerializer<ShapelessAdvancedRecipe> ADVANCED_CRAFTING_SHAPELESS = register("advanced_crafting_shapeless", new ShapelessAdvancedRecipe.Serializer());
	IRecipeSerializer<ShapedAdvancedRecipe> ADVANCED_CRAFTING_SHAPED = register("advanced_crafting_shaped", new ShapedAdvancedRecipe.Serializer());

	static <S extends IRecipeSerializer<T>, T extends IRecipe<?>> S register(String key, S recipeSerializer) {
		return IRecipeSerializer.register(key, recipeSerializer);
	}
}

The recipe still isn't registering, though. Am I supposed to use a RegistryEvent or something?

 

Edited by TheThorneCorporation
Oops, wrong log.
Link to comment
Share on other sites

First, extending an interface is arbitrary the way you are doing it. IRecipeType does not need to be extended and can be just declared a static final variable using IRecipeType#register. Second, IRecipeSerializer needs to be extended on a ForgeRegistryEntry class. The reason I say this is even though you might have already done it is that if you looked at the original class, you can see it extends a basic implementation of a registry. So yes, you do need a RegistryEvent using the old method or could update to using DeferredRegister and RegistryObject.

 

 

  • Like 1
Link to comment
Share on other sites

Okay, I rewrote IThorneRecipeSerializer like this:

public interface IThorneRecipeSerializer<T extends IRecipe<?>> extends IRecipeSerializer<T> {

	public static IRecipeSerializer<ShapelessAdvancedRecipe> ADVANCED_CRAFTING_SHAPELESS = register("advanced_crafting_shapeless", new ShapelessAdvancedRecipe.Serializer());
	public static IRecipeSerializer<ShapedAdvancedRecipe> ADVANCED_CRAFTING_SHAPED = register("advanced_crafting_shaped", new ShapedAdvancedRecipe.Serializer());

	static <S extends IRecipeSerializer<T>, T extends IRecipe<?>> S register(String key, S recipeSerializer) {
		return IRecipeSerializer.register(key, recipeSerializer);
	}
}

 

and added this to my RegistryEvents:

@SubscribeEvent
public static void registerRecipeSerializers(final RegistryEvent.Register<IRecipeSerializer<?>> event) {
	event.getRegistry().registerAll
	(
		IThorneRecipeSerializer.ADVANCED_CRAFTING_SHAPED,
		IThorneRecipeSerializer.ADVANCED_CRAFTING_SHAPELESS
	);
}

 

but it's still not working.

I'll work on getting a GitHub repo up.

Edited by TheThorneCorporation
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.