mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 19:34:09 +01:00
Add inverted flag support to TrapDoor. Fixes BUKKIT-3390
By: Peter Olson <peter.olson@gmail.com>
This commit is contained in:
parent
b965616431
commit
4d1f2668bf
1 changed files with 23 additions and 3 deletions
|
@ -43,6 +43,26 @@ public class TrapDoor extends SimpleAttachableMaterialData implements Openable {
|
|||
setData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if trapdoor is inverted
|
||||
* @return true if inverted (top half), false if normal (bottom half)
|
||||
*/
|
||||
public boolean isInverted() {
|
||||
return ((getData() & 0x8) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set trapdoor inverted state
|
||||
* @param inv - true if inverted (top half), false if normal (bottom half)
|
||||
*/
|
||||
public void setInverted(boolean inv) {
|
||||
int dat = getData() & 0x7;
|
||||
if (inv) {
|
||||
dat |= 0x8;
|
||||
}
|
||||
setData((byte) dat);
|
||||
}
|
||||
|
||||
public BlockFace getAttachedFace() {
|
||||
byte data = (byte) (getData() & 0x3);
|
||||
|
||||
|
@ -65,7 +85,7 @@ public class TrapDoor extends SimpleAttachableMaterialData implements Openable {
|
|||
}
|
||||
|
||||
public void setFacingDirection(BlockFace face) {
|
||||
byte data = (byte) (getData() & 0x4);
|
||||
byte data = (byte) (getData() & 0xC);
|
||||
|
||||
switch (face) {
|
||||
case SOUTH:
|
||||
|
@ -84,11 +104,11 @@ public class TrapDoor extends SimpleAttachableMaterialData implements Openable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (isOpen() ? "OPEN " : "CLOSED ") + super.toString() + " with hinges set " + getAttachedFace();
|
||||
return (isOpen() ? "OPEN " : "CLOSED ") + super.toString() + " with hinges set " + getAttachedFace() + (isInverted() ? " inverted" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrapDoor clone() {
|
||||
return (TrapDoor) super.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue