Let TripwireHook be attachable. Addresses BUKKIT-2278
This commit also makes TripwireHook consistent with other attachables for the facing property.
This commit is contained in:
parent
11fd4acb56
commit
6bbeb93103
@ -6,8 +6,8 @@ import org.bukkit.block.BlockFace;
|
|||||||
/**
|
/**
|
||||||
* Represents the tripwire hook
|
* Represents the tripwire hook
|
||||||
*/
|
*/
|
||||||
public class TripwireHook extends MaterialData implements Directional, Redstone {
|
public class TripwireHook extends SimpleAttachableMaterialData implements Redstone {
|
||||||
|
|
||||||
public TripwireHook() {
|
public TripwireHook() {
|
||||||
super(Material.TRIPWIRE_HOOK);
|
super(Material.TRIPWIRE_HOOK);
|
||||||
}
|
}
|
||||||
@ -19,12 +19,12 @@ public class TripwireHook extends MaterialData implements Directional, Redstone
|
|||||||
public TripwireHook(final int type, final byte data) {
|
public TripwireHook(final int type, final byte data) {
|
||||||
super(type, data);
|
super(type, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TripwireHook(BlockFace dir) {
|
public TripwireHook(BlockFace dir) {
|
||||||
this();
|
this();
|
||||||
setFacingDirection(dir);
|
setFacingDirection(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if tripwire is connected
|
* Test if tripwire is connected
|
||||||
* @return true if connected, false if not
|
* @return true if connected, false if not
|
||||||
@ -32,7 +32,7 @@ public class TripwireHook extends MaterialData implements Directional, Redstone
|
|||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return (getData() & 0x4) != 0;
|
return (getData() & 0x4) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set tripwire connection state
|
* Set tripwire connection state
|
||||||
* @param connected - true if connected, false if not
|
* @param connected - true if connected, false if not
|
||||||
@ -52,7 +52,7 @@ public class TripwireHook extends MaterialData implements Directional, Redstone
|
|||||||
public boolean isActivated() {
|
public boolean isActivated() {
|
||||||
return (getData() & 0x8) != 0;
|
return (getData() & 0x8) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set hook activated state
|
* Set hook activated state
|
||||||
* @param act - true if activated, false if not
|
* @param act - true if activated, false if not
|
||||||
@ -64,41 +64,40 @@ public class TripwireHook extends MaterialData implements Directional, Redstone
|
|||||||
}
|
}
|
||||||
setData((byte) dat);
|
setData((byte) dat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFacingDirection(BlockFace face) {
|
public void setFacingDirection(BlockFace face) {
|
||||||
int dat = getData() & 0xC;
|
int dat = getData() & 0xC;
|
||||||
switch (face) {
|
switch (face) {
|
||||||
case EAST:
|
case NORTH:
|
||||||
break;
|
dat |= 0x1;
|
||||||
case SOUTH:
|
break;
|
||||||
dat |= 0x1;
|
case EAST:
|
||||||
break;
|
dat |= 0x2;
|
||||||
case WEST:
|
break;
|
||||||
dat |= 0x2;
|
case SOUTH:
|
||||||
break;
|
dat |= 0x3;
|
||||||
case NORTH:
|
break;
|
||||||
dat |= 0x3;
|
case WEST:
|
||||||
break;
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
setData((byte) dat);
|
setData((byte) dat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockFace getFacing() {
|
public BlockFace getAttachedFace() {
|
||||||
switch (getData() & 0x3) {
|
switch (getData() & 0x3) {
|
||||||
case 0:
|
case 0:
|
||||||
return BlockFace.EAST;
|
return BlockFace.EAST;
|
||||||
case 1:
|
case 1:
|
||||||
return BlockFace.SOUTH;
|
return BlockFace.SOUTH;
|
||||||
case 2:
|
case 2:
|
||||||
return BlockFace.WEST;
|
return BlockFace.WEST;
|
||||||
case 3:
|
case 3:
|
||||||
return BlockFace.NORTH;
|
return BlockFace.NORTH;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPowered() {
|
public boolean isPowered() {
|
||||||
return isActivated();
|
return isActivated();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user