Solved Placing player heads!

Discussion in 'Plugin Development' started by Oo-Zakk-oO, Apr 20, 2014.

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

    Oo-Zakk-oO

    I have a method to get the top 3 players of my minigame. How can i put a player head at a location with the player skin?
     
  2. Offline

    yewtree8

    you need to get the player meta, then set the block however you want it
     
  3. Offline

    Oo-Zakk-oO

    yewtree8 can you give me an example please?
     
  4. Offline

    yewtree8

    Oo-Zakk-oO

    Code:java
    1. @EventHandler
    2. public void onDeath(PlayerDeathEvent event){
    3. ItemStack head = new ItemStack(Material.SKULL_ITEM, 1);
    4. head.setDurability((short) 3);
    5. SkullMeta skullmeta = (SkullMeta)head.getItemMeta();
    6. skullmeta.setOwner(event.getEntity().getName());
    7. head.setItemMeta(skullmeta);
    8. ((LivingEntity) event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), EntityType.ZOMBIE)).getEquipment().setHelmet(head);
    9. }



    getting the head and setting the head on a zombie,
     
  5. Offline

    Oo-Zakk-oO

    yewtree8 well thats an itemstack its not a block...

    yewtree8 i cant get a block item meta since its not an item...

    I have this but all i see is steves head:
    Code:
        Location loc = getfileloc("config", null, "winsigns.ff");
                        Block b = loc.getBlock();
                        b.setTypeIdAndData(Material.SKULL.getId(), (byte)1, true);
                        Skull skull = (Skull)b.getState();
                        skull.setSkullType(SkullType.PLAYER);
                        skull.setOwner(name);
                        skull.update(true);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  6. Offline

    Badeye

    Oo-Zakk-oO I have the exact same problem, seems like modifying the skullType does not change anything.
     
  7. Offline

    yewtree8

    Oo-Zakk-oO it works for me, if you set it as an itemstack then you will receive a block that is the player's head in the shape of a playerhead, you can't modify the skulltype because it is there.
     
  8. Offline

    Oo-Zakk-oO

  9. Code:java
    1. block.setData((byte)0x1);
    2. BlockState state = block.getState();
    3.  
    4. if(state instanceof Skull)
    5. {
    6. Skull skull = (Skull)state;
    7.  
    8. skull.setRotation(BlockFace.SOUTH_SOUTH_EAST);
    9. skull.setSkullType(SkullType.PLAYER);
    10. skull.setOwner("Notch");
    11. skull.update();
    12. }


    https://forums.bukkit.org/threads/skull-blocks.132842/
     
    Oo-Zakk-oO likes this.
  10. Offline

    Zach_1919

    yewtree8 He doesn't want it in someone's inventory. He wants to actually place the block through the code.
     
  11. Offline

    Oo-Zakk-oO

    YES thank you! I love you Laekh no homo.. :p
     
    Laekh likes this.
Thread Status:
Not open for further replies.

Share This Page