Resource Custom Textured Non-Player Skulls

Discussion in 'Spigot Plugin Development' started by Snowmite, Jun 1, 2017.

  1. About
    So if any of you guys have seen my plugin FoodMC, you will know that it uses custom heads for the food. I decided why not to show my code about how to get custom textured non-player skulls.

    Code (Text):
        public ItemStack createHead(String paramString)
            ItemStack localItemStack = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
            SkullMeta localSkullMeta = (SkullMeta)localItemStack.getItemMeta();

            GameProfile localGameProfile = new GameProfile(UUID.randomUUID(), null);
            byte[] arrayOfByte = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", new Object[] { paramString }).getBytes());
            localGameProfile.getProperties().put("textures", new Property("textures", new String(arrayOfByte)));
            Field localField = null;
                localField = localSkullMeta.getClass().getDeclaredField("profile");
                localField.set(localSkullMeta, localGameProfile);
            catch (NoSuchFieldException|IllegalArgumentException|IllegalAccessException localNoSuchFieldException)
                System.out.println("error: " + localNoSuchFieldException.getMessage());

            return localItemStack;
    How to get a URL for the texture:
    1. Go to
    2. Go to the "Custom Heads" tab
    3. Find any skull you want to use
    4. Click on the skull you want to use
    5. Right click on the "» Download" button, and click Open in New Tab
    6. The URL of that site is what you should use for the string
    THE URL HAS TO START WITH "" or else it wont work!

    Code (Text):
    ItemStack mySkull = MyMainClass.getInstance().createHead("textures.minecraft.blahblahblah");

    ItemMeta meta = mySkull.getItemMeta();


    Anyways, I hope I helped you. If I did, please leave a rating! This is one of my first ever resources btw
  2. Forgot something? ;)
  3. Correct me if I am wrong but if I wanted a truly custom skin, I can modify my own accounts skin, and then grab the textures.minecraft link of my skin, and then change back and the skin I used should stay on said skull (aka url) forever even if I change my own accounts skin over and over?
    • Agree Agree x 2
  4. Also, if it always has to start with "", why not make that constant in each case in the method, so you don't always have to write that exact string prefixing the variable?

    Sent from my iPhone using Tapatalk
  5. You don't need a URL, you can save the base64 of the texture and use it forever.

    We've been doing this for years now. ;)
    • Agree Agree x 1
  6. , @inventivetalent
    • Winner Winner x 1
  7. Yes it should stay.
  8. For some reason, there is no java class called GameProfile for me. How do I fix this?
  9. This thread is more than 3 years old mate. But if you're using Maven, that may be the cause. Try ímporting the jar file as well.
    I read somewhere that the Spigot dependency you receive through Maven doesn't include the vanilla Minecraft packages (I forgot what they're called, NMS?).