Posted August 24, 201312 yr I am creating a mod that add an armor that the player can eat to replenish their hunger bar at the cost of the armor's durability. I created a new class that inherits from the ItemArmor class. However, on right click I run the same methods as the onEaten method of ItemFood. Everything is working properly, my hunger bar is replenishing and my duribility is decreasing, except there are no particle effects rendering and the time it takes to eat once is too fast even though I have overiden the method getMaxItemUseDuration to retrun 4 times the default number of ticks. I am attaching my armor class and a video of what's wrong. So my question is how do I add the particle effects and make the eating duration longer? package eclipse.MoreApples.armor; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemAppleIronBoots extends ItemArmor{ public ItemAppleIronBoots(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4) { super(par1, par2EnumArmorMaterial, par3, par4); } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register){ this.itemIcon = register.registerIcon("more_apples:appleIron_boots"); } public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer){ return "more_apples:textures/models/armor/appleIron_layer_1.png"; } @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par1ItemStack.attemptDamageItem(2, new Random()); par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); par3EntityPlayer.setEating(true); par2World.playSoundAtEntity(par3EntityPlayer, "random.burp", 0.5F, par2World.rand.nextFloat() * 0.1F + 0.9F); par3EntityPlayer.getFoodStats().addStats(2, 0.2F); return par1ItemStack; } @Override public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.eat; } @Override public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 128; } } http://www.mediafire.com/watch/tfu73fvurizbdzq/Eating_Doesn't_Render_Particle_Effects.mp4
August 24, 201312 yr Remove par3EntityPlayer.setEating(true); it is already done by setItemInUse(args); Also move methods in, and override: @Override public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par1ItemStack.attemptDamageItem(2, new Random()); par2World.playSoundAtEntity(par3EntityPlayer, "random.burp", 0.5F, par2World.rand.nextFloat() * 0.1F + 0.9F); par3EntityPlayer.getFoodStats().addStats(2, 0.2F); return par1ItemStack;
August 25, 201312 yr Author Thanks, I overrode the onEaten method and updated the onItemRightClick method. Now the particle effects are loading properly and the eating in on a proper speed. Thanks a bunch!
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.