How to set Skull Owner with the new NBT-System

Discussion in 'Resources' started by pizzafreak08, Dec 20, 2012.

Thread Status:
Not open for further replies.
  1. Since the NBT-System has changed in 1.4.5-Recommended Build there is a new, much easier way to change the NBT-Data of an Item.

    I tried a bit around and got this method now:
    Code:
        private ItemStack setSkin(ItemStack item, String nick) {
            SkullMeta meta = (SkullMeta) item.getItemMeta();
            meta.setOwner(nick);
            item.setItemMeta(meta);
            return item;
        }
    to add a playerskull to an inventory you just do this:
    player.getInventory().addItem(setSkin(new ItemStack(Material.SKULL_ITEM, 1, (byte) 3), "pizzafreak08"));

    BTW: (byte) 3 is to set the skull to player skull and not the default wither skeleton type.

    hope you can use this in your plugin

    pizza
     
    lucasdidur and afistofirony like this.
  2. Offline

    eelem

    How would I make a plugin that allows me to type a command that makes all the player heads in my inventory change into the default head of a human (397:3)? The use for this would be to let me use essential to sell the human head or Steve head(397:3).
     
  3. Offline

    breezeyboy

Thread Status:
Not open for further replies.

Share This Page