Jump to content

Does anyone know how to make custom shapeles recipes?


NukolLodda

Recommended Posts

So I'm new to Minecraft modding and I'm not too sure how to make custom shapeless recipes. Basically I have a machine called the alloy furnace with 3 inputs, but some recipes involving it only requires 2 inputs and as a result I want to make it shapeless. Along with that, the 3 input slots don't have any differences between them so it shouldn't matter which slot you put the item in. However, I want to make it so the recipes aren't hardcoded into my mod so instead json files are used instead. However I've yet to figure out how to allow for shapeless recipes. This is the code I've thought of so far, I'd imagine this probably looks like amateur stuff but this really is the best my almost deep fried brain can think of


boolean hasIng = false; if (recipe.isPresent()) { for (int i = 0; i < entity.itemHandler.getSlots(); i++) { for (int j = 0; j < recipe.get().getIngredients().size(); j++) { if (entity.itemHandler.getStackInSlot(i) .equals(recipe.get().getIngredients().get(j).getItems()[0])) { hasIng = true; } } } }

 

so if anyone can explain this to me, I'd really appreciate it.

Link to comment
Share on other sites

Try searching for the Shapeless Recipe in your workspace program's external libraries, which should have been downloaded along with the assets when you set up gradle for Forge. Looking at that file will show you how Minecraft sets it up and you can tinker with it in a custom file of your own from there. Additionally, take a look at how the crafting table handles the matching up of ingredients for shapeless recipes.

You can also look at my two-slot fuel free furnace type that uses shapeless recipes. I did exactly as described above to design my custom recipe class and then built my entity class.

https://github.com/toadie-odie/TodeCoins/blob/1.3.2/src/main/java/net/warrentode/todecoins/recipe/CoinPressRecipe.java

https://github.com/toadie-odie/TodeCoins/blob/1.3.2/src/main/java/net/warrentode/todecoins/block/entity/CoinPressBlockEntity.java

An alternative recipe check method can be looked at here: 

https://github.com/toadie-odie/TodeVillagers/blob/master_03/src/main/java/net/warrentode/todevillagers/blocks/entity/GlassKilnBlockEntity.java

I think maybe that the Glass Kiln one would be easier for you starting out, it was for me. In your case the points of interest are at lines 164 and 215.

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.



×
×
  • Create New...

Important Information

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