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 * This is the superclass for the {@link DetectorRail} and {@link PoweredRail} classes
8 */
9public 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.NORTH && face != BlockFace.SOUTH && face != BlockFace.EAST && face != BlockFace.WEST) {
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}