Skull appearing as default skin

Discussion in 'Plugin Development' started by nelson2tm, Jun 2, 2016.

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

    nelson2tm

    Hello,

    I am trying to create a inventory GUI with a skull which has a player skin. I've tried multiple things, but the skulls keep appearing as the default Steve skin. What did I do wrong here? online-mode is true on my private localhost server.

    Code:
            ItemStack Toverstaf14 = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
            SkullMeta Toverstaf14Meta = (SkullMeta) Toverstaf14.getItemMeta();
            Toverstaf14Meta.setOwner("nelson2tm");
            Toverstaf14Meta.setDisplayName(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Title");
            ArrayList<String> Toverstaf14Lore = new ArrayList<String>();
            Toverstaf14Lore.add(ChatColor.GRAY + "Lore1");
            Toverstaf14Lore.add(ChatColor.GRAY + "Lore2");
            Toverstaf14Lore.add(ChatColor.GRAY + "Lore3");
            Toverstaf14Lore.add(ChatColor.GRAY + "" + ChatColor.ITALIC + "Lore4");
            Toverstaf14Meta.setLore(Toverstaf14Lore);
            Toverstaf14.setItemMeta(Toverstaf14Meta);
    The title and lores are appearing correctly. Also, when using the default Minecraft /give command, I can get the player skull without issues.
     
  2. Offline

    Mr. Sandwich

    I am not 100% sure but I think that the heads' texture only load when they are placed in the world or in the player's inventory
     
  3. Offline

    I Al Istannen

    @Mr. Sandwich
    Since 1.8 they render in every inventory. They may take a few seconds to sync though. Beofre that they just rendered if placed.


    @nelson2tm
    You don't follow naming conventions. Variables should start with a lowercase letter and then be written in camelCase.

    From glancing at the SkullType enum, it isn't Player.ordinal(), but "3" casted to a short. Try this.
     
  4. Offline

    nelson2tm

    Here's something weird: If I place them they do render when placed on the ground, but the inventory one doesn't render. (Since I don't have a InventoryClickEvent added to the inventory menu yet, I can take items out.)



    [​IMG]

    @Mr. Sandwich I think you meant that the skull in the inventory only rendered the correct skin if placed in the world.
     
  5. Offline

    Mr. Sandwich

    nope, it renders when its in your inventory too
     
  6. Offline

    I Al Istannen

    @nelson2tm
    I am on 1.8:
    Head renders.png
    And it works.

    The exact code I used is (itemStackBuilder is a class I made, just ignore it):
    Code:
    ItemStack item = ItemStackBuilder
        .builder(Material.SKULL_ITEM)
        .setDurability((short) 3)
        .setName(Util.color("&6" + loopPlayer.getDisplayName()))
        .setLore("&3(" + loopPlayer.getName() + ")")
        .setSkullOwner(loopPlayer.getName())
        .build();
    The setSkullOwner is just what you have:
    Code:
            SkullMeta meta = (SkullMeta) item.getItemMeta();
            meta.setOwner(name);
            item.setItemMeta(meta);
            itemMeta = item.getItemMeta();
     
Thread Status:
Not open for further replies.

Share This Page