PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
VanillaEnchantments.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine\item\enchantment;
25
28use pocketmine\utils\RegistryTrait;
29
60 use RegistryTrait;
61
62 protected static function setup() : void{
63 self::register("PROTECTION", new ProtectionEnchantment(
64 KnownTranslationFactory::enchantment_protect_all(),
65 Rarity::COMMON,
66 0,
67 0,
68 4,
69 0.75,
70 null,
71 fn(int $level) : int => 11 * ($level - 1) + 1,
72 20
73 ));
74 self::register("FIRE_PROTECTION", new ProtectionEnchantment(
75 KnownTranslationFactory::enchantment_protect_fire(),
76 Rarity::UNCOMMON,
77 0,
78 0,
79 4,
80 1.25,
81 [
82 EntityDamageEvent::CAUSE_FIRE,
83 EntityDamageEvent::CAUSE_FIRE_TICK,
84 EntityDamageEvent::CAUSE_LAVA
85 //TODO: check fireballs
86 ],
87 fn(int $level) : int => 8 * ($level - 1) + 10,
88 12
89 ));
90 self::register("FEATHER_FALLING", new ProtectionEnchantment(
91 KnownTranslationFactory::enchantment_protect_fall(),
92 Rarity::UNCOMMON,
93 0,
94 0,
95 4,
96 2.5,
97 [
98 EntityDamageEvent::CAUSE_FALL
99 ],
100 fn(int $level) : int => 6 * ($level - 1) + 5,
101 10
102 ));
103 self::register("BLAST_PROTECTION", new ProtectionEnchantment(
104 KnownTranslationFactory::enchantment_protect_explosion(),
105 Rarity::RARE,
106 0,
107 0,
108 4,
109 1.5,
110 [
111 EntityDamageEvent::CAUSE_BLOCK_EXPLOSION,
112 EntityDamageEvent::CAUSE_ENTITY_EXPLOSION
113 ],
114 fn(int $level) : int => 8 * ($level - 1) + 5,
115 12
116 ));
117 self::register("PROJECTILE_PROTECTION", new ProtectionEnchantment(
118 KnownTranslationFactory::enchantment_protect_projectile(),
119 Rarity::UNCOMMON,
120 0,
121 0,
122 4,
123 1.5,
124 [
125 EntityDamageEvent::CAUSE_PROJECTILE
126 ],
127 fn(int $level) : int => 6 * ($level - 1) + 3,
128 15
129 ));
130 self::register("THORNS", new Enchantment(
131 KnownTranslationFactory::enchantment_thorns(),
132 Rarity::MYTHIC,
133 0,
134 0,
135 3,
136 fn(int $level) : int => 20 * ($level - 1) + 10,
137 50
138 ));
139 self::register("RESPIRATION", new Enchantment(
140 KnownTranslationFactory::enchantment_oxygen(),
141 Rarity::RARE,
142 0,
143 0,
144 3,
145 fn(int $level) : int => 10 * $level,
146 30
147 ));
148 self::register("AQUA_AFFINITY", new Enchantment(
149 KnownTranslationFactory::enchantment_waterWorker(),
150 Rarity::RARE,
151 0,
152 0,
153 1,
154 null,
155 40
156 ));
157
158 self::register("SHARPNESS", new SharpnessEnchantment(
159 KnownTranslationFactory::enchantment_damage_all(),
160 Rarity::COMMON,
161 0,
162 0,
163 5,
164 fn(int $level) : int => 11 * ($level - 1) + 1,
165 20
166 ));
167 self::register("KNOCKBACK", new KnockbackEnchantment(
168 KnownTranslationFactory::enchantment_knockback(),
169 Rarity::UNCOMMON,
170 0,
171 0,
172 2,
173 fn(int $level) : int => 20 * ($level - 1) + 5,
174 50
175 ));
176 self::register("FIRE_ASPECT", new FireAspectEnchantment(
177 KnownTranslationFactory::enchantment_fire(),
178 Rarity::RARE,
179 0,
180 0,
181 2,
182 fn(int $level) : int => 20 * ($level - 1) + 10,
183 50
184 ));
185 //TODO: smite, bane of arthropods, looting (these don't make sense now because their applicable mobs don't exist yet)
186
187 self::register("EFFICIENCY", new Enchantment(
188 KnownTranslationFactory::enchantment_digging(),
189 Rarity::COMMON,
190 0,
191 0,
192 5,
193 fn(int $level) : int => 10 * ($level - 1) + 1,
194 50
195 ));
196 self::register("FORTUNE", new Enchantment(
197 KnownTranslationFactory::enchantment_lootBonusDigger(),
198 Rarity::RARE,
199 0,
200 0,
201 3,
202 fn(int $level) : int => 9 * ($level - 1) + 15,
203 50
204 ));
205 self::register("SILK_TOUCH", new Enchantment(
206 KnownTranslationFactory::enchantment_untouching(),
207 Rarity::MYTHIC,
208 0,
209 0,
210 1,
211 fn(int $level) : int => 15,
212 50
213 ));
214 self::register("UNBREAKING", new Enchantment(
215 KnownTranslationFactory::enchantment_durability(),
216 Rarity::UNCOMMON,
217 0,
218 0,
219 3,
220 fn(int $level) : int => 8 * ($level - 1) + 5,
221 50
222 ));
223
224 self::register("POWER", new Enchantment(
225 KnownTranslationFactory::enchantment_arrowDamage(),
226 Rarity::COMMON,
227 0,
228 0,
229 5,
230 fn(int $level) : int => 10 * ($level - 1) + 1,
231 15
232 ));
233 self::register("PUNCH", new Enchantment(
234 KnownTranslationFactory::enchantment_arrowKnockback(),
235 Rarity::RARE,
236 0,
237 0,
238 2,
239 fn(int $level) : int => 20 * ($level - 1) + 12,
240 25
241 ));
242 self::register("FLAME", new Enchantment(
243 KnownTranslationFactory::enchantment_arrowFire(),
244 Rarity::RARE,
245 0,
246 0,
247 1,
248 fn(int $level) : int => 20,
249 30
250 ));
251 self::register("INFINITY", new Enchantment(
252 KnownTranslationFactory::enchantment_arrowInfinite(),
253 Rarity::MYTHIC,
254 0,
255 0,
256 1,
257 fn(int $level) : int => 20,
258 30
259 ));
260
261 self::register("MENDING", new Enchantment(
262 KnownTranslationFactory::enchantment_mending(),
263 Rarity::RARE,
264 0,
265 0,
266 1,
267 fn(int $level) : int => 25,
268 50
269 ));
270
271 self::register("VANISHING", new Enchantment(
272 KnownTranslationFactory::enchantment_curse_vanishing(),
273 Rarity::MYTHIC,
274 0,
275 0,
276 1,
277 fn(int $level) : int => 25,
278 25
279 ));
280
281 self::register("SWIFT_SNEAK", new Enchantment(
282 KnownTranslationFactory::enchantment_swift_sneak(),
283 Rarity::MYTHIC,
284 0,
285 0,
286 3,
287 fn(int $level) : int => 10 * $level,
288 5
289 ));
290 }
291
292 protected static function register(string $name, Enchantment $member) : void{
293 self::_registryRegister($name, $member);
294 }
295
300 public static function getAll() : array{
305 $result = self::_registryGetAll();
306 return $result;
307 }
308}