geforkt von Mirrors/Paper
Retrofit Door in order to work with modern Minecraft doors.
By: Xor Boole <mcyoung@mit.edu>
Dieser Commit ist enthalten in:
Ursprung
dc0588c29d
Commit
bbdebc86a5
@ -255,12 +255,12 @@ public enum Material {
|
||||
BIRCH_FENCE(189),
|
||||
JUNGLE_FENCE(190),
|
||||
DARK_OAK_FENCE(191),
|
||||
ACACIA_FENCE(192),
|
||||
SPRUCE_DOOR(193),
|
||||
BIRCH_DOOR(194),
|
||||
JUNGLE_DOOR(195),
|
||||
ACACIA_DOOR(196),
|
||||
DARK_OAK_DOOR(197),
|
||||
ACACIA_FENCE(192, Door.class),
|
||||
SPRUCE_DOOR(193, Door.class),
|
||||
BIRCH_DOOR(194, Door.class),
|
||||
JUNGLE_DOOR(195, Door.class),
|
||||
ACACIA_DOOR(196, Door.class),
|
||||
DARK_OAK_DOOR(197, Door.class),
|
||||
// ----- Item Separator -----
|
||||
IRON_SPADE(256, 1, 250),
|
||||
IRON_PICKAXE(257, 1, 250),
|
||||
|
@ -6,10 +6,19 @@ import org.bukkit.block.BlockFace;
|
||||
/**
|
||||
* Represents a door.
|
||||
*
|
||||
* @deprecated No longer functions. Do not use.
|
||||
* This class was previously deprecated, but has been retrofitted to
|
||||
* work with modern doors. Some methods are undefined dependant on <code>isTopHalf()</code>
|
||||
* due to Minecraft's internal representation of doors.
|
||||
*/
|
||||
public class Door extends MaterialData implements Directional, Openable {
|
||||
|
||||
// This class breaks API contracts on Directional and Openable because
|
||||
// of the way doors are currently implemented. Beware!
|
||||
|
||||
/**
|
||||
* @deprecated Artifact of old API, equivalent to new <code>Door(Material.WOODEN_DOOR);</code>
|
||||
*/
|
||||
@Deprecated
|
||||
public class Door extends MaterialData implements Directional, Openable {
|
||||
public Door() {
|
||||
super(Material.WOODEN_DOOR);
|
||||
}
|
||||
@ -48,17 +57,15 @@ public class Door extends MaterialData implements Directional, Openable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Does not work (correctly) anymore
|
||||
* Result is undefined if <code>isTopHalf()</code> is true.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isOpen() {
|
||||
return ((getData() & 0x4) == 0x4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Does not work (correctly) anymore
|
||||
* Set whether the door is open. Undefined if <code>isTopHalf()</code> is true.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setOpen(boolean isOpen) {
|
||||
setData((byte) (isOpen ? (getData() | 0x4) : (getData() & ~0x4)));
|
||||
}
|
||||
@ -74,30 +81,18 @@ public class Door extends MaterialData implements Directional, Openable {
|
||||
* Configure this part of the door to be either the top or the bottom half
|
||||
*
|
||||
* @param isTopHalf True to make it the top half.
|
||||
* @deprecated Shouldn't be used anymore
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTopHalf(boolean isTopHalf) {
|
||||
setData((byte) (isTopHalf ? (getData() | 0x8) : (getData() & ~0x8)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BlockFace.SELF
|
||||
* @deprecated Does not work (correctly) anymore
|
||||
* @deprecated This method should not be used; use hinge and facing accessors instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public BlockFace getHingeCorner() {
|
||||
byte d = getData();
|
||||
|
||||
if ((d & 0x3) == 0x3) {
|
||||
return BlockFace.NORTH_WEST;
|
||||
} else if ((d & 0x1) == 0x1) {
|
||||
return BlockFace.SOUTH_EAST;
|
||||
} else if ((d & 0x2) == 0x2) {
|
||||
return BlockFace.SOUTH_WEST;
|
||||
}
|
||||
|
||||
return BlockFace.NORTH_EAST;
|
||||
return BlockFace.SELF;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,13 +103,17 @@ public class Door extends MaterialData implements Directional, Openable {
|
||||
/**
|
||||
* Set the direction that this door should is facing.
|
||||
*
|
||||
* Undefined if <code>isTopHalf()</code> is true.
|
||||
*
|
||||
* @param face the direction
|
||||
* @deprecated Does not work (correctly) anymore
|
||||
*/
|
||||
@Deprecated
|
||||
public void setFacingDirection(BlockFace face) {
|
||||
byte data = (byte) (getData() & 0x12);
|
||||
switch (face) {
|
||||
case WEST:
|
||||
data |= 0x0;
|
||||
break;
|
||||
|
||||
case NORTH:
|
||||
data |= 0x1;
|
||||
break;
|
||||
@ -133,10 +132,10 @@ public class Door extends MaterialData implements Directional, Openable {
|
||||
/**
|
||||
* Get the direction that this door is facing.
|
||||
*
|
||||
* Undefined if <code>isTopHalf()</code> is true.
|
||||
*
|
||||
* @return the direction
|
||||
* @deprecated Does not work (correctly) anymore
|
||||
*/
|
||||
@Deprecated
|
||||
public BlockFace getFacing() {
|
||||
byte data = (byte) (getData() & 0x3);
|
||||
switch (data) {
|
||||
@ -155,6 +154,26 @@ public class Door extends MaterialData implements Directional, Openable {
|
||||
return null; // shouldn't happen
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the side of the door the hinge is on.
|
||||
*
|
||||
* Undefined if <code>isTopHalf()</code> is false.
|
||||
*
|
||||
* @return false for left hinge, true for right hinge
|
||||
*/
|
||||
public boolean getHinge() {
|
||||
return (getData() & 0x1) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the hinge is on the left or right side. Left is false, right is true.
|
||||
*
|
||||
* Undefined if <code>isTopHalf()</code> is false.
|
||||
*/
|
||||
public void setHinge(boolean hinge) {
|
||||
setData((byte) (hinge ? (getData() | 0x1) : (getData() & ~0x1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Door clone() {
|
||||
return (Door) super.clone();
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren