Custom recipes with item with custom NBT as output [duplicate]

I have a small question: does Minecraft JE allow NBT tags in crafting recipes? Because I'm making a map in 1.14.3 and some part of the map need custom NBT tags crafting and I need to use custom crafting chest to make it


Big answer to small question:

No.

You need to do one of the old styles of custom crafting, like throwing items on the ground or checking for a dispenser with certain items in it or something like that.


Here's a very good workaround I shamelessly copied from Michael P.'s answer here (side notes mine):

  1. Set the recipe's "result" to a particular item that a player is not likely to ever have in their inventory (e.g. Spawn Eggs, Bedrock, Command Blocks).
  2. Create an advancement that a player achieves either by crafting your custom recipe or by acquiring the intermediate item into their inventory.
  3. Set the reward of the advancement to trigger a custom function.
  4. Have the custom function remove the intermediate item from the player's inventory and add the actual result with the NBT data.

Side note: Consider revoking the advancement in the function, so that the result replacement can happen multiple times. Unless custom advancements can be granted multiple times, for which I see no indication on the wiki.

Another side note: Didn't test it yet, but this probably doesn't work well with stack-crafting, i.e. you fill in the materials multiple times and then shift-click out the result. Most likely, doing that will only yield one item and have the rest of the materials go to waste. (I'm lucky in that regard, because the recipes I have in mind involve unstackable items.)

UPDATE: I tried it out with a mod item (one of the trophies from Dimensional Dungeons), and it works, but it's a bit wonky. In Creative Mode, it gives you the NBT item immediately, but doesn't clear the intermediate item. In Survival Mode, the intermediate item is cleared and the NBT item is given, but only next time you click a Crafting Table (other container-ish blocks might work as well). Tested under MineCraft 1.15.2, Forge 31.2.37; things might look different in other versions.