Jump to content

[1.8] Making a crafting recipe item back (or another item)


Lycarah

Recommended Posts

Hey guys, at first: Sry if my english is bad (i'm just a german :D).

 

I want to make an crafting recipe (shaped or shapeless doesnt matter) where the item i put in don't loose, or tat i get another item back on the crafting table like the cake recipe where you put a milk bucket in and get the empty bucket back. Something like that, i hope you can understand me. :D

I know how to make normal crafting recipes (shaped and shapeless), but i dont know how i should do THIS :D

 

I hope you can help me :D

Link to comment
Share on other sites

If it's your own item that should give something back, you need to use the container item system.

 

I've written an example of an unbreaking container item (never breaks) and a breaking container item (breaks after a fixed number of uses). You can see how to use them in recipes here.

 

These examples are for 1.7.10, but should work in 1.8 as well.

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

You'll probably need to make your own recipe class that implements

IRecipe

(extending an existing implementation will simplify things) and override

IRecipe#getRemainingItems

to return an array containing the container item for each slot (if any) and your custom remaining item for any slot containing the appropriate vanilla item.

ForgeHooks.defaultRecipeGetRemainingItems

will create and fill an array of the container items, so you can just search for the vanilla item. If you extend an existing shaped/shapeless recipe class, you can probably just call

super.getRemainingItems

instead of the

ForgeHooks

method.

 

Make sure you register your recipe class with

RecipeSorter.register

.

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

Okey, i have tried an own thing...and it worked so i wanna explain how i have done this for anybody who has the same problem, so here it goes:

 

I have made a shapeless crafting recipe where i put my item "braunkohle" in and get an diamond and there will be a stick left, where i have put my item "Braunkohle. It worked for vanilla items only as well, so here is my code so you can see how i have done this:

 

GameRegistry.addShapelessRecipe(new ItemStack(Items.diamond), new ItemStack(braunkohle.setContainerItem(Items.stick)));

GameRegistry.addShapelessRecipe(new ItemStack(Items.blaze_rod), new ItemStack(Items.apple.setContainerItem(Items.stick)));

 

Thanks for all, this thread can be closed now :D

 

PS: Thx Choonster, that works also :D

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



×
×
  • Create New...

Important Information

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