Posted February 20, 20178 yr 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!
February 20, 20178 yr 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 February 20, 20178 yr 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.
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.