PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
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 function spl_object_id;
29
34 case WATER;
35 case MUNDANE;
36 case LONG_MUNDANE;
37 case THICK;
38 case AWKWARD;
39 case NIGHT_VISION;
40 case LONG_NIGHT_VISION;
41 case INVISIBILITY;
42 case LONG_INVISIBILITY;
43 case LEAPING;
44 case LONG_LEAPING;
45 case STRONG_LEAPING;
46 case FIRE_RESISTANCE;
47 case LONG_FIRE_RESISTANCE;
48 case SWIFTNESS;
49 case LONG_SWIFTNESS;
50 case STRONG_SWIFTNESS;
51 case SLOWNESS;
52 case LONG_SLOWNESS;
53 case WATER_BREATHING;
54 case LONG_WATER_BREATHING;
55 case HEALING;
56 case STRONG_HEALING;
57 case HARMING;
58 case STRONG_HARMING;
59 case POISON;
60 case LONG_POISON;
61 case STRONG_POISON;
62 case REGENERATION;
63 case LONG_REGENERATION;
64 case STRONG_REGENERATION;
65 case STRENGTH;
66 case LONG_STRENGTH;
67 case STRONG_STRENGTH;
68 case WEAKNESS;
69 case LONG_WEAKNESS;
70 case WITHER;
71 case TURTLE_MASTER;
72 case LONG_TURTLE_MASTER;
73 case STRONG_TURTLE_MASTER;
74 case SLOW_FALLING;
75 case LONG_SLOW_FALLING;
76 case STRONG_SLOWNESS;
77
81 private function getMetadata() : array{
83 static $cache = [];
84
85 return $cache[spl_object_id($this)] ??= match($this){
86 self::WATER => ["Water", fn() => []],
87 self::MUNDANE => ["Mundane", fn() => []],
88 self::LONG_MUNDANE => ["Long Mundane", fn() => []],
89 self::THICK => ["Thick", fn() => []],
90 self::AWKWARD => ["Awkward", fn() => []],
91 self::NIGHT_VISION => ["Night Vision", fn() => [
92 new EffectInstance(VanillaEffects::NIGHT_VISION(), 3600)
93 ]],
94 self::LONG_NIGHT_VISION => ["Long Night Vision", fn() => [
95 new EffectInstance(VanillaEffects::NIGHT_VISION(), 9600)
96 ]],
97 self::INVISIBILITY => ["Invisibility", fn() => [
98 new EffectInstance(VanillaEffects::INVISIBILITY(), 3600)
99 ]],
100 self::LONG_INVISIBILITY => ["Long Invisibility", fn() => [
101 new EffectInstance(VanillaEffects::INVISIBILITY(), 9600)
102 ]],
103 self::LEAPING => ["Leaping", fn() => [
104 new EffectInstance(VanillaEffects::JUMP_BOOST(), 3600)
105 ]],
106 self::LONG_LEAPING => ["Long Leaping", fn() => [
107 new EffectInstance(VanillaEffects::JUMP_BOOST(), 9600)
108 ]],
109 self::STRONG_LEAPING => ["Strong Leaping", fn() => [
110 new EffectInstance(VanillaEffects::JUMP_BOOST(), 1800, 1)
111 ]],
112 self::FIRE_RESISTANCE => ["Fire Resistance", fn() => [
113 new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 3600)
114 ]],
115 self::LONG_FIRE_RESISTANCE => ["Long Fire Resistance", fn() => [
116 new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 9600)
117 ]],
118 self::SWIFTNESS => ["Swiftness", fn() => [
119 new EffectInstance(VanillaEffects::SPEED(), 3600)
120 ]],
121 self::LONG_SWIFTNESS => ["Long Swiftness", fn() => [
122 new EffectInstance(VanillaEffects::SPEED(), 9600)
123 ]],
124 self::STRONG_SWIFTNESS => ["Strong Swiftness", fn() => [
125 new EffectInstance(VanillaEffects::SPEED(), 1800, 1)
126 ]],
127 self::SLOWNESS => ["Slowness", fn() => [
128 new EffectInstance(VanillaEffects::SLOWNESS(), 1800)
129 ]],
130 self::LONG_SLOWNESS => ["Long Slowness", fn() => [
131 new EffectInstance(VanillaEffects::SLOWNESS(), 4800)
132 ]],
133 self::WATER_BREATHING => ["Water Breathing", fn() => [
134 new EffectInstance(VanillaEffects::WATER_BREATHING(), 3600)
135 ]],
136 self::LONG_WATER_BREATHING => ["Long Water Breathing", fn() => [
137 new EffectInstance(VanillaEffects::WATER_BREATHING(), 9600)
138 ]],
139 self::HEALING => ["Healing", fn() => [
140 new EffectInstance(VanillaEffects::INSTANT_HEALTH())
141 ]],
142 self::STRONG_HEALING => ["Strong Healing", fn() => [
143 new EffectInstance(VanillaEffects::INSTANT_HEALTH(), null, 1)
144 ]],
145 self::HARMING => ["Harming", fn() => [
146 new EffectInstance(VanillaEffects::INSTANT_DAMAGE())
147 ]],
148 self::STRONG_HARMING => ["Strong Harming", fn() => [
149 new EffectInstance(VanillaEffects::INSTANT_DAMAGE(), null, 1)
150 ]],
151 self::POISON => ["Poison", fn() => [
152 new EffectInstance(VanillaEffects::POISON(), 900)
153 ]],
154 self::LONG_POISON => ["Long Poison", fn() => [
155 new EffectInstance(VanillaEffects::POISON(), 2400)
156 ]],
157 self::STRONG_POISON => ["Strong Poison", fn() => [
158 new EffectInstance(VanillaEffects::POISON(), 440, 1)
159 ]],
160 self::REGENERATION => ["Regeneration", fn() => [
161 new EffectInstance(VanillaEffects::REGENERATION(), 900)
162 ]],
163 self::LONG_REGENERATION => ["Long Regeneration", fn() => [
164 new EffectInstance(VanillaEffects::REGENERATION(), 2400)
165 ]],
166 self::STRONG_REGENERATION => ["Strong Regeneration", fn() => [
167 new EffectInstance(VanillaEffects::REGENERATION(), 440, 1)
168 ]],
169 self::STRENGTH => ["Strength", fn() => [
170 new EffectInstance(VanillaEffects::STRENGTH(), 3600)
171 ]],
172 self::LONG_STRENGTH => ["Long Strength", fn() => [
173 new EffectInstance(VanillaEffects::STRENGTH(), 9600)
174 ]],
175 self::STRONG_STRENGTH => ["Strong Strength", fn() => [
176 new EffectInstance(VanillaEffects::STRENGTH(), 1800, 1)
177 ]],
178 self::WEAKNESS => ["Weakness", fn() => [
179 new EffectInstance(VanillaEffects::WEAKNESS(), 1800)
180 ]],
181 self::LONG_WEAKNESS => ["Long Weakness", fn() => [
182 new EffectInstance(VanillaEffects::WEAKNESS(), 4800)
183 ]],
184 self::WITHER => ["Wither", fn() => [
185 new EffectInstance(VanillaEffects::WITHER(), 800, 1)
186 ]],
187 self::TURTLE_MASTER => ["Turtle Master", fn() => [
188 new EffectInstance(VanillaEffects::SLOWNESS(), 20 * 20, 3),
189 new EffectInstance(VanillaEffects::RESISTANCE(), 20 * 20, 2),
190 ]],
191 self::LONG_TURTLE_MASTER => ["Long Turtle Master", fn() => [
192 new EffectInstance(VanillaEffects::SLOWNESS(), 40 * 20, 3),
193 new EffectInstance(VanillaEffects::RESISTANCE(), 40 * 20, 2),
194 ]],
195 self::STRONG_TURTLE_MASTER => ["Strong Turtle Master", fn() => [
196 new EffectInstance(VanillaEffects::SLOWNESS(), 20 * 20, 5),
197 new EffectInstance(VanillaEffects::RESISTANCE(), 20 * 20, 3),
198 ]],
199 self::SLOW_FALLING => ["Slow Falling", fn() => [
200 //TODO
201 ]],
202 self::LONG_SLOW_FALLING => ["Long Slow Falling", fn() => [
203 //TODO
204 ]],
205 self::STRONG_SLOWNESS => ["Strong Slowness", fn() => [
206 new EffectInstance(VanillaEffects::SLOWNESS(), 20 * 20, 3)
207 ]]
208 };
209 }
210
211 public function getDisplayName() : string{ return $this->getMetadata()[0]; }
212
217 public function getEffects() : array{
218 return ($this->getMetadata()[1])();
219 }
220}