Solved Set block direction

Discussion in 'Plugin Development' started by The_Spaceman, Aug 9, 2018.

  1. Offline

    The_Spaceman

    I want to know how to set the block facing. like how to rotate stairs and such...
    Since the damage value has been removed I dont know how to do this.


    EDIT:

    This works

    Code:
    Block block = player.getLocation().getBlock();
    block.setType(Material.STICKY_PISTON);
    BlockData blockData = block.getBlockData();
    if (blockData instanceof Directional) {
      ((Directional) blockData).setFacing(BlockFace.WEST);
      block.setBlockData(blockData);
    }
    
     
    Last edited: Aug 15, 2018 at 9:54 AM
  2. @The_Spaceman

    if(block instanceof Directional)
    {
    ((Directional) b).setFacingDirection(BlockFace.EAST);
    }
    that should work i think
     
  3. Offline

    The_Spaceman

    That doesn't work. You can't cast Block to Directional.

    In the class Directional there is no .setFacingDirection, only .setFacing()

    and block.getBlockData() is not castable to Directional.
     

Share This Page