LutzBlox Posted April 13, 2013 Posted April 13, 2013 I am making a mod that requires you to craft a pocket knife. When you use the pocket knife in crafting recipes, it takes damage. I have the code done for it to take damage, but the game will not let me craft the specified item if the pocket knife has taken damage. Item Class: package mods.GreatOutdoors.client.core; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class PocketKnife extends Item { public PocketKnife(int par1) { super(par1); this.setHasSubtypes(false); this.setMaxDamage(50); this.setCreativeTab(CreativeTabs.tabMaterials); } @SideOnly(Side.CLIENT) @Override public void updateIcons(IconRegister iconRegister) { iconIndex = iconRegister.registerIcon("GreatOutdoors:pocketKnife"); } } Crafting Handler: package mods.GreatOutdoors.client.core; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.ICraftingHandler; public class GreatOutdoorsCraftingHandler implements ICraftingHandler { @Override public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) { for(int i = 0; i < craftMatrix.getSizeInventory();i++) { if(craftMatrix.getStackInSlot(i) != null) { ItemStack j = craftMatrix.getStackInSlot(i); if(j.getItem() != null && j.getItem() == GreatOutdoors_Main.PocketKnife) { ItemStack k = new ItemStack(GreatOutdoors_Main.PocketKnife, 2, (j.getItemDamage()+1)); if(k.getItemDamage() >= k.getMaxDamage()) { k.stackSize--; } craftMatrix.setInventorySlotContents(i, k); } } } } @Override public void onSmelting(EntityPlayer player, ItemStack item) { } } Crafting Recipes: GameRegistry.addShapelessRecipe(new ItemStack(Bark),new ItemStack(Block.wood,1,0),new ItemStack(GreatOutdoors_Main.PocketKnife,1,-1)); Is there any code I need to add to any of these to allow the bark to be crafted even if the pocket knife has a damage value? Thanks in advance! Quote
mnn Posted April 16, 2013 Posted April 16, 2013 Mojang changed in 1.5 value of "any damage" in recipes. Use "OreDictionary.WILDCARD_VALUE" instead of "-1" and you should fine . Quote mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
mnn Posted April 16, 2013 Posted April 16, 2013 Mojang changed in 1.5 value of "any damage" in recipes. Use "OreDictionary.WILDCARD_VALUE" instead of "-1" and you should fine . Quote mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
Recommended Posts
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.