package common.item;

import java.util.List;

import common.entity.npc.EntityNPC;
import common.entity.projectile.EntityHook;
import common.init.SoundEvent;
import common.model.Model;
import common.model.ModelProvider;
import common.model.Transforms;
import common.world.World;

public class ItemFishingRod extends Item
{
    public ItemFishingRod()
    {
        this.setMaxDamage(64);
        this.setMaxStackSize(1);
        this.setTab(CheatTab.tabTools);
    }

//    /**
//     * 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.fishEntity != null)
        {
            int i = playerIn.fishEntity.handleHookRetraction();
            itemStackIn.damageItem(i, playerIn);
            playerIn.swingItem();
        }
        else
        {
            worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F);

            if (!worldIn.client)
            {
                worldIn.spawnEntityInWorld(new EntityHook(worldIn, playerIn));
            }

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

        return itemStackIn;
    }

    /**
     * Checks isDamagable and if it cannot be stacked
     */
    public boolean isItemTool(ItemStack stack)
    {
        return super.isItemTool(stack);
    }

    /**
     * Return the enchantability factor of the item, most of the time is based on material.
     */
    public int getItemEnchantability()
    {
        return 1;
    }
    
    public void getRenderItems(Item itemIn, List<ItemStack> subItems) {
    	subItems.add(new ItemStack(itemIn, 1, 0));
    	subItems.add(new ItemStack(itemIn, 1, 1));
    }

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

    public Model getModel(ModelProvider provider, String name, int meta) {
    	return provider.getModel(this.getTransform(), meta == 1 ? "fishing_rod_cast" : "fishing_rod");
    }
}
