github.com/df-mc/dragonfly@v0.9.13/server/item/potion/potion.go (about) 1 package potion 2 3 import ( 4 "github.com/df-mc/dragonfly/server/entity/effect" 5 "time" 6 ) 7 8 // Potion holds the effects given by the potion type. 9 type Potion struct { 10 potion 11 } 12 13 // Water ... 14 func Water() Potion { 15 return Potion{} 16 } 17 18 // Mundane ... 19 func Mundane() Potion { 20 return Potion{1} 21 } 22 23 // LongMundane ... 24 func LongMundane() Potion { 25 return Potion{2} 26 } 27 28 // Thick ... 29 func Thick() Potion { 30 return Potion{3} 31 } 32 33 // Awkward ... 34 func Awkward() Potion { 35 return Potion{4} 36 } 37 38 // NightVision ... 39 func NightVision() Potion { 40 return Potion{5} 41 } 42 43 // LongNightVision ... 44 func LongNightVision() Potion { 45 return Potion{6} 46 } 47 48 // Invisibility ... 49 func Invisibility() Potion { 50 return Potion{7} 51 } 52 53 // LongInvisibility ... 54 func LongInvisibility() Potion { 55 return Potion{8} 56 } 57 58 // Leaping ... 59 func Leaping() Potion { 60 return Potion{9} 61 } 62 63 // LongLeaping ... 64 func LongLeaping() Potion { 65 return Potion{10} 66 } 67 68 // StrongLeaping ... 69 func StrongLeaping() Potion { 70 return Potion{11} 71 } 72 73 // FireResistance ... 74 func FireResistance() Potion { 75 return Potion{12} 76 } 77 78 // LongFireResistance ... 79 func LongFireResistance() Potion { 80 return Potion{13} 81 } 82 83 // Swiftness ... 84 func Swiftness() Potion { 85 return Potion{14} 86 } 87 88 // LongSwiftness ... 89 func LongSwiftness() Potion { 90 return Potion{15} 91 } 92 93 // StrongSwiftness ... 94 func StrongSwiftness() Potion { 95 return Potion{16} 96 } 97 98 // Slowness ... 99 func Slowness() Potion { 100 return Potion{17} 101 } 102 103 // LongSlowness ... 104 func LongSlowness() Potion { 105 return Potion{18} 106 } 107 108 // WaterBreathing ... 109 func WaterBreathing() Potion { 110 return Potion{19} 111 } 112 113 // LongWaterBreathing ... 114 func LongWaterBreathing() Potion { 115 return Potion{20} 116 } 117 118 // Healing ... 119 func Healing() Potion { 120 return Potion{21} 121 } 122 123 // StrongHealing ... 124 func StrongHealing() Potion { 125 return Potion{22} 126 } 127 128 // Harming ... 129 func Harming() Potion { 130 return Potion{23} 131 } 132 133 // StrongHarming ... 134 func StrongHarming() Potion { 135 return Potion{24} 136 } 137 138 // Poison ... 139 func Poison() Potion { 140 return Potion{25} 141 } 142 143 // LongPoison ... 144 func LongPoison() Potion { 145 return Potion{26} 146 } 147 148 // StrongPoison ... 149 func StrongPoison() Potion { 150 return Potion{27} 151 } 152 153 // Regeneration ... 154 func Regeneration() Potion { 155 return Potion{28} 156 } 157 158 // LongRegeneration ... 159 func LongRegeneration() Potion { 160 return Potion{29} 161 } 162 163 // StrongRegeneration ... 164 func StrongRegeneration() Potion { 165 return Potion{30} 166 } 167 168 // Strength ... 169 func Strength() Potion { 170 return Potion{31} 171 } 172 173 // LongStrength ... 174 func LongStrength() Potion { 175 return Potion{32} 176 } 177 178 // StrongStrength ... 179 func StrongStrength() Potion { 180 return Potion{33} 181 } 182 183 // Weakness ... 184 func Weakness() Potion { 185 return Potion{34} 186 } 187 188 // LongWeakness ... 189 func LongWeakness() Potion { 190 return Potion{35} 191 } 192 193 // Wither ... 194 func Wither() Potion { 195 return Potion{36} 196 } 197 198 // TurtleMaster ... 199 func TurtleMaster() Potion { 200 return Potion{37} 201 } 202 203 // LongTurtleMaster ... 204 func LongTurtleMaster() Potion { 205 return Potion{38} 206 } 207 208 // StrongTurtleMaster ... 209 func StrongTurtleMaster() Potion { 210 return Potion{39} 211 } 212 213 // SlowFalling ... 214 func SlowFalling() Potion { 215 return Potion{40} 216 } 217 218 // LongSlowFalling ... 219 func LongSlowFalling() Potion { 220 return Potion{41} 221 } 222 223 // StrongSlowness ... 224 func StrongSlowness() Potion { 225 return Potion{42} 226 } 227 228 // From returns a Potion by the ID given. 229 func From(id int32) Potion { 230 return Potion{potion(id)} 231 } 232 233 // Effects returns the effects of the potion. 234 func (p Potion) Effects() []effect.Effect { 235 switch p { 236 case NightVision(): 237 return []effect.Effect{effect.New(effect.NightVision{}, 1, 3*time.Minute)} 238 case LongNightVision(): 239 return []effect.Effect{effect.New(effect.NightVision{}, 1, 8*time.Minute)} 240 case Invisibility(): 241 return []effect.Effect{effect.New(effect.Invisibility{}, 1, 3*time.Minute)} 242 case LongInvisibility(): 243 return []effect.Effect{effect.New(effect.Invisibility{}, 1, 8*time.Minute)} 244 case Leaping(): 245 return []effect.Effect{effect.New(effect.JumpBoost{}, 1, 3*time.Minute)} 246 case LongLeaping(): 247 return []effect.Effect{effect.New(effect.JumpBoost{}, 1, 8*time.Minute)} 248 case StrongLeaping(): 249 return []effect.Effect{effect.New(effect.JumpBoost{}, 2, 90*time.Second)} 250 case FireResistance(): 251 return []effect.Effect{effect.New(effect.FireResistance{}, 1, 3*time.Minute)} 252 case LongFireResistance(): 253 return []effect.Effect{effect.New(effect.FireResistance{}, 1, 8*time.Minute)} 254 case Swiftness(): 255 return []effect.Effect{effect.New(effect.Speed{}, 1, 3*time.Minute)} 256 case LongSwiftness(): 257 return []effect.Effect{effect.New(effect.Speed{}, 1, 8*time.Minute)} 258 case StrongSwiftness(): 259 return []effect.Effect{effect.New(effect.Speed{}, 2, 90*time.Second)} 260 case Slowness(): 261 return []effect.Effect{effect.New(effect.Slowness{}, 1, 90*time.Second)} 262 case LongSlowness(): 263 return []effect.Effect{effect.New(effect.Slowness{}, 1, 4*time.Minute)} 264 case WaterBreathing(): 265 return []effect.Effect{effect.New(effect.WaterBreathing{}, 1, 3*time.Minute)} 266 case LongWaterBreathing(): 267 return []effect.Effect{effect.New(effect.WaterBreathing{}, 1, 8*time.Minute)} 268 case Healing(): 269 return []effect.Effect{effect.NewInstant(effect.InstantHealth{}, 1)} 270 case StrongHealing(): 271 return []effect.Effect{effect.NewInstant(effect.InstantHealth{}, 2)} 272 case Harming(): 273 return []effect.Effect{effect.NewInstant(effect.InstantDamage{}, 1)} 274 case StrongHarming(): 275 return []effect.Effect{effect.NewInstant(effect.InstantDamage{}, 2)} 276 case Poison(): 277 return []effect.Effect{effect.New(effect.Poison{}, 1, 45*time.Second)} 278 case LongPoison(): 279 return []effect.Effect{effect.New(effect.Poison{}, 1, 2*time.Minute)} 280 case StrongPoison(): 281 return []effect.Effect{effect.New(effect.Poison{}, 2, 22500*time.Millisecond)} 282 case Regeneration(): 283 return []effect.Effect{effect.New(effect.Regeneration{}, 1, 45*time.Second)} 284 case LongRegeneration(): 285 return []effect.Effect{effect.New(effect.Regeneration{}, 1, 2*time.Minute)} 286 case StrongRegeneration(): 287 return []effect.Effect{effect.New(effect.Regeneration{}, 2, 22*time.Second)} 288 case Strength(): 289 return []effect.Effect{effect.New(effect.Strength{}, 1, 3*time.Minute)} 290 case LongStrength(): 291 return []effect.Effect{effect.New(effect.Strength{}, 1, 8*time.Minute)} 292 case StrongStrength(): 293 return []effect.Effect{effect.New(effect.Strength{}, 2, 90*time.Second)} 294 case Weakness(): 295 return []effect.Effect{effect.New(effect.Weakness{}, 1, 90*time.Second)} 296 case LongWeakness(): 297 return []effect.Effect{effect.New(effect.Weakness{}, 1, 4*time.Minute)} 298 case Wither(): 299 return []effect.Effect{effect.New(effect.Wither{}, 1, 40*time.Second)} 300 case TurtleMaster(): 301 return []effect.Effect{ 302 effect.New(effect.Resistance{}, 3, 20*time.Second), 303 effect.New(effect.Slowness{}, 4, 20*time.Second), 304 } 305 case LongTurtleMaster(): 306 return []effect.Effect{ 307 effect.New(effect.Resistance{}, 3, 40*time.Second), 308 effect.New(effect.Slowness{}, 4, 40*time.Second), 309 } 310 case StrongTurtleMaster(): 311 return []effect.Effect{ 312 effect.New(effect.Resistance{}, 5, 20*time.Second), 313 effect.New(effect.Slowness{}, 6, 20*time.Second), 314 } 315 case SlowFalling(): 316 return []effect.Effect{effect.New(effect.SlowFalling{}, 1, 90*time.Second)} 317 case LongSlowFalling(): 318 return []effect.Effect{effect.New(effect.SlowFalling{}, 1, 4*time.Minute)} 319 case StrongSlowness(): 320 return []effect.Effect{effect.New(effect.Slowness{}, 4, 20*time.Second)} 321 } 322 return []effect.Effect{} 323 } 324 325 type potion uint8 326 327 // Uint8 returns the potion type as a uint8. 328 func (p potion) Uint8() uint8 { 329 return uint8(p) 330 } 331 332 // All ... 333 func All() []Potion { 334 return []Potion{ 335 Water(), Mundane(), LongMundane(), Thick(), Awkward(), NightVision(), LongNightVision(), Invisibility(), 336 LongInvisibility(), Leaping(), LongLeaping(), StrongLeaping(), FireResistance(), LongFireResistance(), 337 Swiftness(), LongSwiftness(), StrongSwiftness(), Slowness(), LongSlowness(), WaterBreathing(), 338 LongWaterBreathing(), Healing(), StrongHealing(), Harming(), StrongHarming(), Poison(), LongPoison(), 339 StrongPoison(), Regeneration(), LongRegeneration(), StrongRegeneration(), Strength(), LongStrength(), 340 StrongStrength(), Weakness(), LongWeakness(), Wither(), TurtleMaster(), LongTurtleMaster(), StrongTurtleMaster(), 341 SlowFalling(), LongSlowFalling(), StrongSlowness(), 342 } 343 }