Ir para conteúdo

Cabeca Custom


R.A

Posts Recomendados

Pessoal eu estou fazendo um menu GUI e gostaria de colocar cabecas custom aquelas cabecas variadas, ja vi um topico na GB que explicava. Mas nao consegui colocar. Alguem poderia me ajudar ?

Link para o comentário
Compartilhar em outros sites


 

Primeiro você cria isso:

Spoiler

public static ItemStack getSkull(String url) {

        ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);

        if (url == null || url.isEmpty())

            return skull;

        SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();

        GameProfile profile = new GameProfile(UUID.randomUUID(), null);

        byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());

        profile.getProperties().put("textures", new Property("textures", new String(encodedData)));

        Field profileField = null;

        try {

            profileField = skullMeta.getClass().getDeclaredField("profile");

        } catch (NoSuchFieldException | SecurityException e) {

            e.printStackTrace();

        }

        profileField.setAccessible(true);

        try {

            profileField.set(skullMeta, profile);

        } catch (IllegalArgumentException | IllegalAccessException e) {

            e.printStackTrace();

        }

        skull.setItemMeta(skullMeta);

        return skull;

    }

E depois é só colocar isso abaixo no ItemStack:

   ItemStack Item = getSkull("link da head");
      

Editado por EduZeraH
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...