mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
added the MaterialData subclass Door
By: sunkid <sunkid@iminurnetz.com>
This commit is contained in:
parent
022f95b2f1
commit
26c1772bd8
3 changed files with 88 additions and 2 deletions
|
@ -67,14 +67,14 @@ public enum Material {
|
|||
FURNACE(61),
|
||||
BURNING_FURNACE(62),
|
||||
SIGN_POST(63, 1, Sign.class),
|
||||
WOODEN_DOOR(64),
|
||||
WOODEN_DOOR(64, Door.class),
|
||||
LADDER(65, Ladder.class),
|
||||
RAILS(66),
|
||||
COBBLESTONE_STAIRS(67),
|
||||
WALL_SIGN(68, 1, Sign.class),
|
||||
LEVER(69, Lever.class),
|
||||
STONE_PLATE(70),
|
||||
IRON_DOOR_BLOCK(71),
|
||||
IRON_DOOR_BLOCK(71, Door.class),
|
||||
WOOD_PLATE(72),
|
||||
REDSTONE_ORE(73),
|
||||
GLOWING_REDSTONE_ORE(74),
|
||||
|
|
|
@ -55,4 +55,33 @@ public enum BlockFace {
|
|||
public int getModZ() {
|
||||
return modZ;
|
||||
}
|
||||
|
||||
public BlockFace getOppositeFace() {
|
||||
switch (this) {
|
||||
case NORTH:
|
||||
return BlockFace.SOUTH;
|
||||
case SOUTH:
|
||||
return BlockFace.NORTH;
|
||||
case EAST:
|
||||
return BlockFace.WEST;
|
||||
case WEST:
|
||||
return BlockFace.EAST;
|
||||
case UP:
|
||||
return BlockFace.DOWN;
|
||||
case DOWN:
|
||||
return BlockFace.UP;
|
||||
case NORTH_EAST:
|
||||
return BlockFace.SOUTH_WEST;
|
||||
case NORTH_WEST:
|
||||
return BlockFace.SOUTH_EAST;
|
||||
case SOUTH_EAST:
|
||||
return BlockFace.NORTH_WEST;
|
||||
case SOUTH_WEST:
|
||||
return BlockFace.NORTH_EAST;
|
||||
case SELF:
|
||||
return BlockFace.SELF;
|
||||
}
|
||||
|
||||
return BlockFace.SELF;
|
||||
}
|
||||
}
|
||||
|
|
57
paper-api/src/main/java/org/bukkit/material/Door.java
Normal file
57
paper-api/src/main/java/org/bukkit/material/Door.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
/**
|
||||
* Represents the different types of coals.
|
||||
* @author sunkid
|
||||
*/
|
||||
public class Door extends MaterialData {
|
||||
public Door(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Door(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Door(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Door(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the door is open.
|
||||
* @return true if the door has swung counterclockwise around its hinge.
|
||||
*/
|
||||
public boolean isOpen() {
|
||||
return ((getData() & 0x4) == 0x4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this is the top half of the door
|
||||
*/
|
||||
public boolean isTopHalf() {
|
||||
return ((getData() & 0x8) == 0x8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the location of the hinges
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue