package common.item;

import common.block.Block;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.ToolMaterial;
import common.material.Material;
import common.util.BlockPos;
import common.world.World;

public class ItemShears extends Item
{
    private final ToolMaterial material;
    
    public ItemShears(ToolMaterial material)
    {
        this.setMaxStackSize(1);
        this.setMaxDamage(material.getMaxUses() - 12);
        this.setTab(CheatTab.tabTools);
        this.material = material;
    }
    
    public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLiving playerIn)
    {
        if (blockIn.getShearsEfficiency() < 0) // blockIn.getMaterial() != Material.leaves && blockIn != Blocks.web && blockIn != Blocks.tallgrass && blockIn != Blocks.vine && blockIn != Blocks.tripwire && blockIn != Blocks.wool)
        {
            return super.onBlockDestroyed(stack, worldIn, blockIn, pos, playerIn);
        }
        else
        {
            stack.damageItem(1, playerIn);
            return true;
        }
    }
    
    public boolean canHarvestBlock(Block blockIn)
    {
        return blockIn.getMaterial() == Material.web || blockIn == Blocks.redstone || blockIn == Blocks.string;
    }

    public float getStrVsBlock(ItemStack stack, Block state)
    {
        return state.getShearsEfficiency() <= 0 ? 1.0F : (((float)state.getShearsEfficiency()) * (this.material.getEfficiencyOnProperMaterial() - 1.0F));
        		// state != Blocks.web && state.getMaterial() != Material.leaves ? (state == Blocks.wool ? 5.0F : super.getStrVsBlock(stack, state)) : 15.0F;
    }
    
    public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
    {
        return this.material.isRepairItem(repair.getItem()) ? true : super.getIsRepairable(toRepair, repair);
    }
    
    public boolean isMagnetic() {
    	return this.material.isMagnetic();
    }
    
    public boolean canBeWielded() {
    	return true;
    }
}
