ItemAppleGold .java

net.minecraft.item.ItemAppleGold (class, 62 lines): members: onFoodEaten, getRarity, hasEffect, getSubItems. imports: Potion, PotionEffect, CreativeTabs.

net.minecraft.itemclass62 linescommonextends ItemFood1.8 KB

API Surface (4)

boolean hasEffect(ItemStack stack)
EnumRarity getRarity(ItemStack stack)
void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems)

Full Source

ItemAppleGold.java62 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.item;
2
3
import java.util.List;
4
import net.minecraft.creativetab.CreativeTabs;
5
import net.minecraft.entity.player.EntityPlayer;
6
import net.minecraft.potion.Potion;
7
import net.minecraft.potion.PotionEffect;
8
import net.minecraft.world.World;
9
10
public class ItemAppleGold extends ItemFood
11
{
12
    public ItemAppleGold(int amount, float saturation, boolean isWolfFood)
13
    {
14
        super(amount, saturation, isWolfFood);
15
        this.setHasSubtypes(true);
16
    }
17
18
    public boolean hasEffect(ItemStack stack)
19
    {
20
        return stack.getMetadata() > 0;
21
    }
22
23
    /**
24
     * Return an item rarity from EnumRarity
25
     */
26
    public EnumRarity getRarity(ItemStack stack)
27
    {
28
        return stack.getMetadata() == 0 ? EnumRarity.RARE : EnumRarity.EPIC;
29
    }
30
31
    protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
32
    {
33
        if (!worldIn.isRemote)
34
        {
35
            player.addPotionEffect(new PotionEffect(Potion.absorption.id, 2400, 0));
36
        }
37
38
        if (stack.getMetadata() > 0)
39
        {
40
            if (!worldIn.isRemote)
41
            {
42
                player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 4));
43
                player.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0));
44
                player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0));
45
            }
46
        }
47
        else
48
        {
49
            super.onFoodEaten(stack, worldIn, player);
50
        }
51
    }
52
53
    /**
54
     * returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
55
     */
56
    public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems)
57
    {
58
        subItems.add(new ItemStack(itemIn, 1, 0));
59
        subItems.add(new ItemStack(itemIn, 1, 1));
60
    }
61
}
62

Deobfuscated MCP 1.8.9 source of ItemAppleGold from Marcelektro/MavenMCP-1.8.9 (net/minecraft/item/ItemAppleGold.java), stored verbatim.