Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
PistonBaseMaterial.java
1 package org.bukkit.material;
2 
3 import org.bukkit.Material;
5 
6 /**
7  * Material data for the piston base block
8  */
9 public class PistonBaseMaterial extends MaterialData implements Directional, Redstone {
10  /**
11  *
12  * @deprecated Magic value
13  */
14  @Deprecated
15  public PistonBaseMaterial(final int type) {
16  super(type);
17  }
18 
19  public PistonBaseMaterial(final Material type) {
20  super(type);
21  }
22 
23  /**
24  *
25  * @deprecated Magic value
26  */
27  @Deprecated
28  public PistonBaseMaterial(final int type, final byte data) {
29  super(type, data);
30  }
31 
32  /**
33  *
34  * @deprecated Magic value
35  */
36  @Deprecated
37  public PistonBaseMaterial(final Material type, final byte data) {
38  super(type, data);
39  }
40 
41  public void setFacingDirection(BlockFace face) {
42  byte data = (byte) (getData() & 0x8);
43 
44  switch (face) {
45  case UP:
46  data |= 1;
47  break;
48  case NORTH:
49  data |= 2;
50  break;
51  case SOUTH:
52  data |= 3;
53  break;
54  case WEST:
55  data |= 4;
56  break;
57  case EAST:
58  data |= 5;
59  break;
60  }
61  setData(data);
62  }
63 
64  public BlockFace getFacing() {
65  byte dir = (byte) (getData() & 7);
66 
67  switch (dir) {
68  case 0:
69  return BlockFace.DOWN;
70  case 1:
71  return BlockFace.UP;
72  case 2:
73  return BlockFace.NORTH;
74  case 3:
75  return BlockFace.SOUTH;
76  case 4:
77  return BlockFace.WEST;
78  case 5:
79  return BlockFace.EAST;
80  default:
81  return BlockFace.SELF;
82  }
83  }
84 
85  public boolean isPowered() {
86  return (getData() & 0x8) == 0x8;
87  }
88 
89  /**
90  * Sets the current state of this piston
91  *
92  * @param powered true if the piston is extended & powered, or false
93  */
94  public void setPowered(boolean powered) {
95  setData((byte) (powered ? (getData() | 0x8) : (getData() & ~0x8)));
96  }
97 
98  /**
99  * Checks if this piston base is sticky, and returns true if so
100  *
101  * @return true if this piston is "sticky", or false
102  */
103  public boolean isSticky() {
104  return this.getItemType() == Material.PISTON_STICKY_BASE;
105  }
106 
107  @Override
108  public PistonBaseMaterial clone() {
109  return (PistonBaseMaterial) super.clone();
110  }
111 }
PistonBaseMaterial(final int type, final byte data)
PistonBaseMaterial(final Material type, final byte data)