Skull with a custom texture?

Discussion in 'General Help' started by rMATTEO, Nov 13, 2016.

Thread Status:
Not open for further replies.
  1. Hi, how can i get a skull with a custom texture?

    Skull that i want:
    /give @p skull 1 3 {display:{Name:"Scared"},SkullOwner:{Id:"2cd3dbb5-6136-4127-9e14-89c328660871",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjM2ZTI2YzQ0NjU5ZTgxNDhlZDU4YWE3OWU0ZDYwZGI1OTVmNDI2NDQyMTE2ZjgxYjU0MTVjMjQ0NmVkOCJ9fX0="}]}}}

    if i put the code up here (in yellow), the skull in the inventory is a steve head with any skin/owner
     
  2. Online

    timtower Administrator Administrator Moderator

    @rMATTEO Place it in the world, is it then still the case?
     
  3. how can i place it?
     
  4. Online

    timtower Administrator Administrator Moderator

    @rMATTEO You right click in the world with the skull in your hand.
    Just like any other block.
     
  5. i know... but how can i place it in a inventory (with this texture)
     
  6. Online

    timtower Administrator Administrator Moderator

    @rMATTEO I am not sure.
    I believe that it was a client side issue but I can't guarantee that.
     
  7. i don't think so couse those emoticons head are in hypixel
     
  8. Offline

    Wispyy

    It is. You need to follow the tutorial, @rMATTEO. I was actually interested in something like this, too, so thanks @bwfcwalshy. Once you follow the steps you can use:
    Code:
    player.getInventory().addItem(Skull.getCustomSkull("http://textures.minecraft.net/texture/7c57f9192e81eb6897c24ecd4935cfb5a731a6f9a57abb51f2b35e8b4be7ebc");
    
    Show Spoiler



    I think you need to use this util, I didn't really read through the tutorial as I'm quite busy with work currently. :eek:
     
  9. Offline

    Wispyy

    @rMATTEO, no problem :D I would try to provide another example, but without my IDE/Testing I'm not sure if it will be correct.
    I'll give it a go, I guess. (This is also assuming that the Skull is an ItemStack able to be put into an inventory ;) - Edit: It's an itemstack.
    ItemStack (open)
    Code:
    public static ItemStack getCustomSkull(String url) {
            GameProfile profile = new GameProfile(UUID.randomUUID(), null);
           PropertyMap propertyMap = profile.getProperties();
           if (propertyMap == null) {
                  throw new IllegalStateException("Profile doesn't contain a property map");
           }
           byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
           propertyMap.put("textures", new Property("textures", new String(encodedData)));
           ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
           ItemMeta headMeta = head.getItemMeta();
           Class<?> headMetaClass = headMeta.getClass();
           Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
           head.setItemMeta(headMeta);
           return head;
    }
    

    Code:
    Inventory inv = new Bukkit.createInventory(/*inventory owner, or null*/, /*multiple of 9*/, "Inventory Name");
    inv.setItem(/*place in the inventory smaller than the multiple of 9 ^*/, Skull.getCustomSkull("URL"));
    Player p = e.getPlayer(); // or if it's a command: Player p = (Player) sender;
    p.openInventory(inv);
    
    Also, noob question lol, but does anyone know if it's possible to get the code to have java highlight (if possible)?
     
    Last edited: Nov 15, 2016
Thread Status:
Not open for further replies.

Share This Page