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 stairs.
8 */
9public class Stairs extends MaterialData implements Directional {
10
11 public Stairs(final int type) {
12 super(type);
13 }
14
15 public Stairs(final Material type) {
16 super(type);
17 }
18
19 public Stairs(final int type, final byte data) {
20 super(type, data);
21 }
22
23 public Stairs(final Material type, final byte data) {
24 super(type, data);
25 }
26
27 /**
28 * @return the direction the stairs ascend towards
29 */
30 public BlockFace getAscendingDirection() {
31 byte data = getData();
32
33 switch (data) {
34 case 0x0:
35 default:
36 return BlockFace.SOUTH;
37
38 case 0x1:
39 return BlockFace.NORTH;
40
41 case 0x2:
42 return BlockFace.WEST;
43
44 case 0x3:
45 return BlockFace.EAST;
46 }
47 }
48
49 /**
50 * @return the direction the stairs descend towards
51 */
52 public BlockFace getDescendingDirection() {
53 return getAscendingDirection().getOppositeFace();
54 }
55
56 /**
57 * Set the direction the stair part of the block is facing
58 */
59 public void setFacingDirection(BlockFace face) {
60 byte data;
61
62 switch (face) {
63 case NORTH:
64 default:
65 data = 0x0;
66 break;
67
68 case SOUTH:
69 data = 0x1;
70 break;
71
72 case EAST:
73 data = 0x2;
74 break;
75
76 case WEST:
77 data = 0x3;
78 break;
79 }
80
81 setData(data);
82 }
83
84 /**
85 * @return the direction the stair part of the block is facing
86 */
87 public BlockFace getFacing() {
88 return getDescendingDirection();
89 }
90
91 @Override
92 public String toString() {
93 return super.toString() + " facing " + getFacing();
94 }
95}