-
Notifications
You must be signed in to change notification settings - Fork 0
/
CraftEffect.java
69 lines (67 loc) · 2.13 KB
/
CraftEffect.java
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
package org.bukkit.craftbukkit;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import org.apache.commons.lang.Validate;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.potion.Potion;
public class CraftEffect {
public static <T> int getDataValue(Effect effect, T data) {
int datavalue;
switch(effect) {
case VILLAGER_PLANT_GROW:
datavalue = (Integer) data;
break;
case POTION_BREAK:
datavalue = ((Potion) data).toDamageValue() & 0x3F;
break;
case RECORD_PLAY:
Validate.isTrue(((Material) data).isRecord(), "Invalid record type!");
datavalue = Item.getIdFromItem(CraftMagicNumbers.getItem((Material) data));
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 = Block.getStateId(CraftMagicNumbers.getBlock((Material) data).getDefaultState());
break;
default:
datavalue = 0;
}
return datavalue;
}
}