package me.km.items;

import java.util.List;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.IItemTier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class ItemKey extends Item {
    private final IItemTier it;

    public ItemKey(IItemTier it) {
        super(new Item.Properties().group(ItemGroup.MISC).maxStackSize(1));
        this.it = it;
    }

    public int getLockPickResistance() {
        return it.getHarvestLevel() + 1;
    }

    @OnlyIn(Dist.CLIENT)
    @Override
    public void addInformation(ItemStack stack, World w, List<ITextComponent> lore, ITooltipFlag flag) {
        if(stack.hasDisplayName()) {
            lore.get(0).applyTextStyle(TextFormatting.GREEN);
        } else {
            lore.get(0).applyTextStyle(TextFormatting.RED);
        }
    }
}
