Posted July 23, 201411 yr I am working on an update to my mod the Recipe Expansion Pack and I am having trouble making the plant book take durability when used (right clicked). I am writing my code inside of the "onItemUse" method. The issue is when I use it on wheat the first time the durability goes from 64/64 to 63/64 but then goes back up to 64/64 again when I use it the second time. This continues in a never ending loop each time I right click it resulting in the durability never going below 63. Here is my code: public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { //Code to check stage of Wheat if(par3World.getBlock(par4, par5, par6) == Blocks.wheat && par2EntityPlayer.worldObj.isRemote) { String text = "Wheat (Stage " + (par3World.getBlockMetadata(par4, par5, par6)); if((par3World.getBlockMetadata(par4, par5, par6) == 7)) { text = text + " - \"Mature\""; } text = text + ")"; if(!text.equals("")) { par2EntityPlayer.addChatComponentMessage(new ChatComponentText(text)); if(!par2EntityPlayer.capabilities.isCreativeMode) { par1ItemStack.damageItem(1, par2EntityPlayer); } } } }[/Code] Any help with this would be greatly appreciated, as it seems very odd and has confused me for quite some time. Creator of the Recipe Expansion Pack mod. http://www.minecraftforum.net/topic/1983421-172-forge-recipe-expansion-pack-version-012/ Updated to 1.7.2!
July 23, 201411 yr Author Actually I just realized the problem. So I figured I would just post this for future reference. The issue is right here: //Code to check stage of Wheat if(par3World.getBlock(par4, par5, par6) == Blocks.wheat && par2EntityPlayer.worldObj.isRemote) { Apparently durability damage must be done client side so it should be this: //Code to check stage of Wheat if(par3World.getBlock(par4, par5, par6) == Blocks.wheat && !par2EntityPlayer.worldObj.isRemote) { Creator of the Recipe Expansion Pack mod. http://www.minecraftforum.net/topic/1983421-172-forge-recipe-expansion-pack-version-012/ Updated to 1.7.2!
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.