@@ -5,18 +5,18 @@ import org.bukkit.block.BlockFace;
|
||||
|
||||
/**
|
||||
* Represents a bed.
|
||||
*
|
||||
*
|
||||
* @author sunkid
|
||||
*/
|
||||
public class Bed extends MaterialData implements Directional {
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor for a bed.
|
||||
*/
|
||||
public Bed() {
|
||||
super(Material.BED_BLOCK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiate a bed facing in a particular direction.
|
||||
* @param direction the direction the bed's head is facing
|
||||
@@ -25,7 +25,7 @@ public class Bed extends MaterialData implements Directional {
|
||||
this();
|
||||
setFacingDirection(direction);
|
||||
}
|
||||
|
||||
|
||||
public Bed(final int type) {
|
||||
super(type);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class Bed extends MaterialData implements Directional {
|
||||
|
||||
/**
|
||||
* Determine if this block represents the head of the bed
|
||||
*
|
||||
*
|
||||
* @return true if this is the head of the bed, false if it is the foot
|
||||
*/
|
||||
public boolean isHeadOfBed() {
|
||||
@@ -57,16 +57,20 @@ public class Bed extends MaterialData implements Directional {
|
||||
*/
|
||||
public void setFacingDirection(BlockFace face) {
|
||||
byte data;
|
||||
|
||||
switch (face) {
|
||||
case WEST:
|
||||
data = 0x0;
|
||||
break;
|
||||
|
||||
case NORTH:
|
||||
data = 0x1;
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
data = 0x2;
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
default:
|
||||
data = 0x3;
|
||||
@@ -81,24 +85,28 @@ public class Bed extends MaterialData implements Directional {
|
||||
|
||||
/**
|
||||
* Get the direction that this bed's head is facing toward
|
||||
*
|
||||
*
|
||||
* @return the direction the head of the bed is facing
|
||||
*/
|
||||
public BlockFace getFacing() {
|
||||
byte data = (byte) (getData() & 0x7);
|
||||
|
||||
switch (data) {
|
||||
case 0x0:
|
||||
return BlockFace.WEST;
|
||||
|
||||
case 0x1:
|
||||
return BlockFace.NORTH;
|
||||
|
||||
case 0x2:
|
||||
return BlockFace.EAST;
|
||||
|
||||
case 0x3:
|
||||
default:
|
||||
return BlockFace.SOUTH;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (isHeadOfBed() ? "HEAD" : "FOOT") + " of " + super.toString() + " facing " + getFacing();
|
||||
|
||||
Reference in New Issue
Block a user