Check if a block has a redstone current in to it.

Discussion in 'Spigot Plugin Development' started by TilionDC, Jun 10, 2016.

  1. Hi. I am trying to figure out if a wall_sign is being powered but I cant figure it out.

    I tried this but it doesn't show the indirectly powered blocks.
    Code (Text):
                BlockFace[] faces = {BlockFace.DOWN, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.UP, BlockFace.WEST, BlockFace.SELF};


                for (BlockFace a : faces) {
                    for(BlockFace b : faces) {
                        if(e.getBlock().getRelative(a).getRelative(b).isBlockFaceIndirectlyPowered(b.getOppositeFace())) {
                            if(e.getBlock().getRelative(a).isBlockFacePowered(b)) {
                                Bukkit.broadcastMessage("Location at: " + e.getBlock().getRelative(a).getType() + " and " + e.getBlock().getRelative(a).getRelative(b).getLocation().toVector());
                            }
                        }
                    }
                }
     
  2. Block#isBlockPowered
    Block#isBlockIndirectlyPowered
     
  3. I still don't get the sign when printing out any block types. Does anyone have a solution to this?