/** * 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() & 0x7); switch (data) { case 0x1: return BlockFace.WEST; case 0x2: return BlockFace.EAST; case 0x3: return BlockFace.NORTH; case 0x4: return BlockFace.SOUTH; } return null; }
/** * Sets the direction this button is pointing toward */ public void setFacingDirection(BlockFace face) { byte data = (byte) (getData() & 0x8); switch (face) { case EAST: data |= 0x1; break; case WEST: data |= 0x2; break; case SOUTH: data |= 0x3; break; case NORTH: data |= 0x4; break; } setData(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() & 0x7); switch (data) { case 0x1: return BlockFace.WEST; case 0x2: return BlockFace.EAST; case 0x3: return BlockFace.NORTH; case 0x4: return BlockFace.SOUTH; } return null; }
/** * Sets the direction this button is pointing toward */ public void setFacingDirection(BlockFace face) { byte data = (byte) (getData() & 0x8); switch (face) { case EAST: data |= 0x1; break; case WEST: data |= 0x2; break; case SOUTH: data |= 0x3; break; case NORTH: data |= 0x4; break; } setData(data); }
@Override public void run() { button.setPowered(!button.isPowered()); btBlock.setData(button.getData()); final Block supportBlock = btBlock.getRelative(button.getAttachedFace()); if (supportBlock != null && supportBlock.getType() != Material.AIR) { final BlockState initialSupportState = supportBlock.getState(); final BlockState supportState = supportBlock.getState(); supportState.setType(Material.AIR); supportState.update(true, false); initialSupportState.update(true); } } }.runTaskLater(ProjectKorra.plugin, 10);
@Override public void run() { button.setPowered(!button.isPowered()); btBlock.setData(button.getData()); final Block supportBlock = btBlock.getRelative(button.getAttachedFace()); if (supportBlock != null && supportBlock.getType() != Material.AIR) { final BlockState initialSupportState = supportBlock.getState(); final BlockState supportState = supportBlock.getState(); supportState.setType(Material.AIR); supportState.update(true, false); initialSupportState.update(true); } } }.runTaskLater(ProjectKorra.plugin, 15);