Jump to content

[1.14.4] [SOLVED] Custom ShapelessRecipe class inconsistent with Crafting


Recommended Posts

Posted (edited)

I've just spent hours trying to figure out what's wrong, and I give up for now and figured I'd ask here.

 

I'm working on a custom Natural Progression mod wherein you can only craft planks by combining a log with an axe (for 1 plank) or a saw (for 4 planks). Since I'm able to say "hey this recipe belongs to me" with any shapeless recipe, I'm also nabbing any recipes where the input is a single Log (determined via ItemTags and BlockTags [block derived from a BlockItem]) so that I can set the output to ItemStack.EMPTY.

 

This works as expected for many logs (including stripped and some of BoP's and others who use the tag and name system similar to Mojang/Forge specifications/recommendations). But the issue is that random (at least as far as I can tell) blocks - such as the Jungle Log and all #minecraft:jungle_logs don't work.

I've narrowed it down to this: 

  1. ShapelessRecipe#matches does not even get called when inserting a single stack (of any qty) of <problem log> to any slot in the crafting table
  2. Upon inserting 2+ stacks of any qty into the crafting table, ShapelessRecipe#matches is called (but at this point it has failed my qualifications for a single log)
  3. The tags are correct for Jungle wood, the only problem child.
  4. My custom recipe of axe + <problem log> = 1 plank works
  5. My custom recipe of saw + <problem log> = 4 planks works

 

Is this an issue in Forge or is it just me? I know I can disable the recipe(s) via JSON but would like to have automatic compatability since this non-hacky solution is available.

 

Here's a video of the problem: https://drive.google.com/file/d/1pFYcqrqI9z0XHxObUTdS__XynVNdSeao/view?usp=sharing

Here's the code in question: https://github.com/oitsjustjose/Natural-Progression/blob/master/src/main/java/com/oitsjustjose/naturalprogression/common/utils/PlankRecipe.java

Edited by oitsjustjose
Change title
Posted
4 hours ago, oitsjustjose said:

Is this an issue in Forge or is it just me?

This is just you. You never actually modify the vanilla recipes or BOPs recipes out of the game. Therefore they are still registered and you are hoping your recipe will be found in the registry first. You cannot do this. It doesnt work in all cases.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
5 hours ago, Animefan8888 said:

This is just you. You never actually modify the vanilla recipes or BOPs recipes out of the game. Therefore they are still registered and you are hoping your recipe will be found in the registry first. You cannot do this. It doesnt work in all cases.

That makes sense. I had a hunch that it had something to do with priority / race condition, it I wasn’t sure and wondered if it was something else. Ok. 
 

Is there a way to programmatically remove recipes? I’m aware of RecipeManager but I’m not sure in which context I can obtain an instance (or should I declare my own?), and either way I’ve had issues with not being able to remove from the list (I imagine by the time it becomes accessible it is immutable but I didn’t look too far into it as it felt like a hack).

Posted
2 hours ago, oitsjustjose said:

That makes sense. I had a hunch that it had something to do with priority / race condition, it I wasn’t sure and wondered if it was something else. Ok. 
 

Is there a way to programmatically remove recipes? I’m aware of RecipeManager but I’m not sure in which context I can obtain an instance (or should I declare my own?), and either way I’ve had issues with not being able to remove from the list (I imagine by the time it becomes accessible it is immutable but I didn’t look too far into it as it felt like a hack).

 

You can see how I remove recipes according to various conditions here. The recipe maps are immutable, but the fields storing them aren't final.

  • Thanks 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
2 hours ago, oitsjustjose said:

Is there a way to programmatically remove recipes?

Of course there is. Normally it shouldn't be done, but since this also refers to other mods I'll say it here(not sure if overriding another mods recipe is viable with the data system). 

 

Basically you'll likely need reflection and the RecipeManager is stored server side inside the World class. If it isn't immutable just replace the IRecipe instance with a dummy instance that returns ItemStack.EMPTY when it is matched. However when replacing them maybe check the output first to see if it is planks. If it is Immutable replace the whole fields value.

  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 hour ago, Choonster said:

 

You can see how I remove recipes according to various conditions here. The recipe maps are immutable, but the fields storing them aren't final.

Wow, this is perfect! Thank you!!

 

I've implemented it, with modifications, here if anyone is curious as to what the solution is -- of course be sure to properly credit Choonster's hard work.

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.