PocketMine-MP 5.23.3 git-976fc63567edab7a6fb6aeae739f43cf9fe57de4
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
61 use RegistryTrait;
62
63 protected static function setup() : void{
64 self::register("PROTECTION", new ProtectionEnchantment(
65 KnownTranslationFactory::enchantment_protect_all(),
66 Rarity::COMMON,
67 4,
68 0.75,
69 null,
70 fn(int $level) : int => 11 * ($level - 1) + 1,
71 20
72 ));
73 self::register("FIRE_PROTECTION", new ProtectionEnchantment(
74 KnownTranslationFactory::enchantment_protect_fire(),
75 Rarity::UNCOMMON,
76 4,
77 1.25,
78 [
79 EntityDamageEvent::CAUSE_FIRE,
80 EntityDamageEvent::CAUSE_FIRE_TICK,
81 EntityDamageEvent::CAUSE_LAVA
82 //TODO: check fireballs
83 ],
84 fn(int $level) : int => 8 * ($level - 1) + 10,
85 12
86 ));
87 self::register("FEATHER_FALLING", new ProtectionEnchantment(
88 KnownTranslationFactory::enchantment_protect_fall(),
89 Rarity::UNCOMMON,
90 4,
91 2.5,
92 [
93 EntityDamageEvent::CAUSE_FALL
94 ],
95 fn(int $level) : int => 6 * ($level - 1) + 5,
96 10
97 ));
98 self::register("BLAST_PROTECTION", new ProtectionEnchantment(
99 KnownTranslationFactory::enchantment_protect_explosion(),
100 Rarity::RARE,
101 4,
102 1.5,
103 [
104 EntityDamageEvent::CAUSE_BLOCK_EXPLOSION,
105 EntityDamageEvent::CAUSE_ENTITY_EXPLOSION
106 ],
107 fn(int $level) : int => 8 * ($level - 1) + 5,
108 12
109 ));
110 self::register("PROJECTILE_PROTECTION", new ProtectionEnchantment(
111 KnownTranslationFactory::enchantment_protect_projectile(),
112 Rarity::UNCOMMON,
113 4,
114 1.5,
115 [
116 EntityDamageEvent::CAUSE_PROJECTILE
117 ],
118 fn(int $level) : int => 6 * ($level - 1) + 3,
119 15
120 ));
121 self::register("THORNS", new Enchantment(
122 KnownTranslationFactory::enchantment_thorns(),
123 Rarity::MYTHIC,
124 3,
125 fn(int $level) : int => 20 * ($level - 1) + 10,
126 50
127 ));
128 self::register("RESPIRATION", new Enchantment(
129 KnownTranslationFactory::enchantment_oxygen(),
130 Rarity::RARE,
131 3,
132 fn(int $level) : int => 10 * $level,
133 30
134 ));
135
136 self::register("FROST_WALKER", new Enchantment(
137 KnownTranslationFactory::enchantment_frostwalker(),
138 Rarity::RARE,
139 2,
140 fn(int $level) : int => 10 * $level,
141 15
142 ));
143 self::register("AQUA_AFFINITY", new Enchantment(
144 KnownTranslationFactory::enchantment_waterWorker(),
145 Rarity::RARE,
146 1,
147 null,
148 40
149 ));
150
151 self::register("SHARPNESS", new SharpnessEnchantment(
152 KnownTranslationFactory::enchantment_damage_all(),
153 Rarity::COMMON,
154 5,
155 fn(int $level) : int => 11 * ($level - 1) + 1,
156 20
157 ));
158 self::register("KNOCKBACK", new KnockbackEnchantment(
159 KnownTranslationFactory::enchantment_knockback(),
160 Rarity::UNCOMMON,
161 2,
162 fn(int $level) : int => 20 * ($level - 1) + 5,
163 50
164 ));
165 self::register("FIRE_ASPECT", new FireAspectEnchantment(
166 KnownTranslationFactory::enchantment_fire(),
167 Rarity::RARE,
168 2,
169 fn(int $level) : int => 20 * ($level - 1) + 10,
170 50
171 ));
172 //TODO: smite, bane of arthropods, looting (these don't make sense now because their applicable mobs don't exist yet)
173
174 self::register("EFFICIENCY", new Enchantment(
175 KnownTranslationFactory::enchantment_digging(),
176 Rarity::COMMON,
177 5,
178 fn(int $level) : int => 10 * ($level - 1) + 1,
179 50
180 ));
181 self::register("FORTUNE", new Enchantment(
182 KnownTranslationFactory::enchantment_lootBonusDigger(),
183 Rarity::RARE,
184 3,
185 fn(int $level) : int => 9 * ($level - 1) + 15,
186 50
187 ));
188 self::register("SILK_TOUCH", new Enchantment(
189 KnownTranslationFactory::enchantment_untouching(),
190 Rarity::MYTHIC,
191 1,
192 fn(int $level) : int => 15,
193 50
194 ));
195 self::register("UNBREAKING", new Enchantment(
196 KnownTranslationFactory::enchantment_durability(),
197 Rarity::UNCOMMON,
198 3,
199 fn(int $level) : int => 8 * ($level - 1) + 5,
200 50
201 ));
202
203 self::register("POWER", new Enchantment(
204 KnownTranslationFactory::enchantment_arrowDamage(),
205 Rarity::COMMON,
206 5,
207 fn(int $level) : int => 10 * ($level - 1) + 1,
208 15
209 ));
210 self::register("PUNCH", new Enchantment(
211 KnownTranslationFactory::enchantment_arrowKnockback(),
212 Rarity::RARE,
213 2,
214 fn(int $level) : int => 20 * ($level - 1) + 12,
215 25
216 ));
217 self::register("FLAME", new Enchantment(
218 KnownTranslationFactory::enchantment_arrowFire(),
219 Rarity::RARE,
220 1,
221 fn(int $level) : int => 20,
222 30
223 ));
224 self::register("INFINITY", new Enchantment(
225 KnownTranslationFactory::enchantment_arrowInfinite(),
226 Rarity::MYTHIC,
227 1,
228 fn(int $level) : int => 20,
229 30
230 ));
231
232 self::register("MENDING", new Enchantment(
233 KnownTranslationFactory::enchantment_mending(),
234 Rarity::RARE,
235 1,
236 fn(int $level) : int => 25,
237 50
238 ));
239
240 self::register("VANISHING", new Enchantment(
241 KnownTranslationFactory::enchantment_curse_vanishing(),
242 Rarity::MYTHIC,
243 1,
244 fn(int $level) : int => 25,
245 25
246 ));
247
248 self::register("SWIFT_SNEAK", new Enchantment(
249 KnownTranslationFactory::enchantment_swift_sneak(),
250 Rarity::MYTHIC,
251 3,
252 fn(int $level) : int => 10 * $level,
253 5
254 ));
255 }
256
257 protected static function register(string $name, Enchantment $member) : void{
258 self::_registryRegister($name, $member);
259 }
260
265 public static function getAll() : array{
270 $result = self::_registryGetAll();
271 return $result;
272 }
273}