Get Type of Skull Block. (and name(?))

Discussion in 'Plugin Development' started by pizzafreak08, Nov 4, 2012.

Thread Status:
Not open for further replies.
  1. Hey,

    i want to get the Type of a placed Skull (e.g. Skeleton, Zombie, ...). I don't know how to. I read how you do it with MobSpawners.

    CreatureSpawner cs = (CreatureSpawner)<block>.getState();
    cs.getCreatureType();

    But there is no Skull class in Bukkit. So is there maybe another way? And do you also know how to get the Name of the Player if it is an Player Skull. It's stored in the NBT-Data or something.

    Thanks
    pizza
     
  2. I can set the Skin with that but i want to get the Type and Skin :D
     
  3. I think the type is caused by the damage value, 5 is player head, 0 is skeleton head
     
  4. Offline

    puyttre

    Oh, I did this before.
    Code:java
    1. new ItemStack(Material.getMaterial(397), 1, (short)2)

    Argument 1 is the material (Skeleton Head), Argument 2 is the amount in the stack, and Argument 3 is the damage value. So the 2 at the end will return a zombie head.
     
  5. yeah i know that. but i want to get the type of a placed skull.
     
  6. Offline

    macmc

    Code:
    Location location = ....
    Skull block = (Skull) location.getBlock().getState();
    block.setSkullType(SkullType.PLAYER);
    // Then you do whatever you want,
    // Change owner etc...
    block.update();
    // Dont forget to call the update
    There you go ;)
    Need to convert the block state to skull
    (Was looking for the same thing :D)
     
Thread Status:
Not open for further replies.

Share This Page