package net.minecraft.item; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.passive.EntityPig; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.stats.StatList; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemCarrotOnAStick extends Item { public ItemCarrotOnAStick() { this.setCreativeTab(CreativeTabs.TRANSPORTATION); this.setMaxStackSize(1); this.setMaxDamage(25); } /** * Returns True is the item is renderer in full 3D when hold. */ @SideOnly(Side.CLIENT) public boolean isFull3D() { return true; } /** * Returns true if this item should be rotated by 180 degrees around the Y axis when being held in an entities * hands. */ @SideOnly(Side.CLIENT) public boolean shouldRotateAroundWhenRendering() { return true; } /** * Called when the equipped item is right clicked. */ public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (worldIn.isRemote) { return new ActionResult(EnumActionResult.PASS, itemstack); } else { if (playerIn.isRiding() && playerIn.getRidingEntity() instanceof EntityPig) { EntityPig entitypig = (EntityPig)playerIn.getRidingEntity(); if (itemstack.getMaxDamage() - itemstack.getMetadata() >= 7 && entitypig.boost()) { itemstack.damageItem(7, playerIn); if (itemstack.isEmpty()) { ItemStack itemstack1 = new ItemStack(Items.FISHING_ROD); itemstack1.setTagCompound(itemstack.getTagCompound()); return new ActionResult(EnumActionResult.SUCCESS, itemstack1); } return new ActionResult(EnumActionResult.SUCCESS, itemstack); } } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.PASS, itemstack); } } }