Solved Heads not showing up as heads!?!?

Discussion in 'Plugin Development' started by vtg_the_kid, Feb 16, 2015.

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

    vtg_the_kid

    I made a command to set a player's head to whatever name's head he wants, here's my code:

    Code:
    @SuppressWarnings("deprecation")
            ItemStack skull = new ItemStack(397, 1, (short) 3);
            SkullMeta meta = (SkullMeta) skull.getItemMeta();
            meta.setOwner(args[0]);
            skull.setItemMeta(meta);
            p.getInventory().setHelmet(skull);
    However it shows up as Steve or Alex skinned! I know you can fix the head by placing it down, destroying it, picking up the drop and wearing it. However, I want the skin to be there when it spawns in! Any idea how to do this? Thanks!
     
  2. Offline

    Monkey_Swag

    I've heard that players see steve skins if their Minecraft version is less than 1.7.9
     
  3. Offline

    fandemangas42

    Code:
    new ItemStack(397, 1, (short) 3);
    This method is deprecated, use Material instead of ids now :
    Code:
    new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
     
    vtg_the_kid likes this.
  4. Offline

    vtg_the_kid

    @Monkey_Swag
    I'm using 1.8.1 and I see steve :(

    @fandemangas42
    Thanks, I undeprecated my code, but it still shows up as steve.

    Does anyone know how to fix this weird issue?

    EDIT: I think the issue may be related to UUIDs. Does anyone know how to get a player head by UUID? There's no such method meta.setOwner(<uuid>) :(
     
    Last edited: Feb 17, 2015
  5. Offline

    fandemangas42

    Code:
            ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM, ChatColor.DARK_AQUA + playerName, (short) 3);
            SkullMeta sm = (SkullMeta) playerSkull.getItemMeta();
            sm.setOwner(playerName);
            playerSkull.setItemMeta(sm);
    This works for me, what Spigot/Craftbukkit version are you using ?
     
  6. Offline

    vtg_the_kid

    1. It doesn't compile (the ItemStack constructor is wrong, did you mean to put that String in there!?!?)
    2. After changing the
    Code:
    ChatColor.DARK_AQUA + playerName
    to a 1, it still doesn't work. It shows up as Steve.
    3. 1.8
    4. Thanks for helping, I appreciate it :D

    EDIT: How exactly does it work for you? When you execute the command and get a head placed in your inventory, does the head show up with the player's skin in your inventory without placing it down?

    Alright I solved this by creating a player head, getting the item drop for it, removing the head, and giving that item drop to the player.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  7. Offline

    fandemangas42

    Yeah the head shows up with the player's skin without placing it down.
     
Thread Status:
Not open for further replies.

Share This Page