EnumEnchantmentType .java

net.minecraft.enchantment.EnumEnchantmentType (enum, 55 lines): members: ALL, ARMOR, ARMOR_FEET, ARMOR_LEGS, ARMOR_TORSO, ARMOR_HEAD, WEAPON, DIGGER, BOW.

net.minecraft.enchantmentenum55 linescommon1.5 KB

API Surface (1)

boolean canEnchantItem(Item p_77557_1_)

Fields & Constants (6)

ARMOR
ARMOR_LEGS
ARMOR_HEAD
DIGGER
BREAKABLE
BOW

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

EnumEnchantmentType.java55 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.enchantment;
2
3
import net.minecraft.item.Item;
4
import net.minecraft.item.ItemArmor;
5
import net.minecraft.item.ItemBow;
6
import net.minecraft.item.ItemFishingRod;
7
import net.minecraft.item.ItemSword;
8
import net.minecraft.item.ItemTool;
9
10
public enum EnumEnchantmentType
11
{
12
    ALL,
13
    ARMOR,
14
    ARMOR_FEET,
15
    ARMOR_LEGS,
16
    ARMOR_TORSO,
17
    ARMOR_HEAD,
18
    WEAPON,
19
    DIGGER,
20
    FISHING_ROD,
21
    BREAKABLE,
22
    BOW;
23
24
    /**
25
     * Return true if the item passed can be enchanted by a enchantment of this type.
26
     */
27
    public boolean canEnchantItem(Item p_77557_1_)
28
    {
29
        if (this == ALL)
30
        {
31
            return true;
32
        }
33
        else if (this == BREAKABLE && p_77557_1_.isDamageable())
34
        {
35
            return true;
36
        }
37
        else if (p_77557_1_ instanceof ItemArmor)
38
        {
39
            if (this == ARMOR)
40
            {
41
                return true;
42
            }
43
            else
44
            {
45
                ItemArmor itemarmor = (ItemArmor)p_77557_1_;
46
                return itemarmor.armorType == 0 ? this == ARMOR_HEAD : (itemarmor.armorType == 2 ? this == ARMOR_LEGS : (itemarmor.armorType == 1 ? this == ARMOR_TORSO : (itemarmor.armorType == 3 ? this == ARMOR_FEET : false)));
47
            }
48
        }
49
        else
50
        {
51
            return p_77557_1_ instanceof ItemSword ? this == WEAPON : (p_77557_1_ instanceof ItemTool ? this == DIGGER : (p_77557_1_ instanceof ItemBow ? this == BOW : (p_77557_1_ instanceof ItemFishingRod ? this == FISHING_ROD : false)));
52
        }
53
    }
54
}
55

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