Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit.material;
2
3import org.bukkit.Material;
4import org.bukkit.block.BlockFace;
5
6/**
7 * Represents Ladder data
8 */
9public class Ladder extends SimpleAttachableMaterialData {
10 public Ladder() {
11 super(Material.LADDER);
12 }
13
14 public Ladder(final int type) {
15 super(type);
16 }
17
18 public Ladder(final Material type) {
19 super(type);
20 }
21
22 public Ladder(final int type, final byte data) {
23 super(type, data);
24 }
25
26 public Ladder(final Material type, final byte data) {
27 super(type, data);
28 }
29
30 /**
31 * Gets the face that this block is attached on
32 *
33 * @return BlockFace attached to
34 */
35 public BlockFace getAttachedFace() {
36 byte data = getData();
37
38 switch (data) {
39 case 0x2:
40 return BlockFace.WEST;
41
42 case 0x3:
43 return BlockFace.EAST;
44
45 case 0x4:
46 return BlockFace.SOUTH;
47
48 case 0x5:
49 return BlockFace.NORTH;
50 }
51
52 return null;
53 }
54
55 /**
56 * Sets the direction this ladder is facing
57 */
58 public void setFacingDirection(BlockFace face) {
59 byte data = (byte) 0x0;
60
61 switch (face) {
62 case WEST:
63 data = 0x2;
64 break;
65
66 case EAST:
67 data = 0x3;
68 break;
69
70 case SOUTH:
71 data = 0x4;
72 break;
73
74 case NORTH:
75 data = 0x5;
76 break;
77 }
78
79 setData(data);
80
81 }
82}