@Override public String toString() { return super.toString() + " " + (isPowered() ? "" : "NOT ") + "POWERED"; }
@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);
if (button.isPowered()) { return true; button.setPowered(true); state.update(); extraUpdate(block);
&& ((Button) getState().getData()).isPowered()) { return true; case WOOD_BUTTON: Button button = (Button) target.getState().getData(); if (button.isPowered() && button.getAttachedFace() == target.getFace(this)) { return true;
/** * 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; }
@Override public void run() { button.setPowered(false); state.update(); if (block.getType() == Material.WOOD_BUTTON || block.getType() == Material.STONE_BUTTON) { extraUpdate(block); block.getWorld().playSound(block.getLocation(), block.getType() == Material.WOOD_BUTTON ? Sound.BLOCK_WOOD_BUTTON_CLICK_OFF : Sound.BLOCK_STONE_BUTTON_CLICK_OFF, 0.3f, 0.5f); } } }.runTaskLater(null, block.getType() == Material.STONE_BUTTON ? 20 : 30);
private void extraUpdate(GlowBlock block) { Button button = (Button) block.getState().getData(); ItemTable itemTable = ItemTable.instance(); GlowBlock target = block.getRelative(button.getAttachedFace()); if (target.getType().isSolid()) { for (BlockFace face2 : ADJACENT) { GlowBlock target2 = target.getRelative(face2); BlockType notifyType = itemTable.getBlock(target2.getType()); if (notifyType != null) { if (target2.getFace(block) == null) { notifyType .onNearBlockChanged(target2, BlockFace.SELF, block, block.getType(), block.getData(), block.getType(), block.getData()); } notifyType.onRedstoneUpdate(target2); } } } }
@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);
Button powerData = (Button)data; registerForUndo(block); powerData.setPowered(!powerData.isPowered()); powerBlock = true; } else if (data instanceof Lever) {
case WOOD_BUTTON: Button button = (Button) target.getState().getData(); if (button.isPowered()) { setFullyPowered(me); return; || target2.getType() == Material.WOOD_BUTTON) { Button button2 = (Button) target2.getState().getData(); if (button2.isPowered() && button2.getAttachedFace() == target2 .getFace(target)) { setFullyPowered(me);
/** * 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; }
final Button button = new Button(Material.STONE_BUTTON, block.getData()); if (!button.isPowered()) { button.setPowered(!button.isPowered()); block.setData(button.getData()); final Block supportBlock = block.getRelative(button.getAttachedFace()); if (supportBlock != null && supportBlock.getType() != Material.AIR) { final BlockState initialSupportState = supportBlock.getState(); final Button button = new Button(Material.WOOD_BUTTON, block.getData()); if (!button.isPowered()) { button.setPowered(!button.isPowered()); block.setData(button.getData()); final Block supportBlock = block.getRelative(button.getAttachedFace()); if (supportBlock != null && supportBlock.getType() != Material.AIR) { final BlockState initialSupportState = supportBlock.getState();
Button powerData = (Button)data; context.registerForUndo(block); powerData.setPowered(!powerData.isPowered()); powerBlock = true; } else if (data instanceof Lever) {
/** * 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 String toString() { return super.toString() + " " + (isPowered() ? "" : "NOT ") + "POWERED"; }
/** * 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); }