Bukkit  1.4.7-R1.0
 All Classes Namespaces Files Functions Variables Enumerator Pages
ExtendedRails.java
Go to the documentation of this file.
1 package org.bukkit.material;
2 
3 import org.bukkit.Material;
4 import org.bukkit.block.BlockFace;
5 
9 public class ExtendedRails extends Rails {
10  public ExtendedRails(final int type) {
11  super(type);
12  }
13 
14  public ExtendedRails(final Material type) {
15  super(type);
16  }
17 
18  public ExtendedRails(final int type, final byte data) {
19  super(type, data);
20  }
21 
22  public ExtendedRails(final Material type, final byte data) {
23  super(type, data);
24  }
25 
26  @Override
27  public boolean isCurve() {
28  return false;
29  }
30 
31  @Override
32  protected byte getConvertedData() {
33  return (byte) (getData() & 0x7);
34  }
35 
36  @Override
37  public void setDirection(BlockFace face, boolean isOnSlope) {
38  boolean extraBitSet = (getData() & 0x8) == 0x8;
39 
40  if (face != BlockFace.WEST && face != BlockFace.EAST && face != BlockFace.NORTH && face != BlockFace.SOUTH) {
41  throw new IllegalArgumentException("Detector rails and powered rails cannot be set on a curve!");
42  }
43 
44  super.setDirection(face, isOnSlope);
45  setData((byte) (extraBitSet ? (getData() | 0x8) : (getData() & ~0x8)));
46  }
47 
48  @Override
49  public ExtendedRails clone() {
50  return (ExtendedRails) super.clone();
51  }
52 }