1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-01-30 19:40:37 +01:00

Added Button MaterialData

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2011-01-15 20:58:34 +00:00
parent 9b8983805a
commit 59524fdb80
2 changed files with 59 additions and 1 deletions
paper-api/src/main/java/org/bukkit

View file

@ -79,7 +79,7 @@ public enum Material {
GLOWING_REDSTONE_ORE(74),
REDSTONE_TORCH_OFF(75, RedstoneTorch.class),
REDSTONE_TORCH_ON(76, RedstoneTorch.class),
STONE_BUTTON(77),
STONE_BUTTON(77, Button.class),
SNOW(78),
ICE(79),
SNOW_BLOCK(80),

View file

@ -0,0 +1,58 @@
package org.bukkit.material;
import org.bukkit.BlockFace;
import org.bukkit.Material;
/**
* Represents a button
*/
public class Button extends MaterialData implements Redstone, Attachable {
public Button(final int type) {
super(type);
}
public Button(final Material type) {
super(type);
}
public Button(final int type, final byte data) {
super(type, data);
}
public Button(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;
}
return null;
}
}