Solved I can't rotate a block

Discussion in 'Spigot Plugin Development' started by shiosaku, Jan 7, 2020.

  1. Code (Java):
    Block cabeza = loc.getBlock();
            cabeza.setType(Material.PLAYER_HEAD);
            Skull cabeza_s = (Skull) cabeza.getState();
           
            cabeza_s.setOwningPlayer(jugador.getPlayer());
           
            BlockData cabeza_data = cabeza.getBlockData();
           
            if(cabeza_data instanceof Directional) {
                Directional direccion_cabeza = (Directional) cabeza_data;
                direccion_cabeza.setFacing(BlockFace.EAST);
                cabeza.setBlockData(direccion_cabeza);
            }
    This is the code I'm using, but the rotation isn't working, I'm doing something wrong?
     
  2. If you're using a recent API, Skull is deprecated and you have to use PLAYER_HEAD as material.
    PLAYER_HEAD is instance of Rotatable, so the correct method is setRotation(BlockFace).

    Edit: Hum... must be verified, not indicated on Rotatable page but only on PLAYER_HEAD.
     
    • Like Like x 1
  3. Thank you, It worked perfectly :D
     
    • Like Like x 1