package common.item;

import java.util.List;

import common.color.TextColor;
import common.entity.npc.EntityNPC;
import common.potion.Potion;
import common.potion.PotionEffect;
import common.world.World;

public class ItemAppleGold extends ItemFood
{
    public ItemAppleGold(int amount, boolean isWolfFood)
    {
        super(amount, isWolfFood);
        this.setHasSubtypes(true);
        this.setColor(TextColor.NEON);
    }

    public boolean hasEffect(ItemStack stack)
    {
        return stack.getMetadata() > 0;
    }

    /**
     * Return an item rarity from EnumRarity
     */
    public TextColor getColor(ItemStack stack)
    {
        return stack.getMetadata() == 0 ? super.getColor(stack) : TextColor.MAGENTA;
    }

    protected void onFoodEaten(ItemStack stack, World worldIn, EntityNPC player)
    {
        if (!worldIn.client)
        {
            player.addEffect(new PotionEffect(Potion.ABSORPTION, 2400, 0));
        }

        if (stack.getMetadata() > 0)
        {
            if (!worldIn.client)
            {
                player.addEffect(new PotionEffect(Potion.REGENERATION, 600, 4));
                player.addEffect(new PotionEffect(Potion.RESISTANCE, 6000, 0));
                player.addEffect(new PotionEffect(Potion.FIRE_RESISTANCE, 6000, 0));
            }
        }
        else
        {
            super.onFoodEaten(stack, worldIn, player);
        }
    }

    /**
     * returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
     */
    public void getSubItems(Item itemIn, CheatTab tab, List<ItemStack> subItems)
    {
        subItems.add(new ItemStack(itemIn, 1, 0));
        subItems.add(new ItemStack(itemIn, 1, 1));
    }
}
