    001package net.minecraft.item;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.util.List;
    006import net.minecraft.creativetab.CreativeTabs;
    007import net.minecraft.entity.player.EntityPlayer;
    008import net.minecraft.potion.Potion;
    009import net.minecraft.potion.PotionEffect;
    010import net.minecraft.world.World;
    011
    012public class ItemAppleGold extends ItemFood
    013{
    014    public ItemAppleGold(int par1, int par2, float par3, boolean par4)
    015    {
    016        super(par1, par2, par3, par4);
    017        this.setHasSubtypes(true);
    018    }
    019
    020    @SideOnly(Side.CLIENT)
    021    public boolean hasEffect(ItemStack par1ItemStack)
    022    {
    023        return par1ItemStack.getItemDamage() > 0;
    024    }
    025
    026    @SideOnly(Side.CLIENT)
    027
    028    /**
    029     * Return an item rarity from EnumRarity
    030     */
    031    public EnumRarity getRarity(ItemStack par1ItemStack)
    032    {
    033        return par1ItemStack.getItemDamage() == 0 ? EnumRarity.rare : EnumRarity.epic;
    034    }
    035
    036    protected void onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    037    {
    038        if (par1ItemStack.getItemDamage() > 0)
    039        {
    040            if (!par2World.isRemote)
    041            {
    042                par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 3));
    043                par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0));
    044                par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0));
    045            }
    046        }
    047        else
    048        {
    049            super.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer);
    050        }
    051    }
    052
    053    @SideOnly(Side.CLIENT)
    054
    055    /**
    056     * returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
    057     */
    058    public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
    059    {
    060        par3List.add(new ItemStack(par1, 1, 0));
    061        par3List.add(new ItemStack(par1, 1, 1));
    062    }
    063}