How to set display name to item from mob please?

Discussion in 'Plugin Development' started by HeyduckGuy, Jun 19, 2021.

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

    HeyduckGuy

    public class zombie implements Listener {
    public void onPlayerKill (EntityDeathEvent event) {
    LivingEntity e = event.getEntity(); if (e instanceof Zombie) {
    e.getLocation().getWorld().dropItem(e.getLocation(),new ItemStack(Material.SUNFLOWER ,3));

    }
    }
    }
    //hello i need to set display name here, but i dont know how to set ItemMeta to this Itemstack
     
    Last edited: Jun 19, 2021
  2. Offline

    davidclue

    You need to create a new ItemStack instance, then modify its item meta, and then drop the ItemStack.
     
  3. Offline

    KarimAKL

    You can set the ItemStack's ItemMeta using ItemStack#setItemMeta(ItemMeta).
    To modify the current ItemMeta you can get the ItemStack's ItemMeta, modify it, then set the ItemStack's ItemMeta to the modified version.
     
Thread Status:
Not open for further replies.

Share This Page