package common.item.tool;

import common.entity.npc.EntityNPC;
import common.entity.projectile.EntityHook;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.model.Transforms;
import common.world.World;

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

//    /**
//     * 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 String[] getSprites() {
    	return new String[] {"fishing_rod_cast"};
    }
    
    public String getSprite(EntityNPC player, ItemStack stack) {
    	return player.fishEntity != null ? "fishing_rod_cast" : null;
    }

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