PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
PotionType.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;
25
28use pocketmine\utils\LegacyEnumShimTrait;
29use function spl_object_id;
30
82 use LegacyEnumShimTrait;
83
84 case WATER;
85 case MUNDANE;
86 case LONG_MUNDANE;
87 case THICK;
88 case AWKWARD;
89 case NIGHT_VISION;
90 case LONG_NIGHT_VISION;
91 case INVISIBILITY;
92 case LONG_INVISIBILITY;
93 case LEAPING;
94 case LONG_LEAPING;
95 case STRONG_LEAPING;
96 case FIRE_RESISTANCE;
97 case LONG_FIRE_RESISTANCE;
98 case SWIFTNESS;
99 case LONG_SWIFTNESS;
100 case STRONG_SWIFTNESS;
101 case SLOWNESS;
102 case LONG_SLOWNESS;
103 case WATER_BREATHING;
104 case LONG_WATER_BREATHING;
105 case HEALING;
106 case STRONG_HEALING;
107 case HARMING;
108 case STRONG_HARMING;
109 case POISON;
110 case LONG_POISON;
111 case STRONG_POISON;
112 case REGENERATION;
113 case LONG_REGENERATION;
114 case STRONG_REGENERATION;
115 case STRENGTH;
116 case LONG_STRENGTH;
117 case STRONG_STRENGTH;
118 case WEAKNESS;
119 case LONG_WEAKNESS;
120 case WITHER;
121 case TURTLE_MASTER;
122 case LONG_TURTLE_MASTER;
123 case STRONG_TURTLE_MASTER;
124 case SLOW_FALLING;
125 case LONG_SLOW_FALLING;
126 case STRONG_SLOWNESS;
127
131 private function getMetadata() : array{
133 static $cache = [];
134
135 return $cache[spl_object_id($this)] ??= match($this){
136 self::WATER => ["Water", fn() => []],
137 self::MUNDANE => ["Mundane", fn() => []],
138 self::LONG_MUNDANE => ["Long Mundane", fn() => []],
139 self::THICK => ["Thick", fn() => []],
140 self::AWKWARD => ["Awkward", fn() => []],
141 self::NIGHT_VISION => ["Night Vision", fn() => [
142 new EffectInstance(VanillaEffects::NIGHT_VISION(), 3600)
143 ]],
144 self::LONG_NIGHT_VISION => ["Long Night Vision", fn() => [
145 new EffectInstance(VanillaEffects::NIGHT_VISION(), 9600)
146 ]],
147 self::INVISIBILITY => ["Invisibility", fn() => [
148 new EffectInstance(VanillaEffects::INVISIBILITY(), 3600)
149 ]],
150 self::LONG_INVISIBILITY => ["Long Invisibility", fn() => [
151 new EffectInstance(VanillaEffects::INVISIBILITY(), 9600)
152 ]],
153 self::LEAPING => ["Leaping", fn() => [
154 new EffectInstance(VanillaEffects::JUMP_BOOST(), 3600)
155 ]],
156 self::LONG_LEAPING => ["Long Leaping", fn() => [
157 new EffectInstance(VanillaEffects::JUMP_BOOST(), 9600)
158 ]],
159 self::STRONG_LEAPING => ["Strong Leaping", fn() => [
160 new EffectInstance(VanillaEffects::JUMP_BOOST(), 1800, 1)
161 ]],
162 self::FIRE_RESISTANCE => ["Fire Resistance", fn() => [
163 new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 3600)
164 ]],
165 self::LONG_FIRE_RESISTANCE => ["Long Fire Resistance", fn() => [
166 new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 9600)
167 ]],
168 self::SWIFTNESS => ["Swiftness", fn() => [
169 new EffectInstance(VanillaEffects::SPEED(), 3600)
170 ]],
171 self::LONG_SWIFTNESS => ["Long Swiftness", fn() => [
172 new EffectInstance(VanillaEffects::SPEED(), 9600)
173 ]],
174 self::STRONG_SWIFTNESS => ["Strong Swiftness", fn() => [
175 new EffectInstance(VanillaEffects::SPEED(), 1800, 1)
176 ]],
177 self::SLOWNESS => ["Slowness", fn() => [
178 new EffectInstance(VanillaEffects::SLOWNESS(), 1800)
179 ]],
180 self::LONG_SLOWNESS => ["Long Slowness", fn() => [
181 new EffectInstance(VanillaEffects::SLOWNESS(), 4800)
182 ]],
183 self::WATER_BREATHING => ["Water Breathing", fn() => [
184 new EffectInstance(VanillaEffects::WATER_BREATHING(), 3600)
185 ]],
186 self::LONG_WATER_BREATHING => ["Long Water Breathing", fn() => [
187 new EffectInstance(VanillaEffects::WATER_BREATHING(), 9600)
188 ]],
189 self::HEALING => ["Healing", fn() => [
190 new EffectInstance(VanillaEffects::INSTANT_HEALTH())
191 ]],
192 self::STRONG_HEALING => ["Strong Healing", fn() => [
193 new EffectInstance(VanillaEffects::INSTANT_HEALTH(), null, 1)
194 ]],
195 self::HARMING => ["Harming", fn() => [
196 new EffectInstance(VanillaEffects::INSTANT_DAMAGE())
197 ]],
198 self::STRONG_HARMING => ["Strong Harming", fn() => [
199 new EffectInstance(VanillaEffects::INSTANT_DAMAGE(), null, 1)
200 ]],
201 self::POISON => ["Poison", fn() => [
202 new EffectInstance(VanillaEffects::POISON(), 900)
203 ]],
204 self::LONG_POISON => ["Long Poison", fn() => [
205 new EffectInstance(VanillaEffects::POISON(), 2400)
206 ]],
207 self::STRONG_POISON => ["Strong Poison", fn() => [
208 new EffectInstance(VanillaEffects::POISON(), 440, 1)
209 ]],
210 self::REGENERATION => ["Regeneration", fn() => [
211 new EffectInstance(VanillaEffects::REGENERATION(), 900)
212 ]],
213 self::LONG_REGENERATION => ["Long Regeneration", fn() => [
214 new EffectInstance(VanillaEffects::REGENERATION(), 2400)
215 ]],
216 self::STRONG_REGENERATION => ["Strong Regeneration", fn() => [
217 new EffectInstance(VanillaEffects::REGENERATION(), 440, 1)
218 ]],
219 self::STRENGTH => ["Strength", fn() => [
220 new EffectInstance(VanillaEffects::STRENGTH(), 3600)
221 ]],
222 self::LONG_STRENGTH => ["Long Strength", fn() => [
223 new EffectInstance(VanillaEffects::STRENGTH(), 9600)
224 ]],
225 self::STRONG_STRENGTH => ["Strong Strength", fn() => [
226 new EffectInstance(VanillaEffects::STRENGTH(), 1800, 1)
227 ]],
228 self::WEAKNESS => ["Weakness", fn() => [
229 new EffectInstance(VanillaEffects::WEAKNESS(), 1800)
230 ]],
231 self::LONG_WEAKNESS => ["Long Weakness", fn() => [
232 new EffectInstance(VanillaEffects::WEAKNESS(), 4800)
233 ]],
234 self::WITHER => ["Wither", fn() => [
235 new EffectInstance(VanillaEffects::WITHER(), 800, 1)
236 ]],
237 self::TURTLE_MASTER => ["Turtle Master", fn() => [
238 new EffectInstance(VanillaEffects::SLOWNESS(), 20 * 20, 3),
239 new EffectInstance(VanillaEffects::RESISTANCE(), 20 * 20, 2),
240 ]],
241 self::LONG_TURTLE_MASTER => ["Long Turtle Master", fn() => [
242 new EffectInstance(VanillaEffects::SLOWNESS(), 40 * 20, 3),
243 new EffectInstance(VanillaEffects::RESISTANCE(), 40 * 20, 2),
244 ]],
245 self::STRONG_TURTLE_MASTER => ["Strong Turtle Master", fn() => [
246 new EffectInstance(VanillaEffects::SLOWNESS(), 20 * 20, 5),
247 new EffectInstance(VanillaEffects::RESISTANCE(), 20 * 20, 3),
248 ]],
249 self::SLOW_FALLING => ["Slow Falling", fn() => [
250 //TODO
251 ]],
252 self::LONG_SLOW_FALLING => ["Long Slow Falling", fn() => [
253 //TODO
254 ]],
255 self::STRONG_SLOWNESS => ["Strong Slowness", fn() => [
256 new EffectInstance(VanillaEffects::SLOWNESS(), 20 * 20, 3)
257 ]]
258 };
259 }
260
261 public function getDisplayName() : string{ return $this->getMetadata()[0]; }
262
267 public function getEffects() : array{
268 return ($this->getMetadata()[1])();
269 }
270}