package common.item.tool;

import common.entity.animal.EntityPig;
import common.entity.npc.EntityNPC;
import common.init.Items;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.model.Transforms;
import common.world.World;

public class ItemCarrotOnAStick extends Item
{
    public ItemCarrotOnAStick()
    {
        this.setTab(CheatTab.TOOLS);
        this.setMaxDamage(25);
    }

//    /**
//     * Returns True is the item is renderer in full 3D when hold.
//     */
//    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.
//     */
//    public boolean shouldRotateAroundWhenRendering()
//    {
//        return true;
//    }

    /**
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
     */
    public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
    {
        if (playerIn.isRiding() && playerIn.vehicle instanceof EntityPig)
        {
            EntityPig entitypig = (EntityPig)playerIn.vehicle;

            if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getItemDamage() >= 7)
            {
                entitypig.getAIControlledByPlayer().boostSpeed();
                itemStackIn.damageItem(7, playerIn);

                if (itemStackIn.size == 0)
                {
                    ItemStack itemstack = new ItemStack(Items.fishing_rod);
                    itemstack.setTagCompound(itemStackIn.getTagCompound());
                    return itemstack;
                }
            }
        }

//        playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
        return itemStackIn;
    }

    public Transforms getTransform() {
    	return Transforms.TOOL_FLIP;
    }
}
