Custom heads in a GUI?

Discussion in 'Plugin Development' started by Tim_M, Aug 20, 2021.

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

    Tim_M

    I'm trying to give a player a Custom Head (https://minecraft-heads.com/custom-heads). Here's my current code:
    Code:
    public ItemStack getHead(String url)
    {
    ItemStack item0 = new ItemStack(Material.PLAYER_HEAD, 1);
    SkullMeta meta0 = (SkullMeta)item0.getItemMeta();
    item0.setItemMeta(meta0);
    
    GameProfile profile = new GameProfile(UUID.randomUUID(), null);
    
    profile.getProperties().put("textures", new Property("textures", url));
    
    try{
    Field profileField = meta0.getClass().getDeclaredField("profile");
    profileField.setAccessible(true);
    profileField.set(meta0, profile);
    }
    catch (Exception e)
    {
    e.printStackTrace();
    return null;
    }
    
    return item0;
    }
    
    It just returns a steve head. How can I fix this?
     
  2. Offline

    KarimAKL

    @Tim_M Taking this chest head for an example. You would scroll to the bottom of the page and find the "Other" section, then get the "Value" field's value and use that in the "textures" property.
     
  3. Offline

    Tim_M

    I do that, but it just returns a steve head. (The code above is a second attempt)
     
  4. Offline

    byteful

    You are setting the meta too early. Set the profile field first then set the meta to the itemstack.
     
    KarimAKL likes this.
  5. Offline

    Tim_M

    It can't be that. This code worked perfectlty in 1.8.9 (I just tested). It means something changed since. Too bad the docs doesn't have much on this.
     
  6. Offline

    Tim_M

    Bump...
     
Thread Status:
Not open for further replies.

Share This Page