Solved Skull_Item Skin not setting?

Discussion in 'Plugin Development' started by kayc01, Oct 26, 2016.

Thread Status:
Not open for further replies.
  1. Hey, very quickly (I hope).
    For some reason when I add a SKULL_ITEM to a players Helmet, it only shows the default SKULL_ITEM.

    However if I use the command /skull MHF_Zombie and place it is the correct skin.
    Am I not applying the owner correctly or Is it failing to apply the owner with the .setHelmet?

    ItemStack ZSkull = new ItemStack(Material.SKULL_ITEM, 1);
                 SkullMeta meta = (SkullMeta) ZSkull.getItemMeta();
                 meta.setDisplayName(ChatColor.DARK_GREEN + "Zombie " + p.getName());
    There are no Errors.
  2. @kayc01
    The problem here is datavalues. If you create a skull without specifying the metadata value it defaults to 0. But to have a custom owner, it needs to be a player skull with data value 3, no other types can have custome owners.

    Also, if you just want it to look like a zombie, you don't need to load a custom skin, since there already is a built in zombie skull in minecraft. It's the one with datavalue 2.
  3. Modifying my code, could you show me how to format and anything extra I need for the data value format.
    I saw something of it but was a bit confused by "(byte)3)".

  4. @kayc01
    I won't modify your code, you're the one coding your plugin, but I'll give you a brief explanation.

    The metadatavalue is just a short you pass into the ItemStack constructor after the amount, so you should actually be casting to short, instead of byte (the reason byte works is because short, and all primitives are a subtype of byte).
    1. new ItemStack(material, amount, (short) datavalue)
    kayc01 likes this.
  5. That worked, thanks! :)
Thread Status:
Not open for further replies.

Share This Page