package com.vanamod.mod.items;

import com.vanamod.mod.VanaMod;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class ItemVanaApple extends ItemFood {

    private String textureName;

    public ItemVanaApple(String name) {
        super(4, 0.3F, false);
        this.textureName = name;
        this.setUnlocalizedName(name);
        this.setCreativeTab(VanaMod.vanaTab);
        this.setAlwaysEdible();
    }

    @Override
    protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
        if (!world.isRemote) {
            // Regeneration III pendant 5 secondes
            player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 100, 2));

            // Fire Resistance II pendant 1 minute 15 secondes
            player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 1500, 1));
        }
    }

    @Override
    public boolean hasEffect(ItemStack stack) {
        return true; // Glow d'enchantement permanent
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IIconRegister iconRegister) {
        this.itemIcon = iconRegister.registerIcon("vanamod:" + this.textureName);
    }
}