Jump to content

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


oitsjustjose

Recommended Posts

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

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

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