blob: 7de0de5e19c07883d2b6de9d6b46cb780610828b (
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
|
package org.bukkit.craftbukkit;
import org.apache.commons.lang.Validate;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.potion.Potion;
public class CraftEffect {
public static <T> int getDataValue(Effect effect, T data) {
int datavalue;
switch(effect) {
case POTION_BREAK:
datavalue = ((Potion) data).toDamageValue() & 0x3F;
break;
case RECORD_PLAY:
Validate.isTrue(((Material) data).isRecord(), "Invalid record type!");
datavalue = ((Material) data).getId();
break;
case SMOKE:
switch((BlockFace) data) { // TODO: Verify (Where did these values come from...?)
case SOUTH_EAST:
datavalue = 0;
break;
case SOUTH:
datavalue = 1;
break;
case SOUTH_WEST:
datavalue = 2;
break;
case EAST:
datavalue = 3;
break;
case UP:
case SELF:
datavalue = 4;
break;
case WEST:
datavalue = 5;
break;
case NORTH_EAST:
datavalue = 6;
break;
case NORTH:
datavalue = 7;
break;
case NORTH_WEST:
datavalue = 8;
break;
default:
throw new IllegalArgumentException("Bad smoke direction!");
}
break;
case STEP_SOUND:
Validate.isTrue(((Material) data).isBlock(), "Material is not a block!");
datavalue = ((Material) data).getId();
break;
default:
datavalue = 0;
}
return datavalue;
}
}
|