Mob egg with name???

Discussion in 'Plugin Development' started by Meatiex, May 22, 2016.

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

    Meatiex

    This code put a zombie spawn egg in slot one, and a blank egg with a custom name in slot 2.... I can't seem to get a zombie egg with a comtom name to work... Any help is awesome!

    Code:
            ItemStack stack = new ItemStack(Material.MONSTER_EGG, 1, (short) 54);
            inv.setItem(0, stack);
            ItemMeta meta = stack.getItemMeta();
            meta.setDisplayName(ChatColor.DARK_GREEN + "" + ChatColor.BOLD + "Creeper");
            stack.setItemMeta(meta);
            inv.setItem(1, stack);
     
    Last edited: May 22, 2016
  2. Offline

    theone1000

    You added the itemstack in the inventory before setting the itemmeta.
     
  3. Offline

    Zombie_Striker

    @theone1000
    That's not his problem. His problem is that the second itemstack (the one after he set the displayname) is blank.


    @Meatiex
    After setting the itemmeta, reset the durability (type) of the egg by using Itemstack#setDurability(short );
     
  4. Offline

    Meatiex

    Code:
    stack.setDurability((short) 54);
    It still shows up blank... This is strange :/


    It seems like its not the damage thats being set, look at this: the one above is the zombie egg, the one below is the blank egg with a name:
    [​IMG]

    EDIT:
    If I manually add the name using NBT it will be a zombie egg with a name
    Still looking for a way to do this with code... Any help is awesome!
     
    Last edited: May 23, 2016
Thread Status:
Not open for further replies.

Share This Page