Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

(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
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I have been trying to download Forge but the Windows Installer isn't coming up, I can see the installer one would use for Linux but no Windows, I have downloaded Java and Jarfix but nothing is working, can someone help?  
    • So I thought that when a capability is attached to an item/entity/etc... the capability will stay until whatever it's attached to is gone. But this doesn't seem to be the case, as when I printed to console whenever a capability is attached, it seems as though a new version of the capability is attached to an item every time I select it in my hotbar, hover over it in inventory, etc. Is this how it's supposed to work? If so, why?
    • Hi, I'm trying to set up a simple forge server just to play with a couple of my friends, but no matter what I do or try I cannot seem to get a Mods folder and for the actual forge part of the server to actually launch. Every time I try to launch the forge.jar via a .bat file I just get a bunch of errors [Errors below] I'm not sure what I'm doing wrong. If I can get some help that would be awesome, thanks C:\Users\User\Desktop\Server>java -Xms2G -Xmx6G -jar forge-1.12.2-14.23.5.2855.jar nogui A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.base/java.lang.reflect.Method.invoke(Method.java:567)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')         at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)         ... 6 more C:\Users\User\Desktop\Server>pause Press any key to continue . . .  
    • Is it ok if i ask what that is?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.