Posted May 14, 20205 yr 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? Edited May 17, 20205 yr by TheThorneCorporation
May 15, 20205 yr Author 20 hours ago, TheRedWaffle said: Have you registered the Recipe/RecipeSerializer? With that hint, you have catapulted me into the depths of knowledge which I needed but did not even know was there. Thank you so much.
May 16, 20205 yr Author 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 May 16, 20205 yr by TheThorneCorporation Oops, wrong log.
May 16, 20205 yr 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.
May 17, 20205 yr Author 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 May 17, 20205 yr by TheThorneCorporation
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.