1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * THIS FILE IS AUTOGENERATED BY build.rs
 * MODIFICATIONS WILL BE OVERWRITTEN
 */

#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub enum PotionEffect {
    Speed = 1,
    Slowness = 2,
    Haste = 3,
    MiningFatigue = 4,
    Strength = 5,
    InstantHealth = 6,
    InstantDamage = 7,
    JumpBoost = 8,
    Nausea = 9,
    Regeneration = 10,
    Resistance = 11,
    FireResistance = 12,
    WaterBreathing = 13,
    Invisibility = 14,
    Blindness = 15,
    NightVision = 16,
    Hunger = 17,
    Weakness = 18,
    Poison = 19,
    Wither = 20,
    HealthBoost = 21,
    Absorption = 22,
    Saturation = 23,
    Glowing = 24,
    Levitation = 25,
    Luck = 26,
    Unluck = 27,
    SlowFalling = 28,
    ConduitPower = 29,
    DolphinsGrace = 30,
    BadOmen = 31,
    HeroOfTheVillage = 32,
    Darkness = 33,
}

impl TryFrom<u32> for PotionEffect {
    type Error = Error;
    fn try_from(value: u32) -> Result<Self, Self::Error> {
        match value {
            x if x == Self::Speed as u32 => Ok(Self::Speed),
            x if x == Self::Slowness as u32 => Ok(Self::Slowness),
            x if x == Self::Haste as u32 => Ok(Self::Haste),
            x if x == Self::MiningFatigue as u32 => Ok(Self::MiningFatigue),
            x if x == Self::Strength as u32 => Ok(Self::Strength),
            x if x == Self::InstantHealth as u32 => Ok(Self::InstantHealth),
            x if x == Self::InstantDamage as u32 => Ok(Self::InstantDamage),
            x if x == Self::JumpBoost as u32 => Ok(Self::JumpBoost),
            x if x == Self::Nausea as u32 => Ok(Self::Nausea),
            x if x == Self::Regeneration as u32 => Ok(Self::Regeneration),
            x if x == Self::Resistance as u32 => Ok(Self::Resistance),
            x if x == Self::FireResistance as u32 => Ok(Self::FireResistance),
            x if x == Self::WaterBreathing as u32 => Ok(Self::WaterBreathing),
            x if x == Self::Invisibility as u32 => Ok(Self::Invisibility),
            x if x == Self::Blindness as u32 => Ok(Self::Blindness),
            x if x == Self::NightVision as u32 => Ok(Self::NightVision),
            x if x == Self::Hunger as u32 => Ok(Self::Hunger),
            x if x == Self::Weakness as u32 => Ok(Self::Weakness),
            x if x == Self::Poison as u32 => Ok(Self::Poison),
            x if x == Self::Wither as u32 => Ok(Self::Wither),
            x if x == Self::HealthBoost as u32 => Ok(Self::HealthBoost),
            x if x == Self::Absorption as u32 => Ok(Self::Absorption),
            x if x == Self::Saturation as u32 => Ok(Self::Saturation),
            x if x == Self::Glowing as u32 => Ok(Self::Glowing),
            x if x == Self::Levitation as u32 => Ok(Self::Levitation),
            x if x == Self::Luck as u32 => Ok(Self::Luck),
            x if x == Self::Unluck as u32 => Ok(Self::Unluck),
            x if x == Self::SlowFalling as u32 => Ok(Self::SlowFalling),
            x if x == Self::ConduitPower as u32 => Ok(Self::ConduitPower),
            x if x == Self::DolphinsGrace as u32 => Ok(Self::DolphinsGrace),
            x if x == Self::BadOmen as u32 => Ok(Self::BadOmen),
            x if x == Self::HeroOfTheVillage as u32 => Ok(Self::HeroOfTheVillage),
            x if x == Self::Darkness as u32 => Ok(Self::Darkness),
            _ => Err(Error::EnumOutOfBound)
        }
    }
}