Solved Skull blockdata

Discussion in 'Plugin Development' started by davidclue, Mar 11, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    davidclue

    How do you change the direction a skull is facing in 1.16 because
    Code:
    skull.setRotation(BlockFace.NORTH);
    is deprecated and in the docs it just says use BlockData but I have no idea how to use block data for this.
     
  2. Offline

    KarimAKL

    @davidclue I would try to print the Skull's BlockData class to the console. You can then look up the type and see if it inherits any class or interface that has a rotation or direction method. You can then downcast to that class and use the method.

    You can probably just use the deprecated method if you cannot find anything useful after doing this.
     
  3. Offline

    davidclue

    I can't find anything about it on google and I can't even use deprecated methods because they just don't work and throw me errors.
    Code:
    mob.getLocation().getBlock().setType(Material.SKELETON_SKULL);
                                Skull skull = (Skull) mob.getLocation().getBlock().getState().getData();
                                Bukkit.getLogger().info(skull.getBlockData().toString());
                                skull.setRotation(BlockFace.NORTH_EAST);
    However, I tried what you told me and got it working it seems there is no class inheritance that can help with rotation but I can just create a new BlockData and set the skull to it.

    Code:
    mob.getLocation().getBlock().setType(Material.SKELETON_SKULL);
                                Bukkit.getLogger().info(mob.getLocation().getBlock().getBlockData().toString());
                                mob.getLocation().getBlock().setBlockData(Bukkit.createBlockData("minecraft:skeleton_skull[rotation="+3+"]"));
    Thanks! :D
     
    KarimAKL likes this.
Thread Status:
Not open for further replies.

Share This Page