Jump to content

[1.10/1.11] Damage vanilla item during crafting?


Cleverpanda

Recommended Posts

Hello.

I'm trying to use shears as a tool in a mod recipe, but they are not being damaged when I craft the item. Doing a bit of research, it looks like I need to use an ShapedOreRecipe that implements IRecipe. Can anyone confirm? Also, I know basically I want to increase damage by 1 and then return the shears in the grid, but I can't find any code examples of how to accomplish this, like what goes in what method and what the minimum code I need is. Any help there would be great too. or an easier method. Thanks!

Link to comment
Share on other sites

You do need your own implementation of IRecipe, though it can extend an existing implementation like ShapedOreRecipe.

 

You need to implement IRecipe#getRemainingItems to return a list containing the container item (ForgeHooks.getContainerItem) for every slot except the shears. For the shears, copy the stack and then damage the copy with ItemStack#attemptDamageItem.

 

If the shears were broken (ItemStack#attemptDamageItem returned true), call ForgeEventFactory.onPlayerDestroyItem with the player returned by ForgeHooks.getCraftingPlayer as the first argument to fire PlayerDestroyItemEvent and then use ItemStack.EMPTY (null in 1.10.2) as the remaining item for the slot.

 

If the shears weren't broken, use the damaged stack as the remaining item for the slot.

Edited by Choonster

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

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.