package common.item.tool;

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

public class ItemAppleGold extends ItemFood
{
	private final boolean powered;
	
    public ItemAppleGold(int amount, boolean powered)
    {
        super(amount, false);
        this.powered = powered;
        this.setColor(powered ? TextColor.MAGENTA : TextColor.NEON);
    }

    public boolean hasEffect(ItemStack stack)
    {
        return this.powered;
    }

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

        if (this.powered)
        {
            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);
        }
    }
}
