Jump to content

[1.10.2] Getting crafting/smelting recipe from item


hugo_the_dwarf

Recommended Posts

So I'm working on professions for my mod, and one of them is a blacksmith (crafts better gear, repairs, upgrades, and salvages items/gear)

Naturally above I mention Salvage which will be one of the skills. I want to be able to take a wooden shovel and dismantle it, with chances of returning each item used to make it

 

33% to return wood plank (no way to find the meta for what type default to oak)

33% per stick (2 sticks)

 

and any other item (that is craftable) like crafting benches, boats, clock, redstone torches, etc. The logic of how i'll handle some things will differ but that's my concern. I'm wondering how I can get the recipe and then make my "dismantle logic"

 

I've asked about smelting recipes because I have another profession "Miner" and breaking blocks that "drop" items other than themself will drop more (coal ore, emerald ore, lapiz ore, redstone ore, etc) however I'd like to be able to check the block (does it drop itself? no bonus, does the block drop items, yes. Can those items be used to remake this block again (IE Glowstone) no bonus) More or less I'd like to be able to ensure that block cannot be recrafted, and placed again to break it again. This would be such things like smooth stone (doesn't drop itself, but drops cobble (unless silk touch, silktouch automatically never gives a bonus)) you can smelt cobble to smooth, naturally no extra cobble should be given.

 

TL;DR

How do I get a recipe for an item, be it crafting or smelting from the item?

Link to comment
Share on other sites

So I'm working on professions for my mod, and one of them is a blacksmith (crafts better gear, repairs, upgrades, and salvages items/gear)

Naturally above I mention Salvage which will be one of the skills. I want to be able to take a wooden shovel and dismantle it, with chances of returning each item used to make it

 

33% to return wood plank (no way to find the meta for what type default to oak)

33% per stick (2 sticks)

 

and any other item (that is craftable) like crafting benches, boats, clock, redstone torches, etc. The logic of how i'll handle some things will differ but that's my concern. I'm wondering how I can get the recipe and then make my "dismantle logic"

 

I've asked about smelting recipes because I have another profession "Miner" and breaking blocks that "drop" items other than themself will drop more (coal ore, emerald ore, lapiz ore, redstone ore, etc) however I'd like to be able to check the block (does it drop itself? no bonus, does the block drop items, yes. Can those items be used to remake this block again (IE Glowstone) no bonus) More or less I'd like to be able to ensure that block cannot be recrafted, and placed again to break it again. This would be such things like smooth stone (doesn't drop itself, but drops cobble (unless silk touch, silktouch automatically never gives a bonus)) you can smelt cobble to smooth, naturally no extra cobble should be given.

 

TL;DR

How do I get a recipe for an item, be it crafting or smelting from the item?

Loop through the recipes. Ie FurnaceRecipes.instance().getSmeltingList() or CraftingManager.getInstance().getRecipeList()

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

Getting the recipe result while looping through the crafting list is very easy, as the IRecipe interface includes

getRecipeOutput()

.  So that'll let you narrow in on the right recipe quickly.

 

From there, you just need to convert it to the proper recipe class (there are several) and get the inputs.  Do note that (most!) tools are of type ShapedOreRecipe and they're made up of lists of items in each slot, rather than a single item (I had to write a recipe comparison function last night that would take in an arbitrary recipe and find recipe with the same pattern, but using a different material: i.e. given the recipe for a wooden axe, find the recipe for the golden axe; that was fun).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.