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