blob: 8a5594996d54be3e78f9692bbecaf5cc61c3f947 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
package org.bukkit.craftbukkit.enchantments;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.enchantments.EnchantmentWrapper;
import org.bukkit.inventory.ItemStack;
public class CraftEnchantment extends Enchantment {
private final net.minecraft.server.Enchantment target;
public CraftEnchantment(net.minecraft.server.Enchantment target) {
super(target.id);
this.target = target;
}
@Override
public int getMaxLevel() {
return target.getMaxLevel();
}
@Override
public int getStartLevel() {
return target.getStartLevel();
}
@Override
public EnchantmentTarget getItemTarget() {
switch (target.slot) {
case ALL:
return EnchantmentTarget.ALL;
case ARMOR:
return EnchantmentTarget.ARMOR;
case ARMOR_FEET:
return EnchantmentTarget.ARMOR_FEET;
case ARMOR_HEAD:
return EnchantmentTarget.ARMOR_HEAD;
case ARMOR_LEGS:
return EnchantmentTarget.ARMOR_LEGS;
case ARMOR_TORSO:
return EnchantmentTarget.ARMOR_TORSO;
case DIGGER:
return EnchantmentTarget.TOOL;
case WEAPON:
return EnchantmentTarget.WEAPON;
case BOW:
return EnchantmentTarget.BOW;
case FISHING_ROD:
return EnchantmentTarget.FISHING_ROD;
default:
return null;
}
}
@Override
public boolean canEnchantItem(ItemStack item) {
return target.canEnchant(CraftItemStack.asNMSCopy(item));
}
@Override
public String getName() {
switch (target.id) {
case 0:
return "PROTECTION_ENVIRONMENTAL";
case 1:
return "PROTECTION_FIRE";
case 2:
return "PROTECTION_FALL";
case 3:
return "PROTECTION_EXPLOSIONS";
case 4:
return "PROTECTION_PROJECTILE";
case 5:
return "OXYGEN";
case 6:
return "WATER_WORKER";
case 7:
return "THORNS";
case 8:
return "DEPTH_STRIDER";
case 16:
return "DAMAGE_ALL";
case 17:
return "DAMAGE_UNDEAD";
case 18:
return "DAMAGE_ARTHROPODS";
case 19:
return "KNOCKBACK";
case 20:
return "FIRE_ASPECT";
case 21:
return "LOOT_BONUS_MOBS";
case 32:
return "DIG_SPEED";
case 33:
return "SILK_TOUCH";
case 34:
return "DURABILITY";
case 35:
return "LOOT_BONUS_BLOCKS";
case 48:
return "ARROW_DAMAGE";
case 49:
return "ARROW_KNOCKBACK";
case 50:
return "ARROW_FIRE";
case 51:
return "ARROW_INFINITE";
case 61:
return "LUCK";
case 62:
return "LURE";
default:
return "UNKNOWN_ENCHANT_" + target.id;
}
}
public static net.minecraft.server.Enchantment getRaw(Enchantment enchantment) {
if (enchantment instanceof EnchantmentWrapper) {
enchantment = ((EnchantmentWrapper) enchantment).getEnchantment();
}
if (enchantment instanceof CraftEnchantment) {
return ((CraftEnchantment) enchantment).target;
}
return null;
}
@Override
public boolean conflictsWith(Enchantment other) {
if (other instanceof EnchantmentWrapper) {
other = ((EnchantmentWrapper) other).getEnchantment();
}
if (!(other instanceof CraftEnchantment)) {
return false;
}
CraftEnchantment ench = (CraftEnchantment) other;
return !target.a(ench.target);
}
}
|