mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Added Lever MaterialData
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
c8183cbb22
commit
9b8983805a
2 changed files with 62 additions and 1 deletions
|
@ -71,7 +71,7 @@ public enum Material {
|
|||
RAILS(66),
|
||||
COBBLESTONE_STAIRS(67),
|
||||
WALL_SIGN(68),
|
||||
LEVER(69),
|
||||
LEVER(69, Lever.class),
|
||||
STONE_PLATE(70),
|
||||
IRON_DOOR_BLOCK(71),
|
||||
WOOD_PLATE(72),
|
||||
|
|
61
paper-api/src/main/java/org/bukkit/material/Lever.java
Normal file
61
paper-api/src/main/java/org/bukkit/material/Lever.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
|
||||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.BlockFace;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Represents a lever
|
||||
*/
|
||||
public class Lever extends MaterialData implements Redstone, Attachable {
|
||||
public Lever(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Lever(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Lever(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Lever(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current state of this Material, indicating if it's powered or
|
||||
* unpowered
|
||||
*
|
||||
* @return true if powered, otherwise false
|
||||
*/
|
||||
public boolean isPowered() {
|
||||
return (getData() & 0x8) == 0x8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the face that this block is attached on
|
||||
*
|
||||
* @return BlockFace attached to
|
||||
*/
|
||||
public BlockFace getAttachedFace() {
|
||||
byte data = (byte) (getData() ^ 0x8);
|
||||
|
||||
switch (data) {
|
||||
case 0x1:
|
||||
return BlockFace.NORTH;
|
||||
case 0x2:
|
||||
return BlockFace.SOUTH;
|
||||
case 0x3:
|
||||
return BlockFace.EAST;
|
||||
case 0x4:
|
||||
return BlockFace.WEST;
|
||||
case 0x5:
|
||||
case 0x6:
|
||||
return BlockFace.DOWN;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue