Example code:
@SuppressWarnings("deprecation") public static ItemStack addNBTSpawnEgg(ItemStack item, int data) { net.minecraft.server.v1_9_R1.ItemStack stack = CraftItemStack.asNMSCopy(item); NBTTagCompound tagCompound = stack.getTag(); if(tagCompound == null){ tagCompound = new NBTTagCompound(); } NBTTagCompound id = new NBTTagCompound(); id.setString("id", EntityType.fromId(data).getName()); tagCompound.set("EntityTag", id); stack.setTag(tagCompound); Debug.debug(stack.getTag().getCompound("EntityTag").getString("id")); return CraftItemStack.asBukkitCopy(stack); }
That works only if i use method player.getInventory().addItem(item); But if i set this item into inventory then not render egg type, is white default monsteregg like without tag. It can be client side bug ? Debug output is OK. "Villager" etc...