package aeryk.atweaks.item.equipment.weapon;

import aeryk.atweaks.creativetab.CreativeTab;
import aeryk.atweaks.library.LibItems;
import aeryk.atweaks.library.LibMaterial;
import aeryk.atweaks.library.LibResources;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;

public class ItemSteelSword extends ItemSword{
    public ItemSteelSword () {
        super(LibMaterial.Tools.STEEL);
        setCreativeTab(CreativeTab.AT_Tab);
        setUnlocalizedName(LibItems.STEEL_SWORD);
    }

    @Override
    public String getUnlocalizedName(){
        return String.format("item.%s%s", LibResources.PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
    }

    @Override
    public String getUnlocalizedName(ItemStack itemStack){
        return String.format("item.%s%s", LibResources.PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
    }

    @Override
    @SideOnly (Side.CLIENT)
    public void registerIcons(IIconRegister iconRegister){
        itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
    }

    protected String getUnwrappedUnlocalizedName(String unlocalizedName){
        return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
    }
}
