mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Added Sign MaterialData
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
1b2e403319
commit
79b2b7fc32
@ -65,12 +65,12 @@ public enum Material {
|
||||
SOIL(60),
|
||||
FURNACE(61),
|
||||
BURNING_FURNACE(62),
|
||||
SIGN_POST(63),
|
||||
SIGN_POST(63, Sign.class),
|
||||
WOODEN_DOOR(64),
|
||||
LADDER(65, Ladder.class),
|
||||
RAILS(66),
|
||||
COBBLESTONE_STAIRS(67),
|
||||
WALL_SIGN(68),
|
||||
WALL_SIGN(68, Sign.class),
|
||||
LEVER(69, Lever.class),
|
||||
STONE_PLATE(70),
|
||||
IRON_DOOR_BLOCK(71),
|
||||
@ -162,7 +162,7 @@ public enum Material {
|
||||
GRILLED_PORK(320),
|
||||
PAINTING(321),
|
||||
GOLDEN_APPLE(322),
|
||||
SIGN(323),
|
||||
SIGN(323, Sign.class),
|
||||
WOOD_DOOR(324),
|
||||
BUCKET(325),
|
||||
WATER_BUCKET(326),
|
||||
|
105
paper-api/src/main/java/org/bukkit/material/Sign.java
Normal file
105
paper-api/src/main/java/org/bukkit/material/Sign.java
Normal file
@ -0,0 +1,105 @@
|
||||
|
||||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.BlockFace;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* MaterialData for signs
|
||||
*/
|
||||
public class Sign extends MaterialData implements Attachable {
|
||||
public Sign(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Sign(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Sign(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Sign(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the face that this block is attached on
|
||||
*
|
||||
* @return BlockFace attached to
|
||||
*/
|
||||
public BlockFace getAttachedFace() {
|
||||
if (getItemType() == Material.WALL_SIGN) {
|
||||
byte data = getData();
|
||||
|
||||
switch (data) {
|
||||
case 0x2:
|
||||
return BlockFace.WEST;
|
||||
case 0x3:
|
||||
return BlockFace.EAST;
|
||||
case 0x4:
|
||||
return BlockFace.SOUTH;
|
||||
case 0x5:
|
||||
return BlockFace.NORTH;
|
||||
}
|
||||
|
||||
return null;
|
||||
} else {
|
||||
return BlockFace.DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the direction that this sign is currently facing
|
||||
*
|
||||
* @return BlockFace indicating where this sign is facing
|
||||
*/
|
||||
public BlockFace getFacing() {
|
||||
byte data = getData();
|
||||
|
||||
if (getAttachedFace() == BlockFace.DOWN) {
|
||||
switch (data) {
|
||||
case 0x0:
|
||||
case 0x1:
|
||||
return BlockFace.WEST;
|
||||
case 0x2:
|
||||
case 0x3:
|
||||
return BlockFace.NORTH_WEST;
|
||||
case 0x4:
|
||||
case 0x5:
|
||||
return BlockFace.NORTH;
|
||||
case 0x6:
|
||||
case 0x7:
|
||||
return BlockFace.NORTH_EAST;
|
||||
case 0x8:
|
||||
case 0x9:
|
||||
return BlockFace.EAST;
|
||||
case 0xA:
|
||||
case 0xB:
|
||||
return BlockFace.SOUTH_EAST;
|
||||
case 0xC:
|
||||
case 0xD:
|
||||
return BlockFace.SOUTH;
|
||||
case 0xE:
|
||||
case 0xF:
|
||||
return BlockFace.SOUTH_WEST;
|
||||
}
|
||||
|
||||
return null;
|
||||
} else {
|
||||
switch (data) {
|
||||
case 0x2:
|
||||
return BlockFace.EAST;
|
||||
case 0x3:
|
||||
return BlockFace.WEST;
|
||||
case 0x4:
|
||||
return BlockFace.NORTH;
|
||||
case 0x5:
|
||||
return BlockFace.SOUTH;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user