summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/EntityEffect.java
blob: fbf21fb3e749987056c73047de6eb284d880df66 (plain)
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
84
package org.bukkit;

import java.util.Map;

import com.google.common.collect.Maps;

/**
 * A list of all Effects that can happen to entities.
 */
public enum EntityEffect {

    /**
     * When mobs get hurt.
     */
    HURT(2),

    /**
     * When a mob dies.
     * <p>
     * <b>This will cause client-glitches!
     */
    DEATH(3),

    /**
     * The smoke when taming a wolf fails.
     * <p>
     * Without client-mods this will be ignored if the entity is not a wolf.
     */
    WOLF_SMOKE(6),

    /**
     * The hearts when taming a wolf succeeds.
     * <p>
     * Without client-mods this will be ignored if the entity is not a wolf.
     */
    WOLF_HEARTS(7),

    /**
     * When a wolf shakes (after being wet).
     * <p>
     * Without client-mods this will be ignored if the entity is not a wolf.
     */
    WOLF_SHAKE(8),

    /**
     * When a sheep eats a LONG_GRASS block.
     */
    SHEEP_EAT(10);

    private final byte data;
    private final static Map<Byte, EntityEffect> BY_DATA = Maps.newHashMap();

    EntityEffect(final int data) {
        this.data = (byte) data;
    }

    /**
     * Gets the EntityEffect with the given data value
     *
     * @param data Data value to fetch
     * @return The {@link EntityEffect} representing the given value, or null if
     *         it doesn't exist
     */
    public byte getData() {
        return data;
    }

    /**
     * Gets the EntityEffect with the given data value
     *
     * @param data Data value to fetch
     * @return The {@link EntityEffect} representing the given value, or null if it doesn't exist
     */
    public static EntityEffect getByData(final byte data) {
        return BY_DATA.get(data);
    }


    static {
        for (EntityEffect entityEffect : values()) {
            BY_DATA.put(entityEffect.data, entityEffect);
        }
    }
}