package me.km.items;

import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.common.capabilities.ICapabilityProvider;

public class ItemGemStone extends Item {
    public ItemGemStone() {
        super(new Properties().group(ItemGroup.MATERIALS));
    }

    @Override
    public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) {
        getTagCompound(stack);
        return null;
    }

    private CompoundNBT getTagCompound(ItemStack stack) {
        CompoundNBT com = stack.getTag();
        if(com == null) {
            com = new CompoundNBT();
            com.putInt("color", 0xFFFFFF);
            stack.setTag(com);
        } else {
            if(!com.contains("color")) {
                com.putInt("color", 0xFFFFFF);
            }
        }
        return com;
    }

    public void setColor(ItemStack stack, int color) {
        getTagCompound(stack).putInt("color", color);
    }

    public int getColor(ItemStack stack) {
        return getTagCompound(stack).getInt("color");
    }
}
