I have a command block system which checks if the user is holding a diamond pickaxe with a custom enchantment, and if so, performs some actions. I'm using a custom enchantment ID of 98 simply because unlike names, it can't be faked by a player without cheats, and because Minecraft ignores any non-standard properties rather than storing them. This part all works fine, and holding a diamond pick with enchantment 98 does what it's supposed to do.
Now, I'd like to give the player a way to actually obtain Enchantment 98. Obviously, it can't be added to the enchanting table's list (can it?), so instead, I'm making it a "treasure enchantment", obtainable in enchanted book form in loot chests. But that's become a problem. I can easily create an enchanted book with a StoredEnchantments ID of 98, but if I try to combine it with a pickaxe in an anvil, it won't let me combine it.
So how can I make an enchanted book that stores a custom enchantment ID (such as 98) but which can still be combined with tools in an anvil to apply that enchantment to it?